instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
When i compile the application in my laptop it runs fine but when i run the same application in the server something is wrong with the date format. But when i checked the system date time format wit my laptop and server it the same format. Can anyone tell me what is wrong.
The issue you are experiencing with date format discrepancies between your laptop and the server could be due to several factors, even if the system date and time formats appear to be the same. Here are some possible reasons and solutions to consider: 1. **Culture and Locale Settings**: - The application might be u...
12,560
[ { "from": "human", "value": "When i compile the application in my laptop it runs fine but when i run the same application in the server something is wrong with the date format. But when i checked the system date time format wit my laptop and server it the same format. Can anyone tell me what is wrong.\n" ...
I'm using the following code for setting/getting deleting cookies: function get_cookie(cookie_name) { var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); if (results) return ( decodeURI(results[2]) ); else return null; } function set_cookie(name, value, exp_y, ...
The issue you're experiencing is likely due to how cookies are being set, accessed, and deleted, particularly the scope of the cookies (domain and path) and how frequently you are setting and deleting them. Here are a few suggestions to improve the consistency of your cookie handling: ### 1. Cookie Path When you set a...
10,594
[ { "from": "human", "value": "I'm using the following code for setting/getting deleting cookies:\nfunction get_cookie(cookie_name)\n{\n var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');\n\n if (results)\n return ( decodeURI(results[2]) );\n else\n return n...
I'm currently working on a web application which has a page which displays a single chart (a .png image). On another part of this page there are a set of links which, when clicked, the entire page reloads and looks exactly the same as before except for the chart in the middle of the page. What I want to do is when a l...
You can achieve the desired functionality by implementing a spinner or loading indicator that takes the same dimensions as the chart image. Here’s how you can do it using JavaScript, HTML, and CSS: 1. **HTML Structure**: Create a container for the chart image and the spinner. 2. **CSS Styling**: Ensure the spinner has...
10,189
[ { "from": "human", "value": "I'm currently working on a web application which has a page which displays a single chart (a .png image). On another part of this page there are a set of links which, when clicked, the entire page reloads and looks exactly the same as before except for the chart in the middle o...
Is there a way to create an html link using h:outputLink, other JSF tag or code to create a non faces request (HTTP GET) with request parameters? For example I have the following navigation-rule <navigation-rule> <navigation-case> <from-outcome>showMessage</from-outcome> <to-view-id>/showMessage.jsf...
In JSF, you can generate a URL that adheres to your navigation rules and includes query parameters by using the `h:outputLink` tag, along with the `javax.faces.context.FacesContext` to construct the URL programmatically. Here’s how you can achieve that: 1. **Define Your Navigation Rule**: Ensure you have your navigati...
12,099
[ { "from": "human", "value": "Is there a way to create an html link using h:outputLink, other JSF tag or code to create a non faces request (HTTP GET) with request parameters?\nFor example I have the following navigation-rule\n<navigation-rule>\n <navigation-case>\n <from-outcome>showMessage</from-...
In WPF, I want to create a hyperlink that navigates to the details of an object, and I want the text of the hyperlink to be the name of the object. Right now, I have this: <TextBlock><Hyperlink Command="local:MyCommands.ViewDetails" CommandParameter="{Binding}">Object Name</Hyperlink></TextBlock> But I want "Object Na...
In WPF, since the `Hyperlink` class does not directly support a `Text` or similar property for binding, you can achieve the desired behavior by placing the `Hyperlink` inside a `TextBlock` and using `Run` elements for the text content. Each `Run` element can be data-bound to the properties of your object. Here's how y...
15,391
[ { "from": "human", "value": "In WPF, I want to create a hyperlink that navigates to the details of an object, and I want the text of the hyperlink to be the name of the object. Right now, I have this:\n<TextBlock><Hyperlink Command=\"local:MyCommands.ViewDetails\" CommandParameter=\"{Binding}\">Object Name<...
I'm generating a self-signed SSL certificate to protect my server's admin section, and I keep getting this message from OpenSSL: unable to write 'random state' What does this mean? This is on an Ubuntu server. I have upgraded libssl to fix the recent security vulnerability.
The message `unable to write 'random state'` from OpenSSL typically indicates an issue with the OpenSSL library trying to save its state to a file, which is usually related to the user's home directory. Here's what you can do to troubleshoot and potentially resolve this issue: 1. **Check Environment Variables**: O...
11,541
[ { "from": "human", "value": "I'm generating a self-signed SSL certificate to protect my server's admin section, and I keep getting this message from OpenSSL:\n\nunable to write 'random state'\n\nWhat does this mean?\nThis is on an Ubuntu server. I have upgraded libssl to fix the recent security vulnerabilit...
We have a rather large SVN repository. Doing SVN updates are taking longer and longer the more we add code. We added svn:externals to folders that were repeated in some projects like the FCKeditor on various websites. This helped, but not that much. What is the best way to reduce update time and boost SVN speed?
Reducing the update time and improving the performance of your SVN repository can be approached from several angles. Here are some strategies you can consider to optimize SVN speed: 1. **Minimize the Working Copy Size**: - **Use Sparse Checkouts**: Instead of checking out the entire repository, you can check out on...
12,523
[ { "from": "human", "value": "We have a rather large SVN repository. Doing SVN updates are taking longer and longer the more we add code. We added svn:externals to folders that were repeated in some projects like the FCKeditor on various websites. This helped, but not that much.\nWhat is the best way to redu...
I have a WCF application that has two Services that I am trying to host in a single Windows Service using net.tcp. I can run either of the services just fine, but as soon as I try to put them both in the Windows Service only the first one loads up. I have determined that the second services ctor is being called but the...
It appears you're trying to host two WCF services in a single Windows Service, but you're facing issues with only one of the services successfully starting. Here are some troubleshooting steps and suggestions to help you resolve the issue: ### Steps to Troubleshoot 1. **Check Service Host Initialization:** Ensure ...
10,319
[ { "from": "human", "value": "I have a WCF application that has two Services that I am trying to host in a single Windows Service using net.tcp. I can run either of the services just fine, but as soon as I try to put them both in the Windows Service only the first one loads up. I have determined that the sec...
I often see code like: Iterator i = list.iterator(); while(i.hasNext()) { ... } but I write that (when Java 1.5 isn't available or for each can't be used) as: for(Iterator i = list.iterator(); i.hasNext(); ) { ... } because It is shorter It keeps i in a smaller scope It reduces the chance of confusion. (Is ...
Your approach to using the `for` loop to iterate through an `Iterator` in Java has valid advantages, especially when it comes to scope and clarity. Let's break down the considerations: ### Advantages of Your Approach 1. **Shorter Code**: By combining the declaration and the iteration control into a single line, you r...
14,122
[ { "from": "human", "value": "I often see code like:\nIterator i = list.iterator();\nwhile(i.hasNext()) {\n ...\n}\n\nbut I write that (when Java 1.5 isn't available or for each can't be used) as:\nfor(Iterator i = list.iterator(); i.hasNext(); ) {\n ...\n}\n\nbecause\n\nIt is shorter\nIt keeps i in a ...
I'm implementing a comment control that uses an ASP.Repeater to display each comment. The comment itself is currently displayed using a table to divide up some images to display the comment in a bubble. I know that tables are supposed to be the epitome of evil for design layout, and really expensive to display for the...
Using tables for layout is generally discouraged in modern web design, as it can lead to accessibility issues and is not as flexible as CSS-based layouts. Instead, you can achieve rounded corners and a bubble-like comment appearance using CSS with `div` elements. Here are some suggestions and an example to help you cre...
9,411
[ { "from": "human", "value": "I'm implementing a comment control that uses an ASP.Repeater to display each comment. The comment itself is currently displayed using a table to divide up some images to display the comment in a bubble.\nI know that tables are supposed to be the epitome of evil for design layou...
Do you use Luabind, toLua++, or some other library (if so, which one) or none at all? For each approach, what are the pro's and con's?
When it comes to integrating Lua with C++ applications, there are several libraries and bindings available, including Luabind, toLua++, and others such as Sol2 or LuaBridge. Each of these libraries has its pros and cons, which are summarized below: ### 1. **Luabind** **Pros:** - **Ease of Use**: Designed to be simple ...
8,025
[ { "from": "human", "value": "Do you use Luabind, toLua++, or some other library (if so, which one) or none at all?\nFor each approach, what are the pro's and con's?\n" }, { "from": "gpt", "value": "When it comes to integrating Lua with C++ applications, there are several libraries and bindings a...
How would I design and organize tests for the concrete methods of an abstract class? Specifically in .NET.
Designing and organizing tests for the concrete methods of an abstract class in .NET involves a few steps. The main challenge is that abstract classes cannot be instantiated directly, so you'll need to create a concrete subclass that implements the abstract methods for the purpose of testing. Here’s a step-by-step guid...
8,418
[ { "from": "human", "value": "How would I design and organize tests for the concrete methods of an abstract class? Specifically in .NET.\n" }, { "from": "gpt", "value": "Designing and organizing tests for the concrete methods of an abstract class in .NET involves a few steps. The main challenge i...
Python allocates integers automatically based on the underlying system architecture. Unfortunately I have a huge dataset which needs to be fully loaded into memory. So, is there a way to force Python to use only 2 bytes for some integers (equivalent of C++ 'short')?
In Python, the built-in `int` type is variable-length and automatically adapts to the size of the integer values. This means that Python integers use more memory than a typical `short` in C or C++, which is usually limited to 2 bytes (16 bits). However, if you want to handle large datasets more efficiently, especially ...
12,886
[ { "from": "human", "value": "Python allocates integers automatically based on the underlying system architecture. Unfortunately I have a huge dataset which needs to be fully loaded into memory. \nSo, is there a way to force Python to use only 2 bytes for some integers (equivalent of C++ 'short')?\n" }, ...
I really want to write .NET apps that run on any platform (PC, Linux and Mac). I am not really concerned about UI capabilities because these are mostly background services. I have heard of MONO and that it allows you to write .NET apps that run on Mac and Linux, but I want to be able to write a single app that when c...
If you want to write .NET applications that can run cross-platform (Windows, Linux, and macOS) and primarily focus on background services, you have some excellent options available, particularly with .NET Core (now known as .NET 5 and later versions). Here’s how you can achieve your goals: ### 1. Use .NET Core/ .NET 5...
10,476
[ { "from": "human", "value": "I really want to write .NET apps that run on any platform (PC, Linux and Mac). I am not really concerned about UI capabilities because these are mostly background services. I have heard of MONO and that it allows you to write .NET apps that run on Mac and Linux, but I want to ...
What's the best library to use to generate RSS for a webserver written in Common Lisp?
When working with Common Lisp to generate RSS feeds, one of the most popular libraries you can use is **`cl-rss`**. This library provides a straightforward way to create RSS feeds in Common Lisp and can be easily integrated into your web server application. Here are some steps you might follow to use `cl-rss`: 1. **I...
12,568
[ { "from": "human", "value": "What's the best library to use to generate RSS for a webserver written in Common Lisp?\n" }, { "from": "gpt", "value": "When working with Common Lisp to generate RSS feeds, one of the most popular libraries you can use is **`cl-rss`**. This library provides a straigh...
I have a function that takes, amongst others, a parameter declared as int privateCount. When I want to call ToString() on this param, ReSharper greys it out and marks it as a redundant call. So, curious as I am, I remove the ToString(), and the code still builds! How can a C# compiler allow this, where str is a strin...
In C#, the `int` type has an implicit conversion to `string` when it is used in a string concatenation context (like in your example with `+=`). This means that when you use `privateCount` with the `+=` operator to append to a string, the C# compiler automatically converts the integer to a string before performing the ...
13,636
[ { "from": "human", "value": "I have a function that takes, amongst others, a parameter declared as int privateCount. When I want to call ToString() on this param, ReSharper greys it out and marks it as a redundant call. So, curious as I am, I remove the ToString(), and the code still builds!\nHow can a C#...
Possible Duplicate: How do you send email from a Java app using Gmail? How do I send an SMTP Message from Java?
To send an SMTP message from Java, you can use the JavaMail API, which provides classes to create, send, and receive email messages. Below are the steps to set it up and send an email using SMTP. ### Step 1: Add JavaMail Dependency If you are using Maven, add the following dependency to your `pom.xml`: ```xml <depen...
9,538
[ { "from": "human", "value": "\nPossible Duplicate:\nHow do you send email from a Java app using Gmail? \n\nHow do I send an SMTP Message from Java?\n" }, { "from": "gpt", "value": "To send an SMTP message from Java, you can use the JavaMail API, which provides classes to create, send, and receiv...
When I am in a list and I press a letter to jump to the first entry that starts with that letter why does it leave that entry on the bottom of the visible entries? It should make the entry the top visable entry so that many entries that start with that letter can be seen. In more concrete terms if I am selecting a stat...
Your observation about the behavior of list navigation when pressing a key to jump to entries is a common point of contention in user interface design. You bring up a valid argument: making the matched entry the top visible item could enhance usability by allowing users to see more options that start with the same lett...
14,127
[ { "from": "human", "value": "When I am in a list and I press a letter to jump to the first entry that starts with that letter why does it leave that entry on the bottom of the visible entries? It should make the entry the top visable entry so that many entries that start with that letter can be seen.\nIn mo...
Can you provide an example of a byte buffer transferred between two java classes via UDP datagram?
Sure! Below is an example of how to transfer a byte buffer between two Java classes using UDP Datagram sockets. One class will act as a UDP server (receiver) and the other will act as a UDP client (sender). ### UDP Server (Receiver) This class will listen for incoming UDP packets and print the received byte buffer. ...
10,551
[ { "from": "human", "value": "Can you provide an example of a byte buffer transferred between two java classes via UDP datagram?\n" }, { "from": "gpt", "value": "Sure! Below is an example of how to transfer a byte buffer between two Java classes using UDP Datagram sockets. One class will act as a...
This is an issue I've run into with a website I'm designing. I'm using a template based design for the site, so the information on the page is thrown inside the template when the page is accessed. The information shown changes based on the page attribute passed in as a GET request. So, to actually load the information ...
To achieve a setup that allows for both dynamic content loading via PHP and static content editing in Dreamweaver, you might consider a hybrid approach where you separate your dynamic content from the template layout. Here’s a suggestion on how you can organize your files and PHP code: ### Step 1: Separate Content fro...
10,274
[ { "from": "human", "value": "This is an issue I've run into with a website I'm designing. I'm using a template based design for the site, so the information on the page is thrown inside the template when the page is accessed. The information shown changes based on the page attribute passed in as a GET reque...
We have a large ASP (classic ASP) application and we would like to convert it to .NET in order to work on further releases. It makes no sense continuing to use ASP as it is obsolete, and we don't want to rewrite it from scratch (Joel Spolsky tells you why). Is there a way to convert it from ASP to ASP.NET automatically...
Converting a classic ASP application to ASP.NET can be a complex task, as the two technologies have fundamental differences in their architecture, programming models, and frameworks. While there is no fully automated tool that can convert an entire classic ASP application to ASP.NET seamlessly, there are some approache...
9,547
[ { "from": "human", "value": "We have a large ASP (classic ASP) application and we would like to convert it to .NET in order to work on further releases. It makes no sense continuing to use ASP as it is obsolete, and we don't want to rewrite it from scratch (Joel Spolsky tells you why).\nIs there a way to co...
This is not a new topic, but I am curious how everyone is handling either .js or .css that is browser specific. Do you have .js functions that have if/else conditions in them or do you have separate files for each browser? Is this really an issue these days with the current versions of each of the popular browsers?
Handling browser-specific JavaScript (JS) and CSS can vary based on your project requirements and the browsers you aim to support. Here's how developers typically manage browser compatibility issues today: ### 1. **Feature Detection vs. Browser Detection** - **Feature Detection:** Instead of checking for browser vers...
9,976
[ { "from": "human", "value": "This is not a new topic, but I am curious how everyone is handling either .js or .css that is browser specific. \nDo you have .js functions that have if/else conditions in them or do you have separate files for each browser? \nIs this really an issue these days with the current...
Is there any centralized repository of useful Objective-C / Cocoa libraries as there is for Perl, Ruby, Python, etc.? In building my first iPhone app, I'm finding myself implementing some very basic functions that would be just a quick "gem install" away in Ruby.
Yes, there is a centralized repository for Objective-C and Cocoa libraries called **CocoaPods**. CocoaPods is a dependency manager for Objective-C and Swift projects that allows you to easily integrate third-party libraries into your Xcode projects. Here's how you can get started with CocoaPods: 1. **Install CocoaPo...
7,713
[ { "from": "human", "value": "Is there any centralized repository of useful Objective-C / Cocoa libraries as there is for Perl, Ruby, Python, etc.?\nIn building my first iPhone app, I'm finding myself implementing some very basic functions that would be just a quick \"gem install\" away in Ruby.\n" }, { ...
Say I have a linked list of numbers of length N. N is very large and I don’t know in advance the exact value of N. How can I most efficiently write a function that will return k completely random numbers from the list?
To efficiently return `k` completely random numbers from a linked list of unknown length `N`, you can use a method known as **Reservoir Sampling**. This technique allows you to sample `k` elements uniformly at random from a stream of data (in this case, your linked list) without needing to know the total number of elem...
7,360
[ { "from": "human", "value": "Say I have a linked list of numbers of length N. N is very large and I don’t know in advance the exact value of N. \nHow can I most efficiently write a function that will return k completely random numbers from the list?\n" }, { "from": "gpt", "value": "To efficientl...
I have a value like this: "Foo Bar" "Another Value" something else What regex will return the values enclosed in the quotation marks (e.g. Foo Bar and Another Value)?
You can use the following regex pattern to match the values enclosed in double quotation marks: ```regex "([^"]*)" ``` Here's how the regex works: - `"`: Matches the opening double quotation mark. - `(`: Begins a capturing group to capture the content inside the quotes. - `[^"]*`: Matches any character except for a ...
14,829
[ { "from": "human", "value": "I have a value like this:\n\"Foo Bar\" \"Another Value\" something else\n\nWhat regex will return the values enclosed in the quotation marks (e.g. Foo Bar and Another Value)?\n" }, { "from": "gpt", "value": "You can use the following regex pattern to match the values...
In my multithreaded application and I see heavy lock contention in it, preventing good scalability across multiple cores. I have decided to use lock free programming to solve this. How can I write a lock free structure?
Creating a lock-free data structure can be a complex task, but it's certainly achievable with the right approach and understanding of concurrency primitives. Lock-free programming generally involves the use of atomic operations to manage concurrent access to shared resources without using traditional locks. Here's a ge...
8,438
[ { "from": "human", "value": "In my multithreaded application and I see heavy lock contention in it, preventing good scalability across multiple cores. I have decided to use lock free programming to solve this.\nHow can I write a lock free structure?\n" }, { "from": "gpt", "value": "Creating a lo...
I'd like to get uniform distribution in range [0.0, 1.0) If possible, please let the implementation make use of random bytes from /dev/urandom. It would also be nice if your solution was thread-safe. If you're not sure, please indicate that. See some solution I thought about after reading other answers.
Certainly! To generate a uniform distribution in the range \([0.0, 1.0)\) using random bytes from `/dev/urandom`, you can follow this approach in Python. This solution also ensures thread safety by using a lock around the random byte reading operation. Here's a complete implementation: ```python import os import struc...
11,848
[ { "from": "human", "value": "I'd like to get uniform distribution in range [0.0, 1.0)\nIf possible, please let the implementation make use of random bytes from /dev/urandom.\nIt would also be nice if your solution was thread-safe. If you're not sure, please indicate that.\nSee some solution I thought about ...
That is, I'd like to have a tuple of values. The use case on my mind: Dictionary<Pair<string, int>, object> or Dictionary<Triple<string, int, int>, object> Are there built-in types like Pair or Triple? Or what's the best way of implementing it? Update There are some general-purpose tuples implementations described in...
In C#, there are no built-in `Pair` or `Triple` types, but you can utilize the `Tuple` class or create your own classes/structs for this purpose. Below are a few options to implement pairs and triples, along with how to use them as dictionary keys: ### Using `Tuple` C# has a built-in `Tuple` class that you can use fo...
7,899
[ { "from": "human", "value": "That is, I'd like to have a tuple of values.\nThe use case on my mind:\nDictionary<Pair<string, int>, object>\n\nor\nDictionary<Triple<string, int, int>, object>\n\nAre there built-in types like Pair or Triple? Or what's the best way of implementing it?\nUpdate There are some ge...
I'm trying to automate a program I made with a test suite via a .cmd file. I can get the program that I ran's return code via %errorlevel%. My program has certain return codes for each type of error. For example: 1 - means failed for such and such a reason 2 - means failed for some other reason ... echo FAILED: Test ...
You can achieve this in a batch file (`.cmd` or `.bat`) by creating a function-like structure using `if` statements to map return codes to error messages. While batch files do not support functions in the same way that a scripting language like Python or Perl does, you can create a set of conditional statements to hand...
13,396
[ { "from": "human", "value": "I'm trying to automate a program I made with a test suite via a .cmd file.\nI can get the program that I ran's return code via %errorlevel%. \nMy program has certain return codes for each type of error.\nFor example: \n1 - means failed for such and such a reason\n2 - means faile...
In a multi-threaded application I'm working on, we occasionally see ConcurrentModificationExceptions on our Lists (which are mostly ArrayList, sometimes Vectors). But there are other times when I think concurrent modifications are happening because iterating through the collection appears to be missing items, but no e...
To address the issues you're facing with `ConcurrentModificationException` and inconsistent reads from a `List` in a multi-threaded environment, you have several options depending on your use case and performance considerations. Here are some approaches you can take: ### 1. Use Synchronization As you've pointed out, ...
5,673
[ { "from": "human", "value": "In a multi-threaded application I'm working on, we occasionally see ConcurrentModificationExceptions on our Lists (which are mostly ArrayList, sometimes Vectors). But there are other times when I think concurrent modifications are happening because iterating through the collect...
I think that java executables (jar files) are trivial to decompile and get the source code. What about other languages? .net and all? Which all languages can compile only to a decompile-able code?
You're correct that Java executables (JAR files) can be relatively easily decompiled back to source code, thanks to the Java bytecode format and the availability of decompilers like JD-GUI, Procyon, and others. When discussing decompilation and the ability to recover source code from compiled binaries, the characteris...
6,253
[ { "from": "human", "value": "I think that java executables (jar files) are trivial to decompile and get the source code.\nWhat about other languages? .net and all?\nWhich all languages can compile only to a decompile-able code?\n" }, { "from": "gpt", "value": "You're correct that Java executable...
Even if it requires manual input. Is there any good-enough option available?
To provide a more tailored answer, could you specify what type of input or context you're referring to? For example, are you looking for options related to software, data entry, content creation, automation, or something else? This would help me give you a more relevant response.
17,062
[ { "from": "human", "value": "Even if it requires manual input. Is there any good-enough option available?\n" }, { "from": "gpt", "value": "To provide a more tailored answer, could you specify what type of input or context you're referring to? For example, are you looking for options related to s...
What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?
In SQL Server 2000, 2005, 2008, and 2012, pagination can be achieved through different approaches. Here’s how you can paginate results and get the total number of records efficiently across these versions: ### SQL Server 2000 In SQL Server 2000, pagination can be done using a combination of `ROW_NUMBER()` and tempora...
10,673
[ { "from": "human", "value": "What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?\n" }, { "from": "gpt", "value": "In SQL Server 2000, 2005, 2008, and 2012, pagination can be achi...
Without spending a long time reviewing the boost source code, could someone give me a quick rundown of how boost bind is implemented?
Boost.Bind is a library in the Boost C++ Libraries that allows for binding arguments to function calls, creating function objects that can be invoked later with those arguments partially or fully applied. Here’s a high-level overview of how Boost.Bind is typically implemented: ### 1. **Function Object Creation:** -...
11,490
[ { "from": "human", "value": "Without spending a long time reviewing the boost source code, could someone give me a quick rundown of how boost bind is implemented? \n" }, { "from": "gpt", "value": "Boost.Bind is a library in the Boost C++ Libraries that allows for binding arguments to function c...
Is it possible to use DateTimePicker (Winforms) to pick both date and time (in the dropdown)? How do you change the custom display of the picked value? Also, is it possible to enable the user to type the date/time manually?
Yes, it is possible to use the `DateTimePicker` control in WinForms to pick both date and time. By default, the `DateTimePicker` can display both date and time if you set its `Format` property to `DateTimePickerFormat.Custom` and provide a custom format string that includes time components. ### Picking both date and t...
10,525
[ { "from": "human", "value": "Is it possible to use DateTimePicker (Winforms) to pick both date and time (in the dropdown)? How do you change the custom display of the picked value? Also, is it possible to enable the user to type the date/time manually?\n" }, { "from": "gpt", "value": "Yes, it is...
I'm having a little problem and I don't see why, it's easy to go around it, but still I want to understand. I have the following class : public class AccountStatement : IAccountStatement { public IList<IAccountStatementCharge> StatementCharges { get; set; } public AccountStatement() { new Account...
The issue you're encountering is due to the way the constructor and property initializations are set up in your `AccountStatement` class. Let's break down what's happening. 1. **Constructor Invocation**: When you create an instance of `AccountStatement` using the object initializer syntax, the default constructor (`pu...
10,914
[ { "from": "human", "value": "I'm having a little problem and I don't see why, it's easy to go around it, but still I want to understand. \nI have the following class :\npublic class AccountStatement : IAccountStatement\n{\n public IList<IAccountStatementCharge> StatementCharges { get; set; }\n\n publ...
I need to get a log of user access to our SQL Server so I can track average and peak concurrency usage. Is there a hidden table or something I'm missing that has this information for me? To my knowledge the application I'm looking at does not track this at the application level. I'm currently working on SQL Server 2000...
In SQL Server 2000, monitoring user access and concurrency can be a bit challenging because there isn't a built-in way to track this directly without some extra setup. However, you can use a combination of system views, dynamic management views (for SQL Server 2005 and later), and some custom logging mechanisms. ### S...
4,509
[ { "from": "human", "value": "I need to get a log of user access to our SQL Server so I can track average and peak concurrency usage. Is there a hidden table or something I'm missing that has this information for me? To my knowledge the application I'm looking at does not track this at the application level....
> jruby -S gem install warbler JRuby limited openssl loaded. gem install jruby-openssl for full support. Successfully installed warbler-0.9.11 1 gem installed Installing ri documentation for warbler-0.9.11... Installing RDoc documentation for warbler-0.9.11... > jruby -S warble <snip>/jruby-1.1.4/bin/warble:1: undefine...
It seems like you're encountering an issue with the `warbler` command after installing the `warbler` gem in JRuby. The error message indicates that the `warble` command is not recognized, specifically mentioning that it can't find the method `warble`. Here are a few steps to help you troubleshoot this issue: 1. **Che...
12,366
[ { "from": "human", "value": "> jruby -S gem install warbler\nJRuby limited openssl loaded. gem install jruby-openssl for full support.\nSuccessfully installed warbler-0.9.11\n1 gem installed\nInstalling ri documentation for warbler-0.9.11...\nInstalling RDoc documentation for warbler-0.9.11...\n> jruby -S w...
I'm discovering a simple solution for singular-plural keywords searches. I heard about stemming but I don't want to use all its features, only plural/singular transformation. The language is Dutch. Have looked at http://www.snowball.tartarus.org before. Does anyone know the simple solution for singular|plural relevant ...
For handling singular and plural forms in Dutch, you might not need the full capabilities of stemming algorithms. Here are a few simpler approaches you can consider: 1. **Manual List of Common Forms**: Create a simple dictionary that maps singular nouns to their plural forms and vice versa. This is manageable for a li...
13,409
[ { "from": "human", "value": "I'm discovering a simple solution for singular-plural keywords searches. I heard about stemming but I don't want to use all its features, only plural/singular transformation. The language is Dutch. Have looked at http://www.snowball.tartarus.org before. Does anyone know the simp...
Has anyone run into issues serializing components into a file and reading them back, specifically in the area where the component vendor upgrades the VCL components. For example a file serialized with DelphiX and then years later read back with delphiY. Do the serialization formats change and if so what can be done t...
Yes, serializing components and then reading them back after a vendor upgrade can lead to issues, particularly when the component library (VCL components, in this case) changes over time. Here are a few key points to consider regarding the serialization of components and handling upgrades: ### 1. **Serialization Forma...
11,980
[ { "from": "human", "value": "Has anyone run into issues serializing components into a file and reading them back, specifically in the area where the component vendor upgrades the VCL components. For example a file serialized with DelphiX and then years later read back with delphiY. Do the serialization fo...
Is that possible to switch an Open Source Project license from GPL to LGPL v3 ? I am the project originator and the only contributor.
Yes, as the originator and sole contributor of an open-source project, you have the authority to change the project's license from the GNU General Public License (GPL) to the GNU Lesser General Public License (LGPL) version 3. Here are the general steps to follow: 1. **Review the Licenses**: Familiarize yourself wit...
9,344
[ { "from": "human", "value": "Is that possible to switch an Open Source Project license from GPL to LGPL v3 ?\nI am the project originator and the only contributor.\n" }, { "from": "gpt", "value": "Yes, as the originator and sole contributor of an open-source project, you have the authority to ch...
I have IIS6 configured such that browsing to http://localhost:8082/Reports gets me the reporting services default home page, which is all as expected. However, when I try to publish a report via Microsoft Business Intelligence Visual Studio 2005 I get the following error: A connection could not be made to the report se...
The error message you are encountering when trying to publish a report from Visual Studio 2005 to SQL Server Reporting Services (SSRS) indicates a connection issue between your Visual Studio environment and the report server. Here are some steps and considerations that might help you troubleshoot and resolve this issue...
13,101
[ { "from": "human", "value": "I have IIS6 configured such that browsing to http://localhost:8082/Reports gets me the reporting services default home page, which is all as expected. However, when I try to publish a report via Microsoft Business Intelligence Visual Studio 2005 I get the following error: A conn...
My domain (let's call it www.example.com) creates a cookie. On another site (let's say, www.myspace.com), my domain is loaded within an iFrame. On every browser (Firefox, Opera, Camino, Safari, etc...) except for Internet Explorer, I can access my own cookie. In IE, it doesn't give me access to the cookie from within t...
The issue you're encountering is related to how Internet Explorer (IE) handles cookies in iframes, especially in older versions. IE has a stricter policy regarding third-party cookies, which can affect your ability to access cookies when your site is loaded in an iframe on another domain. Here are a few potential work...
11,522
[ { "from": "human", "value": "My domain (let's call it www.example.com) creates a cookie.\nOn another site (let's say, www.myspace.com), my domain is loaded within an iFrame.\nOn every browser (Firefox, Opera, Camino, Safari, etc...) except for Internet Explorer, I can access my own cookie. In IE, it doesn't...
I'm writing a report view of an audit trail, and I need to display this in a .jsp. What's the "best" way to get the data from the database to the screen? We're using Spring for dependency injection, Data Access Objects, and Hibernate. I can use hibernate or straight jdbc for this report. If I load all the records into ...
To display an audit trail in a JSP without running out of memory and without embedding your database query logic in the JSP, you can implement a paginated approach using Spring, Hibernate, and a few design patterns. Here’s a step-by-step guide on how to achieve this: ### 1. Use Pagination with Hibernate Instead of lo...
9,133
[ { "from": "human", "value": "I'm writing a report view of an audit trail, and I need to display this in a .jsp. What's the \"best\" way to get the data from the database to the screen?\nWe're using Spring for dependency injection, Data Access Objects, and Hibernate.\nI can use hibernate or straight jdbc for...
I'm setting yup a Greenfield (yeeea!) web application just now was wondering how other people first setup their project with regards to automated/CI build? I generally follow this: Create SVN Repository with basic layout (trunk, braches, lib, etc.) Create basic solution structure (core, ui, tests) Create a basic test ...
It sounds like you have a solid process in place for setting up your Greenfield web application with a focus on automated testing and CI/CD practices. Here’s a more structured breakdown of the steps you might follow, including some additional recommendations and best practices to consider: ### Project Setup Steps for ...
11,082
[ { "from": "human", "value": "I'm setting yup a Greenfield (yeeea!) web application just now was wondering how other people first setup their project with regards to automated/CI build?\nI generally follow this:\n\nCreate SVN Repository with basic layout (trunk, braches, lib, etc.)\nCreate basic solution str...
I've started refactoring some legacy code recently and came across two functions for drawing a coordinate grid, the problem is that these functions differ only in orthogonal variables they treat, something like that void DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1) { for(int x = x0; x < x1; x += ste...
To refactor the two functions `DrawScaleX` and `DrawScaleY` into a single function and avoid code duplication, you can introduce a parameter that determines which axis to draw the scale for. This can be accomplished by using an enumerated type or simply passing a boolean flag (or an integer) to indicate whether you wan...
12,339
[ { "from": "human", "value": "I've started refactoring some legacy code recently and came across two functions for drawing a coordinate grid, the problem is that these functions differ only in orthogonal variables they treat, something like that\nvoid DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int ...
Currently, I am developing a product that does fairly intensive calculations using MS SQL Server 2005. At a high level, the architecture of my product is based on the concept of "runs" where each time I do some analytics it gets stored in a series of run tables (~100 tables per run). The problem I'm having is that whe...
When dealing with performance issues in SQL Server, especially in a scenario where you have a large number of tables and potentially a growing database, it's important to consider several aspects of database design and configuration. Here are some suggestions to improve performance, particularly in your situation: ###...
9,226
[ { "from": "human", "value": "Currently, I am developing a product that does fairly intensive calculations using MS SQL Server 2005. At a high level, the architecture of my product is based on the concept of \"runs\" where each time I do some analytics it gets stored in a series of run tables (~100 tables p...
How can I get all implementations of an interface through reflection in C#?
In C#, you can use reflection to find all implementations of a specific interface. The process generally involves iterating through all types in a given assembly (or assemblies) and checking if each type implements the interface you're interested in. Here's a step-by-step guide on how to do this: 1. **Load the Assembl...
11,442
[ { "from": "human", "value": "How can I get all implementations of an interface through reflection in C#?\n" }, { "from": "gpt", "value": "In C#, you can use reflection to find all implementations of a specific interface. The process generally involves iterating through all types in a given assem...
I need a way to easily export and then import data in a MySQL table from a remote server to my home server. I don't have direct access to the server, and no utilities such as phpMyAdmin are installed. I do, however, have the ability to put PHP scripts on the server. How do I get at the data? I ask this question purely ...
To export and import data from a MySQL table on a remote server to your home server when you have limited access, you can create PHP scripts to facilitate the process. Here's a step-by-step guide on how you can achieve this: ### Step 1: Create Export Script on the Remote Server 1. **Create a PHP file (export.php)** o...
8,019
[ { "from": "human", "value": "I need a way to easily export and then import data in a MySQL table from a remote server to my home server. I don't have direct access to the server, and no utilities such as phpMyAdmin are installed. I do, however, have the ability to put PHP scripts on the server.\nHow do I ge...
Can anyone point me to a tutorial on the best way to open a connection from client to server, read in a binary file and send its contents reliably across the network connection? Even better, is there an open source library that already does this that I could refer to?
Certainly! When it comes to opening a connection from client to server, reading a binary file, and sending its contents reliably over a network, you have several options. Below, I outline a basic approach using TCP sockets in Python, along with some libraries that can help you achieve this. ### Basic Tutorial Using Py...
9,019
[ { "from": "human", "value": "Can anyone point me to a tutorial on the best way to open a connection from client to server, read in a binary file and send its contents reliably across the network connection? Even better, is there an open source library that already does this that I could refer to? \n" }, ...
In a Linux-based system (specifically, Ubuntu Server 8.04), how can you measure downstream bandwidth on a per-user basis? Optimally, I would like a method that provides data directly instead of having to run another process and parse its output. I have a technique for measuring per-user upstream bandwidth by setting ...
To measure downstream bandwidth on a per-user basis in Ubuntu Server 8.04, you can leverage tools that provide network usage statistics based on user accounts. Since you're looking for a method that provides direct data without the need for parsing output from another process, consider the following approaches: ### Me...
8,100
[ { "from": "human", "value": "In a Linux-based system (specifically, Ubuntu Server 8.04), how can you measure downstream bandwidth on a per-user basis? Optimally, I would like a method that provides data directly instead of having to run another process and parse its output. I have a technique for measurin...
I'm using Microsoft.XMLHTTP to get some information from another server from an old ASP/VBScript site. But that other server is restarted fairly often, so I want to check that it's up and running before trying to pull information from it (or avoid my page from giving an HTTP 500 by detecting the problem some other way)...
To check if an external server is up and running before making a request using `Microsoft.XMLHTTP` in an ASP/VBScript application, you can create a function that attempts to send a simple HTTP GET request to the server. If the server is down or unreachable, you can handle the error gracefully rather than allowing your ...
10,549
[ { "from": "human", "value": "I'm using Microsoft.XMLHTTP to get some information from another server from an old ASP/VBScript site. But that other server is restarted fairly often, so I want to check that it's up and running before trying to pull information from it (or avoid my page from giving an HTTP 500...
I have two webapplication, one is a simple authenticationsite which can authenticate the logged in user and redirects him then to another site. Therefore I have to pass ther userId (GUID) to the second application. Currently this is done via the URL but i would like to hide this id. Has anybody an idea how to do this p...
To securely pass the `userId` (or any sensitive information) from one web application to another without exposing it in the URL, you can use a few different approaches. Here are some common techniques you can consider: ### 1. Use Token-Based Authentication Instead of passing the userId directly, you can issue a token ...
8,526
[ { "from": "human", "value": "I have two webapplication, one is a simple authenticationsite which can authenticate the logged in user and redirects him then to another site.\nTherefore I have to pass ther userId (GUID) to the second application. Currently this is done via the URL but i would like to hide thi...
How can you get the directory of the script that was run and use it within the .cmd file?
In a Windows batch file (`.cmd` or `.bat`), you can use a built-in variable to get the directory of the script that was executed. Specifically, you can use `%~dp0`, which expands to the drive letter and path of the batch file. Here’s how you can use `%~dp0` to get the directory of the script and utilize it within your...
13,262
[ { "from": "human", "value": "How can you get the directory of the script that was run and use it within the .cmd file?\n" }, { "from": "gpt", "value": "In a Windows batch file (`.cmd` or `.bat`), you can use a built-in variable to get the directory of the script that was executed. Specifically, ...
I need to write a script to make a source safe project ready to be moved to subversion, what do I need to do so far I can think of: remove .scc files remove .vspcc files Do I need to remove the "read-only" attribute of all the files as well, or will that not matter? What language would you write this script in, I was...
Moving a project from SourceSafe to Subversion (SVN) involves several steps to ensure that the migration is clean and doesn't carry over unnecessary artifacts from SourceSafe. Here’s a breakdown of what you might need to do: ### Steps to Prepare Project for SVN Migration 1. **Remove Source Control Files**: - Delet...
9,744
[ { "from": "human", "value": "I need to write a script to make a source safe project ready to be moved to subversion, what do I need to do so far I can think of:\n\nremove .scc files\nremove .vspcc files\n\nDo I need to remove the \"read-only\" attribute of all the files as well, or will that not matter?\nWh...
I have the handle of process 'A' on a Pocket PC 2003 device. I need to determine if that process is still running from process 'B'. Process 'B' is written in Embedded Visual C++ 4.0.
To check if a process is still running on a Pocket PC 2003 device using Embedded Visual C++ 4.0, you can use the `GetExitCodeProcess` function provided by the Windows CE API. This function allows you to retrieve the exit code for a specified process and determine if it's still running. If the exit code is still `STILL_...
9,282
[ { "from": "human", "value": "I have the handle of process 'A' on a Pocket PC 2003 device. I need to determine if that process is still running from process 'B'. Process 'B' is written in Embedded Visual C++ 4.0.\n" }, { "from": "gpt", "value": "To check if a process is still running on a Pocket ...
The System.Diagnostics.EventLog class provides a way to interact with a windows event log. I use it all the time for simple logging... System.Diagnostics.EventLog.WriteEntry("MyEventSource", "My Special Message") Is there a way to set the user information in the resulting event log entry using .NET?
In .NET, the `System.Diagnostics.EventLog` class does not provide a direct way to set the user information for an event log entry. When you write an entry to the Windows Event Log using `EventLog.WriteEntry`, it logs the entry under the context of the user account that is running the application. If you want to log en...
13,192
[ { "from": "human", "value": "The System.Diagnostics.EventLog class provides a way to interact with a windows event log. I use it all the time for simple logging...\nSystem.Diagnostics.EventLog.WriteEntry(\"MyEventSource\", \"My Special Message\")\n\nIs there a way to set the user information in the resulti...
Is there any source on the web where I could find date and time formats used in individual countries in the World? I was checking languages listed in Control panel in Windows, but there are some countries missing (for example countries in Africa etc.). I found some locale tables on the web, but these usualy differ from...
Yes, there are several resources you can use to find date and time formats used in different countries around the world. Here are some options: 1. **IANA Time Zone Database**: The IANA Time Zone Database contains information about time zones and their offsets. While it focuses on time zones rather than formats, it can...
13,494
[ { "from": "human", "value": "Is there any source on the web where I could find date and time formats used in individual countries in the World? I was checking languages listed in Control panel in Windows, but there are some countries missing (for example countries in Africa etc.).\nI found some locale table...
When is it a good idea to use factory methods within an object instead of a Factory class?
Using factory methods within an object rather than employing a separate Factory class can be advantageous in several scenarios: 1. **Encapsulation of Related Behavior**: If the creation of an object is closely related to the state or behavior of the object itself, it makes sense to use factory methods within that obje...
8,408
[ { "from": "human", "value": "When is it a good idea to use factory methods within an object instead of a Factory class?\n" }, { "from": "gpt", "value": "Using factory methods within an object rather than employing a separate Factory class can be advantageous in several scenarios:\n\n1. **Encapsu...
Math skills are becoming more and more essential, and I wonder where is a good place to brush up on some basics before moving on to some more CompSci specific stuff? A site with lots of video's as well as practice exercises would be a double win but I can't seem to find one.
If you're looking to brush up on your math skills before diving into more computer science-specific topics, there are several excellent online resources that offer video tutorials along with practice exercises. Here are a few recommendations: 1. **Khan Academy**: This is a fantastic resource for learners of all levels...
12,239
[ { "from": "human", "value": "Math skills are becoming more and more essential, and I wonder where is a good place to brush up on some basics before moving on to some more CompSci specific stuff?\nA site with lots of video's as well as practice exercises would be a double win but I can't seem to find one.\n"...
I was reading a MS Excel help article about pivotcache and wonder what they mean by OLE DB and ODBC sources ...You should use the CommandText property instead of the SQL property, which now exists primarily for compatibility with earlier versions of Microsoft Excel. If you use both properties, the CommandTex...
OLE DB and ODBC are both APIs used to connect to different types of data sources, such as databases: - **OLE DB (Object Linking and Embedding, Database)**: This is a set of COM (Component Object Model) interfaces that allows applications to access data from a variety of sources in a uniform manner. It is commonly used...
14,133
[ { "from": "human", "value": "I was reading a MS Excel help article about pivotcache and wonder what they mean by OLE DB and ODBC sources\n\n...You should use the CommandText\n property instead of the SQL property,\n which now exists primarily for\n compatibility with earlier versions of\n Microsoft Exce...
What is the easiest way to extract the original exception from an exception returned via Apache's implementation of XML-RPC?
In Apache's implementation of XML-RPC, when an exception occurs, it is typically wrapped in an XML-RPC fault response. To extract the original exception from this response, you need to look for specific fields in the fault structure. Here’s a step-by-step approach to extracting the original exception: 1. **Identify t...
12,658
[ { "from": "human", "value": "What is the easiest way to extract the original exception from an exception returned via Apache's implementation of XML-RPC?\n" }, { "from": "gpt", "value": "In Apache's implementation of XML-RPC, when an exception occurs, it is typically wrapped in an XML-RPC fault ...
/etc/init.d/* /etc/rc{1-5}.d/*
The `/etc/init.d/` directory and the `/etc/rc*.d/` directories are part of the System V-style init system, which is used by some Unix-like operating systems for managing system services and startup scripts. ### `/etc/init.d/` - This directory contains scripts that start, stop, and manage services. Each script is gener...
12,201
[ { "from": "human", "value": "/etc/init.d/*\n\n\n/etc/rc{1-5}.d/*\n\n" }, { "from": "gpt", "value": "The `/etc/init.d/` directory and the `/etc/rc*.d/` directories are part of the System V-style init system, which is used by some Unix-like operating systems for managing system services and startu...
Right now I have an SSIS package that runs every morning and gives me a report on the number of packages that failed or succeeded from the day before. The information for these packages is contained partly within the sysjobs table (a system table) within the msdb database (a system database) in SQL Server 2005. When tr...
In SQL Server, system tables such as those in the `msdb` database (like `sysjobs`) are not directly exposed via LINQ to SQL's standard ORM mapping capabilities. This is primarily because LINQ to SQL is designed to work with user-defined schemas rather than system tables. However, you can still access system tables in S...
8,913
[ { "from": "human", "value": "Right now I have an SSIS package that runs every morning and gives me a report on the number of packages that failed or succeeded from the day before. The information for these packages is contained partly within the sysjobs table (a system table) within the msdb database (a sys...
Anyone found a good pattern for getting around immutable styles in Silverlight 2? What I mean is does anyone have a workaround for the fact that you cannot switch the style of an element programmatically once it has been set, i.e. the second line here will throw a catastrophic failure exception: this.TestButton.Style =...
In Silverlight 2, styles are indeed immutable once they've been applied to a control. Attempting to set a new style on a control that already has a style will lead to a catastrophic failure. However, there are some workarounds to change styles programmatically. ### Workarounds 1. **Create a new instance of the contro...
11,230
[ { "from": "human", "value": "Anyone found a good pattern for getting around immutable styles in Silverlight 2? What I mean is does anyone have a workaround for the fact that you cannot switch the style of an element programmatically once it has been set, i.e. the second line here will throw a catastrophic f...
Does someone have experience with storing key-value pairs in a database? I've been using this type of table: CREATE TABLE key_value_pairs ( itemid varchar(32) NOT NULL, itemkey varchar(32) NOT NULL, itemvalue varchar(32) NOT NULL, CONSTRAINT ct_primarykey PRIMARY KEY(itemid,item...
When deciding between a key-value pair approach using a table format (the first method) or a fixed-column schema (the second method), there are several considerations to weigh based on your application's requirements, performance needs, and expected usage patterns. ### Option 1: Key-Value Pairs (Normalized Structure) ...
10,910
[ { "from": "human", "value": "Does someone have experience with storing key-value pairs in a database?\nI've been using this type of table:\nCREATE TABLE key_value_pairs ( \n itemid varchar(32) NOT NULL,\n itemkey varchar(32) NOT NULL,\n itemvalue varchar(32) NOT NULL,\n C...
Based on a few posts I've read concerning version control, it seems people think pessimistic locking in a version control system is a bad thing. Why? I understand that it prevents one developer from submitting a change while another has the file checked out, but so what? If your code files are so big that you consta...
Pessimistic locking in version control systems refers to the practice of locking files or resources when a developer is working on them, preventing others from making changes until the lock is released. While this approach can reduce the risk of concurrent changes clashing, there are several reasons why it is generally...
12,161
[ { "from": "human", "value": "Based on a few posts I've read concerning version control, it seems people think pessimistic locking in a version control system is a bad thing. Why? I understand that it prevents one developer from submitting a change while another has the file checked out, but so what? If y...
Is there any way to have different layout based on level of the log message when using log4net? Say, if it is a fatal error, I want to see all kind of information possible - class name, method name, line number etc. But for normal, debug and warning, I want to see only the message (I hope, this can increase the perform...
Yes, you can achieve this in log4net by creating different layouts for different log levels. You can define a custom appender for fatal messages that includes detailed information such as class name, method name, and line number, while using a simpler layout for other log levels. Here’s how to set it up: 1. **Create...
10,154
[ { "from": "human", "value": "Is there any way to have different layout based on level of the log message when using log4net? Say, if it is a fatal error, I want to see all kind of information possible - class name, method name, line number etc. But for normal, debug and warning, I want to see only the messa...
I set up 404 handler page in web.config, but it works ONLY when extension of URL is .aspx (or other which is handled by ASP.NET). I know I can setup static HTML page in website options, but I want to have a page. Is there any options to assign ASPX handler page for all request extensions in IIS?
In IIS, the `web.config` file can be used to configure custom error pages, including a custom 404 error page. However, the behavior you've described—where the 404 handler only works for `.aspx` pages—suggests that non-ASP.NET requests are being handled differently, which is standard behavior since IIS has different pip...
13,305
[ { "from": "human", "value": "I set up 404 handler page in web.config, but it works ONLY when extension of URL is .aspx (or other which is handled by ASP.NET).\nI know I can setup static HTML page in website options, but I want to have a page.\nIs there any options to assign ASPX handler page for all request...
C++ is all about memory ownership - aka ownership semantics. It is the responsibility of the owner of a chunk of dynamically allocated memory to release that memory. So the question really becomes who owns the memory. In C++ ownership is documented by the type a raw pointer is wrapped inside thus in a good (IMO) C++ pr...
Your summary does a great job of outlining the various smart pointer types in C++ and their respective ownership semantics. Here, I'll present another type of ownership semantic that complements your list. ### Ownership Semantic: Unique Ownership (Transferable) #### Smart Pointer: `std::unique_ptr<T>` **Description:...
10,876
[ { "from": "human", "value": "C++ is all about memory ownership - aka ownership semantics.\nIt is the responsibility of the owner of a chunk of dynamically allocated memory to release that memory. So the question really becomes who owns the memory.\nIn C++ ownership is documented by the type a raw pointer is...
I have two vista Business machines. I have IE 7 installed on both. On my first machine (Computer1) if I go to this site (http://www.quirksmode.org/js/detect.html), it says I am using "Explorer 6 on Windows". If I use Computer2 with Vista Business and IE7, it says I am using "Explorer 7 on Windows". Here is a screen...
The issue you're encountering could be due to several factors, even if both machines are running the same version of Internet Explorer 7 (IE7). Here are some possible reasons and solutions: 1. **Compatibility View**: Check if Compatibility View is turned on in IE7 on Computer1. This feature can sometimes cause IE to r...
13,818
[ { "from": "human", "value": "I have two vista Business machines. I have IE 7 installed on both. On my first machine (Computer1) if I go to this site (http://www.quirksmode.org/js/detect.html), it says I am using \"Explorer 6 on Windows\". If I use Computer2 with Vista Business and IE7, it says I am using...
How do I copy a file in Python?
In Python, you can copy a file using the `shutil` module, which provides a convenient method called `shutil.copy()`. This function copies the contents of a file to a specified destination. Here's how you can do it: ### Example: ```python import shutil # Specify the source file and the destination file source = 'path...
14,084
[ { "from": "human", "value": "How do I copy a file in Python?\n" }, { "from": "gpt", "value": "In Python, you can copy a file using the `shutil` module, which provides a convenient method called `shutil.copy()`. This function copies the contents of a file to a specified destination. Here's how yo...
I have a VPS host running 3 sites using Ubuntu Hardy. I've spent much time setting it up. That includes all the installation + configuration and stuff. What ways are there to do backup + restore for VPS?
Backing up and restoring your VPS is crucial to ensure that your data and configurations are safe. Here are several methods you can use for backing up and restoring your VPS running Ubuntu Hardy: ### 1. **Filesystem Backup** #### **Using `tar`** You can create an archive of your website and configurations using the `...
7,816
[ { "from": "human", "value": "I have a VPS host running 3 sites using Ubuntu Hardy. I've spent much time setting it up. That includes all the installation + configuration and stuff. What ways are there to do backup + restore for VPS? \n" }, { "from": "gpt", "value": "Backing up and restoring your...
Can i print out a url /admin/manage/products/add of a certain view in a template? Here is the rule i want to create a link for (r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}), I would like to have /manage/products/add in a template without hardcoding it. How can i do this? Edit...
To generate URLs dynamically in Django templates without hardcoding them, you can use the `{% url %}` template tag. This tag helps you create URLs based on the names of your views or URL patterns. First, make sure your URL pattern for the `create_object` view has a name. For example, you can update your URL configurat...
14,419
[ { "from": "human", "value": "Can i print out a url /admin/manage/products/add of a certain view in a template?\nHere is the rule i want to create a link for\n(r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}),\n\nI would like to have /manage/products/add in a template w...
SVN keyword substition gives is not pretty. E.g., Last updated: $Date$ by $Author$ yields Last updated: $Date: 2008-09-22 14:38:43 -0400 (Mon, 22 Sep 2008) $ by $Author: cconway $" Does anybody have a Javascript snippet that prettifies things and outputs some HTML? The result should be more like: Last update: ...
You can certainly write a JavaScript function to prettify the SVN keyword substitution output and format it into HTML. Here's a sample snippet that achieves this: ```javascript function prettifySVNKeywords(svnOutput) { // Regular expression patterns to match the SVN keywords const datePattern = /\$Date:\s*(\d{...
11,949
[ { "from": "human", "value": "SVN keyword substition gives is not pretty. E.g.,\n\nLast updated: $Date$ by $Author$\n\nyields\n\nLast updated: $Date: 2008-09-22\n 14:38:43 -0400 (Mon, 22 Sep 2008) $ by\n $Author: cconway $\"\n\nDoes anybody have a Javascript snippet that prettifies things and outputs some ...
In C++ the storage class specifier static allocates memory from the data area. What does "data area" mean?
In the context of C++ (and programming in general), the term "data area" typically refers to a section of memory that is used to store static and global variables. Here's a brief overview of memory layout in a typical C++ program, which helps explain the concept of the data area: 1. **Text Segment**: This area contain...
13,041
[ { "from": "human", "value": "In C++ the storage class specifier static allocates memory from the data area. What does \"data area\" mean?\n" }, { "from": "gpt", "value": "In the context of C++ (and programming in general), the term \"data area\" typically refers to a section of memory that is us...
I have this workspace downloaded off the web and I try running it on a tomcat server from a fresh installation of Eclipse Ganymede. This particular project came with its own workspace. When I select Tomcat v6.0 I get a message Cannot create a server using the selected type Older tomcat versions are available, thoug...
The error message you're encountering when trying to set up the Tomcat v6.0 server in Eclipse Ganymede could be due to several reasons. Here are some steps you can take to troubleshoot and resolve the issue: ### 1. Check Tomcat Installation Make sure that you have a proper installation of Tomcat v6.0 on your system. Y...
9,484
[ { "from": "human", "value": "I have this workspace downloaded off the web and I try running it on a tomcat server from a fresh installation of Eclipse Ganymede. This particular project came with its own workspace. \nWhen I select Tomcat v6.0 I get a message \n\nCannot create a server using the selected type...
I am using jProfiler to find memory leaks in a Java swing application. I have identified instances of a JFrame which keeps growing in count. This frame is opened, and then closed. Using jProfiler, and viewing the Paths to GC Root there is only one reference, 'JNI Global reference'. What does this mean? Why is it hangin...
When you observe that instances of a `JFrame` (or any other Java object) are not being garbage collected and you see "JNI Global reference" as the path to GC root in JProfiler, it indicates that there is a native code reference that is holding onto these `JFrame` instances. Here’s a breakdown of what this means and why...
10,917
[ { "from": "human", "value": "I am using jProfiler to find memory leaks in a Java swing application. I have identified instances of a JFrame which keeps growing in count.\nThis frame is opened, and then closed.\nUsing jProfiler, and viewing the Paths to GC Root there is only one reference, 'JNI Global refere...
I keep running into this problem when debugging JSP pages in OpenNMS. The Jetty wiki talks about keepGenerated (http://docs.codehaus.org/display/JETTY/KeepGenerated) in webdefault.xml but it seems unclear how this works in embedded setups.
When dealing with JSP pages in an embedded Jetty setup like in OpenNMS, the `keepGenerated` attribute from the `webdefault.xml` configuration file is particularly relevant for development and debugging purposes. It allows you to keep the generated servlet files for your JSP pages, making it easier to debug your code. ...
11,560
[ { "from": "human", "value": "I keep running into this problem when debugging JSP pages in OpenNMS. The Jetty wiki talks about keepGenerated (http://docs.codehaus.org/display/JETTY/KeepGenerated) in webdefault.xml but it seems unclear how this works in embedded setups.\n" }, { "from": "gpt", "val...
Here is my current question: I'm guessing that my problem (described below) is being caused by ASP.NET worker processes being recycled, per the answers below—I'm using InProc sessions storage and don't see much chance of moving away, due to the restriction for other types of storage that all session objects be serializ...
ASP.NET session state is sensitive to various factors that could lead to the loss of session data, especially when using InProc session storage. If you're encountering issues where sessions are seemingly lost and you're not aware of the worker process recycling, there are several potential causes to consider: 1. **App...
9,704
[ { "from": "human", "value": "Here is my current question:\nI'm guessing that my problem (described below) is being caused by ASP.NET worker processes being recycled, per the answers below—I'm using InProc sessions storage and don't see much chance of moving away, due to the restriction for other types of st...
I've been doing some work with the JAX-RS reference implementation (Jersey). I know of at least two other frameworks (Restlet & Apache CXF). My question is: Has anyone done some comparison between those frameworks and if so, which framework would you recommend and why?
Yes, there have been various comparisons and evaluations of JAX-RS implementations and REST frameworks like Jersey, Restlet, and Apache CXF. Each framework has its strengths and weaknesses depending on your specific requirements and project context. Here's a brief overview of each and some considerations for choosing o...
12,402
[ { "from": "human", "value": "I've been doing some work with the JAX-RS reference implementation (Jersey).\nI know of at least two other frameworks (Restlet & Apache CXF).\nMy question is: Has anyone done some comparison between those frameworks and if so, which framework would you recommend and why?\n" },...
Is there a tool or a way to find out how much memory consumed by each DLL or object in .NET? The more detail it analyzes the better. Thanks.
Yes, there are several tools and methods you can use to analyze memory consumption by DLLs or objects in .NET applications. Here are some popular ones: ### 1. **Visual Studio Diagnostic Tools** - **Memory Usage Tool**: Visual Studio includes a built-in diagnostic tool that allows you to analyze memory usage. You can t...
8,046
[ { "from": "human", "value": "Is there a tool or a way to find out how much memory consumed by each DLL or object in .NET?\nThe more detail it analyzes the better. Thanks.\n" }, { "from": "gpt", "value": "Yes, there are several tools and methods you can use to analyze memory consumption by DLLs o...
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} What's the difference between: function sum(x, y) { return x+y; } // and var sum = function (x, y) { return x+y; } Why is one used over the other?
The two ways of defining a function in JavaScript that you’ve mentioned are called "function declarations" and "function expressions," respectively. Here are the key differences between them: ### 1. **Function Declaration** ```javascript function sum(x, y) { return x + y; } ``` - **Hoisting:** Function declaration...
11,116
[ { "from": "human", "value": "\nPossible Duplicate:\nJavaScript: var functionName = function() {} vs function functionName() {} \n\nWhat's the difference between:\nfunction sum(x, y) {\n return x+y;\n}\n\n// and \n\nvar sum = function (x, y) {\n return x+y;\n}\n\nWhy is one used over the other?\n" }, ...
I have the feeling that is easy to find samples, tutorials and simple examples on Flex. It seems harder to find tips and good practices based on real-life projects. Any tips on how to : How to write maintainable actionscript code How to ensure a clean separation of concern. Has anybody used an MVC framework such as ca...
Writing maintainable ActionScript code and ensuring a clean separation of concerns in a Flex application is essential for long-term sustainability and scalability. Here are some tips and best practices based on real-life projects: ### 1. Writing Maintainable ActionScript Code - **Follow Coding Conventions**: Use cons...
9,267
[ { "from": "human", "value": "I have the feeling that is easy to find samples, tutorials and simple examples on Flex.\nIt seems harder to find tips and good practices based on real-life projects.\nAny tips on how to :\n\nHow to write maintainable actionscript code\nHow to ensure a clean separation of concern...
Like the Delicious submission bookmark-let, I'd like to have some standard JavaScript I can use to submit any visited URL to a 3rd party site when that's possible by URL. Suggestions? For example, I've been using javascript:void(location.href="http://www.yacktrack.com/home?query="+encodeURI(location.href)) so far b...
Creating a bookmarklet for submitting URLs to a third-party site can be a simple yet effective way to share content. Your existing code snippet is functional, but there are ways to enhance it or make it more versatile. Here are a few suggestions: ### 1. General Bookmarklet Structure You can create a more generic book...
10,328
[ { "from": "human", "value": "Like the Delicious submission bookmark-let, I'd like to have some standard JavaScript I can use to submit any visited URL to a 3rd party site when that's possible by URL. Suggestions?\nFor example, I've been using \njavascript:void(location.href=\"http://www.yacktrack.com/home?...
I have an HTTP server which is in our internal network and accessible only from inside it. I would like to put another server that would listen to an HTTPS port accessible from outside, and forward the requests to that HTTP server (and send back the responses via HTTPS). I know that there are several ways to do this wi...
Yes, you can achieve this using Apache HTTP Server with the appropriate modules, and it requires minimal configuration. Here’s how you can set it up to act as a reverse proxy, allowing external HTTPS requests to be forwarded to your internal HTTP server. ### Prerequisites 1. Ensure you have Apache HTTP Server install...
11,105
[ { "from": "human", "value": "I have an HTTP server which is in our internal network and accessible only from inside it. I would like to put another server that would listen to an HTTPS port accessible from outside, and forward the requests to that HTTP server (and send back the responses via HTTPS). I know ...
I want to access the call stack at runtime in a Native C++ application. I am not using the IDE. How do I display the call stack? Update: I have a function which is called from many points all over the application. It crashes on rare occasions. I was looking for a way to get name of the caller and log it.
In a native C++ application, if you want to access the call stack at runtime to log the function calls, you can use a combination of platform-specific libraries and methods. Here's how you can achieve this for different platforms: ### On Windows 1. **Use `StackWalk64`**: This function can be used to retrieve the call...
11,035
[ { "from": "human", "value": "I want to access the call stack at runtime in a Native C++ application. I am not using the IDE. How do I display the call stack?\nUpdate: I have a function which is called from many points all over the application. It crashes on rare occasions. I was looking for a way to get nam...
I know that JTable can sort by a single column. But is it possible to allow for multiple column sort or do I need to write the code myself?
JTable in Swing, by default, supports sorting by a single column. However, if you want to enable multi-column sorting, you will need to implement custom logic since JTable does not provide built-in support for it out of the box. Here's a general approach you can take to implement multi-column sorting: 1. **Create a C...
8,173
[ { "from": "human", "value": "I know that JTable can sort by a single column. But is it possible to allow for multiple column sort or do I need to write the code myself?\n" }, { "from": "gpt", "value": "JTable in Swing, by default, supports sorting by a single column. However, if you want to enab...
I want to write a function that takes an array of letters as an argument and a number of those letters to select. Say you provide an array of 8 letters and want to select 3 letters from that. Then you should get: 8! / ((8 - 3)! * 3!) = 56 Arrays (or words) in return consisting of 3 letters each.
To generate all possible combinations of a specified number of letters from an array, you can use a recursive approach or leverage the `combinations` function from Python's `itertools` module. Below is a function that takes an array of letters and a number, and returns all unique combinations of the specified size: ``...
10,759
[ { "from": "human", "value": "I want to write a function that takes an array of letters as an argument and a number of those letters to select. \nSay you provide an array of 8 letters and want to select 3 letters from that. Then you should get:\n8! / ((8 - 3)! * 3!) = 56\n\nArrays (or words) in return consis...
Is there a one button way to save a screenshot directly to a file in Windows? TheSoftwareJedi accurately answered above question for Windows 8 and 10. Below original extra material remains for posterity. This is a very important question as the 316K views shows as of 2021. Asked in 2008, SO closed this question arou...
Yes, there is a one-button way to save a screenshot directly to a file in Windows, specifically for Windows 8, 10, and later versions. You can use the following methods: ### Method 1: Windows Key + Print Screen 1. Press **Windows key + Print Screen (PrtScn)**. 2. Your screen will briefly dim, indicating that a screens...
13,682
[ { "from": "human", "value": "Is there a one button way to save a screenshot directly to a file in Windows?\n\nTheSoftwareJedi accurately answered above question for Windows 8 and 10. Below original extra material remains for posterity.\n\nThis is a very important question as the 316K views shows as of 2021...
Does anyone know of an MD5/SHA1/etc routine that is easily used with GLib (i.e. you can give it a GIOChannel, etc)?
Yes, GLib provides a straightforward way to compute MD5, SHA1, and other hash values using the `GChecksum` class. You can use `GChecksum` in combination with a `GIOChannel` to compute the hash of data being read from it. Here is a simple example of how to use `GChecksum` with `GIOChannel` in C: ```c #include <glib.h>...
11,876
[ { "from": "human", "value": "Does anyone know of an MD5/SHA1/etc routine that is easily used with GLib (i.e. you can give it a GIOChannel, etc)?\n" }, { "from": "gpt", "value": "Yes, GLib provides a straightforward way to compute MD5, SHA1, and other hash values using the `GChecksum` class. You ...
I'm using GDI+ in C++. (This issue might exist in C# too). I notice that whenever I call Graphics::MeasureString() or Graphics::DrawString(), the string is padded with blank space on the left and right. For example, if I am using a Courier font, (not italic!) and I measure "P" I get 90, but "PP" gives me 150. I woul...
The behavior you're observing in GDI+ when using `Graphics::MeasureString()` with certain fonts, especially monospaced ones like Courier, is indeed often due to the way GDI+ measures text. While one might expect monospaced fonts to behave consistently in terms of width, GDI+ includes some additional metrics in its meas...
12,248
[ { "from": "human", "value": "I'm using GDI+ in C++. (This issue might exist in C# too). \nI notice that whenever I call Graphics::MeasureString() or Graphics::DrawString(), the string is padded with blank space on the left and right.\nFor example, if I am using a Courier font, (not italic!) and I measure \...
I really like Araxis Merge for a graphical DIFF program for the PC. I have no idea what's available for linux, though. We're running SUSE linux on our z800 mainframe. I'd be most grateful if I could get a few pointers to what programs everyone else likes.
Sure! There are several popular graphical diff and merge tools available for Linux that you might find useful. Here are a few recommendations: 1. **Meld**: Meld is a popular visual diff and merge tool that offers a clean interface and supports both file and directory comparisons. It’s user-friendly and integrates well...
13,228
[ { "from": "human", "value": "I really like Araxis Merge for a graphical DIFF program for the PC. I have no idea what's available for linux, though. We're running SUSE linux on our z800 mainframe.\nI'd be most grateful if I could get a few pointers to what programs everyone else likes.\n" }, { "from...
I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the number of times each elements is used is t...
To generate a list of permutations according to your criteria, you can follow these steps: 1. **Input Parameters:** Define your parameters \( x \), \( y \), and \( z \). Here \( x \) is the number of unique elements (from 0 to \( x-1 \)), \( y \) is the number of lists you want, and \( z \) is the number of elements i...
10,361
[ { "from": "human", "value": "I need to make a random list of permutations. The elements can be anything but assume that they are the integers 0 through x-1. I want to make y lists, each containing z elements. The rules are that no list may contain the same element twice and that over all the lists, the n...
Can WampServer be used successfully in production? Is this a bad idea? So everyone knows, and I don't see how this mattered, we've paid for a windows dedicated box and we have existing IIS apps. We just wanted to use a PHP based CMS which installs easier on apache (since it has some dependencies). So, as the title indi...
Using WampServer in a production environment is generally not recommended for several reasons, even though it can technically be done. Here's a breakdown of why deploying WampServer in a production setting might be a bad idea: ### 1. **Development Focus**: WampServer is primarily designed for developers to create and ...
14,054
[ { "from": "human", "value": "Can WampServer be used successfully in production? Is this a bad idea?\nSo everyone knows, and I don't see how this mattered, we've paid for a windows dedicated box and we have existing IIS apps. We just wanted to use a PHP based CMS which installs easier on apache (since it has...
I have Excel add-in which I add so many class modules that it is now very bulky. I want to convert it into a type library or a COM package so that I can re-use it for the other apps in the MS Office suite. I ported the add-in to Visual Studio as a class library project but Excel Automation doesn't recognize the classes...
To expose your .NET classes for use in OLE Automation and make them recognizable in Excel and other Office applications, you need to follow certain steps and ensure your class library is properly set up. Here’s a structured approach to achieve this: ### 1. Set Up Your Project for COM Interop - **Use the right project...
10,419
[ { "from": "human", "value": "I have Excel add-in which I add so many class modules that it is now very bulky. I want to convert it into a type library or a COM package so that I can re-use it for the other apps in the MS Office suite.\nI ported the add-in to Visual Studio as a class library project but Exce...
If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation?
In Python, `__init__.py` files are used to mark a directory as a Python package. If your `__init__.py` files are empty, they serve primarily to define the package structure rather than providing functionality. Here’s how you can handle them in version control and installation: 1. **Storing Empty `__init__.py` Files in...
11,946
[ { "from": "human", "value": "If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation?\n" }, { "from": "gpt", "value": "In Python, `__init__.py` files are used to mark a director...
I am working on an application that is about 250,000 lines of code. I'm currently the only developer working on this application that was originally built in .NET 1.1. Pervasive throughout is a class that inherits from CollectionBase. All database collections inherit from this class. I am considering refactoring to...
Refactoring a large codebase, especially one that involves foundational changes like changing a base class from `CollectionBase` to a generic `List<T>`, is a significant undertaking. Here are some considerations and steps to guide you through this refactor: ### Considerations Before Refactoring 1. **Impact Analysis**...
11,125
[ { "from": "human", "value": "I am working on an application that is about 250,000 lines of code. I'm currently the only developer working on this application that was originally built in .NET 1.1. Pervasive throughout is a class that inherits from CollectionBase. All database collections inherit from thi...
I'm interested in building a PC for a car that will boot off of a USB flash drive. I'm planning on using Windows PE 2.0 for it with the GUI being written in C# or VB.NET. Obviously, for this to work, I'd need to have .NET 2.0 or later installed. Understanding that .NET is not included by default, is there a way to pack...
Creating a PC for a car that boots off a USB flash drive using Windows PE (Preinstallation Environment) 2.0 and running a .NET application involves a few steps and considerations. Windows PE 2.0 is based on Windows Vista, and .NET Framework 2.0 is indeed not included by default. ### Step 1: Preparing Windows PE 2.0 1...
11,056
[ { "from": "human", "value": "I'm interested in building a PC for a car that will boot off of a USB flash drive. I'm planning on using Windows PE 2.0 for it with the GUI being written in C# or VB.NET.\nObviously, for this to work, I'd need to have .NET 2.0 or later installed. Understanding that .NET is not i...
Earlier today a question was asked regarding input validation strategies in web apps. The top answer, at time of writing, suggests in PHP just using htmlspecialchars and mysql_real_escape_string. My question is: Is this always enough? Is there more we should know? Where do these functions break down?
While `htmlspecialchars` and `mysql_real_escape_string` are commonly referenced functions for input validation and sanitization in PHP, relying solely on them is not sufficient for comprehensive security in web applications. Here's a breakdown of their use cases, limitations, and additional considerations for input val...
8,649
[ { "from": "human", "value": "Earlier today a question was asked regarding input validation strategies in web apps.\nThe top answer, at time of writing, suggests in PHP just using htmlspecialchars and mysql_real_escape_string. \nMy question is: Is this always enough? Is there more we should know? Where do th...