instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a "unterminated string literal."
I checked the line and the lines around it and everything seems fine-parentheses, braces, and... | An "unterminated string literal" error in JavaScript typically indicates that there's a string in your code that hasn't been closed properly, but since you've already checked for balanced quotes, here are some other possible causes and troubleshooting tips:
1. **Escaped Quotes**: Check for any strings that may contain... | 24,064 | [
{
"from": "human",
"value": "I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a \"unterminated string literal.\" \nI checked the line and the lines around it and ev... |
I have a large legacy system to maintain. The codebase uses threads all over the place and those threads share a lot of mutable data. I know, sounds bad. Anyway, don't answer "rewrite the whole application from scratch" or I'll vote you down :-) I have tried to run some static analysis tools on the codebase, but none o... | Given the complexity and potential issues in your legacy codebase, identifying problematic patterns related to thread safety, especially with shared mutable state, can be challenging. While completely automatic solutions might not capture everything, there are several strategies and tools you can employ to improve the ... | 20,634 | [
{
"from": "human",
"value": "I have a large legacy system to maintain. The codebase uses threads all over the place and those threads share a lot of mutable data. I know, sounds bad. Anyway, don't answer \"rewrite the whole application from scratch\" or I'll vote you down :-) I have tried to run some static... |
I'm beginning work on a project that will access a Drupal site to create (and eventually edit) nodes on the site, via the XML-RPC facility and BlogAPI module shipped with Drupal. This includes file uploading, as the project is to allow people to upload pictures en mass to a Drupal site with minimal ado.
What I'd like t... | When working with Drupal's XML-RPC implementation and the BlogAPI module for creating and editing nodes, there are several caveats and best practices to keep in mind. Here are some points to consider:
### 1. **Version Compatibility**:
- Ensure that you are using a compatible version of Drupal and the BlogAPI module... | 24,315 | [
{
"from": "human",
"value": "I'm beginning work on a project that will access a Drupal site to create (and eventually edit) nodes on the site, via the XML-RPC facility and BlogAPI module shipped with Drupal. This includes file uploading, as the project is to allow people to upload pictures en mass to a Drup... |
Suppose I have a class with some attributes. How is it best (in the Pythonic-OOP) sense to access these attributes ? Just like obj.attr ? Or perhaps write get accessors ?
What are the accepted naming styles for such things ?
Edit:
Can you elaborate on the best-practices of naming attributes with a single or double lea... | In Pythonic Object-Oriented Programming (OOP), accessing attributes is typically done directly via `obj.attr`. This is considered more Pythonic than using getter methods, as Python encourages direct access to attributes unless there’s a strong reason to restrict access. Direct access keeps the code clean and readable, ... | 23,207 | [
{
"from": "human",
"value": "Suppose I have a class with some attributes. How is it best (in the Pythonic-OOP) sense to access these attributes ? Just like obj.attr ? Or perhaps write get accessors ? \nWhat are the accepted naming styles for such things ?\nEdit:\nCan you elaborate on the best-practices of n... |
Does anyone have an example using the table object in YUI library. More specifically, I'd like to dynamically load it from JSON or SQL?
http://www.grails.org/YUI+Plugin
| Certainly! Below is a simple example of how you can use the YUI (Yahoo User Interface) library to create a dynamic table that loads data from a JSON source. This example assumes you have already included the YUI library in your project.
### Step 1: Include the YUI Library
You can include YUI in your HTML file as foll... | 19,799 | [
{
"from": "human",
"value": "Does anyone have an example using the table object in YUI library. More specifically, I'd like to dynamically load it from JSON or SQL?\nhttp://www.grails.org/YUI+Plugin\n"
},
{
"from": "gpt",
"value": "Certainly! Below is a simple example of how you can use the YUI... |
I have a CVS repository on my local workstation. I've demonstrated to my employer that version control is a great idea. Alright! So now I want to migrate my CVS history from my local workstation onto a real server.
I have installed CVS on the server and it is working.
Now, can I just move my repository files? Or do I h... | To migrate your CVS repository along with its history to a new server, you cannot simply move the repository files or check in the current codebase again, as this would indeed lose all of your historical data. Instead, you will need to transfer the entire CVS repository correctly.
Here’s how to do it:
### Step 1: Loc... | 23,474 | [
{
"from": "human",
"value": "I have a CVS repository on my local workstation. I've demonstrated to my employer that version control is a great idea. Alright! So now I want to migrate my CVS history from my local workstation onto a real server.\nI have installed CVS on the server and it is working.\nNow, can... |
If you are creating a 1d array, you can implement it as a list, or else use the 'array' module in the standard library. I have always used lists for 1d arrays.
What is the reason or circumstance where I would want to use the array module instead?
Is it for performance and memory optimization, or am I missing something... | You're correct in noting that Python's lists can be used to create 1D arrays, and they are very flexible and easy to use. However, there are specific circumstances where using the `array` module (or even other libraries like NumPy) might be more beneficial. Here are the main reasons to consider using the `array` module... | 25,188 | [
{
"from": "human",
"value": "If you are creating a 1d array, you can implement it as a list, or else use the 'array' module in the standard library. I have always used lists for 1d arrays.\nWhat is the reason or circumstance where I would want to use the array module instead?\nIs it for performance and mem... |
Is there any point to freeing memory in an atexit() function?
I have a global variable that gets malloc'ed after startup. I could write an atexit() function to free it, but isn't the system going to reclaim all that memory when the program exits anyway?
Is there any benefit to being tidy and actively cleaning it up mys... | When a program exits, the operating system reclaims all the memory that was allocated by that program, including any memory allocated with `malloc()`. This means that, technically, from the perspective of the operating system, you don't need to free memory before your program terminates; the OS will clean up for you.
... | 25,032 | [
{
"from": "human",
"value": "Is there any point to freeing memory in an atexit() function?\nI have a global variable that gets malloc'ed after startup. I could write an atexit() function to free it, but isn't the system going to reclaim all that memory when the program exits anyway?\nIs there any benefit to... |
I need to perform a filtered query from within a django template, to get a set of objects equivalent to python code within a view:
queryset = Modelclass.objects.filter(somekey=foo)
In my template I would like to do
{% for object in data.somekey_set.FILTER %}
but I just can't seem to find out how to write FILTER.
| In Django templates, you can't perform filtering directly like you can in Python code. Instead, you typically prepare your data in the view and then pass the filtered queryset to the template context. However, if you really need to filter within the template context, you can utilize the `filter` template tag, but you n... | 24,531 | [
{
"from": "human",
"value": "I need to perform a filtered query from within a django template, to get a set of objects equivalent to python code within a view:\nqueryset = Modelclass.objects.filter(somekey=foo)\n\nIn my template I would like to do\n{% for object in data.somekey_set.FILTER %}\n\nbut I just c... |
I'm looking at building a simple web app that will expose an API that lets third-party (well, written by me, but that's not the point) apps query for and modify user-specific data stored on the site.
Obviously I don't want to allow apps to be able to get user-specific information without that users consent. I would wan... | What you're describing is a common requirement in web app development, and there are established standards and protocols that can help you achieve secure application authentication and user authorization. The most widely used standards for this purpose are OAuth 2.0 and OpenID Connect.
### OAuth 2.0
**OAuth 2.0** is ... | 21,635 | [
{
"from": "human",
"value": "I'm looking at building a simple web app that will expose an API that lets third-party (well, written by me, but that's not the point) apps query for and modify user-specific data stored on the site.\nObviously I don't want to allow apps to be able to get user-specific informati... |
I'm using a DataGridViewCheckBoxCell but I can't figure out how to have the ->Value property working "correctly".
for (int i = this->dgvConfigs->Rows->Count - 1; i >= 0 ; i --){
DataGridViewCheckBoxCell^ dgvcbc = (DataGridViewCheckBoxCell^) this->dgvConfigs->Rows[i]->Cells[2];
// This is truely a weird behavior of ... | The issue you're encountering with the `DataGridViewCheckBoxCell` in your `DataGridView` is likely due to the fact that the `Value` property of the `DataGridViewCheckBoxCell` may not directly return a primitive boolean value (`true` or `false`), even though it visually appears as such in the debugger.
Instead of compa... | 25,206 | [
{
"from": "human",
"value": "I'm using a DataGridViewCheckBoxCell but I can't figure out how to have the ->Value property working \"correctly\".\nfor (int i = this->dgvConfigs->Rows->Count - 1; i >= 0 ; i --){\n DataGridViewCheckBoxCell^ dgvcbc = (DataGridViewCheckBoxCell^) this->dgvConfigs->Rows[i]->Cells... |
Sorry, I couldn't figure out a good way to phrase my real question.
I run a high-traffic ASP.NET site on a 64-bit machine. I have IIS running in 32-bit mode, however, due to some legacy components of the app. I am running this particular web app inside an application pool that has the web garden option on (running 6 ... | It sounds like you're facing a few issues related to debugging an ASP.NET application using WinDbg with a memory dump, particularly with the CLR and SOS extensions. Here's a step-by-step guide to troubleshoot the situation and ensure you can properly analyze the memory dump:
### 1. Verify Your Setup
- **Windows Versio... | 18,160 | [
{
"from": "human",
"value": "Sorry, I couldn't figure out a good way to phrase my real question.\nI run a high-traffic ASP.NET site on a 64-bit machine. I have IIS running in 32-bit mode, however, due to some legacy components of the app. I am running this particular web app inside an application pool tha... |
I have a the following scenarios. I am trying to calculate throughput of the java's XSLT transformer. I have 10 threrads, each iterates 1000 times. The task of the thread is to read the XML and XSLT file and trasnform it and write to a new file.
I want to calculate the TPS. Can you please suggest the way to calculate ... | To calculate Transactions Per Second (TPS) for your scenario using Java's XSLT transformer with 10 threads, each processing 1000 transformations, you can follow these steps:
### Step-by-Step Guide to Calculate TPS
1. **Define a Transaction**: In your case, each transformation of an XML file using an XSLT file can be ... | 19,262 | [
{
"from": "human",
"value": "I have a the following scenarios. I am trying to calculate throughput of the java's XSLT transformer. I have 10 threrads, each iterates 1000 times. The task of the thread is to read the XML and XSLT file and trasnform it and write to a new file. \nI want to calculate the TPS. Ca... |
When mouse nears top edge of scrollpane, it scrolls up until it reaches the top only interrupted if the mouse leaves the top edge area.
Same for bottom edge.
| To implement a scrolling feature where a `JScrollPane` automatically scrolls when the mouse hovers near the top or bottom edge, you can add a mouse listener to detect the mouse position and a timer to perform the scrolling action. Below is a simple example using Java Swing:
### Example Code:
```java
import javax.swin... | 24,281 | [
{
"from": "human",
"value": "When mouse nears top edge of scrollpane, it scrolls up until it reaches the top only interrupted if the mouse leaves the top edge area.\nSame for bottom edge.\n"
},
{
"from": "gpt",
"value": "To implement a scrolling feature where a `JScrollPane` automatically scroll... |
How can I add line numbers to a range of lines in a file opened in Vim? Not as in :set nu—this just displays line numbers—but actually have them be prepended to each line in the file?
| To prepend line numbers to each line in a file opened in Vim, you can use the following method:
1. Open your file in Vim.
2. Enter command mode by pressing `Esc`.
3. Use the following command to prepend line numbers to each line in the file:
```
:%s/^/\=line('.') . ' '/
```
Here's a breakdown of the comm... | 26,523 | [
{
"from": "human",
"value": "How can I add line numbers to a range of lines in a file opened in Vim? Not as in :set nu—this just displays line numbers—but actually have them be prepended to each line in the file?\n"
},
{
"from": "gpt",
"value": "To prepend line numbers to each line in a file ope... |
What would be the best approach to install a keyboard hook on Linux (X-windows) in order to trigger some application when some key-combo is pressed?? Is there a way to do this regardless of which window manager is running? The idea is to have an application being called ( or brought to foreground ) when some key is pre... | To install a keyboard hook on Linux (especially in an X Window System environment) that can trigger an application based on a key combination, you can use various methods. The solution should ideally work regardless of which window manager is being used. Below are some approaches you can consider:
### 1. Using `xbindk... | 21,106 | [
{
"from": "human",
"value": "What would be the best approach to install a keyboard hook on Linux (X-windows) in order to trigger some application when some key-combo is pressed?? Is there a way to do this regardless of which window manager is running? The idea is to have an application being called ( or bro... |
I've tried these, and they did not work (Access opens, but it does not wait:
start "C:\program files\Microsoft Office\Office\MSACCESS.EXE" filename.mdb
start /WAIT "C:\program files\Microsoft Office\Office\MSACCESS.EXE" filename.mdb
start /W "C:\program files\Microsoft Office\Office\MSACCESS.EXE" filename.mdb
start ... | It seems you're trying to open Microsoft Access with a specific database file while ensuring that the command line waits for Access to close before proceeding. However, the `start` command does not always behave as expected with applications like Access. Here are a couple of alternative methods to accomplish what you w... | 25,329 | [
{
"from": "human",
"value": "I've tried these, and they did not work (Access opens, but it does not wait:\nstart \"C:\\program files\\Microsoft Office\\Office\\MSACCESS.EXE\" filename.mdb\n\nstart /WAIT \"C:\\program files\\Microsoft Office\\Office\\MSACCESS.EXE\" filename.mdb\n\nstart /W \"C:\\program file... |
Previously Visual Studio had templates for mobile web forms (not the mobile SDK). They appear to be gone in Visual Studio 2008 and the only solution I've seen is to download some templates from Omar here:
http://blogs.msdn.com/webdevtools/archive/2007/09/17/tip-trick-asp-net-mobile-development-with-visual-studio-2008.... | As of Visual Studio 2008, Microsoft did not continue to provide built-in templates for ASP.NET Mobile Web Forms that were available in earlier versions. The shift in focus towards modern web development practices and technologies led to a decline in support for older mobile development frameworks like ASP.NET Mobile.
... | 27,237 | [
{
"from": "human",
"value": "Previously Visual Studio had templates for mobile web forms (not the mobile SDK). They appear to be gone in Visual Studio 2008 and the only solution I've seen is to download some templates from Omar here:\nhttp://blogs.msdn.com/webdevtools/archive/2007/09/17/tip-trick-asp-net-m... |
I am developing an application from windows vista machine. The web application is hosted in IIS. From that application i try to write to a network share on another vista machine but i keep getting the access denied error. On the share i gave everyone, guest, network, anonymous logon full control share and ntfs access. ... | When you're encountering an "Access Denied" error while trying to access a network share from an application hosted in IIS, but it works fine when running from Visual Studio, the issue is likely related to the user context under which the IIS application pool is running. Here are some steps you can take to troubleshoot... | 23,191 | [
{
"from": "human",
"value": "I am developing an application from windows vista machine. The web application is hosted in IIS. From that application i try to write to a network share on another vista machine but i keep getting the access denied error. On the share i gave everyone, guest, network, anonymous l... |
How does the Chinese GB18030 code set differ from Unicode?
What special techniques are required for handling GB18030?
Are there any (open source) libraries for handling GB18030?
| GB18030 is a Chinese national standard for character encoding that includes support for all of the characters in Unicode, as well as additional characters. Here are some key differences and considerations regarding GB18030 and Unicode, as well as tools for handling GB18030:
### Differences Between GB18030 and Unicode
... | 22,574 | [
{
"from": "human",
"value": "How does the Chinese GB18030 code set differ from Unicode?\nWhat special techniques are required for handling GB18030?\nAre there any (open source) libraries for handling GB18030?\n"
},
{
"from": "gpt",
"value": "GB18030 is a Chinese national standard for character e... |
I'd like to know if it is possible to redirect StreamWriter output to a variable
Something like
String^ myString;
StreamWriter sw = gcnew StreamWriter([somehow specify myString])
sw->WriteLine("Foo");
then myString will contain Foo.
The reason I would like to do this is to reuse a complex function. I should probably r... | In C++/CLI, you can't directly redirect the output of a `StreamWriter` to a string variable like you're describing. However, you can achieve the desired functionality by using a `StringWriter`, which is specifically designed to capture output in a string.
Here’s how you can use `StringWriter` to accomplish this:
```... | 24,453 | [
{
"from": "human",
"value": "I'd like to know if it is possible to redirect StreamWriter output to a variable\nSomething like\nString^ myString;\nStreamWriter sw = gcnew StreamWriter([somehow specify myString])\nsw->WriteLine(\"Foo\");\n\nthen myString will contain Foo.\nThe reason I would like to do this i... |
Python is quite cool, but unfortunately, its debugger is not as good as perl -d.
One thing that I do very commonly when experimenting with code is to call a function from within the debugger, and step into that function, like so:
# NOTE THAT THIS PROGRAM EXITS IMMEDIATELY WITHOUT CALLING FOO()
~> cat -n /tmp/show_per... | In Python, the built-in debugger `pdb` does not have the same interactive functionality that Perl's `-d` provides when it comes to stepping into functions called from the debugger itself. However, there are a few workarounds and alternatives that can achieve similar functionality.
### 1. Use `pdb` with an Exception
Y... | 22,541 | [
{
"from": "human",
"value": "Python is quite cool, but unfortunately, its debugger is not as good as perl -d. \nOne thing that I do very commonly when experimenting with code is to call a function from within the debugger, and step into that function, like so:\n# NOTE THAT THIS PROGRAM EXITS IMMEDIATELY WI... |
We use Visual Studio 2008 and Surround SCM for source control. SCM drops files into each directory named ".MySCMServerInfo" which are user specific data files that shouldn't be checked into source control. They are similar to the .scc files dropped by Visual Source Safe. We also have several WAPs (Web Application Pro... | In Visual Studio 2008, you can exclude specific file types from being tracked in source control by creating or modifying a `.scc` file (or similar file that Visual Studio uses for source control operations) or by configuring your Surround SCM settings. Here’s how you can ignore files with a specific extension like `.My... | 23,817 | [
{
"from": "human",
"value": "We use Visual Studio 2008 and Surround SCM for source control. SCM drops files into each directory named \".MySCMServerInfo\" which are user specific data files that shouldn't be checked into source control. They are similar to the .scc files dropped by Visual Source Safe. We ... |
I'd like to have a context menu for my tab headers in a Syncfusion TabControlAdv control, and have a separate menu for the controls inside each tab. The likely menu entries will be "Add Tab", "Delete Tab" and "Clone Tab", and neither of them makes much sense to show when the user rightclicks in the middle of my control... | Certainly! To implement a context menu for your `TabControlAdv` headers and a different context menu for the controls within each tab, you can use the `ContextMenuStrip` component in WinForms. Below is an example code snippet demonstrating how to set up separate context menus for both the tab headers and the controls w... | 18,312 | [
{
"from": "human",
"value": "I'd like to have a context menu for my tab headers in a Syncfusion TabControlAdv control, and have a separate menu for the controls inside each tab. The likely menu entries will be \"Add Tab\", \"Delete Tab\" and \"Clone Tab\", and neither of them makes much sense to show when t... |
What is the best way to reset a PIC18 using C code with the HiTech Pic18 C compiler?
Edit:
I am currenlty using
void reset()
{
#asm
reset
#endasm
}
but there must be a better way
| Resetting a PIC18 microcontroller using C code with the HiTech PIC18 C compiler can indeed be done more cleanly and maintainably than using assembly code directly. The assembly instruction you're using is a valid way to invoke a reset, but there are alternatives that can be cleaner and more compatible with C programmin... | 20,677 | [
{
"from": "human",
"value": "What is the best way to reset a PIC18 using C code with the HiTech Pic18 C compiler?\nEdit:\nI am currenlty using\nvoid reset()\n{\n#asm \n reset\n#endasm\n}\n\nbut there must be a better way\n"
},
{
"from": "gpt",
"value": "Resetting a PIC18 microcontroller using... |
We use Grid Control 10.2.0.4, with a catalog repository database also at 10.2.0.4. It seems that after a week or two of being up, the response time of the web interface gets very poor (20+ seconds to navigate to a new page, when normally 2-3 seconds is seen). The only thing we've found to overcome it is a restart of th... | Performance issues with Oracle Grid Control (GC), particularly with the web interface slowing down over time, can be attributed to several factors. Here are some common causes and troubleshooting steps that might help improve performance and manage the issue:
### 1. **Database Performance**:
- **Check Database Reso... | 23,850 | [
{
"from": "human",
"value": "We use Grid Control 10.2.0.4, with a catalog repository database also at 10.2.0.4. It seems that after a week or two of being up, the response time of the web interface gets very poor (20+ seconds to navigate to a new page, when normally 2-3 seconds is seen). The only thing we'v... |
This may sound strange but sometimes when your ASP.NET webapp isn't working and you can't tell why, you call Microsoft, pay them something like $300 and get about 1-3 weeks of 1-3 people looking at your configuration, memory dumps, sometimes code... but usually not the db, and with a fairly good percentage they help yo... | It's common for developers to seek support for various web frameworks and platforms when they encounter issues, and several options are available for support services across the frameworks you've mentioned. Here's a brief overview of support options and experiences for each of the frameworks listed:
### Django
**Suppo... | 25,029 | [
{
"from": "human",
"value": "This may sound strange but sometimes when your ASP.NET webapp isn't working and you can't tell why, you call Microsoft, pay them something like $300 and get about 1-3 weeks of 1-3 people looking at your configuration, memory dumps, sometimes code... but usually not the db, and w... |
If we put aside the rights and wrongs of putting demo data into a live system for a minute (that's a whole separate discussion!), we are being asked to store some demo data in our live system so that it can be credibly demonstrated without the appearance of smoke + mirrors (we want to use the same login page for exampl... | Storing demo data in a live system can be a challenging endeavor, especially when considering the potential for it to interfere with day-to-day operations. Here are some approaches that can help manage this situation:
### 1. **Segregated Namespace or Prefixes:**
- **Separate IDs/Prefixes:** Use a specific prefix or... | 22,147 | [
{
"from": "human",
"value": "If we put aside the rights and wrongs of putting demo data into a live system for a minute (that's a whole separate discussion!), we are being asked to store some demo data in our live system so that it can be credibly demonstrated without the appearance of smoke + mirrors (we w... |
I've been running the built-in Ant from the command line on a Macintosh (10.5.5) and have run into some trouble with the Mail task. Running the Mail task produces the following message:
[mail] Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer
This is most likely due to a missing ant-javama... | The issue you're encountering with the Mail task in Apache Ant is indeed likely due to the missing `ant-javamail.jar` file. The `.pom` file you see indicates that you may have a Project Object Model file for a Maven project, but it doesn't provide the actual library that Ant needs to send emails.
Here's how you can re... | 24,296 | [
{
"from": "human",
"value": "I've been running the built-in Ant from the command line on a Macintosh (10.5.5) and have run into some trouble with the Mail task. Running the Mail task produces the following message:\n[mail] Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer\n\nThi... |
I'm writing a small article on humanly readable alternatives to Guids/UIDs, for example those used on TinyURL for the url hashes (which are often printed in magazines, so need to be short).
The simple uid I'm generating is - 6 characters: either a lowercase letter (a-z) or 0-9.
"According to my calculations captain", ... | To assess the clash rate of your 6-character unique identifiers generated using lowercase letters (a-z) and digits (0-9), we first need to understand the total number of possible combinations, the probability of a clash, and then the expected number of clashes.
### Total Combinations
You are using:
- 26 lowercase let... | 17,762 | [
{
"from": "human",
"value": "I'm writing a small article on humanly readable alternatives to Guids/UIDs, for example those used on TinyURL for the url hashes (which are often printed in magazines, so need to be short).\nThe simple uid I'm generating is - 6 characters: either a lowercase letter (a-z) or 0-9.... |
If I have the following Linq code:
context.Table1s.InsertOnSubmit(t);
context.Table1s.InsertOnSubmit(t2);
context.Table1s.InsertOnSubmit(t3);
context.SubmitChanges();
And I get a database error due to the 2nd insert, Linq throws an exception that there was an error. But, is there a way to find out that it was the 2n... | In LINQ to SQL, when you call `SubmitChanges()`, it attempts to submit all the changes to the database in one batch. If an error occurs during this operation, it will throw an exception, but unfortunately, it does not provide detailed information on which specific insert operation failed.
To identify which specific op... | 23,681 | [
{
"from": "human",
"value": "If I have the following Linq code:\ncontext.Table1s.InsertOnSubmit(t);\ncontext.Table1s.InsertOnSubmit(t2);\ncontext.Table1s.InsertOnSubmit(t3);\n\ncontext.SubmitChanges();\n\nAnd I get a database error due to the 2nd insert, Linq throws an exception that there was an error. Bu... |
The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources?
using (OleDbConnection conn = new OleDbConnection(connectionStri... | When you execute a command using `OleDbCommand`, resources are consumed, and if you're executing the same command multiple times in quick succession without releasing resources properly, you may encounter issues like "System Resources Exceeded." Here are some strategies to mitigate this problem:
1. **Batch Inserts**: ... | 22,188 | [
{
"from": "human",
"value": "The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = \"System Resources Exceeded\" is thrown. Is there something else I should be doing to free up resources?\nusing (OleDbConnecti... |
I have a list of variable names, like this:
['foo', 'bar', 'baz']
(I originally asked how I convert a list of variables. See Greg Hewgill's answer below.)
How do I convert this to a dictionary where the keys are the variable names (as strings) and the values are the values of the variables?
{'foo': foo, 'bar': bar, '... | Using `eval` can be risky, as it executes arbitrary code and can introduce security vulnerabilities, especially if any part of the input can be influenced by an external source. A more secure and clearer approach would be to directly use the `locals()` function to get the current local variable scope and construct the ... | 24,905 | [
{
"from": "human",
"value": "I have a list of variable names, like this:\n['foo', 'bar', 'baz']\n\n(I originally asked how I convert a list of variables. See Greg Hewgill's answer below.)\nHow do I convert this to a dictionary where the keys are the variable names (as strings) and the values are the values... |
Introduction
In my current organisation, we have many desktop and web applications all feeding into each other at some point. When looking after older applications or creating new applications, it's proving very difficult to try and remember which system rely on other systems in order to work. I'm not talking about sof... | To effectively track dependencies between entire systems within your organization, you should consider adopting an **Architecture Dependency Matrix** combined with a **Documentation System**. Below, I detail a comprehensive approach that utilizes these techniques:
### 1. **Architecture Dependency Matrix**
An Architec... | 16,895 | [
{
"from": "human",
"value": "Introduction\nIn my current organisation, we have many desktop and web applications all feeding into each other at some point. When looking after older applications or creating new applications, it's proving very difficult to try and remember which system rely on other systems i... |
In a vxWorks Real-Time process, you can pass environment variables as one of the parameter of the main routine.
How do you use the environment variables in the kernel context?
| In VxWorks, environment variables can be passed to the main routine of a real-time process, and you can access them within the kernel context using the provided environment management functions.
Here's a brief overview of how to use environment variables in VxWorks:
1. **Passing Environment Variables**: When you star... | 19,549 | [
{
"from": "human",
"value": "In a vxWorks Real-Time process, you can pass environment variables as one of the parameter of the main routine.\nHow do you use the environment variables in the kernel context?\n"
},
{
"from": "gpt",
"value": "In VxWorks, environment variables can be passed to the ma... |
In most modern IDEs, you can have Debug and Release build configurations, and you can quickly switch between them.
In Delphi 7, this does not seem to be possible. I have to go to Project Settings and toggle optimization and all the debug information stuff manually.
It would be great if there was a plugin or some such t... | In Delphi 7, there isn't a built-in feature for easily switching between Debug and Release configurations like in more modern IDEs, but there are some workarounds and tools that can help streamline the process:
### Workarounds:
1. **Use Project Groups**: You can create a project group that contains your main project ... | 25,261 | [
{
"from": "human",
"value": "In most modern IDEs, you can have Debug and Release build configurations, and you can quickly switch between them.\nIn Delphi 7, this does not seem to be possible. I have to go to Project Settings and toggle optimization and all the debug information stuff manually.\nIt would be... |
Like, testing for :
invalid inputs (strings containing "'"s)
giving random id's in url parameters to access "unauthorized" pages
prevent sql injection
...
| When testing a web application for security vulnerabilities and robustness, it's crucial to perform various types of testing to ensure that the application handles invalid inputs properly and is secure against common web threats such as SQL injection and unauthorized access. Below are some key aspects and methods to co... | 23,745 | [
{
"from": "human",
"value": "Like, testing for : \n\ninvalid inputs (strings containing \"'\"s)\ngiving random id's in url parameters to access \"unauthorized\" pages\nprevent sql injection\n...\n\n"
},
{
"from": "gpt",
"value": "When testing a web application for security vulnerabilities and ro... |
Yes, There's More Than One Way To Do It but there must be a canonical or most efficient or most concise way. I'll add answers I know of and see what percolates to the top.
To be clear, the question is how best to read the contents of a file into a string.
One solution per answer.
| Certainly! Here’s one way to read the contents of a file into a string in Python using the built-in `open()` function and `read()` method:
```python
with open('filename.txt', 'r') as file:
contents = file.read()
```
This approach ensures that the file is properly closed after reading, and it is both concise and e... | 27,609 | [
{
"from": "human",
"value": "Yes, There's More Than One Way To Do It but there must be a canonical or most efficient or most concise way. I'll add answers I know of and see what percolates to the top.\nTo be clear, the question is how best to read the contents of a file into a string.\nOne solution per answ... |
Provided I have admin access, I need a way to manage (Create, modify, remove) local accounts in a remote machine from an ASP.NET client.
I'm clueless in how to approach this. Is WMI a possibility (System.Management namespace)?
Any pointers?
| Yes, you can indeed use Windows Management Instrumentation (WMI) to manage local user accounts on a remote machine from an ASP.NET application, assuming you have the necessary permissions. The `System.Management` namespace provides the classes you need to interact with WMI.
Here’s a general approach on how to accompli... | 20,270 | [
{
"from": "human",
"value": "Provided I have admin access, I need a way to manage (Create, modify, remove) local accounts in a remote machine from an ASP.NET client.\nI'm clueless in how to approach this. Is WMI a possibility (System.Management namespace)?\nAny pointers?\n"
},
{
"from": "gpt",
"... |
I have an Excel VBA macro which does the equivalent of the following HTTP POST which works successfully:
Set WebClient = CreateObject("WinHttp.WinHttpRequest.5.1")
' ... Configure WebClient for a POST request
RequestBody = "<request>"
WebClient.send RequestBody
Previously, I had explicitly set the type of RequestBody ... | In VBA, the behavior you're experiencing can be attributed to how data types and variable initialization are handled.
### Explanation:
1. **Implicit vs. Explicit Typing**:
- When you declare a variable without specifying a type, VBA treats it as a Variant by default. A Variant can hold any type of data, including ... | 23,772 | [
{
"from": "human",
"value": "I have an Excel VBA macro which does the equivalent of the following HTTP POST which works successfully:\nSet WebClient = CreateObject(\"WinHttp.WinHttpRequest.5.1\")\n' ... Configure WebClient for a POST request\nRequestBody = \"<request>\"\nWebClient.send RequestBody\n\nPrevio... |
Much searching and reading has not told me whether the capicom.encrypteddata class module (it's VB6, but that shouldn't matter in answering this question) is using 2-key 3DES or 3-key 3DES. (.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_3DES) Anyone know which one it is using? A source of this information would also... | In CAPICOM, the `CAPICOM_ENCRYPTION_ALGORITHM_3DES` refers to the Triple DES (3DES) encryption algorithm. However, it is important to understand the implementation specifics regarding the keying option used.
Triple DES can be configured to use different keying modes:
- **2-key 3DES**: Uses two keys, effectively making... | 25,926 | [
{
"from": "human",
"value": "Much searching and reading has not told me whether the capicom.encrypteddata class module (it's VB6, but that shouldn't matter in answering this question) is using 2-key 3DES or 3-key 3DES. (.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_3DES) Anyone know which one it is using?... |
how to show all values of a particular field in a text box ???
ie. for eg. when u run the SP, u'll be getting 3 rows. and i want to show the (eg.empname)
in a textbox each value separated by a comma.
(ram, john, sita).
| To display all values of a particular field (like `empname`) from a stored procedure (SP) in a text box, you will typically follow these steps, depending on your programming environment (such as C#, ASP.NET, etc.). Below, I'll outline a basic example using C# with ADO.NET, which is a common way to interact with a datab... | 22,825 | [
{
"from": "human",
"value": "how to show all values of a particular field in a text box ???\nie. for eg. when u run the SP, u'll be getting 3 rows. and i want to show the (eg.empname)\nin a textbox each value separated by a comma. \n(ram, john, sita). \n"
},
{
"from": "gpt",
"value": "To display... |
I'm looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down miserably here as it checks for locale changes on every call to isdigit(). Our current best is derived from the best of perl + tcl's atof implementat... | Optimizing `atof()` for performance in a specific context, like converting ASCII strings to floating-point numbers in a multithreaded environment, is quite challenging, but there are several avenues you can explore beyond the existing C implementations you mentioned. Here are some ideas and resources that may help you ... | 11,460 | [
{
"from": "human",
"value": "I'm looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down miserably here as it checks for locale changes on every call to isdigit(). Our current best is derived from ... |
Is it possible to use an ocx (ActiveX Control) on a winform (probably adding it programatically) without first having the ocx registered with regsrv32?
What I'm trying to achieve is to enable xcopy installation. I've had the "AxInterop..dll" and "Interop..dll" file generated from my dev machine.
I've seen the possibili... | Using an ActiveX control (OCX) in a WinForms application typically requires that the control be registered on the system using `regsvr32`. This is because ActiveX controls rely on registration information to function correctly, which includes details about the control's location, threading model, and interface informat... | 24,016 | [
{
"from": "human",
"value": "Is it possible to use an ocx (ActiveX Control) on a winform (probably adding it programatically) without first having the ocx registered with regsrv32?\nWhat I'm trying to achieve is to enable xcopy installation. I've had the \"AxInterop..dll\" and \"Interop..dll\" file generate... |
I recently learned about the basic structure of the .docx file (it's a specially structured zip archive). However, docx is not formated like a doc.
How does a doc file work? What is the file format, structure, etc?
| The `.doc` file format is the older binary file format used by Microsoft Word prior to the introduction of the `.docx` format with Word 2007. Understanding the structure of `.doc` files involves a bit of a dive into binary file formats and how data is structured in these files.
### Overview of the .doc File Format
1.... | 21,768 | [
{
"from": "human",
"value": "I recently learned about the basic structure of the .docx file (it's a specially structured zip archive). However, docx is not formated like a doc.\nHow does a doc file work? What is the file format, structure, etc?\n"
},
{
"from": "gpt",
"value": "The `.doc` file ... |
Every time I start Emacs I see a page of help text and a bunch of messages suggesting that I try the tutorial. How do I stop this from happening?
| The help text and tutorial suggestions you see when starting Emacs can be caused by the default startup behavior. To prevent this from happening, you can customize your Emacs configuration. Here’s how to do that:
1. **Modify the `init.el` file**: Open your Emacs configuration file, which is typically located at `~/.em... | 21,431 | [
{
"from": "human",
"value": "Every time I start Emacs I see a page of help text and a bunch of messages suggesting that I try the tutorial. How do I stop this from happening?\n"
},
{
"from": "gpt",
"value": "The help text and tutorial suggestions you see when starting Emacs can be caused by the... |
Is a http header that I can set in IIS that will essentially tell the users browser that url
"/something/img.gif"
and url
"/SomeThing/IMG.gif"
are in fact the same thing and that the browser should NOT re-download that resource? I'm running into cache issues where some urls are cased differently, and so users brows... | In IIS (Internet Information Services), HTTP headers can be configured to help manage caching behavior, but there is no direct HTTP header that specifically tells the browser that two different URLs (with different cases) point to the same resource. However, you can manage caching and help mitigate issues caused by cas... | 23,767 | [
{
"from": "human",
"value": "Is a http header that I can set in IIS that will essentially tell the users browser that url \n\"/something/img.gif\" \nand url \n\"/SomeThing/IMG.gif\" \nare in fact the same thing and that the browser should NOT re-download that resource? I'm running into cache issues where so... |
What are some recommendations for finding Expression Blend/WPF Designers to perform contract work? I think a (local) freelance designer might be the most reasonably priced, but I don't even know where to start.
As additional background, I am located in the Midwest region of the US, where designers are not as prevalent... | Finding skilled Expression Blend/WPF designers can be challenging, especially in regions where these specialists are less common. However, there are several strategies you can use to find qualified candidates for contract work:
### 1. Online Freelance Platforms
- **Upwork**: Create a job posting specifying your needs ... | 22,663 | [
{
"from": "human",
"value": "What are some recommendations for finding Expression Blend/WPF Designers to perform contract work? I think a (local) freelance designer might be the most reasonably priced, but I don't even know where to start.\nAs additional background, I am located in the Midwest region of th... |
What's the best data type in SQL to represent Decimal in .NET?
We want to store decimal numbers with up to 9 decimal place precision and want to avoid rounding errors etc on the front end.
Reading about data types, it appears using Decimal in .NET is the best option because you will not get rounding errors, although it... | When working with decimal numbers in SQL and .NET, you want to ensure that the data types used in both environments align well to minimize conversion issues and avoid rounding errors. Given your requirement for up to 9 decimal places of precision, here are the best practices for choosing a suitable data type:
### In S... | 23,855 | [
{
"from": "human",
"value": "What's the best data type in SQL to represent Decimal in .NET?\nWe want to store decimal numbers with up to 9 decimal place precision and want to avoid rounding errors etc on the front end.\nReading about data types, it appears using Decimal in .NET is the best option because yo... |
given a matrix of distances between points is there an algorithm for determining a set of n-dimensional points that has these distances? (or at least minimises the error)
sort of like a n-dimensional version of the turnpike problem.
The best I can come up with is using multidimensional scaling.
| Yes, there are several algorithms that can help reconstruct or approximate a set of points in n-dimensional space based on a given matrix of distances. Here are some common approaches:
1. **Multidimensional Scaling (MDS)**: As you mentioned, MDS is a widely used technique for dimensionality reduction that seeks to pre... | 21,257 | [
{
"from": "human",
"value": "given a matrix of distances between points is there an algorithm for determining a set of n-dimensional points that has these distances? (or at least minimises the error) \nsort of like a n-dimensional version of the turnpike problem.\nThe best I can come up with is using multid... |
I'm building a web application and would like to use the strongest hashing algorithm possible for passwords. What are the differences, if any, between sha512, whirlpool, ripemd160 and tiger192,4? Which one would be considered cryptographically stronger?
| When it comes to hashing passwords, it's important to choose an algorithm that is not only strong but also resistant to various attack vectors, such as brute force and rainbow table attacks. The algorithms you mentioned—SHA-512, Whirlpool, RIPEMD-160, and Tiger-192,4—are all cryptographic hash functions, but they diffe... | 21,741 | [
{
"from": "human",
"value": "I'm building a web application and would like to use the strongest hashing algorithm possible for passwords. What are the differences, if any, between sha512, whirlpool, ripemd160 and tiger192,4? Which one would be considered cryptographically stronger?\n"
},
{
"from":... |
I want to write a script, to be packaged into a gem, which will modify its parameters and then exec a new ruby process with the modified params. In other words, something similar to a shell script which modifies its params and then does an exec $SHELL $*. In order to do this, I need a robust way of discovering the pa... | To create a Ruby script that modifies its parameters and then execs a new Ruby process with the modified parameters, you can follow these steps. The key components are finding the Ruby executable path and capturing the current process's parameters.
Here's how to achieve that:
1. **Finding the Ruby Executable Path**: ... | 21,245 | [
{
"from": "human",
"value": "I want to write a script, to be packaged into a gem, which will modify its parameters and then exec a new ruby process with the modified params. In other words, something similar to a shell script which modifies its params and then does an exec $SHELL $*. In order to do this, ... |
When calling php via cli, the current directory is NOT changed to the one of the script. All the scripts i have running in crontab run via the CLI, so this is an issue.
I'm currently fixing the problem by doing a chdir() with the absolute path where the script is, but i REALLY dont like hardcoding paths into stuff like... | When you run a PHP script from the command line (CLI), the current working directory remains the same as it was when the script was invoked, which can lead to issues when your script relies on relative paths. To address this without hardcoding paths, you can dynamically set the current directory to the location of the ... | 23,723 | [
{
"from": "human",
"value": "When calling php via cli, the current directory is NOT changed to the one of the script. All the scripts i have running in crontab run via the CLI, so this is an issue.\nI'm currently fixing the problem by doing a chdir() with the absolute path where the script is, but i REALLY ... |
I am building a custom win32 control/widget and would like to change the cursor to a horizontal "splitter" symbol when hovering over a particular vertical line in the control. IE: I want to drag this vertical line (splitter bar) left and right (WEST and EAST).
Of the the system cursors (OCR_*), the only cursor that mak... | In Windows, while the predefined system cursor constants like `OCR_SIZEWE` exist, there isn't a predefined cursor that matches exactly what you're describing (a small, custom-style horizontal splitter cursor). However, you can create your own custom cursor using a bitmap resource and load it into your application, whic... | 14,551 | [
{
"from": "human",
"value": "I am building a custom win32 control/widget and would like to change the cursor to a horizontal \"splitter\" symbol when hovering over a particular vertical line in the control. IE: I want to drag this vertical line (splitter bar) left and right (WEST and EAST).\nOf the the syst... |
My colleague insists on explicitly specifying the namespace in code as opposed to using the using directive. In other words he wants to use the fully qualified name for each type every time this type occurs in code. Something like
public class MyClass
{
public static void Main()
{
System.Console.WriteL... | Your colleague's preference for using fully qualified names instead of the `using` directive does have some rationale, but it also has significant drawbacks that are worth considering. Let's examine both sides in more detail.
### Pros of Using Fully Qualified Names
1. **Simplicity in Copy-Pasting**: As your colleague... | 23,098 | [
{
"from": "human",
"value": "My colleague insists on explicitly specifying the namespace in code as opposed to using the using directive. In other words he wants to use the fully qualified name for each type every time this type occurs in code. Something like \npublic class MyClass\n{\n public static voi... |
I have an application that loads external SWF files and plays them inside a Adobe Flex / Air application via the SWFLoader Flex component. I have been trying to find a way to unload them from a button click event. I have Google'd far and wide and no one seems to have been able to do it without a hack. The combination o... | Unloading external SWF files from a `SWFLoader` in an Adobe Flex / AIR application can indeed be a challenging task. Here are some considerations and possible approaches to more effectively unload SWFs and minimize issues like lingering sounds and memory leaks.
### 1. Clean Up Resources
When you're unloading a SWF, it... | 21,792 | [
{
"from": "human",
"value": "I have an application that loads external SWF files and plays them inside a Adobe Flex / Air application via the SWFLoader Flex component. I have been trying to find a way to unload them from a button click event. I have Google'd far and wide and no one seems to have been able t... |
i know this doesnt work but i dont know why, also how can i make it work?
<% int result = referer.indexOf("smlMoverDetail.do"); %>
<% if (result == -1){%>
<%out.print("checking");%>
<bean:define id="JOININGDATE" name="smlMoverDetailForm"
property="empFDJoiningDate" type="java.lang.String" toScope="session"/>
<%... | The issue you're experiencing seems to stem from the context in which you're trying to use JSP and the JSTL (JavaServer Pages Standard Tag Library) tags. Your original code uses scriptlets (`<% %>`) to get the index of a string and then uses that to conditionally execute a `<bean:define>`. However, the way you've struc... | 21,261 | [
{
"from": "human",
"value": "i know this doesnt work but i dont know why, also how can i make it work?\n <% int result = referer.indexOf(\"smlMoverDetail.do\"); %>\n\n <% if (result == -1){%> \n <%out.print(\"checking\");%>\n <bean:define id=\"JOININGDATE\" name=\"smlMoverDetailForm\"\n property=\"empFDJoin... |
Imagine I have the folling XML file:
<a>before<b>middle</b>after</a>
I want to convert it into something like this:
<a>beforemiddleafter</a>
In other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this command: "mv ./directory/* .", but for xml n... | To achieve your goal of transforming the XML and removing the child elements by moving their text content to the parent node, you can use `xmlstarlet` with an XSLT stylesheet. Here's how you can do it:
1. **Create an XSLT file (let's call it `remove-links.xsl`)**:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<xsl:st... | 16,632 | [
{
"from": "human",
"value": "Imagine I have the folling XML file:\n<a>before<b>middle</b>after</a>\nI want to convert it into something like this:\n<a>beforemiddleafter</a>\nIn other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this... |
I have a server application that receives information over a network and processes it.
The server is multi-threaded and handles multiple sockets at time, and threads are created without my control through BeginInvoke and EndInvoke style methods, which are chained by corresponding callback functions.
I'm trying to creat... | To update a UI control, such as a ListBox, from a non-UI thread, you need to ensure that you invoke the update on the thread that created the UI (usually the main UI thread). Here's how you can do that in a Windows Forms application.
### Using Invoke to Access UI Controls Safely
You can use the `Invoke` method to exe... | 22,968 | [
{
"from": "human",
"value": "I have a server application that receives information over a network and processes it.\nThe server is multi-threaded and handles multiple sockets at time, and threads are created without my control through BeginInvoke and EndInvoke style methods, which are chained by correspondi... |
What is the best way to change a user-password remotely in Unix?
This must be performed by the user, in a Web-app or Windows-App, without using SSH or any direct connection between the user and the server (direct command line not allowed).
Thanks
Webmin seemed to be a good application to do that, but I found it extrem... | Changing a user password remotely in a Unix environment without using SSH or direct command line access can be achieved through various web-based management tools or applications. Here are some alternatives to Webmin and Usermin that you might consider:
### 1. **Cockpit**
- **Overview**: Cockpit is a modern web-based ... | 22,360 | [
{
"from": "human",
"value": "What is the best way to change a user-password remotely in Unix?\nThis must be performed by the user, in a Web-app or Windows-App, without using SSH or any direct connection between the user and the server (direct command line not allowed).\nThanks\n\nWebmin seemed to be a good ... |
This question comes close to what I need, but my scenario is slightly different. The source table and destination table are the same and the primary key is a uniqueidentifier (guid). When I try this:
insert into MyTable
select * from MyTable where uniqueId = @Id;
I obviously get a primary key constraint violation,... | Certainly! To achieve what you described, you can create an `INSERT` statement that selects specific columns from your source row while generating a new `uniqueidentifier` for the primary key. You can also insert the value of the original primary key into another field, such as `PreviousId`.
Here’s an example of how y... | 21,602 | [
{
"from": "human",
"value": "This question comes close to what I need, but my scenario is slightly different. The source table and destination table are the same and the primary key is a uniqueidentifier (guid). When I try this:\ninsert into MyTable\n select * from MyTable where uniqueId = @Id;\n\nI obvi... |
I'm struggling with Visual Studio 2008. I've used some form of "Zen" colors for more than I can remember. In VS2008 I keep getting one color that I cannot read and I have been unable to identify it; the purpose of the question is to avoid trial an error (the VS color interface is really ugly with no "real time" apply b... | In Visual Studio 2008, the issue you're encountering with the white background during debugging is typically related to the "Current Statement" highlight color. This color highlights the line of code that is currently being executed when you're debugging, and it can be difficult to read depending on your color scheme.
... | 23,948 | [
{
"from": "human",
"value": "I'm struggling with Visual Studio 2008. I've used some form of \"Zen\" colors for more than I can remember. In VS2008 I keep getting one color that I cannot read and I have been unable to identify it; the purpose of the question is to avoid trial an error (the VS color interface... |
I am looking for the way to mount NTFS hard disk on FreeBSD 6.2 in read/write mode.
searching google, I found that NTFS-3G can be a help.
Using NTFS-3G, there is no problem when I try to mount/unmount NTFS manually:
mount: ntfs-3g /dev/ad1s1 /home/admin/data -o uid=1002,
or
umount: umount /home/admin/data
But I have a ... | Mounting an NTFS partition in FreeBSD 6.2 using NTFS-3G at boot time can be tricky, especially since that version is quite old. Here are a few suggestions to troubleshoot and resolve the issue:
### 1. Verify NTFS-3G Installation
First, ensure that NTFS-3G is correctly installed on your FreeBSD system. You can check if... | 19,587 | [
{
"from": "human",
"value": "I am looking for the way to mount NTFS hard disk on FreeBSD 6.2 in read/write mode.\nsearching google, I found that NTFS-3G can be a help.\nUsing NTFS-3G, there is no problem when I try to mount/unmount NTFS manually:\nmount: ntfs-3g /dev/ad1s1 /home/admin/data -o uid=1002,\nor\... |
I have an asp.net text form that contains numerous decimal fields that are optional. I want to selectively update the database but not inserting a "0" for fields that do not have data (maintaining the null status).
Typically, I would create multiple functions, each with a different signature to handle this. However, I... | To handle selectively updating the database without inserting a "0" for optional decimal fields that are left empty, you can approach this problem in a few ways without creating multiple function signatures. Below are some practical strategies you could consider:
### 1. Use Nullable Types
In your data model, ensure t... | 18,837 | [
{
"from": "human",
"value": "I have an asp.net text form that contains numerous decimal fields that are optional. I want to selectively update the database but not inserting a \"0\" for fields that do not have data (maintaining the null status). \nTypically, I would create multiple functions, each with a di... |
A website of mine will host the usual images, javascript and CSS stylesheets in the database. Since these are unlikely to change each day, I am going to use some client caching on these to reduce the server load.
How long do you cache these? A few days? More?
I'm probably not going to reuse the same name twice if I upd... | Caching static assets like images, JavaScript, and CSS stylesheets is an effective way to improve the performance of your website and reduce server load. Since you're using unique names for updated resources, this alleviates concerns about clients receiving outdated files. Here are some general guidelines for caching t... | 24,868 | [
{
"from": "human",
"value": "A website of mine will host the usual images, javascript and CSS stylesheets in the database. Since these are unlikely to change each day, I am going to use some client caching on these to reduce the server load.\nHow long do you cache these? A few days? More?\nI'm probably not ... |
How do I go about calling a method on state change in AASM?
I'd like to call update_foo when the state transitions to paid in the following model:
class Foo < ActiveRecord::Base
include AASM
# State Machine
aasm_initial_state :incomplete
aasm_state :incomplete
aasm_state :paid
aasm_event :pay do
trans... | To call a method when a state transitions in AASM (Acts As State Machine), you can use the `after_transition` callback. This allows you to specify a method to be called after a successful transition to a particular state.
Here’s how you can modify your `Foo` model to call the `update_foo` method after transitioning to... | 26,577 | [
{
"from": "human",
"value": "How do I go about calling a method on state change in AASM?\nI'd like to call update_foo when the state transitions to paid in the following model:\nclass Foo < ActiveRecord::Base\n include AASM\n\n # State Machine\n aasm_initial_state :incomplete\n aasm_state :incomplete\n ... |
Given the following file:
department=value1
location=valueA
location=valueB
department=value2
I use the following to load the file into a Perl hash:
use File::Slurp;
use Data::Dumper;
my %hash = map {
s/#.*//;
s/^\s+//;
s/\s+$//;
m/(.*?)\s*=\s*(.*)/;
} read_file($file);
print Dumper(\%hash);
The result, h... | To achieve the desired result where multiple values for the same key are combined into a single string separated by commas, you can modify your approach to check if the key already exists in the hash before assigning the value. If it does, you append the new value to the existing value, separated by a comma.
Here's ho... | 24,624 | [
{
"from": "human",
"value": "Given the following file:\ndepartment=value1\nlocation=valueA\nlocation=valueB\ndepartment=value2\n\nI use the following to load the file into a Perl hash:\nuse File::Slurp;\nuse Data::Dumper;\nmy %hash = map {\n s/#.*//;\n s/^\\s+//;\n s/\\s+$//;\n m/(.*?)\\s*=\\s*(.*)/... |
I have a Crystal Report that looks like:
Date | Person | Ticket | Summary
Date | Person | Ticket | Summary
Date | Person | Ticket | Summary
I would like it to look like:
Date
Person | Ticket | Summary
Person | Ticket | Summary
Date
Person | Ticket | Summary
All values are pulled from a MS SQL 2000 database, th... | To achieve the desired layout for your Crystal Report, you will need to make adjustments to how the data is organized and displayed. Here are the steps you can follow:
### Step 1: Modify the Report Design
1. **Open your Crystal Report** in the report designer.
2. **Group Your Data**:
- Go to the **Insert** menu ... | 19,962 | [
{
"from": "human",
"value": "I have a Crystal Report that looks like:\nDate | Person | Ticket | Summary \nDate | Person | Ticket | Summary \nDate | Person | Ticket | Summary \nI would like it to look like: \nDate \nPerson | Ticket | Summary \nPerson | Ticket | Summary \nDate \nPerson | Ticket | Summary\nAl... |
I am planning to use php in an embedded environment. Our current web server is thttpd. I am considering two options now: whether to run it as a cgi or as SAPI module. I know cgi has advantage in terms of security. But if we are to use php as cgi, an instance of the php should be loaded into the memory for each request.... | When using PHP with thttpd, you have a couple of options: running PHP as a CGI script or using it as a SAPI (Server Application Programming Interface) module. Here are some considerations for each approach, along with answers to your specific questions:
### PHP as CGI
1. **Memory Usage**: When PHP is run as a CGI, a ... | 23,841 | [
{
"from": "human",
"value": "I am planning to use php in an embedded environment. Our current web server is thttpd. I am considering two options now: whether to run it as a cgi or as SAPI module. I know cgi has advantage in terms of security. But if we are to use php as cgi, an instance of the php should be... |
Is there a FOSS batch compiling solution for Delphi that takes version as an input parameter?
I am using Delphi 7 and this remains the most tedious operation. Are there any other solutions, workarounds to make this easy.
| Yes, there are some Free and Open Source Software (FOSS) solutions and workarounds to facilitate batch compiling in Delphi, especially for older versions like Delphi 7. While there might not be a dedicated tool that specifically takes the version as an input parameter out of the box, you can use a combination of batch ... | 21,568 | [
{
"from": "human",
"value": "Is there a FOSS batch compiling solution for Delphi that takes version as an input parameter?\nI am using Delphi 7 and this remains the most tedious operation. Are there any other solutions, workarounds to make this easy.\n"
},
{
"from": "gpt",
"value": "Yes, there a... |
I am trying to help someone write a program that I thought would be easy, but of course it never is :)
I am trying to take a class roster (usually between 10-20 students) and effectivly uniquely pair off each classmate to another to make unique groups. Therefore in a class of 10 people, you can have 9 groups.
It needs ... | Creating a unique pairing system for a small class roster can be a fun challenge! You can implement a straightforward approach in Java (or any other language) to ensure that each student is paired uniquely and handle both even and odd numbers of students. Here’s a possible solution using an algorithm that keeps track o... | 20,871 | [
{
"from": "human",
"value": "I am trying to help someone write a program that I thought would be easy, but of course it never is :)\nI am trying to take a class roster (usually between 10-20 students) and effectivly uniquely pair off each classmate to another to make unique groups. Therefore in a class of 1... |
It would be a shame if it doesn't, because it will make for more attractive looking Android applications.
| It sounds like you might be discussing the potential benefits of design improvements in Android applications. Aesthetic enhancements, such as better UI/UX design, animations, and overall visual appeal, can indeed make Android apps more attractive and engaging for users.
Modern design principles, like Material Design ... | 27,772 | [
{
"from": "human",
"value": "It would be a shame if it doesn't, because it will make for more attractive looking Android applications.\n"
},
{
"from": "gpt",
"value": "It sounds like you might be discussing the potential benefits of design improvements in Android applications. Aesthetic enhancem... |
I have been using Ruby for a while now and I find, for bigger projects, it can take up a fair amount of memory. What are some best practices for reducing memory usage in Ruby?
Please, let each answer have one "best practice" and let the community vote it up.
| Certainly! Here are some best practices for reducing memory usage in Ruby, with each answer focusing on a single practice:
### Best Practice 1: Use Symbols Instead of Strings
In Ruby, strings are mutable and can consume more memory, especially when used as keys in hashes or frequently created. Instead, consider using... | 19,194 | [
{
"from": "human",
"value": "I have been using Ruby for a while now and I find, for bigger projects, it can take up a fair amount of memory. What are some best practices for reducing memory usage in Ruby?\n\nPlease, let each answer have one \"best practice\" and let the community vote it up.\n\n"
},
{
... |
I have a Spring MVC web app which uses Spring Security. I want to know the username of the currently logged in user. I'm using the code snippet given below . Is this the accepted way?
I don't like having a call to a static method inside this controller - that defeats the whole purpose of Spring, IMHO. Is there a ... | In Spring MVC with Spring Security, while using `SecurityContextHolder.getContext().getAuthentication()` is a common approach to access the currently logged-in user's information, it’s understandable that you might prefer dependency injection over static method calls for better testability and adherence to the principl... | 25,705 | [
{
"from": "human",
"value": "I have a Spring MVC web app which uses Spring Security. I want to know the username of the currently logged in user. I'm using the code snippet given below . Is this the accepted way? \nI don't like having a call to a static method inside this controller - that defeats the w... |
I have data in a MySQL database. I am sending the user a URL to get their data out as a CSV file.
I have the e-mailing of the link, MySQL query, etc. covered.
How can I, when they click the link, have a pop-up to download a CVS with the record from MySQL?
I have all the information to get the record already. I just do... | To create and serve a CSV file for download in PHP, you can follow these steps. Here’s a simple example that outlines how to create a PHP script that will output CSV data based on records fetched from a MySQL database.
### Step 1: Create the PHP script to generate and download the CSV
1. **Create a new PHP file**, fo... | 21,187 | [
{
"from": "human",
"value": "I have data in a MySQL database. I am sending the user a URL to get their data out as a CSV file.\nI have the e-mailing of the link, MySQL query, etc. covered.\nHow can I, when they click the link, have a pop-up to download a CVS with the record from MySQL? \nI have all the info... |
Wikipedia provides a number of citations used in the sciences, however does one stand out in computer science and software engineering related documents? My initial guess is to the IEEE format, as they have a number of conferences and publications related to both fields, but I couldn't find anything definite.
| You're correct that IEEE format is widely used in computer science and software engineering, particularly because IEEE publishes numerous journals and conference proceedings relevant to these fields. However, the choice of citation style can depend on the specific context or publication venue.
In addition to IEEE, oth... | 26,787 | [
{
"from": "human",
"value": "Wikipedia provides a number of citations used in the sciences, however does one stand out in computer science and software engineering related documents? My initial guess is to the IEEE format, as they have a number of conferences and publications related to both fields, but I c... |
I've been looking around the System.Xml namespace, but don't see anything that would support this. Does anyone know if it's built into .Net, or would I have to obtain a third party library to do it?
NOTE: I wish it were as simple as generating an xsd, but that won't do for my specific situation.
| The `System.Xml` namespace in .NET provides a variety of classes for working with XML, but it does not have built-in support for converting XML directly to a specific class or object model without some additional work. If you're looking for a way to deserialize XML into .NET objects, you might want to consider using th... | 21,923 | [
{
"from": "human",
"value": "I've been looking around the System.Xml namespace, but don't see anything that would support this. Does anyone know if it's built into .Net, or would I have to obtain a third party library to do it?\nNOTE: I wish it were as simple as generating an xsd, but that won't do for my ... |
I've been researching PHP frameworks as of late for some personal projects, and it looks like most of them use a front controller to mimic a response. The controller gets the params from the request, and re-routes by sending the appropriate headers depending on the logic. This is the "response". Is this the best way to... | Using a front controller pattern is indeed a common and effective approach for handling routing and responses in PHP frameworks. This pattern centralizes the request handling, making it easier to manage application flow, apply middleware, and implement common functionality like authentication, logging, and error handli... | 18,749 | [
{
"from": "human",
"value": "I've been researching PHP frameworks as of late for some personal projects, and it looks like most of them use a front controller to mimic a response. The controller gets the params from the request, and re-routes by sending the appropriate headers depending on the logic. This i... |
I have written a custom Rails model. This model is backed by an actually server not by a database table (so it does not inherit from ActiveRecord::Base). In order to get the requested information from the server I open a SSH connection to it. Because rails does not reuse object a new object, as well as a new SSH con... | Ruby does not provide a built-in mechanism specifically for notifying an object when it is about to be destroyed. However, you can implement a solution using Ruby's object lifecycle by defining a destructor method.
In Ruby, you can use the `ObjectSpace` module to finalize objects when they are no longer accessible. Yo... | 24,734 | [
{
"from": "human",
"value": "I have written a custom Rails model. This model is backed by an actually server not by a database table (so it does not inherit from ActiveRecord::Base). In order to get the requested information from the server I open a SSH connection to it. Because rails does not reuse obje... |
I currently have a Visual Studio solution with 8 web applications.
When I try run one of these applications, 8 instances of the Casini Web Development Servers are launched.
Is there anyway to specify that only the web application I have set as startup project will be launched and not all 8.
I am using Visual Studio 200... | In Visual Studio 2008, when you have multiple web applications in a solution and you want to ensure that only the startup project is launched (rather than all of them), you can follow these steps:
1. **Set the Startup Project**:
- Right-click on the specific web application project in the Solution Explorer.
- Se... | 27,129 | [
{
"from": "human",
"value": "I currently have a Visual Studio solution with 8 web applications.\nWhen I try run one of these applications, 8 instances of the Casini Web Development Servers are launched.\nIs there anyway to specify that only the web application I have set as startup project will be launched ... |
If I were to use more than one, what order should I use modifier keywords such as:
public, private, protected, virtual, abstract, override, new, static, internal, sealed, and any others I'm forgetting.
| In C#, the order of modifier keywords for class members (fields, properties, methods, etc.) is generally standardized and can improve readability when used consistently. The following is a common convention for the order of these modifiers:
1. **Access Modifiers**:
- `public`
- `private`
- `protected`
- `i... | 23,676 | [
{
"from": "human",
"value": "If I were to use more than one, what order should I use modifier keywords such as:\npublic, private, protected, virtual, abstract, override, new, static, internal, sealed, and any others I'm forgetting.\n"
},
{
"from": "gpt",
"value": "In C#, the order of modifier ke... |
So i am reorganizing a winforms C# solution to help decouple and make it cleaner and more organized. The solution tracks a small business orders,etc . .
I have broken out the projects so far into
App.View - all GUI Related Code
App.Data - just data structures and interfaces. No other implementation code
App.BusinessLo... | Based on the descriptions of the classes you provided and the structure of your solution, here's a suggestion on where to place each class:
1. **A Class that retrieves user preferences from a database**
- **Project:** `App.BusinessLogic`
- **Reason:** This class is responsible for retrieving data related to user... | 21,738 | [
{
"from": "human",
"value": "So i am reorganizing a winforms C# solution to help decouple and make it cleaner and more organized. The solution tracks a small business orders,etc . .\nI have broken out the projects so far into\nApp.View - all GUI Related Code\nApp.Data - just data structures and interfaces.... |
I am trying to use the same http cookie (in effect a asmx sessionid), in multiple WCF client endpoints.
The server has several endpoints, one of them is:
AuthenticationService.asmx
Login() <- Creates a HTTP cookie that is the servers ASP.NET sessionid
Logout() <- Destroys the same cookies
SomeOtherService... | To share the HTTP cookie (specifically the ASP.NET session ID cookie) across multiple WCF client endpoints, you'll need to configure your WCF clients to use the same `CookieContainer`. This allows WCF to automatically handle cookie storage and sending for multiple requests. Here's how you can do that:
### Steps to Sha... | 23,081 | [
{
"from": "human",
"value": "I am trying to use the same http cookie (in effect a asmx sessionid), in multiple WCF client endpoints. \nThe server has several endpoints, one of them is: \nAuthenticationService.asmx\n Login() <- Creates a HTTP cookie that is the servers ASP.NET sessionid\n Logout() <-... |
I'm new to Windows programming and after reading the Petzold book I wonder: is it still good practice to use the TCHAR type and the _T() function to declare strings or should I just use the wchar_t and L"" strings in new code?
I will target only modern Windows (as of this writing versions 10 and 11) and my code will be... | Welcome to Windows programming! Your question about using `TCHAR` and `_T()` versus `wchar_t` and wide strings (`L""`) is an important one, especially in the context of internationalization (i18n) and modern Windows development.
### Historical Context
`TCHAR` and `_T()` were introduced to facilitate Unicode and ANSI s... | 23,585 | [
{
"from": "human",
"value": "I'm new to Windows programming and after reading the Petzold book I wonder: is it still good practice to use the TCHAR type and the _T() function to declare strings or should I just use the wchar_t and L\"\" strings in new code?\nI will target only modern Windows (as of this wri... |
I have a couple variants of a program that I want to compare on performance. Both perform essentially the same task.
One does it all in C and memory. The other calls an external utility and does file IO.
How do I reliably compare them?
1) Getting "time on CPU" using "time" favors the second variant for calling system(... | It sounds like you're trying to measure the total CPU time consumed by both variants of your program in a fair way. Since you're aware that using `time` alone can be misleading due to I/O operations and waiting for system calls, you've hit upon a common challenge in performance comparison between CPU-bound and I/O-boun... | 21,936 | [
{
"from": "human",
"value": "I have a couple variants of a program that I want to compare on performance. Both perform essentially the same task.\nOne does it all in C and memory. The other calls an external utility and does file IO.\nHow do I reliably compare them? \n1) Getting \"time on CPU\" using \"time... |
I created a Rails application normally. Then created the scaffold for an event class. Then tried the following code. When run it complains about a InvalidAuthenticityToken when the destroy method is executed. How do I authenticate to avoid this response?
require 'rubygems'
require 'activeresource'
class Event < Active... | The error you are encountering, `InvalidAuthenticityToken`, typically occurs in Rails applications that use CSRF (Cross-Site Request Forgery) protection. When making requests from an external application or using ActiveResource, you need to ensure that the authenticity token is included in your requests.
Here’s how yo... | 23,438 | [
{
"from": "human",
"value": "I created a Rails application normally. Then created the scaffold for an event class. Then tried the following code. When run it complains about a InvalidAuthenticityToken when the destroy method is executed. How do I authenticate to avoid this response?\nrequire 'rubygems'\nreq... |
The end() function in jQuery reverts the element set back to what it was before the last destructive change, so I can see how it's supposed to be used, but I've seen some code examples, eg: on alistapart (which were probably from older versions of jQuery - the article is from 2006) which finished every statement off wi... | The `.end()` function in jQuery is used to return the previous set of matched elements in the jQuery object, effectively undoing the last filtering operation. This can be particularly useful when you chain multiple jQuery methods together, and you want to return to a previous state in the chain.
### Code Example:
In y... | 21,819 | [
{
"from": "human",
"value": "The end() function in jQuery reverts the element set back to what it was before the last destructive change, so I can see how it's supposed to be used, but I've seen some code examples, eg: on alistapart (which were probably from older versions of jQuery - the article is from 20... |
I am thinking of developing a web search engine using Erlang, Mnesia & Yaws. Is it possible to make a powerful and the fastest web search engine using these software? What will it need to accomplish this and how what do I start with?
| Developing a web search engine using Erlang, Mnesia, and Yaws is an intriguing idea, as these technologies have their strengths, particularly in scalability and fault tolerance. However, creating a powerful and fast search engine requires careful consideration of architecture, indexing, search algorithms, and resource ... | 21,172 | [
{
"from": "human",
"value": "I am thinking of developing a web search engine using Erlang, Mnesia & Yaws. Is it possible to make a powerful and the fastest web search engine using these software? What will it need to accomplish this and how what do I start with? \n"
},
{
"from": "gpt",
"value": ... |
In an effort to satisfy "The Joel Test" question #2 "Can you make a build in one step?", I'm trying to complete a release candidate build script with the creation of a CD iso from the collection of files gathered and generated by the installer creator.
There seem to be many good tools (many free) out there that will cr... | Creating an ISO file from the command line in a Windows environment can be accomplished using several tools. Below are a few options that can be integrated into your NAnt build script:
### 1. **Cygwin and mkisofs**
You can use Cygwin, a POSIX compatibility layer that runs on Windows, which includes the `mkisofs` comma... | 22,485 | [
{
"from": "human",
"value": "In an effort to satisfy \"The Joel Test\" question #2 \"Can you make a build in one step?\", I'm trying to complete a release candidate build script with the creation of a CD iso from the collection of files gathered and generated by the installer creator.\nThere seem to be many... |
I'm currently working through an assignment that deals with Big-O and running times. I have this one question presented to me that seems to be very easy, but I'm not sure if I'm doing it correctly. The rest of the problems have been quite difficult, and I feel like I'm overlooking something here.
First, you have these ... | You're on the right track with your calculations, but let's clarify a few points to make sure everything is clear and correct.
1. **Understanding the running time**: The expression \( 50n^3 \) represents the total number of operations required by algorithm A for an input of size \( n \). In this case, for \( n = 300 \... | 21,846 | [
{
"from": "human",
"value": "I'm currently working through an assignment that deals with Big-O and running times. I have this one question presented to me that seems to be very easy, but I'm not sure if I'm doing it correctly. The rest of the problems have been quite difficult, and I feel like I'm overlooki... |
Today at work we came across the following code (some of you might recognize it):
#define GET_VAL( val, type ) \
{ \
ASSERT( ( pIP + sizeof(type) ) <= pMethodEnd ); \
val = ( *((type *&)(pIP))++ ); \
}
Basically we have a byte a... | Certainly! The C and C++ languages are known for their complex syntax and behaviors, which can lead to code that is challenging to understand at first glance. Here are some examples that might cause you to stop and think:
### 1. Pointer Arithmetic with Structs
```cpp
struct Data {
int id;
float value;
};
Data... | 17,521 | [
{
"from": "human",
"value": "Today at work we came across the following code (some of you might recognize it):\n#define GET_VAL( val, type ) \\\n { \\\n ASSERT( ( pIP + sizeof(type) ) <= pMethodEnd ); \\\n val = ( *((type *&)(pIP))++ ); ... |
I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc.
I've found solutions to this problem but they rely on alternative color palettes than RGB.
I would rather just use straight RGB than mapping back and forth.... | Generating aesthetically pleasing random colors in the RGB color space can be challenging, as RGB doesn't inherently restrict colors to visually harmonious combinations. However, you can establish a set of rules or constraints to guide the generation of colors that are more likely to be pleasing to the eye. Here’s a si... | 7,988 | [
{
"from": "human",
"value": "I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc. \nI've found solutions to this problem but they rely on alternative color palettes than RGB.\nI would rather just us... |
The more I learn about WPF and XAML, the more I realize that you can do pretty much all of your GUI initialization and event handling glue in either XAML or in code (say C# code or VB.Net code).
My question is to those who have been working on WPF for longer and ideally those who have shipped apps with it -- where di... | Great question! The choice between using XAML and code-behind for WPF (Windows Presentation Foundation) applications is indeed a common dilemma for developers. Here are some tips and best practices based on experience and the common trends in the WPF community:
### General Guidelines
1. **Use XAML for UI Definition**... | 20,828 | [
{
"from": "human",
"value": "The more I learn about WPF and XAML, the more I realize that you can do pretty much all of your GUI initialization and event handling glue in either XAML or in code (say C# code or VB.Net code). \nMy question is to those who have been working on WPF for longer and ideally those... |
I am attempting to have a ReportHandler service to handle report creation. Reports can have multiple, differing number of parameters that could be set. In the system currently there are several different methods of creating reports (MS reporting services, html reports, etc) and the way the data is generated for each ... | It sounds like you're facing a challenging situation with the need to handle various types of reports and input parameters in a unified manner. While a big switch statement could work, it can lead to code that's hard to maintain and extend. Instead, consider using the following design patterns and techniques to create ... | 22,597 | [
{
"from": "human",
"value": "I am attempting to have a ReportHandler service to handle report creation. Reports can have multiple, differing number of parameters that could be set. In the system currently there are several different methods of creating reports (MS reporting services, html reports, etc) an... |
Which would be a neat implemenation of a N-ary tree in C language?
Particulary, I want to implement an n-ary tree, not self-ballancing, with an unbound number of children in each node, in which each node holds an already defined struct, like this for example:
struct task {
char command[MAX_LENGTH];
int required_tim... | Implementing an N-ary tree in C where each node can hold a predefined struct, such as your `task` struct, is straightforward. Below is a simple implementation of an N-ary tree where each node can have an unbounded number of children. The implementation includes functions to create a node, add children, and a traversal ... | 17,012 | [
{
"from": "human",
"value": "Which would be a neat implemenation of a N-ary tree in C language?\nParticulary, I want to implement an n-ary tree, not self-ballancing, with an unbound number of children in each node, in which each node holds an already defined struct, like this for example:\nstruct task {\n ... |
I was helping out some colleagues of mine with an SQL problem. Mainly they wanted to move all the rows from table A to table B (both tables having the same columns (names and types)). Although this was done in Oracle 11g I don't think it really matters.
Their initial naive implementation was something like
BEGIN
INS... | Yes, the data loss you experienced during the copying of rows from table A to table B can be attributed to the way transactions and isolation levels work in relational databases like Oracle and SQL Server.
Here's a breakdown of what's happening in the initial approach:
### Transaction Context
1. **INSERT into B**: W... | 24,815 | [
{
"from": "human",
"value": "I was helping out some colleagues of mine with an SQL problem. Mainly they wanted to move all the rows from table A to table B (both tables having the same columns (names and types)). Although this was done in Oracle 11g I don't think it really matters.\nTheir initial naive impl... |
I have a DataRow and I am getting one of the elements which is a Amount with a dollar sign. I am calling a toString on it. Is there another method I can call on it to remove the dollar sign if present.
So something like:
dr.ToString.Substring(1, dr.ToString.Length);
But more conditionally in case the dollar sign ever ... | If you want to remove a dollar sign (`$`) from a string representation of an amount in a `DataRow`, you can use the `Replace` method or use `TrimStart` if you just want to remove leading dollar signs. Here's a simple example of how you can do that without explicitly defining another string.
### Using `Replace` Method
... | 16,547 | [
{
"from": "human",
"value": "I have a DataRow and I am getting one of the elements which is a Amount with a dollar sign. I am calling a toString on it. Is there another method I can call on it to remove the dollar sign if present. \nSo something like:\ndr.ToString.Substring(1, dr.ToString.Length);\nBut more... |
I've been reading about UpdateFrom, used to update a business object from the request. Is it massively susceptible to XSS code and extra form parameters being posted?
| The `UpdateFrom` method in many frameworks (like ASP.NET) is often used to map data from an incoming request (like form data) to a business object. While this method can simplify the process of updating objects, it does come with certain risks if not implemented carefully, particularly concerning Cross-Site Scripting (... | 23,291 | [
{
"from": "human",
"value": "I've been reading about UpdateFrom, used to update a business object from the request. Is it massively susceptible to XSS code and extra form parameters being posted?\n"
},
{
"from": "gpt",
"value": "The `UpdateFrom` method in many frameworks (like ASP.NET) is often ... |
Since AS3 does not allow private constructors, it seems the only way to construct a singleton and guarantee the constructor isn't explicitly created via "new" is to pass a single parameter and check it.
I've heard two recommendations, one is to check the caller and ensure it's the static getInstance(), and the other is... | In ActionScript 3 (AS3), implementing the Singleton pattern can indeed be challenging due to the lack of private constructors. However, there are several effective approaches to ensure that a class can only be instantiated once, and you've already identified some common methods. Let's explore these options and clarify ... | 15,703 | [
{
"from": "human",
"value": "Since AS3 does not allow private constructors, it seems the only way to construct a singleton and guarantee the constructor isn't explicitly created via \"new\" is to pass a single parameter and check it.\nI've heard two recommendations, one is to check the caller and ensure it'... |
I'm trying to get a bare-bones example of logging going in my ASP.NET application. I would like to use the My.Log functionality to write out error log messages to a text log file. I have tried several things via Google but none of them seem to work. In general, when I use any of the properties of My.Log.DefaultFileWrit... | To set up logging in your ASP.NET application using the `My.Log` functionality with the `FileLogTraceListener`, follow these steps carefully. Make sure that your web.config is correctly configured and that your code is correctly structured.
### 1. Update your `web.config`
You need to make sure that your `web.config` ... | 25,509 | [
{
"from": "human",
"value": "I'm trying to get a bare-bones example of logging going in my ASP.NET application. I would like to use the My.Log functionality to write out error log messages to a text log file. I have tried several things via Google but none of them seem to work. In general, when I use any of... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.