instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
I'm expanding my Ruby understanding by coding an equivalent of Kent Beck's xUnit in Ruby. Python (which Kent writes in) has an assert() method in the language which is used extensively. Ruby does not. I think it should be easy to add this but is Kernel the right place to put it?
BTW, I know of the existence of the v... | Great to hear that you're diving deeper into Ruby by implementing your own testing framework! While Ruby does not have a built-in `assert()` method like Python, you can certainly create one. Adding it to the `Kernel` module is a reasonable choice since `Kernel` is included in the `Object` class, which means that any ob... | 15,317 | [
{
"from": "human",
"value": "I'm expanding my Ruby understanding by coding an equivalent of Kent Beck's xUnit in Ruby. Python (which Kent writes in) has an assert() method in the language which is used extensively. Ruby does not. I think it should be easy to add this but is Kernel the right place to put ... |
For ActionScript 2, I've used NaturalDocs. However it has pretty poor support for PHP. I've looked so far at doxygen and phpDocumentor, but their output is pretty ugly in my opinion. Does anyone have any experience with automatic documentation generation for PHP? I'd prefer to be able to use javadoc-style tags, they ar... | If you're looking for a way to generate documentation for PHP using Javadoc-style tags, here are a few options you might consider:
1. **phpDocumentor**: While you mentioned that you found phpDocumentor's output to be unattractive, it is a widely used tool and allows customization of templates. You can create or modify... | 16,767 | [
{
"from": "human",
"value": "For ActionScript 2, I've used NaturalDocs. However it has pretty poor support for PHP. I've looked so far at doxygen and phpDocumentor, but their output is pretty ugly in my opinion. Does anyone have any experience with automatic documentation generation for PHP? I'd prefer to b... |
I have a form in which people will be entering dollar values.
Possible inputs:
$999,999,999.99
999,999,999.99
999999999
99,999
$99,999
The user can enter a dollar value however they wish. I want to read the inputs as doubles so I can total them.
I tried just typecasting the strings to doubles but that didn't work. Tota... | When working with dollar amounts in string format, it's important to first remove any non-numeric characters (except for the decimal point). This includes removing the dollar sign (`$`) and any commas (`,`). After cleaning the strings, you can safely convert them to `double`.
Here's how you can do it in PHP:
```php
$... | 17,142 | [
{
"from": "human",
"value": "I have a form in which people will be entering dollar values.\nPossible inputs:\n$999,999,999.99\n999,999,999.99\n999999999\n99,999\n$99,999\nThe user can enter a dollar value however they wish. I want to read the inputs as doubles so I can total them.\nI tried just typecasting ... |
How can I add a line break to text when it is being set as an attribute i.e.:
<TextBlock Text="Stuff on line1 \n Stuff on line2" />
Breaking it out into the exploded format isn't an option for my particular situation. What I need is some way to emulate the following:
<TextBlock>
<TextBlock.Text>
Stuff on line1 ... | When you're setting text directly in XAML as an attribute and want to include a line break, you can't use `\n` directly. Instead, you can use the `
` character entity to represent a line break in XAML.
However, this approach has limitations depending on the context in which you're using the `TextBlock`. The `Text... | 16,456 | [
{
"from": "human",
"value": "How can I add a line break to text when it is being set as an attribute i.e.:\n<TextBlock Text=\"Stuff on line1 \\n Stuff on line2\" />\n\nBreaking it out into the exploded format isn't an option for my particular situation. What I need is some way to emulate the following:\n<T... |
I'm currently designing a brand new database. In school, we always learned to put a primary key in each table.
I read a lot of articles/discussions/newsgroups posts saying that it's better to use unique constraint (aka unique index for some db) instead of PK.
What's your point of view?
| When designing a database, it's essential to understand the roles of primary keys (PK) and unique constraints, as they serve related but distinct purposes. Here’s a breakdown of both concepts and their uses:
### Primary Key (PK):
1. **Uniqueness**: A primary key uniquely identifies each record in a table.
2. **Not Nul... | 13,889 | [
{
"from": "human",
"value": "I'm currently designing a brand new database. In school, we always learned to put a primary key in each table.\nI read a lot of articles/discussions/newsgroups posts saying that it's better to use unique constraint (aka unique index for some db) instead of PK.\nWhat's your point... |
Consider a database table holding names, with three rows:
Peter
Paul
Mary
Is there an easy way to turn this into a single string of Peter, Paul, Mary?
| Yes, you can easily concatenate the names from the rows into a single string using SQL. The exact method may vary slightly depending on the database management system (DBMS) you are using, but here are some common approaches.
### Using SQL (for most databases):
1. **Using `GROUP_CONCAT()` (MySQL):**
```sql
SELECT GR... | 18,591 | [
{
"from": "human",
"value": "Consider a database table holding names, with three rows:\nPeter\nPaul\nMary\n\nIs there an easy way to turn this into a single string of Peter, Paul, Mary?\n"
},
{
"from": "gpt",
"value": "Yes, you can easily concatenate the names from the rows into a single string ... |
What is the average time that it would take a complete novice, whose background is mostly Windows XP, to go through the FreeBSD handbook and get sufficient mastery to setup a server from the ground up?
| The time it takes for a complete novice to go through the FreeBSD Handbook and gain sufficient mastery to set up a server from the ground up can vary significantly based on several factors, including the individual's learning style, prior experience with computers, and the complexity of the server they intend to set up... | 16,526 | [
{
"from": "human",
"value": "What is the average time that it would take a complete novice, whose background is mostly Windows XP, to go through the FreeBSD handbook and get sufficient mastery to setup a server from the ground up?\n"
},
{
"from": "gpt",
"value": "The time it takes for a complete... |
I recently converted a ruby library to a gem, which seemed to break the command line usability
Worked fine as a library
$ ruby -r foobar -e 'p FooBar.question' # => "answer"
And as a gem, irb knows how to require a gem from command-line switches
$ irb -rubygems -r foobar
irb(main):001:0> FooBar.question # => "an... | The issue you are encountering arises from the fact that the `-rubygems` flag is no longer supported in the same way when using the `-r` option to require gems in Ruby 1.9 and later. The `-rubygems` flag has been deprecated, and as of Ruby 2.0, it is no longer necessary to specify it. You can simply require the gem as ... | 16,347 | [
{
"from": "human",
"value": "I recently converted a ruby library to a gem, which seemed to break the command line usability\nWorked fine as a library\n $ ruby -r foobar -e 'p FooBar.question' # => \"answer\"\n\nAnd as a gem, irb knows how to require a gem from command-line switches\n $ irb -rubygems -r fo... |
One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:
self.__value = 1
def value():
return self.__value
Is there a simple way of providing access to the private members of a class that I wish to subclass? Often I wish to simply work... | In Python, the convention for private members is to use a double underscore prefix (e.g., `__value`) which triggers name mangling. This means the member gets a name that includes the class name, thus making it harder (though not impossible) to access from outside the class.
If you want to allow subclasses to access th... | 15,274 | [
{
"from": "human",
"value": "One of the really nice things about python is the simplicity with which you can name variables that have the same name as the accessor:\nself.__value = 1\n\ndef value():\n return self.__value\n\nIs there a simple way of providing access to the private members of a class that ... |
I have an MDI application (written in .NET 2.0) which lets users open multiple child forms. The child forms are always maximized inside the MDI parent. When the MDI parent is maximized and I attempt to do a MessageBox.Show, the MessageBox doesn't show. If I do an alt-tab (or even just press alt) the MessageBox pops ... | This issue you're experiencing with the MessageBox in an MDI application can be frustrating, particularly when it behaves differently based on whether the MDI parent is maximized or not. The problem likely relates to how Windows manages window focus and z-order with MDI applications.
Here are several suggestions to po... | 9,575 | [
{
"from": "human",
"value": "I have an MDI application (written in .NET 2.0) which lets users open multiple child forms. The child forms are always maximized inside the MDI parent. When the MDI parent is maximized and I attempt to do a MessageBox.Show, the MessageBox doesn't show. If I do an alt-tab (or ... |
I have a PHP script that is called from a cron job every minute. This script takes some info from the database and then calls another PHP script using the System function (passing it some parameters).
That means that I can start up to 10 scripts from this "main" one. And what I would like to do is that I would call the... | To execute a PHP script in the background without waiting for it to complete in a `system` call, you can use the `nohup` command along with `&` to make sure it runs in the background. The `nohup` command allows the process to run independently of the terminal session that initiated it, and adding `&` at the end sends i... | 15,762 | [
{
"from": "human",
"value": "I have a PHP script that is called from a cron job every minute. This script takes some info from the database and then calls another PHP script using the System function (passing it some parameters).\nThat means that I can start up to 10 scripts from this \"main\" one. And what... |
what configuration needs to be tweaked, and where does it live, in order to increase the maximum allowed post size?
| To increase the maximum allowed post size for a web application, you typically need to modify the configuration settings for your web server and possibly for your application framework. Here are the common locations and settings for popular web servers and frameworks:
### 1. **PHP (if you're using a PHP-based applicat... | 14,483 | [
{
"from": "human",
"value": "what configuration needs to be tweaked, and where does it live, in order to increase the maximum allowed post size?\n"
},
{
"from": "gpt",
"value": "To increase the maximum allowed post size for a web application, you typically need to modify the configuration settin... |
I am wondering if someone can put a bit of an authoritative reference summary of when the !important declaration in CSS does not work to override inline styles.
| In CSS, the `!important` declaration is used to increase the specificity of a style rule, making it override other styles that would normally take precedence. However, there are specific circumstances where `!important` may not work as expected, especially in relation to inline styles. Here’s a summary of those scenari... | 16,847 | [
{
"from": "human",
"value": "I am wondering if someone can put a bit of an authoritative reference summary of when the !important declaration in CSS does not work to override inline styles.\n"
},
{
"from": "gpt",
"value": "In CSS, the `!important` declaration is used to increase the specificity ... |
I'm writing a php script where I call
$lines = file('base_list.txt');
to break a file up into an array. The file has over 100,000 lines in it, which should be 100,000 elements in the array, but when I run
print_r($lines);
exit;
the array only contains 7280 elements.
So I'm curious, WTF? Is there a limit on the amo... | The issue you're experiencing with the `file()` function in PHP returning fewer lines than expected could be caused by several factors. Here are a few troubleshooting steps and considerations to help you identify the problem:
1. **File Encoding**: Check the encoding of your `base_list.txt` file. If the file contains s... | 14,719 | [
{
"from": "human",
"value": "I'm writing a php script where I call \n$lines = file('base_list.txt');\n\nto break a file up into an array. The file has over 100,000 lines in it, which should be 100,000 elements in the array, but when I run \nprint_r($lines);\nexit;\n\nthe array only contains 7280 elements. \... |
I have a command line program, which outputs logging to the screen.
I want error lines to show up in red. Is there some special character codes I can output to switch the text color to red, then switch it back to white?
I'm using ruby but I imagine this would be the same in any other language.
Something like:
red = "\0... | Yes, you can change the text color in the terminal using ANSI escape codes. The specific codes for red text and resetting the color are as follows:
- **Red text:** `\033[31m`
- **Reset to default color:** `\033[0m`
You can use these codes in your Ruby program as follows:
```ruby
red = "\033[31m"
reset = "\033[0m"
#... | 17,748 | [
{
"from": "human",
"value": "I have a command line program, which outputs logging to the screen.\nI want error lines to show up in red. Is there some special character codes I can output to switch the text color to red, then switch it back to white?\nI'm using ruby but I imagine this would be the same in an... |
I'm trying to Unit Test a class that has many internal functions. These obviously need testing too, but my Tests project is seperate, mainly because it covers many small, related projects. What I have so far is:
FieldInfo[] _fields =
typeof(ButtonedForm.TitleButton).GetFields(
BindingFlags.NonPublic | Bind... | To access internal members of a class from a different assembly, you can use the `InternalsVisibleTo` attribute. This attribute allows you to specify which other assemblies can access the internal types and members of your assembly.
Here's how you can achieve that in your case:
1. **Modify the Assembly Info**: In you... | 14,740 | [
{
"from": "human",
"value": "I'm trying to Unit Test a class that has many internal functions. These obviously need testing too, but my Tests project is seperate, mainly because it covers many small, related projects. What I have so far is:\nFieldInfo[] _fields = \n typeof(ButtonedForm.TitleButton).GetFi... |
I'd like to limit the size of the file that can be uploaded to an application. To achieve this, I'd like to abort the upload process from the server side when the size of the file being uploaded exceeds a limit.
Is there a way to abort an upload process from the server side without waiting the HTTP request to finish?
| Aborting an upload from the server side before the HTTP request finishes can be a bit challenging because, by the time the server processes the upload, it typically already has received some or all of the data. However, there are approaches you can take to manage file uploads and enforce size limits effectively:
### 1... | 13,196 | [
{
"from": "human",
"value": "I'd like to limit the size of the file that can be uploaded to an application. To achieve this, I'd like to abort the upload process from the server side when the size of the file being uploaded exceeds a limit.\nIs there a way to abort an upload process from the server side wit... |
I am trying to update an element in a list with Lotus Formula.
I thought you would do it like this:
x := "0":"0":"0";
x[1] := "1";
But when I try to save I get the following error:
:= must be immediately preceded by a field or variable name
| In Lotus Formula, the syntax for updating elements in a list is slightly different from what you might expect from other programming languages. You cannot use the `:=` operator to assign a value directly to an element of a list.
Instead, you should use the `@Replace` function to create a new list with the updated valu... | 19,104 | [
{
"from": "human",
"value": "I am trying to update an element in a list with Lotus Formula.\nI thought you would do it like this:\nx := \"0\":\"0\":\"0\";\nx[1] := \"1\";\n\nBut when I try to save I get the following error:\n:= must be immediately preceded by a field or variable name\n\n"
},
{
"from... |
I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:
Will you have a python 2 and python 3 version to be maintained concurrently or will you simply have a python 3 version once it's finished?
Have you a... | It's great to hear you're interested in the transition from Python 2 to Python 3! Since Python 3 was officially released in December 2008 and Python 2 has reached its end-of-life as of January 1, 2020, the focus for most projects has shifted to Python 3. Here are some thoughts regarding your questions:
1. **Concurrent... | 15,608 | [
{
"from": "human",
"value": "I'm sure this is a subject that's on most python developers' minds considering that Python 3 is coming out soon. Some questions to get us going in the right direction:\n\nWill you have a python 2 and python 3 version to be maintained concurrently or will you simply have a pytho... |
What’s the best way to capitalize the first letter of each word in a string in SQL Server.
| In SQL Server, you can capitalize the first letter of each word in a string using a combination of string functions. One common approach is to create a user-defined function that processes the input string. Here's a sample implementation:
```sql
CREATE FUNCTION dbo.CapitalizeWords (@input NVARCHAR(MAX))
RETURNS NVARCH... | 14,368 | [
{
"from": "human",
"value": "What’s the best way to capitalize the first letter of each word in a string in SQL Server.\n"
},
{
"from": "gpt",
"value": "In SQL Server, you can capitalize the first letter of each word in a string using a combination of string functions. One common approach is to ... |
When in incremental search mode in Intellij IDEA, is there a way to select the rest of the word. For example, suppose I want to find the word “handleReservationGranted”. I type Ctrl-f to enter incremental search mode, and start typing the letters “han”. Now suppose I have found the beginning of “handleReservationGrante... | In IntelliJ IDEA 7.0.3, there isn't a direct equivalent feature like in XEmacs where you can quickly select the remainder of the word in incremental search mode. However, you can use a workaround to achieve a similar effect:
1. Enter incremental search mode with **Ctrl + F**.
2. Type the initial part of the word, e.g.... | 16,531 | [
{
"from": "human",
"value": "When in incremental search mode in Intellij IDEA, is there a way to select the rest of the word. For example, suppose I want to find the word “handleReservationGranted”. I type Ctrl-f to enter incremental search mode, and start typing the letters “han”. Now suppose I have found ... |
Often we need to add a non-nullable column to a table, and it is quite a mission. Using a default constraint as is doesn’t work, so we have to create nullable columns, update them to default values, then make them non-nullable. Is there not an easier way to do this?
| Yes, there is an easier way to add a non-nullable column to a table without going through the steps of creating a nullable column, updating it, and then making it non-nullable. Most modern relational database management systems (RDBMS) support adding non-nullable columns with a default value in a single operation. Howe... | 15,790 | [
{
"from": "human",
"value": "Often we need to add a non-nullable column to a table, and it is quite a mission. Using a default constraint as is doesn’t work, so we have to create nullable columns, update them to default values, then make them non-nullable. Is there not an easier way to do this?\n"
},
... |
Groovy adds the execute method to String to make executing shells fairly easy;
println "ls".execute().text
but if an error happens, then there is no resulting output. Is there an easy way to get both the standard error and standard output? (other than creating a bunch of code to create two threads to read both input... | Yes, you can achieve this in Groovy by creating a helper method that executes a shell command and captures both the standard output and standard error. Instead of creating multiple threads to handle the output streams, you can use Groovy's `ProcessBuilder` which provides a simpler way to manage both outputs.
Here's an... | 16,703 | [
{
"from": "human",
"value": "Groovy adds the execute method to String to make executing shells fairly easy;\nprintln \"ls\".execute().text\n\nbut if an error happens, then there is no resulting output. Is there an easy way to get both the standard error and standard output? (other than creating a bunch of... |
I'm looking for a groovy equivalent on .NET
http://boo.codehaus.org/
So far Boo looks interesting, but it is statically typed, yet does include some of the metaprogramming features I'd be looking for.
Can anyone comment on the experience of using Boo and is it worth looking into for more than hobby purposes at a 1.0 Ve... | Boo is indeed an interesting language that runs on the .NET framework and offers features that some developers find appealing, especially those looking for a syntax reminiscent of Python combined with the power of the .NET ecosystem. Here are some points to consider if you're evaluating Boo for more than hobby purposes... | 12,158 | [
{
"from": "human",
"value": "I'm looking for a groovy equivalent on .NET\nhttp://boo.codehaus.org/\nSo far Boo looks interesting, but it is statically typed, yet does include some of the metaprogramming features I'd be looking for.\nCan anyone comment on the experience of using Boo and is it worth looking i... |
I am no AppleScript Jedi, I've only done a few simple things, but I haven't been able to figure this one out and could use some help:
My wife uses slides for her Art History courses and would like to use the same slides for exams (sans identifying names). Rather than create a new presentation, I'd like a tool that iter... | Certainly! You can create an AppleScript to iterate through the slides in a Keynote presentation and hide text fields. Here's a basic example to get you started. This script will go through each slide and hide the text boxes.
1. Open the `Script Editor` on your Mac.
2. Copy and paste the following script into the edit... | 15,793 | [
{
"from": "human",
"value": "I am no AppleScript Jedi, I've only done a few simple things, but I haven't been able to figure this one out and could use some help:\nMy wife uses slides for her Art History courses and would like to use the same slides for exams (sans identifying names). Rather than create a n... |
I hit this error while my web application was trying to execute a SELECT INTO on a MSSQL 2005 database. I really have two questions:
What does this error mean and how does this happen?
Is there a way to prevent these errors by coding in a different way?
| To address your questions regarding the error encountered while executing a `SELECT INTO` statement in a Microsoft SQL Server 2005 database, let's break it down:
### 1. Understanding the Error
The `SELECT INTO` statement in SQL Server is used to create a new table and populate it with data from an existing table. Com... | 14,119 | [
{
"from": "human",
"value": "I hit this error while my web application was trying to execute a SELECT INTO on a MSSQL 2005 database. I really have two questions:\n\nWhat does this error mean and how does this happen?\nIs there a way to prevent these errors by coding in a different way?\n\n"
},
{
"f... |
Not sure how to ask a followup on SO, but this is in reference to an earlier question:
Fetch one row per account id from list
The query I'm working with is:
SELECT *
FROM scores s1
WHERE accountid NOT IN (SELECT accountid FROM scores s2 WHERE s1.score < s2.score)
ORDER BY score DESC
This selects the top scores, and li... | To ensure that you fetch only one row per `accountid`, even when multiple occurrences of the top score exist, you can use the `ROW_NUMBER()` window function. This will allow you to assign a unique rank to each score per account, and then you can filter to get only the top score for each account. Here’s how you can modi... | 15,705 | [
{
"from": "human",
"value": "Not sure how to ask a followup on SO, but this is in reference to an earlier question:\nFetch one row per account id from list\nThe query I'm working with is:\nSELECT *\nFROM scores s1\nWHERE accountid NOT IN (SELECT accountid FROM scores s2 WHERE s1.score < s2.score)\nORDER BY ... |
What is the slickest way to initialize an array of dynamic size in C# that you know of?
This is the best I could come up with
private bool[] GetPageNumbersToLink(IPagedResult result)
{
if (result.TotalPages <= 9)
return new bool[result.TotalPages + 1].Select(b => true).ToArray();
...
| In C#, if you're looking for a slick way to initialize an array of dynamic size, you can leverage the `Enumerable.Range` method in combination with `Select` to create an array that meets your criteria. Given your scenario, here's an elegant approach to initialize a boolean array based on `result.TotalPages`.
You can s... | 17,179 | [
{
"from": "human",
"value": "What is the slickest way to initialize an array of dynamic size in C# that you know of?\nThis is the best I could come up with\nprivate bool[] GetPageNumbersToLink(IPagedResult result)\n{\n if (result.TotalPages <= 9)\n return new bool[result.TotalPages + 1].Select(b => t... |
Not that I'm doing something like that, but I am kind of interested how bad a practice like that is.
| It seems like you might be referring to a potentially unethical or harmful practice, though it's not clear what specific practice you're discussing. In general, engaging in unethical behavior can have significant negative consequences, including:
1. **Legal Repercussions**: Many unethical practices can also be illegal... | 15,726 | [
{
"from": "human",
"value": "Not that I'm doing something like that, but I am kind of interested how bad a practice like that is.\n"
},
{
"from": "gpt",
"value": "It seems like you might be referring to a potentially unethical or harmful practice, though it's not clear what specific practice you... |
I'm an experienced programmer but just starting out with Flash/Actionscript. I'm working on a project that for certain reasons requires me to use Actionscript 2 rather than 3.
When I run the following (I just put it in frame one of a new flash project), the output is a 3 rather than a 1 ? I need it to be a 1.
Why does ... | The behavior you're observing is due to how variable scoping and closures work in ActionScript 2. Specifically, when you define a function within a loop, that function captures the variable `ii` by reference, not by value. As a result, all functions created in the loop refer to the same `ii` variable, which retains its... | 16,082 | [
{
"from": "human",
"value": "I'm an experienced programmer but just starting out with Flash/Actionscript. I'm working on a project that for certain reasons requires me to use Actionscript 2 rather than 3.\nWhen I run the following (I just put it in frame one of a new flash project), the output is a 3 rather... |
In this article Jeroen explains an example of using an XML file to remap Java Bean getters and setters to .NET Properties.
What would the XML file look like if I wanted to, say, remap a Java method called showDialog() to ShowDialog() in .NET? Has anyone worked with the remapping option before? Any idea where to get inf... | To remap a Java method like `showDialog()` to its .NET equivalent `ShowDialog()` using an XML file, you would typically create a mapping entry that specifies the Java method and the corresponding .NET property or method.
Here’s an example of what the XML file might look like for your specific remapping:
```xml
<remap... | 14,241 | [
{
"from": "human",
"value": "In this article Jeroen explains an example of using an XML file to remap Java Bean getters and setters to .NET Properties.\nWhat would the XML file look like if I wanted to, say, remap a Java method called showDialog() to ShowDialog() in .NET? Has anyone worked with the remappin... |
In this code I am debugging, I have this code snipit:
ddlExpYear.SelectedItem.Value.Substring(2).PadLeft(2, '0');
What does this return? I really can't run this too much as it is part of a live credit card application. The DropDownList as you could imagine from the name contains the 4-digit year.
UPDATE: Thanks everyo... | The code snippet you've provided is accessing a value from a DropDownList (likely in a .NET web application) and performing some string manipulation on it. Let's break it down step by step:
1. **ddlExpYear.SelectedItem.Value**: This retrieves the selected item's value from a DropDownList named `ddlExpYear`. Assuming t... | 14,217 | [
{
"from": "human",
"value": "In this code I am debugging, I have this code snipit:\nddlExpYear.SelectedItem.Value.Substring(2).PadLeft(2, '0');\n\nWhat does this return? I really can't run this too much as it is part of a live credit card application. The DropDownList as you could imagine from the name cont... |
I see on Stack Overflow and PEP 8 that the recommendation is to use spaces only for indentation in Python programs. I can understand the need for consistent indentation and I have felt that pain.
Is there an underlying reason for spaces to be preferred? I would have thought that tabs were far easier to work with.
| The preference for spaces over tabs in Python, as recommended by PEP 8 and commonly seen in programming communities like Stack Overflow, has several underlying reasons. Here are the main points:
1. **Consistency Across Environments**: Different text editors and IDEs can interpret tab characters in varying ways. For ex... | 16,672 | [
{
"from": "human",
"value": "I see on Stack Overflow and PEP 8 that the recommendation is to use spaces only for indentation in Python programs. I can understand the need for consistent indentation and I have felt that pain.\nIs there an underlying reason for spaces to be preferred? I would have thought t... |
What code generation tools are built-in to vs.net 2008 or are officially available via Microsoft?
I know of:
Entity Framework
sqlmetal
What else is there?
Ideally i'm looking for something that will generate from an existing database schema.
| In addition to the Entity Framework and SqlMetal that you've already mentioned, there are a few other code generation tools and frameworks that were either built into Visual Studio 2008 or are officially available via Microsoft for generating code from an existing database schema:
1. **LINQ to SQL**: This is another O... | 17,996 | [
{
"from": "human",
"value": "What code generation tools are built-in to vs.net 2008 or are officially available via Microsoft?\nI know of:\n\nEntity Framework\nsqlmetal\n\nWhat else is there?\nIdeally i'm looking for something that will generate from an existing database schema.\n"
},
{
"from": "gpt... |
To all the people who know lambda calculus: What benefit has it bought you, regarding programming? Would you recommend that people learn it?
| Lambda calculus is a formal system in mathematical logic and computer science for expressing computation based on function abstraction and application. Understanding lambda calculus can provide several benefits to programmers, especially those involved in functional programming or theoretical computer science. Here are... | 11,358 | [
{
"from": "human",
"value": "To all the people who know lambda calculus: What benefit has it bought you, regarding programming? Would you recommend that people learn it?\n"
},
{
"from": "gpt",
"value": "Lambda calculus is a formal system in mathematical logic and computer science for expressing ... |
I have a string of arbitrary length, and starting at position p0, I need to find the first occurrence of one of three 3-letter patterns.
Assume the string contain only letters. I need to find the count of triplets starting at position p0 and jumping forward in triplets until the first occurrence of either 'aaa' or 'bbb... | Yes, it is possible to use a regex to find the count of triplets starting at a given position in a string until the first occurrence of any of the specified patterns ('aaa', 'bbb', or 'ccc'). However, a regex alone does not inherently provide a way to count triplets in the way you are describing (i.e., jumping forward ... | 12,795 | [
{
"from": "human",
"value": "I have a string of arbitrary length, and starting at position p0, I need to find the first occurrence of one of three 3-letter patterns.\nAssume the string contain only letters. I need to find the count of triplets starting at position p0 and jumping forward in triplets until th... |
What is the difference between old style and new style classes in Python? When should I use one or the other?
| In Python, classes can be categorized into two styles: old-style classes and new-style classes. This distinction is primarily relevant in Python 2, as Python 3 only supports new-style classes. Here are the main differences and considerations:
### Old-Style Classes (Python 2.x)
- **Definition**: Old-style classes are ... | 12,994 | [
{
"from": "human",
"value": "What is the difference between old style and new style classes in Python? When should I use one or the other?\n"
},
{
"from": "gpt",
"value": "In Python, classes can be categorized into two styles: old-style classes and new-style classes. This distinction is primari... |
I'm using the Crystal Reports included with VisualStudio 2005. I would like to change the image that is displayed on the report at runtime ideally by building a path to the image file and then have that image displayed on the report.
Has anyone been able to accomplish this with this version of Crystal Reports?
| Yes, you can change the image displayed in a Crystal Report at runtime in Visual Studio 2005. Here’s how you can accomplish this:
### Steps to Display an Image at Runtime in Crystal Reports:
1. **Prepare Your Report**:
- Open your Crystal Report in Visual Studio.
- Drag and drop an `Image` control from the Tool... | 16,315 | [
{
"from": "human",
"value": "I'm using the Crystal Reports included with VisualStudio 2005. I would like to change the image that is displayed on the report at runtime ideally by building a path to the image file and then have that image displayed on the report.\nHas anyone been able to accomplish this with... |
Does anyone know of a good program where I can paste in xml (getting it from a System.out in my java class) and it will format the xml so it's not a really long line of text?
| Yes, there are several programs and online tools that you can use to format XML for better readability. Here are a few options:
### Online Tools:
1. **XML Formatter**:
- [FreeFormatter.com](https://www.freeformatter.com/xml-formatter.html) - A simple online tool where you can paste your XML and format it.
- [XML... | 17,578 | [
{
"from": "human",
"value": "Does anyone know of a good program where I can paste in xml (getting it from a System.out in my java class) and it will format the xml so it's not a really long line of text?\n"
},
{
"from": "gpt",
"value": "Yes, there are several programs and online tools that you c... |
If I try and access some random string in the URL of my rails app, such as /asdfasdifjasdfkj then I am seeing a rails error message
Routing Error
No route matches "/asdfasdifjasdfkj" with {:method=>:get}
Even though I am in production mode. Clearly I don't want any real users to see this, and would prefer a 404 page. ... | In a Ruby on Rails application, the default behavior when a route is not found (like in your case with `/asdfasdifjasdfkj`) is to display a routing error. To prevent users from seeing detailed error messages, including stack traces, you can customize the behavior of your application in production mode.
Here are the st... | 14,337 | [
{
"from": "human",
"value": "If I try and access some random string in the URL of my rails app, such as /asdfasdifjasdfkj then I am seeing a rails error message \nRouting Error\nNo route matches \"/asdfasdifjasdfkj\" with {:method=>:get}\nEven though I am in production mode. Clearly I don't want any real us... |
I've begun to use TDD. As mentioned in an earlier question the biggest difficulty is handling interface changes. How do you reduce the impact on your test cases as requirements change?
| Using Test-Driven Development (TDD) can be a powerful approach to software development, but managing changes in interfaces and requirements can certainly present challenges. Here are some strategies to help reduce the impact on your test cases when requirements change:
1. **Use Meaningful Tests**: Write tests that foc... | 12,701 | [
{
"from": "human",
"value": "I've begun to use TDD. As mentioned in an earlier question the biggest difficulty is handling interface changes. How do you reduce the impact on your test cases as requirements change?\n"
},
{
"from": "gpt",
"value": "Using Test-Driven Development (TDD) can be a po... |
I've updated my TortoiseSVN client and now I'm getting the error when trying to update or commit to different repositories:
The requested name is valid, but no data of the requested type was
found
Any ideas on how I can solve this? Internet Explorer shows up appropriate URL just fine.
TortoiseSVN 1.5.3, Build 13783... | The error message you're encountering with TortoiseSVN typically indicates that there's a problem with how TortoiseSVN is resolving the repository URLs, particularly regarding the network settings or DNS configuration. Here are several steps you can take to troubleshoot and potentially resolve the issue:
1. **Check Re... | 15,205 | [
{
"from": "human",
"value": "I've updated my TortoiseSVN client and now I'm getting the error when trying to update or commit to different repositories:\n\nThe requested name is valid, but no data of the requested type was\n found\n\nAny ideas on how I can solve this? Internet Explorer shows up appropriate... |
What would be the easiest way to re-order existing page events according to the ASP.NET Page LifeCycle?
I'm trying to make my events more readable and maybe make it easy to scroll into a sequentially near event.
If there's no easy way, is there a non-mouse way to quickly switch to a page event without having to type t... | To reorder existing page events according to the ASP.NET Page Life Cycle, you typically want to follow the sequence of the events as they occur during the lifecycle of a page. Here’s the common order of the ASP.NET Page Life Cycle events:
1. **Page_Init**: This event occurs when the page is initialized.
2. **Page_Load... | 12,832 | [
{
"from": "human",
"value": "What would be the easiest way to re-order existing page events according to the ASP.NET Page LifeCycle?\nI'm trying to make my events more readable and maybe make it easy to scroll into a sequentially near event. \nIf there's no easy way, is there a non-mouse way to quickly swit... |
How do I have a script run every, say 30 minutes? I assume there are different ways for different OSs. I'm using OS X.
| On macOS, there are a few ways to schedule a script to run every 30 minutes. The most common method is to use `cron`, but you can also use `launchd`, which is the recommended method for macOS. Below are instructions for both methods.
### Method 1: Using `cron`
1. **Open Terminal**: You can find Terminal in `Applicati... | 11,831 | [
{
"from": "human",
"value": "How do I have a script run every, say 30 minutes? I assume there are different ways for different OSs. I'm using OS X.\n"
},
{
"from": "gpt",
"value": "On macOS, there are a few ways to schedule a script to run every 30 minutes. The most common method is to use `cr... |
I like having my warning level set at W4 but all new projects start at W3. Is there some way to change the default value for warning levels for new projects?
| Yes, you can change the default warning level for new projects in Visual Studio. The steps to do this can vary slightly depending on the version of Visual Studio you're using, but here are the general steps to set your default warning level:
### Option 1: Change the Default Settings in Project Template
1. **Open Visu... | 16,916 | [
{
"from": "human",
"value": "I like having my warning level set at W4 but all new projects start at W3. Is there some way to change the default value for warning levels for new projects?\n"
},
{
"from": "gpt",
"value": "Yes, you can change the default warning level for new projects in Visual St... |
I'm processing a huge file with (GNU) awk, (other available tools are: Linux shell tools, some old (>5.0) version of Perl, but can't install modules).
My problem: if some field1, field2, field3 contain X, Y, Z I must search for a file in another directory which contains field4, and field5 on one line, and insert some d... | Yes, it is possible to achieve your goal using `awk`. The general approach is to read the data from your reference file into an associative array for fast lookups, and then process the original file line by line to perform the required actions.
Here's a step-by-step outline of the solution:
1. Load the reference file... | 12,289 | [
{
"from": "human",
"value": "I'm processing a huge file with (GNU) awk, (other available tools are: Linux shell tools, some old (>5.0) version of Perl, but can't install modules).\nMy problem: if some field1, field2, field3 contain X, Y, Z I must search for a file in another directory which contains field4,... |
I need to generate multiple random values under SQL Server 2005 and somehow this simply won't work
with Random(Value) as
(
select rand() Value
union all
select rand() from Random
)select top 10 * from Random
What's the preferred workaround?
| In SQL Server 2005, you can't use recursive Common Table Expressions (CTEs) to generate multiple rows as you were trying to do in your example. The `RAND()` function is not deterministic and does not work in this context. Instead, you can create a numbers table or use a tally table approach to generate multiple random ... | 16,298 | [
{
"from": "human",
"value": "I need to generate multiple random values under SQL Server 2005 and somehow this simply won't work\nwith Random(Value) as\n(\n select rand() Value\n union all\n select rand() from Random\n \n)select top 10 * from Random\n\nWhat's the preferred workaround?\n"
},... |
I have a table that has redundant data and I'm trying to identify all rows that have duplicate sub-rows (for lack of a better word). By sub-rows I mean considering COL1 and COL2 only.
So let's say I have something like this:
COL1 COL2 COL3
---------------------
aa 111 blah_x
aa 111 blah_j
aa ... | To retrieve the rows that have duplicate values in the combination of `COL1` and `COL2`, you can use a SQL query that utilizes a Common Table Expression (CTE) or a subquery to first identify the duplicates based on `COL1` and `COL2`. Then, you can join that result back to the original table to get the full rows.
Here'... | 15,673 | [
{
"from": "human",
"value": "I have a table that has redundant data and I'm trying to identify all rows that have duplicate sub-rows (for lack of a better word). By sub-rows I mean considering COL1 and COL2 only. \nSo let's say I have something like this:\n COL1 COL2 COL3\n ---------------------\n aa ... |
V8's documentation explains how to create a Javascript object that wraps a C++ object. The Javascript object holds on to a pointer to a C++ object instance. My question is, let's say you create the C++ object on the heap, how can you get a notification when the Javascript object is collected by the gc, so you can free ... | In V8, you can use a **`WeakReference`** to create a link between the JavaScript object and the C++ object. By setting up a weak reference, you can be notified when the JavaScript object is garbage collected, allowing you to clean up the associated C++ object.
Here's how you can do it:
1. **Create the JavaScript obje... | 14,833 | [
{
"from": "human",
"value": "V8's documentation explains how to create a Javascript object that wraps a C++ object. The Javascript object holds on to a pointer to a C++ object instance. My question is, let's say you create the C++ object on the heap, how can you get a notification when the Javascript object... |
I sometimes notice programs that crash on my computer with the error: "pure virtual function call".
How do these programs even compile when an object cannot be created of an abstract class?
| The error "pure virtual function call" occurs in C++ when a program attempts to call a pure virtual function that is not overridden in a derived class. Here's a bit of context on how this can happen and why the program can still compile:
1. **Abstract Classes**: In C++, a class that has at least one pure virtual funct... | 15,366 | [
{
"from": "human",
"value": "I sometimes notice programs that crash on my computer with the error: \"pure virtual function call\".\nHow do these programs even compile when an object cannot be created of an abstract class?\n"
},
{
"from": "gpt",
"value": "The error \"pure virtual function call\" ... |
Can't understand why the following takes place:
String date = "06-04-2007 07:05";
SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm");
Date myDate = fmt.parse(date);
System.out.println(myDate); //Mon Jun 04 07:05:00 EDT 2007
long timestamp = myDate.getTime();
System.out.println(timestamp); //118095510000... | The output you're seeing from `getTime()` and the way milliseconds are represented is correct and can be a bit confusing if you're not familiar with how the `Date` class works in Java.
Here's what's happening in your code:
1. **Creating a `Date` object from a formatted string**:
```java
String date = "06-04-200... | 13,720 | [
{
"from": "human",
"value": "Can't understand why the following takes place:\nString date = \"06-04-2007 07:05\";\nSimpleDateFormat fmt = new SimpleDateFormat(\"MM-dd-yyyy HH:mm\");\nDate myDate = fmt.parse(date); \n\nSystem.out.println(myDate); //Mon Jun 04 07:05:00 EDT 2007\nlong timestamp = myDate.getTi... |
Under what circumstances might you want to use multiple indirection (that is, a chain of pointers as in Foo **) in C++?
| Using multiple indirection, such as a chain of pointers (`Foo **`), can be useful in a variety of scenarios in C++. Here are some common situations where you might want to use this approach:
1. **Dynamic Data Structures**: When you need to create a data structure that requires a dynamic array of pointers, such as a 2D... | 14,062 | [
{
"from": "human",
"value": "Under what circumstances might you want to use multiple indirection (that is, a chain of pointers as in Foo **) in C++?\n"
},
{
"from": "gpt",
"value": "Using multiple indirection, such as a chain of pointers (`Foo **`), can be useful in a variety of scenarios in C++... |
This is an excerpt of code from a class I am working with in Java (below). Obviously the code is defining a static variable named EPSILON with the data type double. What I don't understand is the "1E-14" part. What kind of number is that? What does it mean?
final double EPSILON = 1E-14;
| In Java (and many other programming languages), the notation `1E-14` is a way to express numbers in scientific notation, which is useful for representing very small or very large values in a more compact form.
In this case, `1E-14` means \(1 \times 10^{-14}\). Here's the breakdown:
- The `1` is the coefficient (the s... | 18,063 | [
{
"from": "human",
"value": "This is an excerpt of code from a class I am working with in Java (below). Obviously the code is defining a static variable named EPSILON with the data type double. What I don't understand is the \"1E-14\" part. What kind of number is that? What does it mean?\nfinal double EPSIL... |
One of my goals over the next few months is to get familiar with NHibernate and am curious if anyone out there has any suggestions of where to begin. Preferably, I'd like to find a example project that demonstrates what you would see in an in-the-field application.
| Getting started with NHibernate can be a rewarding experience, as it is a powerful ORM (Object-Relational Mapping) tool for .NET applications. Here are some suggestions to help you familiarize yourself with NHibernate, along with recommendations for example projects that showcase its capabilities:
### 1. **Official NH... | 13,422 | [
{
"from": "human",
"value": "One of my goals over the next few months is to get familiar with NHibernate and am curious if anyone out there has any suggestions of where to begin. Preferably, I'd like to find a example project that demonstrates what you would see in an in-the-field application.\n"
},
{
... |
So if you have a RIA version (Silverlight or Flash) and a standard HTML version (or AJAX even), should you have the same URL for both, or is it ok to have a different one for the RIA app and just redirect accordingly?
So, for instance, if you have a site (http://example.com), is it ok to have the about page URL for the... | When it comes to designing a web application that includes both a Rich Internet Application (RIA) version (like Silverlight or Flash) and a standard HTML/AJAX version, you have a couple of options for structuring URLs. Each approach has its own advantages and considerations:
### Option 1: Same URL for Both Versions
Us... | 14,974 | [
{
"from": "human",
"value": "So if you have a RIA version (Silverlight or Flash) and a standard HTML version (or AJAX even), should you have the same URL for both, or is it ok to have a different one for the RIA app and just redirect accordingly?\nSo, for instance, if you have a site (http://example.com), i... |
I want to make sure that a set of functions have the same signature in some C code. Ideally I would be able to define a new type that described the return value and arguments of a function and then declare my set of functions using this new type.
Additionally, is there a way to specify default values for the arguments... | In C, you can define a function pointer type to specify the signature of a set of functions, ensuring that they all adhere to the same return type and parameter types. Here's how you can define a function pointer type and use it to declare multiple functions:
### Step 1: Define a function pointer type
You can use `typ... | 17,027 | [
{
"from": "human",
"value": "I want to make sure that a set of functions have the same signature in some C code. Ideally I would be able to define a new type that described the return value and arguments of a function and then declare my set of functions using this new type. \nAdditionally, is there a way t... |
Trying to move my development environment to Linux. And new to Curl. Can't get it to install the IDE & RTE packages on an AMD HP PC running Ubuntu x64. I tried to install the Debian package via the package installer and get "Error: Wrong architecture - i386". Tried using the --force-architecture switch but it errors o... | It sounds like you're encountering an architecture mismatch while trying to install packages on your AMD-based HP PC running a 64-bit version of Ubuntu. The error message "Error: Wrong architecture - i386" indicates that the package you're trying to install is intended for a 32-bit architecture (i386) while your system... | 15,306 | [
{
"from": "human",
"value": "Trying to move my development environment to Linux. And new to Curl. Can't get it to install the IDE & RTE packages on an AMD HP PC running Ubuntu x64. I tried to install the Debian package via the package installer and get \"Error: Wrong architecture - i386\". Tried using the ... |
I need to see if a given process id is running, and it must work in either Java or JRuby (preferably a Ruby solution). It can be system dependent for Linux (specifically Debian and/or Ubuntu).
I already have the PID I am looking for, just need to see if it is currently running.
UPDATE:
Thanks for all the responses ev... | If you're looking to check if a given process ID (PID) is running in Ruby (specifically JRuby if needed), you can utilize the standard library without relying on external gems. Here's how you can do it using a simple approach that works on Linux:
### Ruby Solution
You can check the existence of a process using the `/... | 16,888 | [
{
"from": "human",
"value": "I need to see if a given process id is running, and it must work in either Java or JRuby (preferably a Ruby solution). It can be system dependent for Linux (specifically Debian and/or Ubuntu).\nI already have the PID I am looking for, just need to see if it is currently running... |
Since I've joined twitter I have found it very helpful to keep my finger on the pulse of technology and where it is going.
I follow many of the top Microsoft developers and find it interesting to see their struggles, opinions, and influences...
codinghorror / Jeff Atwood
shanselman / Scott Hanselman
haacked / Phi... | Twitter can be a mixed bag when it comes to staying technically savvy, especially in fields like software development and technology. While it can certainly be a distraction due to the sheer volume of content and potential for non-technical chatter, it also provides a valuable platform for real-time updates, industry i... | 15,996 | [
{
"from": "human",
"value": "Since I've joined twitter I have found it very helpful to keep my finger on the pulse of technology and where it is going.\nI follow many of the top Microsoft developers and find it interesting to see their struggles, opinions, and influences...\n\ncodinghorror / Jeff Atwood \n... |
The tiny text entry cursor in the Visual Studio 2005's editor is driving me nuts. I'd ideally like to be able to highlight (say in yellow) the entire line that I'm currently on, but I'll settle for just making the cursor bigger and/or a different colour. Any help gratefully received!
| Unfortunately, Visual Studio 2005 has limited customization options for the text cursor and line highlighting features compared to more modern IDEs. However, there are a few methods you can try to enhance your experience:
### 1. Change the Cursor Size:
While Visual Studio 2005 does not allow direct customization of th... | 15,123 | [
{
"from": "human",
"value": "The tiny text entry cursor in the Visual Studio 2005's editor is driving me nuts. I'd ideally like to be able to highlight (say in yellow) the entire line that I'm currently on, but I'll settle for just making the cursor bigger and/or a different colour. Any help gratefully re... |
On my OS X box, the kernel is a 32-bit binary and yet it can run a 64-bit binary.
How does this work?
cristi:~ diciu$ file ./a.out
./a.out: Mach-O 64-bit executable x86_64
cristi:~ diciu$ file /mach_kernel
/mach_kernel: Mach-O universal binary with 2 architectures
/mach_kernel (for architecture i386): Mach-O executab... | What you're encountering is an example of the architecture and compatibility features that are built into macOS (formerly OS X) and its underlying Mach kernel. Your OS X box is capable of running both 32-bit and 64-bit binaries, and this is how it works:
1. **Universal Binaries**: The Mach-O file format supports unive... | 16,976 | [
{
"from": "human",
"value": "On my OS X box, the kernel is a 32-bit binary and yet it can run a 64-bit binary.\nHow does this work?\ncristi:~ diciu$ file ./a.out\n./a.out: Mach-O 64-bit executable x86_64\ncristi:~ diciu$ file /mach_kernel\n/mach_kernel: Mach-O universal binary with 2 architectures\n/mach_ke... |
Conventional IPv4 dotted quad notation separates the address from the port with a colon, as in this example of a webserver on the loopback interface:
127.0.0.1:80
but with IPv6 notation the address itself can contain colons. For example, this is the short form of the loopback address:
::1
How are ports (or their func... | In IPv6 notation, to specify an address along with its port, you need to enclose the IPv6 address in square brackets. This is to distinguish the address from the port number, especially since IPv6 addresses contain colons.
For example, if you want to specify the loopback address (::1) with port 80, you would write it ... | 19,608 | [
{
"from": "human",
"value": "Conventional IPv4 dotted quad notation separates the address from the port with a colon, as in this example of a webserver on the loopback interface:\n127.0.0.1:80\n\nbut with IPv6 notation the address itself can contain colons. For example, this is the short form of the loopbac... |
Is there a tool, method or setting in the standard VBA Editor to warn about variables that have been Dim'med, but aren't being used?
| In the standard VBA Editor, there isn't a built-in tool or setting specifically designed to warn you about unused variables. However, there are a few approaches you can use to manage and identify unused variables in your VBA projects:
1. **Option Explicit**: Always start your modules with `Option Explicit`. This force... | 17,376 | [
{
"from": "human",
"value": "Is there a tool, method or setting in the standard VBA Editor to warn about variables that have been Dim'med, but aren't being used?\n"
},
{
"from": "gpt",
"value": "In the standard VBA Editor, there isn't a built-in tool or setting specifically designed to warn you ... |
In c#, how can I check to see if a link button has been clicked in the page load method?
I need to know if it was clicked before the click event is fired.
| In ASP.NET Web Forms, the `Page_Load` method is executed on every request to the page, including the initial page load and postbacks (which occur when events such as button clicks happen). To determine if a link button was clicked during the page load, you can use the `IsPostBack` property along with checking the `Comm... | 17,116 | [
{
"from": "human",
"value": "In c#, how can I check to see if a link button has been clicked in the page load method? \nI need to know if it was clicked before the click event is fired.\n"
},
{
"from": "gpt",
"value": "In ASP.NET Web Forms, the `Page_Load` method is executed on every request to ... |
Suppose we have an iterator (an infinite one) that returns lists (or finite iterators), for example one returned by
infinite = itertools.cycle([[1,2,3]])
Note: it is not the same problem as just flattening a nested list - solutions which try to exhaustively process the list will not work, e.g. [item for sublist in in... | To create an infinite iterator that yields items from an infinite iterator of lists (like the one you provided with `itertools.cycle`), you can use `itertools.chain.from_iterable()` along with a generator. The key here is to create a generator that yields items from each list one by one without exhausting memory.
Here... | 16,611 | [
{
"from": "human",
"value": "Suppose we have an iterator (an infinite one) that returns lists (or finite iterators), for example one returned by\ninfinite = itertools.cycle([[1,2,3]])\n\nNote: it is not the same problem as just flattening a nested list - solutions which try to exhaustively process the list... |
I want to programmatically create a new column in an MS Access table. I've tried many permutations of ALTER TABLE MyTable Add MyField DECIMAL (9,4) NULL; and got:
Syntax Error in Field Definition
I can easily create a number field that goes to a Double type, but I want decimal. I would very strongly prefer to do ... | In Microsoft Access, the SQL syntax for adding a new column to a table has some nuances, particularly when it comes to specifying the data types. Unlike other SQL databases, Access uses the `CURRENCY` data type instead of `DECIMAL`, and it doesn't directly support the `DECIMAL(p,s)` syntax.
Here's how you can add a ne... | 18,243 | [
{
"from": "human",
"value": "I want to programmatically create a new column in an MS Access table. I've tried many permutations of ALTER TABLE MyTable Add MyField DECIMAL (9,4) NULL; and got: \n\nSyntax Error in Field Definition\n\nI can easily create a number field that goes to a Double type, but I want ... |
I'm not that up on VB.NET, the application I'm working on was not written by myself.
It works fine through the IDE but once I run it from the exe it gives me the above error.
Any clues?
This is really hacking me off!
| It sounds like you're experiencing an issue where the application works fine within the Visual Studio IDE but throws an error when you run it from the executable file (EXE). This is a common issue that can occur due to several reasons. Here are some potential causes and solutions that you can explore:
1. **File Paths*... | 14,918 | [
{
"from": "human",
"value": "I'm not that up on VB.NET, the application I'm working on was not written by myself.\nIt works fine through the IDE but once I run it from the exe it gives me the above error.\nAny clues?\nThis is really hacking me off!\n"
},
{
"from": "gpt",
"value": "It sounds like... |
I have a class with a ToString method that produces XML. I want to unit test it to ensure it is producing valid xml. I have a DTD to validate the XML against.
Should I include the DTD as a string within the unit test to avoid a dependency on it, or is there a smarter way to do this?
| When unit testing XML generation, there are a few considerations to keep in mind regarding the use of a DTD (Document Type Definition) for validation. Both of the options you mentioned have their merits, but here are some guidelines to help you make a decision:
### Option 1: Include the DTD as a String Within the Unit... | 13,904 | [
{
"from": "human",
"value": "I have a class with a ToString method that produces XML. I want to unit test it to ensure it is producing valid xml. I have a DTD to validate the XML against. \nShould I include the DTD as a string within the unit test to avoid a dependency on it, or is there a smarter way to do... |
I plan to serialize a Django model to XML when it's saved or updated. (The XML's going to be imported into a flash movie). Is it better to listen for a post_save() or pre_save() signal and then perform the serialization, or to just handle it in the model's save() methon
| In Django, both `pre_save` and `post_save` signals can be used for actions related to saving a model, but they serve different purposes and have distinct implications.
### `pre_save`
- The `pre_save` signal is sent just before a model’s `save()` method is called. This means you can modify the instance before it gets s... | 14,993 | [
{
"from": "human",
"value": "I plan to serialize a Django model to XML when it's saved or updated. (The XML's going to be imported into a flash movie). Is it better to listen for a post_save() or pre_save() signal and then perform the serialization, or to just handle it in the model's save() m... |
I'm making a method combining Scrum with the OpenUP lifecycle and deliverables. I also want to keep the OpenUP disciplines apart from "Project Management". I can "hide" it so that it's not immediately obvious in my generated method site. But when you then navigate to the "Risk List" artefact for example the PM is stil... | To remove the Project Management (PM) discipline from your custom method while still maintaining the integrity of the OpenUP library, you can consider the following approaches:
1. **Override or Customize the Method Configuration**: Depending on the method framework you're using, you might have the ability to customize... | 16,594 | [
{
"from": "human",
"value": "I'm making a method combining Scrum with the OpenUP lifecycle and deliverables. I also want to keep the OpenUP disciplines apart from \"Project Management\". I can \"hide\" it so that it's not immediately obvious in my generated method site. But when you then navigate to the \"... |
I'm not asking about converting a LaTeX document to html.
What I'd like to be able to do is have some way to use LaTeX math commands in an html document, and have it appear correctly in a browser. This could be done server or client side.
| You can display LaTeX math commands in an HTML document using several libraries that render LaTeX in the browser. Two popular options are MathJax and KaTeX. Both libraries allow you to include LaTeX expressions in your HTML and render them correctly in the browser.
### Using MathJax
1. **Include MathJax**: Add the Ma... | 9,842 | [
{
"from": "human",
"value": "I'm not asking about converting a LaTeX document to html. \nWhat I'd like to be able to do is have some way to use LaTeX math commands in an html document, and have it appear correctly in a browser. This could be done server or client side.\n"
},
{
"from": "gpt",
"va... |
Every indication I have, based on my experience in embedded computing is that doing something like this would require expensive equipment to get access to the platform (ICE debuggers, JTAG probes, I2C programmers, etc, etc), but I've always wondered if some ambitious hacker out there has found a way to load native code... | There have indeed been instances where developers and hackers have sought to bypass the restrictions imposed by BlackBerry's official SDKs to load native code onto BlackBerry devices. Historically, platforms like BlackBerry have had strict security and development guidelines to protect both the user experience and the ... | 17,221 | [
{
"from": "human",
"value": "Every indication I have, based on my experience in embedded computing is that doing something like this would require expensive equipment to get access to the platform (ICE debuggers, JTAG probes, I2C programmers, etc, etc), but I've always wondered if some ambitious hacker out ... |
Using Xcode 3.1 on OSX 10.5; is it possible to attach (the debugger) to a running remote process?
I know that it's possible to start and debug a remote process (as explained here), but it would be great if I could find a way to attach to an already running remote process...
edit to add: Thanks. I've submitted a bug rep... | In Xcode 3.1 on OSX 10.5, attaching the debugger to a running remote process is not natively supported in the same way you can start and debug a remote process. The built-in debugger functionalities primarily focus on launching and debugging applications locally or starting remote processes for debugging.
However, you... | 18,366 | [
{
"from": "human",
"value": "Using Xcode 3.1 on OSX 10.5; is it possible to attach (the debugger) to a running remote process?\nI know that it's possible to start and debug a remote process (as explained here), but it would be great if I could find a way to attach to an already running remote process...\ned... |
We want to switch a web server from Windows 2003 to Windows 2003 Enterprise (64 bits) to use 8GB of RAM. Will IIS 6.0 and an ASPNET 1.1 application be able to benefit from the change?
| Switching from Windows Server 2003 Standard Edition to Windows Server 2003 Enterprise Edition (64-bit) primarily provides benefits in terms of scalability and memory usage. Here's how your IIS 6.0 and ASP.NET 1.1 application can benefit:
1. **Increased Memory Availability**: Windows Server 2003 Enterprise Edition supp... | 16,610 | [
{
"from": "human",
"value": "We want to switch a web server from Windows 2003 to Windows 2003 Enterprise (64 bits) to use 8GB of RAM. Will IIS 6.0 and an ASPNET 1.1 application be able to benefit from the change?\n"
},
{
"from": "gpt",
"value": "Switching from Windows Server 2003 Standard Editio... |
Resharper, RefactorPro, etc?
| ReSharper and RefactorPro are both tools designed to enhance the development experience, particularly for .NET developers using Visual Studio. Here's a brief overview of each:
### ReSharper
- **Developer**: JetBrains
- **Purpose**: ReSharper is a productivity extension for Visual Studio that provides developers with a... | 14,496 | [
{
"from": "human",
"value": "Resharper, RefactorPro, etc?\n"
},
{
"from": "gpt",
"value": "ReSharper and RefactorPro are both tools designed to enhance the development experience, particularly for .NET developers using Visual Studio. Here's a brief overview of each:\n\n### ReSharper\n- **Develop... |
I have a .ico file that is embedded as a resource (build action set to resource). I am trying to create a NotifyIcon. How can I reference my icon?
notifyIcon = new NotifyIcon();
notifyIcon.Icon = ?? // my icon file is called MyIcon.ico and is embedded
| To reference an embedded `.ico` file in your application as a resource for a `NotifyIcon`, you need to use the `ResourceManager` class or directly access the resource using its name. Assuming you have an icon file named `MyIcon.ico` embedded as a resource, you can do this using the `Icon` class from the `System.Drawing... | 13,635 | [
{
"from": "human",
"value": "I have a .ico file that is embedded as a resource (build action set to resource). I am trying to create a NotifyIcon. How can I reference my icon?\nnotifyIcon = new NotifyIcon();\nnotifyIcon.Icon = ?? // my icon file is called MyIcon.ico and is embedded\n\n"
},
{
"... |
Is there a way to exclude all svn externals when doing a recursive update?
Is there a way to exclude only 1 of all of the svn externals when doing a recursive update?
Basically I'd like to cut down the svn update time, and a couple of the SVN externals that I have will just about never get updated.
| Yes, you can manage SVN externals in a couple of different ways to control how they are updated during a recursive `svn update`. However, SVN does not provide a built-in flag to exclude externals entirely from an update or to exclude specific externals directly. That said, here are some workarounds:
### Excluding All ... | 15,343 | [
{
"from": "human",
"value": "Is there a way to exclude all svn externals when doing a recursive update?\nIs there a way to exclude only 1 of all of the svn externals when doing a recursive update?\nBasically I'd like to cut down the svn update time, and a couple of the SVN externals that I have will just ab... |
For a long time ago, I have thought that, in java, reversing the domain you own for package naming is silly and awkward.
Which do you use for package naming in your projects?
| In Java, it's a common convention to use a reversed domain name for package naming. This practice helps to avoid naming conflicts between packages from different organizations, as it creates a unique namespace for your classes and interfaces. For example, if your domain is `example.com`, you might use a package name li... | 17,603 | [
{
"from": "human",
"value": "For a long time ago, I have thought that, in java, reversing the domain you own for package naming is silly and awkward.\nWhich do you use for package naming in your projects?\n"
},
{
"from": "gpt",
"value": "In Java, it's a common convention to use a reversed domain... |
Since AspectJ LoadTime-Weaving needs to load the JVM with an agent/it's own classloader - is there a way to load/make changes in the user's JVM from my applet? or maybe just before loading the applet (with a parent applet?)
| Using AspectJ's Load-Time Weaving (LTW) typically requires the Java Virtual Machine (JVM) to be started with a special agent that weaves aspects into the bytecode of classes as they are loaded. This means that modifications or enhancements to the class definitions happen at runtime but before the classes are executed. ... | 13,801 | [
{
"from": "human",
"value": "Since AspectJ LoadTime-Weaving needs to load the JVM with an agent/it's own classloader - is there a way to load/make changes in the user's JVM from my applet? or maybe just before loading the applet (with a parent applet?)\n"
},
{
"from": "gpt",
"value": "Using Aspe... |
here is my directory structure.
/user/a
/user/b
/user/b
inside folder a,b,c there is a file person.java (it is the Same file, just a one line modification.
now, on my shell, im on my /user/ directory and i try to do
javac */person.java
the shell returns the following error,
person.java:14: duplicate class: person
... | The error you're encountering, "duplicate class: person," occurs because the Java compiler (`javac`) finds multiple definitions of the class `person` from the different copies of `person.java` located in the directories `a`, `b`, and `c`. Java does not allow multiple classes with the same name to be defined in the same... | 11,715 | [
{
"from": "human",
"value": "here is my directory structure.\n/user/a\n/user/b\n/user/b\ninside folder a,b,c there is a file person.java (it is the Same file, just a one line modification.\nnow, on my shell, im on my /user/ directory and i try to do \n javac */person.java\n\nthe shell returns the followin... |
I want to write some JavaScript that will change the onmousedown of a div at runtime. So on load a mouse down on the div will do one thing and if a JavaScript function is called a mouse down on the div will do something else. Is this possible?
| Yes, it is definitely possible to change the `onmousedown` event handler of a `div` at runtime in JavaScript. You can achieve this by using the `addEventListener` method to set up your mouse down event handler, and then remove or replace it when you want to change the functionality.
Here's a simple example to illustra... | 14,708 | [
{
"from": "human",
"value": "I want to write some JavaScript that will change the onmousedown of a div at runtime. So on load a mouse down on the div will do one thing and if a JavaScript function is called a mouse down on the div will do something else. Is this possible?\n"
},
{
"from": "gpt",
... |
I'm getting an unexpected T_CONCAT_EQUAL error on a line of the following form:
$arg1 .= "arg2".$arg3."arg4";
I'm using PHP5. I could simply go an do the following:
$arg1 = $arg1."arg2".$arg3."arg4";
but I'd like to know whats going wrong in the first place. Any ideas?
Thanks,
sweeney
| The `T_CONCAT_EQUAL` error you're encountering typically indicates that the PHP interpreter is having trouble parsing the concatenation operation. In your case, the line:
```php
$arg1 .= "arg2" . $arg3 . "arg4";
```
is meant to append (concatenate) strings to the variable `$arg1`. The correct syntax should work witho... | 16,031 | [
{
"from": "human",
"value": "I'm getting an unexpected T_CONCAT_EQUAL error on a line of the following form:\n$arg1 .= \"arg2\".$arg3.\"arg4\";\n\nI'm using PHP5. I could simply go an do the following:\n$arg1 = $arg1.\"arg2\".$arg3.\"arg4\";\n\nbut I'd like to know whats going wrong in the first place. An... |
I have a directory with several subdirectories with files.
How can I copy all files in the subdirectories to a new location?
Edit: I do not want to copy the directories, just the files...
As this is still on XP, I chose the below solution:
for /D %S IN ("src\*.*") DO @COPY "%S\" "dest\"
Thanks!
| To copy all files from subdirectories to a new location in Windows XP without copying the directories, you can use the command prompt and the `for` loop, but with a slight modification to your original command.
The command you provided will not work as intended because it tries to copy directories instead of files. He... | 18,172 | [
{
"from": "human",
"value": "I have a directory with several subdirectories with files.\nHow can I copy all files in the subdirectories to a new location?\nEdit: I do not want to copy the directories, just the files...\nAs this is still on XP, I chose the below solution:\n for /D %S IN (\"src\\*.*\") DO @C... |
In wxWidgets, how can you find the pixels per inch on a wxDC? I'd like to be able to scale things by a real world number like inches. That often makes it easier to use the same code for printing to the screen and the printer.
| In wxWidgets, you can find the pixels per inch (PPI) on a `wxDC` (Device Context) by using the `GetPPI()` method. This method returns the PPI of the device context, which is helpful for converting between logical units (like inches) and pixel units.
Here's how you can retrieve the PPI and use it for scaling:
```cpp
#... | 14,825 | [
{
"from": "human",
"value": "In wxWidgets, how can you find the pixels per inch on a wxDC? I'd like to be able to scale things by a real world number like inches. That often makes it easier to use the same code for printing to the screen and the printer.\n"
},
{
"from": "gpt",
"value": "In wxWid... |
I'm looking at improving the performance of some SQL, currently CTEs are being used and referenced multiple times in the script. Would I get improvements using a table variable instead? (Can't use a temporary table as the code is within functions).
| Using Common Table Expressions (CTEs) in SQL can be convenient for readability, but they can lead to performance issues, especially if they are referenced multiple times in a query. This is because CTEs can be re-evaluated each time they are referenced, which can add overhead, particularly for complex queries or large ... | 8,290 | [
{
"from": "human",
"value": "I'm looking at improving the performance of some SQL, currently CTEs are being used and referenced multiple times in the script. Would I get improvements using a table variable instead? (Can't use a temporary table as the code is within functions).\n"
},
{
"from": "gpt",... |
In python is it possible to get or set a logical directory (as opposed to an absolute one).
For example if I have:
/real/path/to/dir
and I have
/linked/path/to/dir
linked to the same directory.
using os.getcwd and os.chdir will always use the absolute path
>>> import os
>>> os.chdir('/linked/path/to/dir')
>>> print o... | In Python, the `os.getcwd()` function will always return the absolute path of the current working directory, as you noted. This is because it resolves the symbolic links and gives you the canonical path. However, there are ways to handle "logical" directories in your code.
If you want to maintain knowledge of the orig... | 16,134 | [
{
"from": "human",
"value": "In python is it possible to get or set a logical directory (as opposed to an absolute one).\nFor example if I have:\n/real/path/to/dir\n\nand I have\n/linked/path/to/dir\n\nlinked to the same directory.\nusing os.getcwd and os.chdir will always use the absolute path\n>>> import ... |
When I cut (kill) text in Emacs 22.1.1 (in its own window on X, in KDE, on Kubuntu), I can't paste (yank) it in any other application.
| The issue you are experiencing with Emacs not allowing you to paste (yank) text into other applications is related to how Emacs interacts with the clipboard. By default, Emacs uses its own clipboard (known as the "kill ring"), and this might not be synchronized with the system clipboard you typically use in other appli... | 6,430 | [
{
"from": "human",
"value": "When I cut (kill) text in Emacs 22.1.1 (in its own window on X, in KDE, on Kubuntu), I can't paste (yank) it in any other application.\n"
},
{
"from": "gpt",
"value": "The issue you are experiencing with Emacs not allowing you to paste (yank) text into other applicat... |
I want to search for $maximumTotalAllowedAfterFinish and replace it with $minimumTotalAllowedAfterFinish. Instead of typing the long text:
:%s/$maximumTotalAllowedAfterFinish/$minimumTotalAllowedAfterFinish/g
Is there a way to COPY these long variable names down into the search line, since, on the command line I can't... | In Vim, you can easily copy the contents of a register to use in your command line for substitutions. Here's a step-by-step guide on how to do this:
1. **Yank the Variable Names**: First, you need to copy the variable names into a register. To do this, go to the line where `$maximumTotalAllowedAfterFinish` is located ... | 12,367 | [
{
"from": "human",
"value": "I want to search for $maximumTotalAllowedAfterFinish and replace it with $minimumTotalAllowedAfterFinish. Instead of typing the long text:\n:%s/$maximumTotalAllowedAfterFinish/$minimumTotalAllowedAfterFinish/g\n\nIs there a way to COPY these long variable names down into the sea... |
Here's my code in a gridview that is bound at runtime:
...
<asp:templatefield>
<edititemtemplate>
<asp:dropdownlist runat="server" id="ddgvOpp" />
</edititemtemplate>
<itemtemplate>
<%# Eval("opponent.name") %>
</itemtemplate>
</asp:templatefield>
...
I want to bind the dropdownlist "dd... | The issue you are facing is due to the way you are trying to find the `DropDownList` control in the `GridView` row. The `DropDownList` is not in a cell but rather in a `TemplateField`. When you access controls in a `TemplateField`, you should be using the `FindControl` method on the `Cell` of the `TemplateField` itself... | 15,502 | [
{
"from": "human",
"value": "Here's my code in a gridview that is bound at runtime:\n...\n<asp:templatefield>\n <edititemtemplate>\n <asp:dropdownlist runat=\"server\" id=\"ddgvOpp\" />\n </edititemtemplate>\n <itemtemplate>\n <%# Eval(\"opponent.name\") %>\n </itemtemplate>\n</asp... |
I've seen Best tools for working with DocBook XML documents, but my question is slightly different. Which is the currently recommended formatting toolchain - as opposed to editing tool - for XML DocBook?
In Eric Raymond's 'The Art of Unix Programming' from 2003 (an excellent book!), the suggestion is XML-FO (XML Forma... | As of the latest information available, if you're looking for a toolchain to format XML DocBook documents, there are a few popular options to consider. While Apache FOP (Formatting Objects Processor) is a commonly used tool, especially in the context of XML-FO, there are several alternatives and complementary tools you... | 11,888 | [
{
"from": "human",
"value": "I've seen Best tools for working with DocBook XML documents, but my question is slightly different. Which is the currently recommended formatting toolchain - as opposed to editing tool - for XML DocBook?\nIn Eric Raymond's 'The Art of Unix Programming' from 2003 (an excellent b... |
So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state?
The biggest things I use global state (as I understand it) for is managing key pieces of information between our devel... | You're correct in identifying that global state can lead to difficulties in testing. When your functions depend on global variables (like your static `Globals` class), it can make unit tests fragile and harder to isolate. This is because tests can inadvertently affect each other if they rely on shared global state, lea... | 11,931 | [
{
"from": "human",
"value": "So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state?\nThe biggest things I use global state (as I understand it) for is managing k... |
I had someting like this in my code (.Net 2.0, MS SQL)
SqlConnection connection = new SqlConnection(@"Data Source=localhost;Initial
Catalog=DataBase;Integrated Security=True");
connection.Open();
SqlCommand cmdInsert = connection.CreateCommand();
SqlTransaction sqlTran = connection.BeginTransaction();
cmdInser... | Your revised approach using `SqlBulkCopy` for inserting a large number of records is a great improvement over the row-by-row insert method. This change significantly reduces the execution time from over a minute to around 20 seconds, similar to what you observed with SSIS.
Let’s break down the improvements you made a... | 10,128 | [
{
"from": "human",
"value": "I had someting like this in my code (.Net 2.0, MS SQL)\nSqlConnection connection = new SqlConnection(@\"Data Source=localhost;Initial\nCatalog=DataBase;Integrated Security=True\");\n connection.Open();\n\n SqlCommand cmdInsert = connection.CreateCommand();\n SqlTransaction sq... |
UPDATED: I'm asking this from a development perspective, however to illustrate, a canoical non-development example that comes to mind is that if it costs, say, $10,000
to keep a uptime rate of 99%, then it theoretically can cost $100,000 to keep a rate
of 99.9%, and possibly $1,000,000 to keep a rate of 99.99%.
Some... | Your question touches on the critical balance of quality, cost, and time in software development, which is often referred to as the Project Triangle (or Iron Triangle). Let's explore how to approach this in a software development context, along with your analogy of uptime and its relation to quality metrics.
### Under... | 12,146 | [
{
"from": "human",
"value": "UPDATED: I'm asking this from a development perspective, however to illustrate, a canoical non-development example that comes to mind is that if it costs, say, $10,000 \nto keep a uptime rate of 99%, then it theoretically can cost $100,000 to keep a rate \nof 99.9%, and possibly... |
At the moment we use HSQLDB as an embedded database, but we search for a database with less memory footprint as the data volume grows.
Derby / JavaDB is not an option at the moment because it stores properties globally in the system properties. So we thought of h2.
While we used HSQLDB we created a Server-object, set t... | Yes, you can run an H2 database in server mode and set parameters programmatically in a way similar to how you did with HSQLDB. H2 provides a JDBC connection interface that can be utilized to create and manage a server instance.
Below is a simple example of how to start an H2 server and configure it programmatically:
... | 15,189 | [
{
"from": "human",
"value": "At the moment we use HSQLDB as an embedded database, but we search for a database with less memory footprint as the data volume grows.\nDerby / JavaDB is not an option at the moment because it stores properties globally in the system properties. So we thought of h2.\nWhile we us... |
I'd like to make some custom MenuHeaders in WPF so I can have (for example), an icon and text in a menu item.
Normally using MenuItems, if you populate the Header field with straight text, you can add an accelerator by using an underscore. eg, _File
However, if I wanted to put in a UserControl, I believe this function ... | In WPF, if you want to use a `UserControl` as the `Header` of a `MenuItem`, you can indeed lose the functionality of the underscore for keyboard shortcuts (accelerators). However, you can implement your own keyboard shortcuts by handling the key events.
To create a custom menu header that includes both an icon (e.g., ... | 8,257 | [
{
"from": "human",
"value": "I'd like to make some custom MenuHeaders in WPF so I can have (for example), an icon and text in a menu item.\nNormally using MenuItems, if you populate the Header field with straight text, you can add an accelerator by using an underscore. eg, _File\nHowever, if I wanted to put... |
I am starting a project for which we will have a thin client, sending requests and getting responses from a server.
We are still in the planning stages, so we have a choice to settle on either an Eclipse based GUI (Eclipse plugin) or using GWT as a fromtend for the application.
I am not very familiar with Eclipse as a ... | Both Eclipse-based GUIs and GWT (Google Web Toolkit) have their own sets of benefits and drawbacks. Let's break down the two approaches based on your project requirements and considerations:
### Eclipse-based GUI (Eclipse Plugin)
#### Benefits:
1. **Integrated Development Environment**: If users are already familiar ... | 13,856 | [
{
"from": "human",
"value": "I am starting a project for which we will have a thin client, sending requests and getting responses from a server.\nWe are still in the planning stages, so we have a choice to settle on either an Eclipse based GUI (Eclipse plugin) or using GWT as a fromtend for the application.... |
I am working on a web app that uses Perl and I need to look into speeding up portions of the app.
I thought I'd start profiling the particular calls for the portion I wish to investigate. I've done some searching on profiling Perl code, but unfortunately most of what I find says that I should run my perl code with -... | Profiling a Perl web application can indeed be a challenge, especially when you want to focus on specific methods or parts of your code rather than the whole application. Here are a few approaches you can consider to target specific sections of your code without manually injecting timer code everywhere:
### 1. **Use D... | 14,112 | [
{
"from": "human",
"value": "I am working on a web app that uses Perl and I need to look into speeding up portions of the app. \nI thought I'd start profiling the particular calls for the portion I wish to investigate. I've done some searching on profiling Perl code, but unfortunately most of what I find ... |
I've got a class named BackgroundWorker that has a thread constantly running. To turn this thread off, an instance variable named stop to needs to be true.
To make sure the thread is freed when the class is done being used, I've added IDisposable and a finalizer that invokes Dispose(). Assuming that stop = true does i... | Your implementation shows a basic understanding of the `IDisposable` pattern in C#, but there are a few points to clarify and improve upon. Here are the key aspects to consider:
1. **Calling Dispose from Finalizer**: Yes, it is acceptable to call `Dispose` from a finalizer, but you should ensure that you do it in a sa... | 15,425 | [
{
"from": "human",
"value": "I've got a class named BackgroundWorker that has a thread constantly running. To turn this thread off, an instance variable named stop to needs to be true. \nTo make sure the thread is freed when the class is done being used, I've added IDisposable and a finalizer that invokes D... |
What are the preffered plugins for monitoring and analyzing the performance of a Rails app? I'm looking for both database/query analyzers and the rest of the stack if possible, though not necessarily all in one plugin. Which ones do you recommend?
( Bonus points for free ones :)
For example, this one looks spify.
| Monitoring and analyzing the performance of a Rails application can be achieved through a combination of plugins and tools that focus on various aspects of the stack, including database performance, application performance, and general monitoring. Here are some recommended options, including free ones:
### Database/Qu... | 14,013 | [
{
"from": "human",
"value": "What are the preffered plugins for monitoring and analyzing the performance of a Rails app? I'm looking for both database/query analyzers and the rest of the stack if possible, though not necessarily all in one plugin. Which ones do you recommend?\n( Bonus points for free ones :... |
My database is located in e.g. california.
My user table has all the user's timezone e.g. -0700 UTC
How can I adjust the time from my database server whenever I display a date to the user who lives in e.g. new york? UTC/GMT -4 hours
| To adjust the time stored in your database for display to users in different time zones, you can follow these steps:
1. **Store Dates in UTC**: Ensure that all date and time values in your database are stored in UTC. This makes it easier to perform conversions, as you have a single standard to work from.
2. **Retrie... | 11,534 | [
{
"from": "human",
"value": "My database is located in e.g. california.\nMy user table has all the user's timezone e.g. -0700 UTC \nHow can I adjust the time from my database server whenever I display a date to the user who lives in e.g. new york? UTC/GMT -4 hours\n"
},
{
"from": "gpt",
"value"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.