instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
Static metaprogramming (aka "template metaprogramming") is a great C++ technique that allows the execution of programs at compile-time. A light bulb went off in my head as soon as I read this canonical metaprogramming example:
#include <iostream>
using namespace std;
template< int n >
struct factorial { enum { ret = ... | Learning C++ static metaprogramming (or template metaprogramming) can be quite rewarding, and there are several excellent resources available to help you dive deeper into the subject. Here’s a list of some of the best sources, including books, websites, and online courseware:
### Books
1. **"C++ Templates: The Comple... | 9,696 | [
{
"from": "human",
"value": "Static metaprogramming (aka \"template metaprogramming\") is a great C++ technique that allows the execution of programs at compile-time. A light bulb went off in my head as soon as I read this canonical metaprogramming example:\n#include <iostream>\nusing namespace std;\n\ntem... |
We have a strange problem occurring once in a while on our servers. It usually happens when one or more of our web applications are upgraded. Debugging the problem has gotten me this far...
During the processing of a request:
In the ASP.NET application we put an object in session
In code running later (same request) w... | It sounds like you're dealing with a frustrating issue related to ASP.NET session state, particularly in the context of application upgrades. Here are a few considerations and troubleshooting steps that may help you identify and potentially resolve the underlying problem:
### 1. **Session State Configuration**
- **... | 13,184 | [
{
"from": "human",
"value": "We have a strange problem occurring once in a while on our servers. It usually happens when one or more of our web applications are upgraded. Debugging the problem has gotten me this far...\nDuring the processing of a request:\n\nIn the ASP.NET application we put an object in se... |
In applying for jobs via agents I sometimes get blocked by an agent who says do you know software package X. When I reply that I know the similar package Y they might say unless you know X I cannot put you forward.
The problem is that some of these agents don't know what they talking about, they are merely being used b... | Transitioning from SQL Server to Oracle can vary in complexity based on your existing skill set, familiarity with database concepts, and the specific features of Oracle you need to learn. However, given your background in SQL Server, you can expect to gain a reasonable proficiency in Oracle in a fairly short time.
###... | 15,829 | [
{
"from": "human",
"value": "In applying for jobs via agents I sometimes get blocked by an agent who says do you know software package X. When I reply that I know the similar package Y they might say unless you know X I cannot put you forward.\nThe problem is that some of these agents don't know what they t... |
I am creating a site in which different pages can look very different depending upon certain conditions (ie logged in or not, form filled out or not, etc). This makes it necessary to output diferent blocks of html at different times.
Doing that, however, makes my php code look horrific... it really messes with the for... | When dealing with dynamic HTML output in PHP, especially when the layout can vary significantly based on different conditions, it's important to keep your code maintainable and readable. Here are several strategies you can employ to manage your HTML output without cluttering your PHP code:
### 1. **Template Files / In... | 14,109 | [
{
"from": "human",
"value": "I am creating a site in which different pages can look very different depending upon certain conditions (ie logged in or not, form filled out or not, etc). This makes it necessary to output diferent blocks of html at different times.\nDoing that, however, makes my php code look... |
I'm building a C++/MFC program in a multilingual environment. I have one main (national) language and three international languages. Every time I add a feature to the program I have to keep the international languages up-to-date with the national one. The resource editor in Visual Studio is not very helpful because I f... | For managing multilingual resources in C++/MFC projects, there are a few tools and techniques that can help streamline the process of translating your resource files (.rc) and keeping translations in sync with the original language. Here are some tools and methods you can consider:
### 1. **Poedit**
- **Description**:... | 15,561 | [
{
"from": "human",
"value": "I'm building a C++/MFC program in a multilingual environment. I have one main (national) language and three international languages. Every time I add a feature to the program I have to keep the international languages up-to-date with the national one. The resource editor in Visu... |
We're currently planning a new API for an application and debating the various data formats we should use for interchange. There's a fairly intense discussion going on about the relative merits of CSV, JSON and XML.
Basically, the crux of the argument is whether we should support CSV at all because of the lack of recur... | It sounds like you’re making a thoughtful decision regarding the data formats for your API based on the needs of your application and the development experience for your API consumers. Here are some insights on each format you've mentioned, along with some recommendations for your API design:
### CSV
- **Pros**:
- S... | 14,338 | [
{
"from": "human",
"value": "We're currently planning a new API for an application and debating the various data formats we should use for interchange. There's a fairly intense discussion going on about the relative merits of CSV, JSON and XML.\nBasically, the crux of the argument is whether we should suppo... |
One of our internally written tool is fed a cvs commit trace of the form:
Checking in src/com/package/AFile.java;
/home/cvs/src/com/package/AFile.java,v <-- Afile.java
new revision: 1.1.2.56; previous revision: 1.1.2.55
done
The tool then acquires the file from cvs by issuing a cvs update -r 1.1.2.56 comma... | When you run `cvs update -r 1.1.2.56` in a working directory that does not have the file already checked out, CVS will not be able to retrieve the new version of the file directly because it only updates existing files in the working directory.
To address this issue, you can use the `cvs checkout` command to specifica... | 17,396 | [
{
"from": "human",
"value": "One of our internally written tool is fed a cvs commit trace of the form:\nChecking in src/com/package/AFile.java;\n /home/cvs/src/com/package/AFile.java,v <-- Afile.java\n new revision: 1.1.2.56; previous revision: 1.1.2.55\n done\n\nThe tool then acquires the file fro... |
I would like to create an XML-based website. I want to use XML files as datasources since it is a kind of online directory site. Can someone please give me a starting point? Are there any good online resources that I can refer to? I am pretty comfortable with ASP and JavaScript.
| Creating an XML-based website can be an interesting project, especially for an online directory. Here’s a starting point and resources to help you:
### Step 1: Define Your XML Structure
First, you need to define how your XML files will be structured. Here’s a simple example of what your XML data might look like for a... | 7,578 | [
{
"from": "human",
"value": "I would like to create an XML-based website. I want to use XML files as datasources since it is a kind of online directory site. Can someone please give me a starting point? Are there any good online resources that I can refer to? I am pretty comfortable with ASP and JavaScript.... |
Let say we defined an interface for tax service as ITaxService, and we got more than one implementation of TaxService (by region) however I wanted to attach a specific tax implementation to a specific customer from the spcific region.
Will DI help in this scenario? How? "code snippet would be much appreciate"
| Yes, Dependency Injection (DI) can definitely help in this scenario by allowing you to select a specific implementation of the `ITaxService` interface based on the customer's region at runtime. This can be achieved through a combination of DI container configuration and a factory or strategy pattern that resolves the a... | 14,900 | [
{
"from": "human",
"value": "Let say we defined an interface for tax service as ITaxService, and we got more than one implementation of TaxService (by region) however I wanted to attach a specific tax implementation to a specific customer from the spcific region.\nWill DI help in this scenario? How? \"code ... |
Background
I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator to upload an ... | To tackle the issue of the browser caching the image and not reflecting the changes immediately, there are a couple of strategies you can employ without having to rename the image or make significant changes to your database structure.
### 1. Cache-Control Headers
The most effective way to prevent caching for a speci... | 11,275 | [
{
"from": "human",
"value": "Background\nI am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that fo... |
Just how much slower are events? I have written a streaming XML parser (that can handle open-ended and incomplete documents) and by tearing out the events and using an interface instead I got a significant speed boost.
Does any one else have any war stories?
(Let's not open the GC can of worms here, we all know it's br... | It's great to hear about your experience with optimizing a streaming XML parser! Performance issues related to event-driven architectures can indeed be significant, particularly when you start dealing with large datasets or high-throughput scenarios. Here are a few war stories and considerations that others have encoun... | 13,982 | [
{
"from": "human",
"value": "Just how much slower are events? I have written a streaming XML parser (that can handle open-ended and incomplete documents) and by tearing out the events and using an interface instead I got a significant speed boost.\nDoes any one else have any war stories?\n(Let's not open th... |
I want to store the data returned by $_SERVER["REMOTE_ADDR"] in PHP into a DB field, pretty simple task, really. The problem is that I can't find any proper information about the maximum length of the textual representation of an IPv6 address, which is what a webserver provides through $_SERVER["REMOTE_ADDR"].
I'm not... | The maximum length of the textual representation of an IPv6 address is 39 characters. This includes the following components:
- A standard IPv6 address is written as eight groups of four hexadecimal digits, separated by colons (`:`).
- The longest form, which uses no shorthand notation, is `ffff:ffff:ffff:ffff:ffff:ff... | 19,147 | [
{
"from": "human",
"value": "I want to store the data returned by $_SERVER[\"REMOTE_ADDR\"] in PHP into a DB field, pretty simple task, really. The problem is that I can't find any proper information about the maximum length of the textual representation of an IPv6 address, which is what a webserver provide... |
How can I have a relative path in the web.config file. This value is not in the connection string so I cannot use |DataDirectory| (I think), so what can I do?
| In a `web.config` file, using relative paths is common for certain configurations, but you need to be careful about how you define them. While `|DataDirectory|` is a placeholder specifically for connection strings, you can still utilize relative paths in other configuration sections, but the approach might differ depen... | 13,430 | [
{
"from": "human",
"value": "How can I have a relative path in the web.config file. This value is not in the connection string so I cannot use |DataDirectory| (I think), so what can I do?\n"
},
{
"from": "gpt",
"value": "In a `web.config` file, using relative paths is common for certain configur... |
Does excess use of AJAX affects performance? In context of big size web-applications, how do you handle AJAX requests to control asynchronous requests?
| Excessive use of AJAX can indeed impact performance, especially in large web applications. Here are some considerations and strategies for effectively handling AJAX requests:
### 1. **Network Overhead**
- **Frequent Requests**: Making too many AJAX requests can lead to increased network overhead, including latency ... | 15,399 | [
{
"from": "human",
"value": "Does excess use of AJAX affects performance? In context of big size web-applications, how do you handle AJAX requests to control asynchronous requests?\n"
},
{
"from": "gpt",
"value": "Excessive use of AJAX can indeed impact performance, especially in large web appli... |
Using C# in Visual Studio 2008 and stepping through a function in the debugger I get to the end of a function and am on the final curly brace } and about to return. Is there a way to find out what value the function is about to return?
This is necessary if the return value is calculated such as:
return (x.Func() > y.Fu... | In Visual Studio 2008, while debugging and stepping through your code, you can find out the value that a function is about to return by evaluating the expression at the return statement using the Immediate Window or the Watch window.
Here’s how you can do that:
### Using the Immediate Window
1. While at the final cur... | 17,714 | [
{
"from": "human",
"value": "Using C# in Visual Studio 2008 and stepping through a function in the debugger I get to the end of a function and am on the final curly brace } and about to return. Is there a way to find out what value the function is about to return?\nThis is necessary if the return value is c... |
What's your favorite open source database design/modeling tool?
I'm looking for one that supports several databases, especially Firebird SQL but I can't find one on Google.
| One popular open-source database design and modeling tool that supports multiple database systems, including Firebird SQL, is **DBeaver**. DBeaver is a free and open-source database management tool that provides a user-friendly interface for database design, data editing, and query execution. It supports various databa... | 19,097 | [
{
"from": "human",
"value": "What's your favorite open source database design/modeling tool?\nI'm looking for one that supports several databases, especially Firebird SQL but I can't find one on Google.\n"
},
{
"from": "gpt",
"value": "One popular open-source database design and modeling tool th... |
This is a real issue that applies on tagging items in general (and yes, this applies to StackOverflow too, and no, it is not a question about StackOverflow).
The whole tagging issue helps cluster similar items, whatever items they may be (jokes, blog posts, so questions etc). However, there (usually but not strictly) i... | Tagging systems can indeed enhance the organization and discoverability of content, but managing the hierarchical relationships between tags can become complex. Here are some strategies and considerations for handling hierarchical tagging:
### Methods for Managing Hierarchical Tags
1. **Tag Inheritance:**
- **Desc... | 15,371 | [
{
"from": "human",
"value": "This is a real issue that applies on tagging items in general (and yes, this applies to StackOverflow too, and no, it is not a question about StackOverflow).\nThe whole tagging issue helps cluster similar items, whatever items they may be (jokes, blog posts, so questions etc). H... |
I am programming a UNIX shell and I have to use the execv() system call to create a process.
One of the parameters for execv() is the filepath for the executable. So if somebody types in /bin/ls, it will run the ls executable. But what I need is a function such that when ls is typed, it will search for the filepath o... | You can implement a simple path searching function similar to what the `which` command does by following these steps:
1. **Retrieve the `PATH` environment variable**: This variable contains a colon-separated list of directories where executables are located.
2. **Split the `PATH` variable**: Break the `PATH` string i... | 12,903 | [
{
"from": "human",
"value": "I am programming a UNIX shell and I have to use the execv() system call to create a process.\nOne of the parameters for execv() is the filepath for the executable. So if somebody types in /bin/ls, it will run the ls executable. But what I need is a function such that when ls i... |
I've always been a largely independent learner gleaning what I can from Wikipedia and various books. However, I fear that I may have biased my self-education by inadvertent omission of topics and concepts. My goal is to teach myself the equivalent of an undergraduate degree in Computer Science from a top university (do... | It's great that you're taking the initiative to self-educate in Computer Science! The collection of books you’ve started with is a solid foundation, but there are definitely some additional topics and materials you might consider to achieve a comprehensive understanding equivalent to an undergraduate degree.
### Topic... | 11,781 | [
{
"from": "human",
"value": "I've always been a largely independent learner gleaning what I can from Wikipedia and various books. However, I fear that I may have biased my self-education by inadvertent omission of topics and concepts. My goal is to teach myself the equivalent of an undergraduate degree in C... |
What are the benefits and drawbacks with using Centralized versus Distributed Version Control Systems (DVCS)? Have you run into any problems in DVCS and how did you safeguard against these problems? Keep the discussion tool agnostic and flaming to minimum.
For those wondering what DVCS tools are available, here is a li... | Centralized Version Control Systems (CVCS) and Distributed Version Control Systems (DVCS) both serve the purpose of managing changes to source code and collaborative work among developers, but they do so in fundamentally different ways. Below, I’ll discuss the benefits and drawbacks of each, as well as potential proble... | 9,433 | [
{
"from": "human",
"value": "What are the benefits and drawbacks with using Centralized versus Distributed Version Control Systems (DVCS)? Have you run into any problems in DVCS and how did you safeguard against these problems? Keep the discussion tool agnostic and flaming to minimum.\nFor those wondering w... |
The following test fails:
#!/usr/bin/env python
def f(*args):
"""
>>> t = 1, -1
>>> f(*map(lambda i: lambda: i, t))
[1, -1]
>>> f(*(lambda: i for i in t)) # -> [-1, -1]
[1, -1]
>>> f(*[lambda: i for i in t]) # -> [-1, -1]
[1, -1]
"""
alist = [a() for a in args]
print(alist)
... | The issue you're encountering is related to how closures work in Python, particularly with regards to the `lambda` function and variable scope.
In your original example, when you create `lambda` functions inside a loop, they capture the variable `i`. By the time the lambda function is executed, `i` will have the value... | 15,496 | [
{
"from": "human",
"value": "The following test fails:\n#!/usr/bin/env python\ndef f(*args):\n \"\"\"\n >>> t = 1, -1\n >>> f(*map(lambda i: lambda: i, t))\n [1, -1]\n >>> f(*(lambda: i for i in t)) # -> [-1, -1]\n [1, -1]\n >>> f(*[lambda: i for i in t]) # -> [-1, -1]\n [1, -1]\n ... |
Or do you populate your form controls manually by a method?
Is either considered a best practice?
| The decision to populate form controls manually or automatically often depends on the specific requirements of your application, as well as the preferences of your development team. Both approaches can be valid and come with their own pros and cons. Here's a breakdown of each method:
### Manually Populating Form Contr... | 11,894 | [
{
"from": "human",
"value": "Or do you populate your form controls manually by a method?\nIs either considered a best practice?\n"
},
{
"from": "gpt",
"value": "The decision to populate form controls manually or automatically often depends on the specific requirements of your application, as wel... |
I am currently working on the authentication of an AJAX based site, and was wondering if anybody had any reccomendations on best practices for this sort of thing.
My original approach was a cookie based system. Essentially I set a cookie with an auth code, and every data access changed the cookie. As well, whenever t... | When implementing authentication for an AJAX-based site, it's important to balance security and usability. Your initial approach with cookie-based authentication has its merits but can indeed lead to issues with out-of-order AJAX requests, especially if you're frequently updating the cookie. Here are some best practice... | 12,969 | [
{
"from": "human",
"value": "I am currently working on the authentication of an AJAX based site, and was wondering if anybody had any reccomendations on best practices for this sort of thing.\nMy original approach was a cookie based system. Essentially I set a cookie with an auth code, and every data acces... |
I have two tables that are joined together.
A has many B
Normally you would do:
select * from a,b where b.a_id = a.id
To get all of the records from a that has a record in b.
How do I get just the records in a that does not have anything in b?
| To retrieve records from table `A` that do not have any corresponding records in table `B`, you can use a `LEFT JOIN` in combination with a `WHERE` clause to filter out records that have matches in `B`. Here's how you can do it:
```sql
SELECT *
FROM A
LEFT JOIN B ON B.a_id = A.id
WHERE B.a_id IS NULL;
```
In this que... | 15,484 | [
{
"from": "human",
"value": "I have two tables that are joined together. \nA has many B\nNormally you would do: \nselect * from a,b where b.a_id = a.id\n\nTo get all of the records from a that has a record in b. \nHow do I get just the records in a that does not have anything in b?\n"
},
{
"from": "... |
My question is, which version-naming scheme should be used for what type of project.
Very common is major.minor.fix, but even this can lead to 4 number (i.e. Firefox 2.0.0.16). Some have a model that odd numbers indicate developer-versions and even numbers stable releases. And all sorts of additions can enter the mix, ... | When choosing a version-naming scheme for a project, several factors should be taken into consideration, including the nature of the project (open source vs. closed source), the target audience, the release frequency, and the significance of changes. Below, I'll outline some common versioning schemes and their appropri... | 12,254 | [
{
"from": "human",
"value": "My question is, which version-naming scheme should be used for what type of project.\nVery common is major.minor.fix, but even this can lead to 4 number (i.e. Firefox 2.0.0.16). Some have a model that odd numbers indicate developer-versions and even numbers stable releases. And ... |
After seeing the cool new "reputation" tab on the stackoverflow user page, I was inspired to play with the Flot charting library a little. I have a line chart that has several hundred series. Only a couple of these series will be visible at any given time. My data series are grouped into several "categories" and I a... | In the Flot charting library, the color of each series can be determined based on its color index. By default, Flot uses a predefined set of colors for the series, and you can access these colors programmatically.
If you want to obtain the actual color values assigned to each color index, you can refer to Flot's defau... | 16,572 | [
{
"from": "human",
"value": "After seeing the cool new \"reputation\" tab on the stackoverflow user page, I was inspired to play with the Flot charting library a little. I have a line chart that has several hundred series. Only a couple of these series will be visible at any given time. My data series ar... |
I ran into an issue when installing Team Foundation Server 2008 Workgroup Edition. I have a Windows Server 2003 SP2 machine that's practically new. I have installed SQL Server 2008 with almost all of the options. When I run through the TFS installation, it allows me to enter my SQL instance name and then goes through t... | The error message you're encountering during the installation of Team Foundation Server 2008 Workgroup Edition indicates that TFS is having trouble recognizing your SQL Server 2008 installation. Here are some troubleshooting steps you can follow to resolve this issue:
1. **Check SQL Server Version**: Ensure that you a... | 14,641 | [
{
"from": "human",
"value": "I ran into an issue when installing Team Foundation Server 2008 Workgroup Edition. I have a Windows Server 2003 SP2 machine that's practically new. I have installed SQL Server 2008 with almost all of the options. When I run through the TFS installation, it allows me to enter my ... |
I have a wrapper around a C++ function call which I call from C# code. How do I attach a debugger in Visual Studio to step into the native C++ code?
This is the wrapper that I have which calls GetData() defined in a C++ file:
[DllImport("Unmanaged.dll", CallingConvention=CallingConvention.Cdecl,
Ent... | To debug native C++ code while working with C# code in Visual Studio, you need to ensure that you can attach the debugger to the native process correctly. Here’s a step-by-step guide on how to set this up:
### Step 1: Prepare Your Project
1. **Build the C++ Project**: Ensure that your C++ project is built with debug i... | 9,358 | [
{
"from": "human",
"value": "I have a wrapper around a C++ function call which I call from C# code. How do I attach a debugger in Visual Studio to step into the native C++ code?\nThis is the wrapper that I have which calls GetData() defined in a C++ file:\n [DllImport(\"Unmanaged.dll\", CallingConvention... |
I'm trying to design some tables to store some data, which has to be converted to different languages later. Can anybody provide some "best practices" or guidelines for this?
Thanks
| When designing a database schema that will support multilingual content, there are several best practices and guidelines you can follow to ensure flexibility, maintainability, and performance. Here are some key considerations:
### 1. **Separate Content from Structure**
- **Use a Content Table**: Have a dedicated ta... | 13,472 | [
{
"from": "human",
"value": "I'm trying to design some tables to store some data, which has to be converted to different languages later. Can anybody provide some \"best practices\" or guidelines for this?\nThanks\n"
},
{
"from": "gpt",
"value": "When designing a database schema that will suppor... |
I noticed last night that the WCF extensions for Visual Studio 2005 aren't available on their site any longer. I've read that they want people to use Visual Studio 2008 for WCF/WF/WPF.
Have they made an official statement regarding this?
edit:
I already have the CTP3 for VS2005. I want to know what Microsoft's offici... | Microsoft has indeed encouraged developers to move to Visual Studio 2008 for developing applications using Windows Communication Foundation (WCF), Windows Workflow Foundation (WF), and Windows Presentation Foundation (WPF). The official stance has generally been that Visual Studio 2008 provides improved support, featur... | 19,234 | [
{
"from": "human",
"value": "I noticed last night that the WCF extensions for Visual Studio 2005 aren't available on their site any longer. I've read that they want people to use Visual Studio 2008 for WCF/WF/WPF.\nHave they made an official statement regarding this?\nedit:\nI already have the CTP3 for VS2... |
In a follow-up to a previous question regarding exceptions, what are best practices for creating a custom exception in .NET?
More specifically should you inherit from System.Exception, System.ApplicationException or some other base exception?
| Creating custom exceptions in .NET is an essential practice when you need to represent specific error scenarios that are not adequately covered by existing exceptions. Here are best practices for creating a custom exception in .NET:
### 1. Inherit from `System.Exception`
It is generally recommended to inherit directl... | 12,963 | [
{
"from": "human",
"value": "In a follow-up to a previous question regarding exceptions, what are best practices for creating a custom exception in .NET? \nMore specifically should you inherit from System.Exception, System.ApplicationException or some other base exception?\n"
},
{
"from": "gpt",
... |
I am working on Linux with the GCC compiler. When my C++ program crashes I would like it to automatically generate a stacktrace.
My program is being run by many different users and it also runs on Linux, Windows and Macintosh (all versions are compiled using gcc).
I would like my program to be able to generate a stack ... | To achieve automatic generation of a stack trace when your C++ program crashes, you can use signal handling along with some platform-specific functionality to capture the backtrace. Here’s a basic outline of how you might implement this in your program on Linux:
### Step 1: Set Up Signal Handling
You can use the `sig... | 12,774 | [
{
"from": "human",
"value": "I am working on Linux with the GCC compiler. When my C++ program crashes I would like it to automatically generate a stacktrace.\nMy program is being run by many different users and it also runs on Linux, Windows and Macintosh (all versions are compiled using gcc).\nI would like... |
I'm trying to figure out the best way to determine whether I'm in the last iteration of a loop over a map in order to do something like the following:
for (iter = someMap.begin(); iter != someMap.end(); ++iter) {
bool last_iteration;
// do something for all iterations
if (!last_iteration) {
// do so... | In C++, when working with standard containers like `std::map`, you don't have random access iterators, and you cannot calculate the last iteration directly by accessing an index. Instead, a common approach to determine whether you're in the last iteration of a loop over a `std::map` is to use the iterator itself to che... | 15,442 | [
{
"from": "human",
"value": "I'm trying to figure out the best way to determine whether I'm in the last iteration of a loop over a map in order to do something like the following:\nfor (iter = someMap.begin(); iter != someMap.end(); ++iter) {\n bool last_iteration;\n // do something for all iterations... |
What is the benefit of referencing resources using globally-unique URIs (as REST does) versus using a proprietary id format?
For example:
http://host.com/student/5
http://host.com/student?id=5
In the first approach the entire URL is the ID. In the second approach only the 5 is the ID. What is the practical benefit of... | Your questions touch on important aspects of RESTful design and resource addressing. Let’s break down the benefits of using globally-unique URIs (like in the first example) versus proprietary ID formats (like in the second example), and clarify the distinction between the two approaches.
### Benefits of Addressability... | 13,032 | [
{
"from": "human",
"value": "What is the benefit of referencing resources using globally-unique URIs (as REST does) versus using a proprietary id format?\nFor example:\n\nhttp://host.com/student/5\nhttp://host.com/student?id=5\n\nIn the first approach the entire URL is the ID. In the second approach only th... |
Is the Entity Framework aware of identity columns?
I am using SQL Server 2005 Express Edition and have several tables where the primary key is an identity column. when I use these tables to create an entity model and use the model in conjunction with an entity datasource bond to a formview in order to create a new ent... | Yes, the Entity Framework (EF) does recognize identity columns in SQL Server, but the behavior you are experiencing where you're prompted for a value for the identity column can occur due to how the model is configured or how you're using the Entity Data Source.
Here are a few steps you can take to ensure that you don... | 16,476 | [
{
"from": "human",
"value": "Is the Entity Framework aware of identity columns? \nI am using SQL Server 2005 Express Edition and have several tables where the primary key is an identity column. when I use these tables to create an entity model and use the model in conjunction with an entity datasource bond ... |
I have URLs of the form http://domain/image/⟨uuid⟩/42x42/some_name.png. The Web server (nginx) is configured to look for a file /some/path/image/⟨uuid⟩/thumbnail_42x42.png, and if it does not exist, it sends the URL to the backend (Django via mod_wsgi) which then generates the thumbnail. Then the backend emits a 302 re... | Your approach to handling the thumbnail generation and serving in a two-step process using a 302 redirect is generally a good one and is in line with how HTTP is designed to work. However, the behavior of different browsers and user agents can vary based on the implementation of the HTTP specifications.
### General Be... | 10,952 | [
{
"from": "human",
"value": "I have URLs of the form http://domain/image/⟨uuid⟩/42x42/some_name.png. The Web server (nginx) is configured to look for a file /some/path/image/⟨uuid⟩/thumbnail_42x42.png, and if it does not exist, it sends the URL to the backend (Django via mod_wsgi) which then generates the t... |
I am working on converting a CVS repository that has the following symbols (among others):
tcm-6.1.0-branch -- a branch
tcm-6.1.0 -- a tag
Using the standard transformations cvs2svn identifies them properly. However, I'd like to do some clean up during the conversion. Specifically I'd like to drop the redundant '-b... | The situation you're encountering is a common challenge when dealing with CVS to SVN conversions due to how CVS manages tags and branches, and how those are translated into SVN's structure. The core of the issue is that both branches and tags in your conversion end up with the same name after transformation, leading to... | 13,426 | [
{
"from": "human",
"value": "I am working on converting a CVS repository that has the following symbols (among others):\ntcm-6.1.0-branch -- a branch\ntcm-6.1.0 -- a tag\nUsing the standard transformations cvs2svn identifies them properly. However, I'd like to do some clean up during the conversion. Spe... |
In visual C++, I can do things like this:
template <class T>
class A{
protected:
T i;
};
template <class T>
class B : public A<T>{
T geti() {return i;}
};
If I try to compile this in g++, I get an error. I have to do this:
template <class T>
class B : public A<T>{
T geti() {return A<T>::i;}
};
Am I not ... | The code you provided should compile correctly with both Visual C++ and GCC. However, the error you're encountering with GCC is likely due to the fact that the member `i` in class `A` is protected. In C++, protected members are only accessible in the class itself and in derived classes, but when you're trying to access... | 18,318 | [
{
"from": "human",
"value": "In visual C++, I can do things like this:\ntemplate <class T>\nclass A{\nprotected:\n T i;\n};\n\ntemplate <class T>\nclass B : public A<T>{\n T geti() {return i;}\n};\n\nIf I try to compile this in g++, I get an error. I have to do this:\ntemplate <class T>\nclass B : pu... |
I was wonder if any knows how to open up a windows *.dmp file after a application crash written C/C++.
| To open and analyze a Windows dump file (*.dmp) created after an application crash, you can use several tools, but one of the most common and effective methods is to use Microsoft’s Debugging Tools for Windows, which includes WinDbg. Here's how to open and analyze a dump file using WinDbg:
### Step-by-Step Instruction... | 13,939 | [
{
"from": "human",
"value": "I was wonder if any knows how to open up a windows *.dmp file after a application crash written C/C++.\n"
},
{
"from": "gpt",
"value": "To open and analyze a Windows dump file (*.dmp) created after an application crash, you can use several tools, but one of the most ... |
I have a webapp development problem that I've developed one solution for, but am trying to find other ideas that might get around some performance issues I'm seeing.
problem statement:
a user enters several keywords/tokens
the application searches for matches to the tokens
need one result for each token
ie, if an e... | To address the problem of retrieving entries based on multiple tokens while ensuring each entry is returned the correct number of times (based on token matches) and is sorted accordingly, you can use a single SQL query instead of running multiple queries for each token.
Here's a proposed solution using SQL. This appr... | 14,760 | [
{
"from": "human",
"value": "I have a webapp development problem that I've developed one solution for, but am trying to find other ideas that might get around some performance issues I'm seeing.\nproblem statement: \n\na user enters several keywords/tokens\nthe application searches for matches to the tokens... |
Due to the lack of generic variance in the .NET framework, is it more "correct" to have methods that handle the non-generic versions of the System.Collection interfaces, if the methods are being designed to handle multiple types?
Ideally, once moved to .NET 3.5, the code would modified to change these methods into exte... | In the context of the .NET framework prior to version 2.0, where generics were not yet introduced, the use of non-generic collections like `ArrayList` and `Hashtable` was common to manage collections of objects. If you are designing methods that are intended to handle collections containing multiple types, using the no... | 13,026 | [
{
"from": "human",
"value": "Due to the lack of generic variance in the .NET framework, is it more \"correct\" to have methods that handle the non-generic versions of the System.Collection interfaces, if the methods are being designed to handle multiple types?\nIdeally, once moved to .NET 3.5, the code woul... |
What is the best way to convert an int or null to boolean value in an SQL query, such that:
Any non-null value is TRUE in the results
Any null value is FALSE in the results
| To convert an integer (or `NULL`) to a boolean value in an SQL query such that any non-null value is treated as `TRUE` and `NULL` is treated as `FALSE`, you can use a combination of the `CASE` statement or the `COALESCE` function along with a simple condition. Here are a few methods to achieve this:
### Method 1: Usin... | 17,104 | [
{
"from": "human",
"value": "What is the best way to convert an int or null to boolean value in an SQL query, such that:\n\nAny non-null value is TRUE in the results\nAny null value is FALSE in the results\n\n"
},
{
"from": "gpt",
"value": "To convert an integer (or `NULL`) to a boolean value in... |
I'd like to slice and dice large datafiles, up to a gig, in a fairly quick and efficient manner. If I use something like UNIX's "CUT", it's extremely fast, even in a CYGWIN environment.
I've tried developing and benchmarking various Ruby scripts to process these files, and always end up with glacial results.
What w... | If you're finding that your Ruby scripts for processing large data files are running too slowly, there are several strategies you can consider to improve performance. Here are some approaches:
### 1. Use Streaming with Enumerators
Instead of loading the entire file into memory, you can read the file line by line usin... | 16,412 | [
{
"from": "human",
"value": "I'd like to slice and dice large datafiles, up to a gig, in a fairly quick and efficient manner. If I use something like UNIX's \"CUT\", it's extremely fast, even in a CYGWIN environment. \nI've tried developing and benchmarking various Ruby scripts to process these files, and ... |
I have an idea for how to solve this problem, but I wanted to know if there's something easier and more extensible to my problem.
The program I'm working on has two basic forms of data: images, and the information associated with those images. The information associated with the images has been previously stored in a ... | Your scenario and the associated requirements lend themselves well to several approaches in C#. Below are some options, each with its benefits and considerations regarding extensibility, serialization, and performance:
### 1. **Using Dynamic Objects (ExpandoObject)**
C# provides `ExpandoObject`, which allows you to d... | 15,669 | [
{
"from": "human",
"value": "I have an idea for how to solve this problem, but I wanted to know if there's something easier and more extensible to my problem.\nThe program I'm working on has two basic forms of data: images, and the information associated with those images. The information associated with t... |
I'd like to know do I normalize a URL in python.
For example, If I have a url string like : "http://www.example.com/foo goo/bar.html"
I need a library in python that will transform the extra space (or any other non normalized character) to a proper URL.
| To normalize a URL in Python, you can use the `urllib.parse` module from the standard library. This module provides functions for manipulating URLs, including encoding spaces and other special characters. For your example, you can replace spaces with `%20` and ensure the URL is in a proper format.
Here’s how you can a... | 17,199 | [
{
"from": "human",
"value": "I'd like to know do I normalize a URL in python. \nFor example, If I have a url string like : \"http://www.example.com/foo goo/bar.html\"\nI need a library in python that will transform the extra space (or any other non normalized character) to a proper URL.\n"
},
{
"fro... |
How can I Handler 404 errors without the framework throwing an Exception 500 error code?
| Handling 404 errors effectively without resulting in a 500 Internal Server Error is a crucial aspect of building robust web applications. Here are several strategies you can use to handle 404 errors gracefully, depending on your tech stack and environment:
### General Strategies
1. **Custom Error Pages**: Create a cu... | 10,084 | [
{
"from": "human",
"value": "How can I Handler 404 errors without the framework throwing an Exception 500 error code?\n"
},
{
"from": "gpt",
"value": "Handling 404 errors effectively without resulting in a 500 Internal Server Error is a crucial aspect of building robust web applications. Here ar... |
Unfortunately, I need to do this. I'm using ELMAH for my error log. Before I route to my error.aspx view, I have to grab the default ELMAH error log so I can log the exception. You used to be able to use
Elmah.ErrorLog.Default
However, this is now marked as obsolete. The compiler directs me to use the method
Elma... | In ASP.NET MVC, you often deal with `HttpContextBase`, which is a more testable version of the `HttpContext`. However, when you have libraries or methods that require the traditional `HttpContext`, like ELMAH's `ErrorLog.GetDefault(HttpContext context)`, you can easily convert `HttpContextBase` to `HttpContext`.
### S... | 17,698 | [
{
"from": "human",
"value": "Unfortunately, I need to do this. I'm using ELMAH for my error log. Before I route to my error.aspx view, I have to grab the default ELMAH error log so I can log the exception. You used to be able to use \nElmah.ErrorLog.Default\n\nHowever, this is now marked as obsolete. Th... |
I have three TextBox controls on the page
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"
OnTextChanged="TextBox_TextChanged" TabIndex="1">
<asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"
OnTextChanged="TextBox_TextChanged" TabIndex="2">
<asp:TextBox ID="TextBox3" runat="serv... | To address the `InvalidCastException` that arises when trying to cast `LiteralControl` to `WebControl`, you can filter your controls more carefully by checking for the appropriate type.
Instead of directly querying all controls and attempting to cast them, you should first ensure that the control you're working with ... | 17,744 | [
{
"from": "human",
"value": "I have three TextBox controls on the page\n<asp:TextBox ID=\"TextBox1\" runat=\"server\" AutoPostBack=\"True\"\n OnTextChanged=\"TextBox_TextChanged\" TabIndex=\"1\">\n<asp:TextBox ID=\"TextBox2\" runat=\"server\" AutoPostBack=\"True\"\n OnTextChanged=\"TextBox_Tex... |
Is there a mod_rewrite equivalent for IIS 7.0 that's
a) more or less complete
b) suitable for a production environment, i.e. battle-tested/dependable/secure
Do you have an experience-based recommendation?
| Yes, in IIS 7.0 and later versions, the equivalent of Apache's `mod_rewrite` is the **URL Rewrite Module**. This module is designed to provide URL manipulation functionality, allowing you to create rules for rewriting URLs, redirecting requests, and more, similar to what you can achieve with `mod_rewrite`.
### Key Fea... | 16,110 | [
{
"from": "human",
"value": "Is there a mod_rewrite equivalent for IIS 7.0 that's \na) more or less complete \nb) suitable for a production environment, i.e. battle-tested/dependable/secure\nDo you have an experience-based recommendation?\n"
},
{
"from": "gpt",
"value": "Yes, in IIS 7.0 and late... |
With the best will in the world, whatever software you (and me) write will have some kind of defect in it.
What can I do, as a developer, to make things easier for the support department (first line, through to third line, and development) to diagnose, workaround and fix problems that the user encounters.
Notes
I'm ex... | Improving the supportability of your software can significantly ease the burden on your support department and improve user experience. Here are several technical and procedural practices you can adopt:
### Technical Practices
1. **Comprehensive Logging**:
- Implement structured and comprehensive logging throughou... | 13,226 | [
{
"from": "human",
"value": "With the best will in the world, whatever software you (and me) write will have some kind of defect in it.\nWhat can I do, as a developer, to make things easier for the support department (first line, through to third line, and development) to diagnose, workaround and fix proble... |
I'm doing some architectural cleanup that involves moving a bunch of classes into different projects and/or namespaces. Currently I'm moving the files by hand, building, and then manually adding using Foo statements as needed to resolve compilation errors. Anyone know of a smarter way of doing this? (We're a CodeRush a... | Refactoring and moving classes across projects and namespaces can be a time-consuming task if done manually. Fortunately, both CodeRush and ReSharper offer features that can help automate and streamline this process, making it more efficient.
### Using CodeRush:
1. **Move Type**: CodeRush has a "Move Type" feature th... | 15,460 | [
{
"from": "human",
"value": "I'm doing some architectural cleanup that involves moving a bunch of classes into different projects and/or namespaces. Currently I'm moving the files by hand, building, and then manually adding using Foo statements as needed to resolve compilation errors. Anyone know of a smart... |
Assuming I have three tables :
TableA (key, value)
TableB (key, value)
TableC (key, value)
and I want to return a value for all keys. If the key exists in TableC return that value else if the key exists in B return that value else return the value from table A
The best I have come up with so far is
SELECT key,Value
FRO... | You can simplify your query by using a `LEFT JOIN` approach along with `COALESCE` to efficiently return the desired values based on the specified priority. Here's how you can structure your query:
```sql
SELECT
COALESCE(c.key, b.key, a.key) AS key,
COALESCE(c.value, b.value, a.value) AS value
FROM
TableA... | 17,156 | [
{
"from": "human",
"value": "Assuming I have three tables :\nTableA (key, value)\nTableB (key, value)\nTableC (key, value)\nand I want to return a value for all keys. If the key exists in TableC return that value else if the key exists in B return that value else return the value from table A\nThe best I ha... |
I have a WiX installer and a single custom action (plus undo and rollback) for it which uses a property from the installer. The custom action has to happen after all the files are on the hard disk. It seems that you need 16 entries in the WXS file for this; eight within the root, like so:
<CustomAction Id="SetForRollba... | Yes, your current approach is a standard way to handle custom actions in WiX where you need to account for rollback and undo scenarios, but it can be simplified by consolidating some of the Custom Action definitions and their sequence entries. Here are a few suggestions to optimize your setup:
### 1. Combine Custom Ac... | 16,742 | [
{
"from": "human",
"value": "I have a WiX installer and a single custom action (plus undo and rollback) for it which uses a property from the installer. The custom action has to happen after all the files are on the hard disk. It seems that you need 16 entries in the WXS file for this; eight within the root... |
Is it worth it to develop WAP webpage for cellular since now cellular have browser that is really better than before?
I have a PHP website and I would like to increase the use of portable device to use it. Is it worth it to implement.
| Developing a WAP (Wireless Application Protocol) webpage for cellular devices is generally not necessary or recommended anymore, especially if your current site is built with PHP and you're targeting modern smartphones. Here's why:
### Modern Browser Capabilities
1. **Improved Browsers**: Today's mobile browsers are s... | 18,010 | [
{
"from": "human",
"value": "Is it worth it to develop WAP webpage for cellular since now cellular have browser that is really better than before?\nI have a PHP website and I would like to increase the use of portable device to use it. Is it worth it to implement.\n"
},
{
"from": "gpt",
"value":... |
This is an age-old question where given a table with attributes 'type', 'variety' and 'price', that you fetch the record with the minimum price for each type there is.
In SQL, we can do this by:
select f.type, f.variety, f.price
from ( select type, min(price) as minprice from table group by type ) as x
inner join... | Yes, there are ways to optimize and improve the implementation you provided to fetch records with the minimum price for each type from a table. The approach you shared involves two separate queries which can be less efficient, especially if the dataset is large.
Here’s a more efficient approach using a single SQL quer... | 17,721 | [
{
"from": "human",
"value": "This is an age-old question where given a table with attributes 'type', 'variety' and 'price', that you fetch the record with the minimum price for each type there is.\nIn SQL, we can do this by:\nselect f.type, f.variety, f.price \nfrom ( select type, min(price) as minprice ... |
I'm moving DB from MySQL (used ODBC) to MS SQL and I want to "translate" SQL queries to LINQ. Can someone help me with this (it should SUM Charge column for every location and group result by months):
SELECT
sum(case when Location="Location1" then Charge else 0 end) as Location1,
sum(case when Location="Location2" then... | To translate your SQL query into LINQ while ensuring you properly group the results by both year and month, you can use the following approach. The LINQ query will achieve the same goal of summing the `Charge` column for each location, grouping by year and month, and selecting the desired output format.
Here's how you... | 16,673 | [
{
"from": "human",
"value": "I'm moving DB from MySQL (used ODBC) to MS SQL and I want to \"translate\" SQL queries to LINQ. Can someone help me with this (it should SUM Charge column for every location and group result by months):\nSELECT\nsum(case when Location=\"Location1\" then Charge else 0 end) as Loc... |
In VB6, I used a call to the Windows API, GetAsyncKeyState, to determine if the user has hit the ESC key to allow them to exit out of a long running loop.
Declare Function GetAsyncKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Is there an equivalent in pure .NET that does require a direct call to the API?
| In .NET, particularly in Windows Forms applications, you can achieve similar functionality to monitor key states without directly calling the Windows API. Instead, you can use events provided by the framework.
However, if you're specifically interested in monitoring key states such as detecting when the ESC key is pr... | 14,982 | [
{
"from": "human",
"value": "In VB6, I used a call to the Windows API, GetAsyncKeyState, to determine if the user has hit the ESC key to allow them to exit out of a long running loop.\nDeclare Function GetAsyncKeyState Lib \"user32\" (ByVal nVirtKey As Long) As Integer\n\nIs there an equivalent in pure .NET... |
What is the easiest way to do this? Is it possible with managed code?
| To provide you with the most accurate information, I need more context about what specific task or problem you are referring to. The term "managed code" typically relates to programming environments that handle memory management automatically, such as .NET (C#, VB.NET) or Java.
Could you please clarify what you're tr... | 20,897 | [
{
"from": "human",
"value": "What is the easiest way to do this? Is it possible with managed code?\n"
},
{
"from": "gpt",
"value": "To provide you with the most accurate information, I need more context about what specific task or problem you are referring to. The term \"managed code\" typically... |
Is there a way to check to see if a date/time is valid you would think these would be easy to check:
$date = '0000-00-00';
$time = '00:00:00';
$dateTime = $date . ' ' . $time;
if(strtotime($dateTime)) {
// why is this valid?
}
what really gets me is this:
echo date('Y-m-d', strtotime($date));
results in: "1999-... | The issue you're encountering arises from how PHP's `strtotime()` function handles invalid dates, and how date-related functions operate in general.
1. **Handling of Invalid Dates**: The value `'0000-00-00'` is considered a "special" case in PHP. When you use `strtotime()` on this value, it returns `false`, which is w... | 17,746 | [
{
"from": "human",
"value": "Is there a way to check to see if a date/time is valid you would think these would be easy to check:\n$date = '0000-00-00';\n$time = '00:00:00';\n$dateTime = $date . ' ' . $time;\n\nif(strtotime($dateTime)) {\n // why is this valid?\n}\n\nwhat really gets me is this:\necho da... |
Does anyone know if silverlight plugs into chrome, or when they plan to support it?
| As of now, Silverlight is no longer supported by modern web browsers, including Google Chrome. Microsoft officially ended support for Silverlight on October 12, 2021. Major web browsers have also phased out support for NPAPI plugins, which includes Silverlight.
If you're looking for alternatives for web applications ... | 19,765 | [
{
"from": "human",
"value": "Does anyone know if silverlight plugs into chrome, or when they plan to support it?\n"
},
{
"from": "gpt",
"value": "As of now, Silverlight is no longer supported by modern web browsers, including Google Chrome. Microsoft officially ended support for Silverlight on O... |
I'm trying to build a web page with a number of drop-down select boxes that load their options asynchronously when the box is first opened. This works very well under Firefox, but not under Internet Explorer.
Below is a small example of what I'm trying to achieve. Basically, there is a select box (with the id "select... | The behavior you are experiencing is a known issue with Internet Explorer (especially older versions) when dealing with select elements and dynamically modifying their options. When the select box is clicked and options are added or modified asynchronously, IE closes the dropdown prematurely.
To work around this, you ... | 15,347 | [
{
"from": "human",
"value": "I'm trying to build a web page with a number of drop-down select boxes that load their options asynchronously when the box is first opened. This works very well under Firefox, but not under Internet Explorer.\nBelow is a small example of what I'm trying to achieve. Basically, ... |
I want to replace the first occurrence in a given string.
How can I accomplish this in .NET?
| In .NET, you can replace the first occurrence of a substring in a string by using the `IndexOf` method to find the position of the substring and then constructing a new string with the desired replacement. Here's how you can do it:
### C# Example
```csharp
using System;
class Program
{
static void Main()
{
... | 15,846 | [
{
"from": "human",
"value": "I want to replace the first occurrence in a given string. \nHow can I accomplish this in .NET?\n"
},
{
"from": "gpt",
"value": "In .NET, you can replace the first occurrence of a substring in a string by using the `IndexOf` method to find the position of the substrin... |
I would like to display some memory statistics (working set, GCs etc.) on a web page using the .NET/Process performance counters. Unfortunately, if there are multiple application pools on that server, they are differentiated using an index (#1, #2 etc.) but I don't know how to match a process ID (which I have) to that ... | Yes, you can programmatically retrieve information about the application pools and their corresponding process IDs in an ASP.NET web application using the System.Diagnostics and the Microsoft.Web.Administration namespaces. Below, I’ll guide you through the steps to match a process ID to its respective application pool ... | 8,464 | [
{
"from": "human",
"value": "I would like to display some memory statistics (working set, GCs etc.) on a web page using the .NET/Process performance counters. Unfortunately, if there are multiple application pools on that server, they are differentiated using an index (#1, #2 etc.) but I don't know how to m... |
I have a interest in a reported bug which Microsoft have made available a hotfix for. When looking on the site, I'm not able to figure out if this fix is included in a service pack or not. Do anyone know where I can find this out?
| To determine whether a specific hotfix from Microsoft is included in a service pack, you can follow these steps:
1. **Microsoft Support Website**: Start by visiting the Microsoft Support website and searching for the specific hotfix you are interested in. The hotfix page often includes details about whether it is incl... | 16,187 | [
{
"from": "human",
"value": "I have a interest in a reported bug which Microsoft have made available a hotfix for. When looking on the site, I'm not able to figure out if this fix is included in a service pack or not. Do anyone know where I can find this out?\n"
},
{
"from": "gpt",
"value": "To ... |
Sessions in PHP seemed to have changed since the last time I used them, so I'm looking for a simple way of using sessions but at the same time for it to be relatively secure and a good common practice.
| Using sessions in PHP can be quite straightforward, but ensuring they are secure is essential. Here's a simple guide to help you manage sessions securely and effectively:
### Basic Usage of Sessions in PHP
1. **Start a Session**: At the beginning of your script, call `session_start()` to initialize session handling.
... | 9,690 | [
{
"from": "human",
"value": "Sessions in PHP seemed to have changed since the last time I used them, so I'm looking for a simple way of using sessions but at the same time for it to be relatively secure and a good common practice.\n"
},
{
"from": "gpt",
"value": "Using sessions in PHP can be qui... |
I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file.
How do I get sed to replace just the first occurrence of a string in a file rather than replacing every occur... | To replace just the first occurrence of a string using `sed`, you can use the `sed` command in combination with the `q` command, which tells `sed` to quit after processing the first match. Here's how you can do it for your specific case:
```bash
sed -i '0,/^#include/{s/^#include/#include "newfile.h"\n&/}' your_file.cp... | 16,330 | [
{
"from": "human",
"value": "I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file. \nHow do I get sed to replace just the first occurrence of a string i... |
In my database, I have a model which has a field which should be selected from one of a list of options. As an example, consider a model which needs to store a measurement, such as 5ft or 13cm or 12.24m3. The obvious way to achieve this is to have a decimal field and then some other field to store the unit of measureme... | When it comes to modeling measurements with associated units in a database, there are several approaches you can consider, each with its own trade-offs in terms of complexity, performance, and ease of querying. Let's discuss a few common strategies:
### 1. Using a Separate Units Table (Normalized Approach)
You mentio... | 12,889 | [
{
"from": "human",
"value": "In my database, I have a model which has a field which should be selected from one of a list of options. As an example, consider a model which needs to store a measurement, such as 5ft or 13cm or 12.24m3. The obvious way to achieve this is to have a decimal field and then some o... |
We are building an hosted application that uses MS SQL Server Analysis Services 2005 for some of the reporting, specifically OLAP cube browsing. Since it is designed to be used by very large global organizations, security is important.
It seems that Microsoft's preferred client tool for browsing OLAP cubes is Excel 20... | Your use case is quite complex, and it's understandable that you're seeking a way to handle authentication and security effectively for your OLAP cubes in an internet-facing application without resorting to Windows accounts. Here are a few potential solutions and best practices that can help you achieve the functionali... | 10,953 | [
{
"from": "human",
"value": "We are building an hosted application that uses MS SQL Server Analysis Services 2005 for some of the reporting, specifically OLAP cube browsing. Since it is designed to be used by very large global organizations, security is important.\nIt seems that Microsoft's preferred clien... |
I would like to generate a random floating point number between 2 values. What is the best way to do this in C#?
| In C#, you can generate a random floating-point number between two values using the `Random` class. Here’s a simple way to do this:
1. Create an instance of the `Random` class.
2. Use the `NextDouble` method to generate a random number between 0.0 and 1.0, and then scale it to the desired range.
Here's an example of ... | 11,958 | [
{
"from": "human",
"value": "I would like to generate a random floating point number between 2 values. What is the best way to do this in C#?\n"
},
{
"from": "gpt",
"value": "In C#, you can generate a random floating-point number between two values using the `Random` class. Here’s a simple way ... |
I'm sending mail from my C# Application, using the SmtpClient. Works great, but I have to decide if I want to send the mail as Plain Text or HTML. I wonder, is there a way to send both? I think that's called multipart.
I googled a bit, but most examples essentially did not use SmtpClient but composed the whole SMTP-Bod... | Yes, you can send multipart emails (including both plain text and HTML) using the built-in functionality of the .NET Framework, even in version 3.0. While `SmtpClient` is used for sending the email, you'll need to construct a `MailMessage` object that supports different content types.
Here’s a simple example to show h... | 12,647 | [
{
"from": "human",
"value": "I'm sending mail from my C# Application, using the SmtpClient. Works great, but I have to decide if I want to send the mail as Plain Text or HTML. I wonder, is there a way to send both? I think that's called multipart.\nI googled a bit, but most examples essentially did not use ... |
I use my mobile phone for connection to the internet on my laptop, I also have a wired connection to a LAN which doesn't have internet conectivity, it just has our TFS server on it.
The problem is that I can't use the internet (from the phone) with the LAN cable plugged in. Is there a way to set the default route to my... | Yes, you can change the routing so that your internet connection from your mobile phone is used instead of the LAN connection when both are connected. Here's how to set the default route to your mobile phone connection in Windows XP:
### Steps to Set the Default Route to Your Mobile Phone:
1. **Connect Your Mobile Ph... | 8,790 | [
{
"from": "human",
"value": "I use my mobile phone for connection to the internet on my laptop, I also have a wired connection to a LAN which doesn't have internet conectivity, it just has our TFS server on it.\nThe problem is that I can't use the internet (from the phone) with the LAN cable plugged in. Is ... |
How do I preview a url using ajax? I have seen this done with search engine plug ins and would like to learn how to do this. Specifically, I would like to be able to mouse over a link and see the preview of the webpage using ajax.
| To create a URL preview feature that displays a preview of a webpage when you hover over a link, you can use Ajax to fetch data from the URL and display it in a tooltip or pop-up. The following steps will guide you through creating a simple version of this functionality using HTML, CSS, and JavaScript with jQuery for A... | 11,576 | [
{
"from": "human",
"value": "How do I preview a url using ajax? I have seen this done with search engine plug ins and would like to learn how to do this. Specifically, I would like to be able to mouse over a link and see the preview of the webpage using ajax.\n"
},
{
"from": "gpt",
"value": "To ... |
I wrote a program in C with Ubuntu Linux and now I need to port it over to a UNIX machine (or what I believe to be a UNIX box). It compiles fine on my Ubuntu with GCC but when I try to compile it with GCC on the UNIX box, it gives this error:
a.c: In function `goUpDir':
a.c:44: parse error before `char'
a.c:45: `newDi... | The parse errors you're encountering when compiling your C code on a UNIX machine could be related to several potential issues. Here are a few suggestions and things to check:
1. **Include Header Files**: Make sure you include the necessary header files at the top of your C source file. For example, if you are using `... | 17,102 | [
{
"from": "human",
"value": "I wrote a program in C with Ubuntu Linux and now I need to port it over to a UNIX machine (or what I believe to be a UNIX box). It compiles fine on my Ubuntu with GCC but when I try to compile it with GCC on the UNIX box, it gives this error:\na.c: In function `goUpDir':\na.c:4... |
Is it possible to pass a function/callback from javascript to a java applet?
For example i have an applet with a button that when pressed it will call the passed js callback
function onCommand() {
alert('Button pressed from applet');
}
applet.onCommand(onCommand);
| Passing a JavaScript function or callback to a Java applet isn't directly supported in the way that you might pass a function as an argument in JavaScript. However, you can achieve similar functionality by using the JavaScript-to-Java bridge provided by the browser when running applets. Here’s how you can communicate b... | 11,185 | [
{
"from": "human",
"value": "Is it possible to pass a function/callback from javascript to a java applet?\nFor example i have an applet with a button that when pressed it will call the passed js callback\nfunction onCommand() {\n alert('Button pressed from applet');\n}\napplet.onCommand(onCommand);\n\n"
... |
I want to test a connection to a machine in my local intranet. I know the IP address.
What port number should I use? 555? BTW: I'm using .NET.
| When testing a connection to a machine on your local intranet using .NET, the port number you use depends on the specific service you want to connect to on that machine. Port 555 is not a standard port and could be used for various applications, but it is not commonly associated with any widely used service.
Here are ... | 16,754 | [
{
"from": "human",
"value": "I want to test a connection to a machine in my local intranet. I know the IP address. \nWhat port number should I use? 555? BTW: I'm using .NET.\n"
},
{
"from": "gpt",
"value": "When testing a connection to a machine on your local intranet using .NET, the port numbe... |
I have a datetime column in MySQL.
How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?
| To convert a datetime column from MySQL to a specific format (mm/dd/yy H:M AM/PM) in PHP, you can use the `DateTime` class. Here’s a step-by-step approach:
1. **Fetch the datetime from the database**: After you execute your SQL query, you'll get the datetime value.
2. **Create a `DateTime` object**: Use this value to... | 16,983 | [
{
"from": "human",
"value": "I have a datetime column in MySQL. \nHow can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?\n"
},
{
"from": "gpt",
"value": "To convert a datetime column from MySQL to a specific format (mm/dd/yy H:M AM/PM) in PHP, you can use the `DateTime` class. He... |
Originally I am looking for a solution in Actionscript. The point of this question is the algorithm, which detects the exact Minute, when a clock has to switch the Daylight Saving Time.
So for example between the 25th and the 31th of October we have to check, if the actual date is a sunday, it is before or after 2 o'c... | To implement an algorithm that determines the moment Daylight Saving Time (DST) switches, particularly for the end of DST in October, we need to identify the last Sunday of October and check whether the time is before or after 2:00 AM on that day.
Below is a general outline of the algorithm you could implement in Acti... | 13,255 | [
{
"from": "human",
"value": "Originally I am looking for a solution in Actionscript. The point of this question is the algorithm, which detects the exact Minute, when a clock has to switch the Daylight Saving Time. \nSo for example between the 25th and the 31th of October we have to check, if the actual dat... |
I almost feel embarrassed to ask, but I always struggle with how to organize exception definitions. The three ways I've done this before are:
Use the file-per-class rule. I'm not crazy about this because it clutters up my directory structure and namespaces. I could organize them into subdirectories and segment name... | It's completely normal to feel uncertain about organizing exception definitions; it’s a nuanced topic that often lacks a one-size-fits-all solution. The right approach can depend on several factors, including the size of your codebase, your team’s conventions, and the specific needs of your application. Here are some c... | 16,555 | [
{
"from": "human",
"value": "I almost feel embarrassed to ask, but I always struggle with how to organize exception definitions. The three ways I've done this before are:\n\nUse the file-per-class rule. I'm not crazy about this because it clutters up my directory structure and namespaces. I could organiz... |
I find way too many projects to get involved in, way to many languages to play with (and way too many cool features within those languages), and way too many books to read...
How do you guys stay focused and actually get anything done, rather than leaving a trail of partially complete "experiments?"
| Staying focused in a world with endless projects, languages, and resources can be challenging, but there are several strategies you can employ to make your learning and experimentation more effective. Here are some tips to help you maintain focus and make tangible progress:
1. **Set Clear Goals**: Define specific, mea... | 16,519 | [
{
"from": "human",
"value": "I find way too many projects to get involved in, way to many languages to play with (and way too many cool features within those languages), and way too many books to read...\nHow do you guys stay focused and actually get anything done, rather than leaving a trail of partially c... |
For example, I rarely need:
using System.Text;
but it's always there by default. I assume the application will use more memory if your code contains unnecessary using directives. But is there anything else I should be aware of?
Also, does it make any difference whatsoever if the same using directive is used in only on... | The `using` directives in C# serve to simplify the syntax by allowing you to reference types without needing to specify their full namespace. Although it might seem that having unnecessary `using` directives could have performance implications, it's helpful to clarify a few points:
1. **Memory Consumption**: Having un... | 15,208 | [
{
"from": "human",
"value": "For example, I rarely need:\nusing System.Text;\n\nbut it's always there by default. I assume the application will use more memory if your code contains unnecessary using directives. But is there anything else I should be aware of?\nAlso, does it make any difference whatsoever i... |
I am trying to write a servlet that will send a XML file (xml formatted string) to another servlet via a POST.
(Non essential xml generating code replaced with "Hello there")
StringBuilder sb= new StringBuilder();
sb.append("Hello there");
URL url = new URL("theservlet's URL");
HttpURLConnection connec... | Your code is close to working, but there are a few important details that need to be addressed when sending an XML string via a POST request using `HttpURLConnection`. Here’s a corrected version of your servlet code along with some explanations:
### Key Adjustments:
1. **Set Content-Type**: It's essential to set the `... | 9,500 | [
{
"from": "human",
"value": "I am trying to write a servlet that will send a XML file (xml formatted string) to another servlet via a POST.\n(Non essential xml generating code replaced with \"Hello there\")\n StringBuilder sb= new StringBuilder();\n sb.append(\"Hello there\");\n\n URL url = new URL... |
Following Izb's question about Best binary XML format for JavaME, I'm looking for an implementation for either binary XML-like formats or just plain XML. My metrics for such implementation, by most important first, are:
Supported phones. A basic JTWI phone should be able to run it.
It should be either verified or ope... | For your requirements regarding a binary XML format or plain XML implementation for Java ME (JTWI phones), here are some options that might fit your criteria:
### 1. **KXmlParser**
- **Description**: A lightweight XML parser for Java ME.
- **Supported Phones**: Works on a variety of Java ME devices as it adheres to JT... | 13,274 | [
{
"from": "human",
"value": "Following Izb's question about Best binary XML format for JavaME, I'm looking for an implementation for either binary XML-like formats or just plain XML. My metrics for such implementation, by most important first, are:\n\nSupported phones. A basic JTWI phone should be able to r... |
I'd like to know how to script this. Also, is there an out of the box GUI tool that will let me do this?
| Certainly! However, I'll need more context about what you're trying to script and what specific functionality you want. Are you looking to automate a task, create a GUI, manipulate data, or something else entirely?
For scripting, commonly used languages include:
- **Python**: Great for a variety of tasks including a... | 19,314 | [
{
"from": "human",
"value": "I'd like to know how to script this. Also, is there an out of the box GUI tool that will let me do this?\n"
},
{
"from": "gpt",
"value": "Certainly! However, I'll need more context about what you're trying to script and what specific functionality you want. Are you l... |
I need to create a quick-n-dirty knob control in Visual Basic 2005 Express, the value of which is incremented/decremented by "grabbing" it with the mouse and moving the cursor up/down. Because the knob itself doesn't move, I need to keep tracking the mouse movement outside of the rectangle of the control.
I use a Label... | To create a knob control that can be adjusted by dragging the mouse up and down in Visual Basic 2005 Express, you will mainly need to handle mouse events to track when the user grabs the knob and moves the mouse. Here's a general outline of the steps and events you should use:
### Step 1: Define Your Control
You ment... | 5,243 | [
{
"from": "human",
"value": "I need to create a quick-n-dirty knob control in Visual Basic 2005 Express, the value of which is incremented/decremented by \"grabbing\" it with the mouse and moving the cursor up/down. Because the knob itself doesn't move, I need to keep tracking the mouse movement outside of ... |
ASP.NET 2.0 web application, how to implement shortcut key combination of CTRL + Letter, preferably through JavaScript, to make web application ergonomically better? How to capture multiple-key keyboard events through JavaScript?
| Implementing keyboard shortcuts like `CTRL + Letter` in an ASP.NET 2.0 web application can enhance user experience significantly. You can achieve this using JavaScript by capturing keyboard events. Here's a step-by-step guide on how to implement this:
### Step 1: Add JavaScript to Capture Key Events
You can use the `... | 10,776 | [
{
"from": "human",
"value": "ASP.NET 2.0 web application, how to implement shortcut key combination of CTRL + Letter, preferably through JavaScript, to make web application ergonomically better? How to capture multiple-key keyboard events through JavaScript?\n"
},
{
"from": "gpt",
"value": "Impl... |
A friend of mine brought up this questiont he other day, he's recently bought a garmin heart rate moniter device which keeps track of his heart rate and allows him to upload his heart rate stats for a day to his computer.
The only problem is there are no linux drivers for the garmin USB device, he's managed to interpre... | Reverse engineering binary data can be a challenging task, especially if you don't have any documentation regarding the structure. However, you can approach the problem methodically. Here are some steps to help you get started:
### 1. **Gather Information**
- **Device Documentation:** Look for any available documenta... | 9,314 | [
{
"from": "human",
"value": "A friend of mine brought up this questiont he other day, he's recently bought a garmin heart rate moniter device which keeps track of his heart rate and allows him to upload his heart rate stats for a day to his computer.\nThe only problem is there are no linux drivers for the g... |
Back in VB6, I wrote a few functions that would let me code without having to care about the difference between null and '' for strings, null and 0 for numbers, etc. Nothing kills my productivity more when coding than having to add special case code for dealing with data that might cause some irrelevant error; 9999/10... | It's a great question! In C#, you have a few options to handle scenarios where you want to convert different types of data (like strings from user input, database values, etc.) while avoiding potential pitfalls like null values, empty strings, or type mismatches. While you could certainly write custom helper functions,... | 14,297 | [
{
"from": "human",
"value": "Back in VB6, I wrote a few functions that would let me code without having to care about the difference between null and '' for strings, null and 0 for numbers, etc. Nothing kills my productivity more when coding than having to add special case code for dealing with data that m... |
How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form?
I know you need to use Win32 API calls and override the WndProc procedure, but I haven't been able to figure out a solution that works right.
Does anyone know how to do this? More specifically, does anyone ... | To draw a custom button next to the standard minimize, maximize, and close buttons in the title bar of a form in a Windows application, you need to work with the Windows API. This involves subclassing the form and overriding its `WndProc` method. Below is a step-by-step guide that should help you accomplish this.
### ... | 7,155 | [
{
"from": "human",
"value": "How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form?\nI know you need to use Win32 API calls and override the WndProc procedure, but I haven't been able to figure out a solution that works right.\nDoes anyone know how ... |
I've been asked to write code/design things in an interview. Sometimes even to provide code samples. Very reasonable and very wise (always surprised when this DOESN'T happen)
I had a job a year or so back where the code was so awful that I would not have taken the job, if I'd seen the mess I had to deal with ahead of... | It’s definitely not out of the question to ask for a code sample or to view the database design during the interview process, especially if you’re seriously considering accepting an offer. Here are some points to consider when approaching this:
1. **Timing**: As you mentioned, it's wise to wait until later in the inte... | 14,558 | [
{
"from": "human",
"value": "I've been asked to write code/design things in an interview. Sometimes even to provide code samples. Very reasonable and very wise (always surprised when this DOESN'T happen)\nI had a job a year or so back where the code was so awful that I would not have taken the job, if I'd... |
I am using a textbox in a .NET 2 winforms app that is setup with a custom AutoCompleteSource. Is there anyway through code that I can increase the width of the list that appears containing the auto complete suggestions?
Ideally I would like to do this without increasing the width of the textbox as I am short for spa... | In .NET WinForms, the `TextBox` control's `AutoComplete` feature does not provide a built-in way to change the width of the dropdown list that shows the autocomplete suggestions directly. The width of the dropdown list is generally determined by the width of the `TextBox` itself.
However, you can implement a workaroun... | 13,911 | [
{
"from": "human",
"value": "I am using a textbox in a .NET 2 winforms app that is setup with a custom AutoCompleteSource. Is there anyway through code that I can increase the width of the list that appears containing the auto complete suggestions? \nIdeally I would like to do this without increasing the ... |
I need to enumerate all running applications. In particular, all top windows. And for every window I need to add my custom item to the system menu of that window.
How can I accomplish that in C++?
Update.
I would be more than happy to have a solution for Windows, MacOS, and Ubuntu (though, I'm not sure if MacOS and Ubu... | To enumerate all running applications and modify their window menus in C++, you can use platform-specific APIs. Below is a brief overview of how to accomplish this task on Windows, macOS, and Ubuntu.
### Windows
On Windows, you can use the Win32 API to enumerate windows and modify their system menu. Here's a simple e... | 12,098 | [
{
"from": "human",
"value": "I need to enumerate all running applications. In particular, all top windows. And for every window I need to add my custom item to the system menu of that window.\nHow can I accomplish that in C++?\nUpdate.\nI would be more than happy to have a solution for Windows, MacOS, and U... |
Is it possible to get notified (without polling, but via an event) when a drive letter becomes accessible. For example if you have an external hard drive that always appears as drive F - is it possible to have an event raised when that is connected and F becomes accessible?
| Yes, it is possible to receive notifications when a drive letter becomes accessible in Windows, without resorting to polling. You can achieve this using the Windows API to listen for device change notifications. The relevant API functions are found in the `Windows.h` header and involve registering for device notificati... | 15,397 | [
{
"from": "human",
"value": "Is it possible to get notified (without polling, but via an event) when a drive letter becomes accessible. For example if you have an external hard drive that always appears as drive F - is it possible to have an event raised when that is connected and F becomes accessible?\n"
... |
I've written 2 reasonably large scale apps in .net so far, and both of them have needed an updating facility to automatically update the application when I roll out new code.
I've found the 'Enterprise application block updater' a bit too complex for my needs, and I've found 'click once' frustrating when it comes to pu... | Automatic updating of applications is a common requirement, especially for desktop applications. While you've found some methods that have their drawbacks, there are indeed several other approaches you can consider for implementing an update mechanism. Here are a few alternatives:
### 1. **Self-Updater Using HTTP/HTTP... | 15,316 | [
{
"from": "human",
"value": "I've written 2 reasonably large scale apps in .net so far, and both of them have needed an updating facility to automatically update the application when I roll out new code.\nI've found the 'Enterprise application block updater' a bit too complex for my needs, and I've found 'c... |
I'm looking for a standard way to connect to databases in PHP. We've all been there - first start with some rudimentary code to connect/query/iterate/insert/disconnect, then the code grew as the program grew, and it ended up with a mess that's hardly reusable.
I know there are many PEAR, PECL, and other PHP libraries/c... | When it comes to connecting to databases in PHP, the landscape has evolved, and there are a few robust, maintained, and widely-used libraries and extensions that you can use to simplify database interactions. Here are some recommended approaches:
### 1. **PDO (PHP Data Objects)**
PDO is a native PHP extension that pr... | 14,661 | [
{
"from": "human",
"value": "I'm looking for a standard way to connect to databases in PHP. We've all been there - first start with some rudimentary code to connect/query/iterate/insert/disconnect, then the code grew as the program grew, and it ended up with a mess that's hardly reusable.\nI know there are ... |
What does the following code do in C/C++?
if (blah(), 5) {
//do something
}
| The code you provided uses the comma operator in C/C++. Let's break it down:
```c
if (blah(), 5) {
//do something
}
```
1. **Comma Operator**: The expression inside the `if` statement `blah(), 5` utilizes the comma operator. In C/C++, the comma operator evaluates its first operand (`blah()` in this case) and disc... | 18,949 | [
{
"from": "human",
"value": "What does the following code do in C/C++?\nif (blah(), 5) {\n //do something\n}\n\n"
},
{
"from": "gpt",
"value": "The code you provided uses the comma operator in C/C++. Let's break it down:\n\n```c\nif (blah(), 5) {\n //do something\n}\n```\n\n1. **Comma Oper... |
I'm using the wxGlade designer to generate the GUI for a small application.
It generates a class, inherited from wxFrame, which is the main application window.
In order to facilitate the maintenance, I'd like to avoid writing additional code in this generated class.
But all the widgets created with the wxGlade are actu... | Yes, you can access the widgets created by wxGlade outside the generated class by utilizing a few techniques. Here are some strategies to consider:
1. **Create Accessor Methods**: Modify the auto-generated class (with caution) to add public methods that return pointers to specific widgets. For example, you can add a m... | 16,017 | [
{
"from": "human",
"value": "I'm using the wxGlade designer to generate the GUI for a small application.\nIt generates a class, inherited from wxFrame, which is the main application window.\nIn order to facilitate the maintenance, I'd like to avoid writing additional code in this generated class.\nBut all t... |
What's the best way to manage a slew of browser UI tests? I'm looking for an approach that may have worked for you in the past when dealing with numerous automated browser tests. Obvious answers such as "they should be refactored into lower-level UI tests" aren't what I'm looking for. Ultimately these tests are incredi... | Managing a large suite of browser UI tests can indeed be challenging, especially when you're working within specific constraints like free software and .NET-focused tools. Here are several strategies that can help minimize the time and effort required to maintain and execute these tests:
### 1. Test Prioritization and... | 16,001 | [
{
"from": "human",
"value": "What's the best way to manage a slew of browser UI tests? I'm looking for an approach that may have worked for you in the past when dealing with numerous automated browser tests. Obvious answers such as \"they should be refactored into lower-level UI tests\" aren't what I'm look... |
Recently, I've started having a problem with my SQL Server 2005 client running on Windows XP where right-clicking on any job and selecting Properties instead brings me to the New Job window. Also, if I select "View History", I get the history for all jobs, instead of the one I right-clicked on.
This happened to me o... | It sounds like you encountered a known issue with SQL Server Management Studio (SSMS) that can occur due to a lack of updates or potential corruption in the installation. SQL Server 2005, especially on an older operating system like Windows XP, can run into various quirks over time.
Here are some insights and suggesti... | 8,865 | [
{
"from": "human",
"value": "Recently, I've started having a problem with my SQL Server 2005 client running on Windows XP where right-clicking on any job and selecting Properties instead brings me to the New Job window. Also, if I select \"View History\", I get the history for all jobs, instead of the one ... |
I'd like to enable/disable some other controls based on how many items are in my ListView control. I can't find any event that would do this, either on the ListView itself or on the ListViewItemCollection. Maybe there's a way to generically watch any collection in C# for changes?
I'd be happy with other events too, eve... | In a WinForms application, the `ListView` control does not directly raise events when items are added or removed. However, you can achieve the desired behavior by creating your own wrapper around the `ListView` or by handling specific events related to adding/removing items.
### 1. Use `ListView` Events
While `ListVi... | 14,414 | [
{
"from": "human",
"value": "I'd like to enable/disable some other controls based on how many items are in my ListView control. I can't find any event that would do this, either on the ListView itself or on the ListViewItemCollection. Maybe there's a way to generically watch any collection in C# for changes... |
In C# and in Java (and possibly other languages as well), variables declared in a "try" block are not in scope in the corresponding "catch" or "finally" blocks. For example, the following code does not compile:
try {
String s = "test";
// (more code...)
}
catch {
Console.Out.WriteLine(s); //Java fans: think "Sy... | The decision to limit the scope of variables declared within a `try` block to that block alone is rooted in several principles of programming language design, including scope management, clarity, and maintainability of the code. Here are some rationales behind this design decision in languages like Java and C#:
### 1.... | 15,163 | [
{
"from": "human",
"value": "In C# and in Java (and possibly other languages as well), variables declared in a \"try\" block are not in scope in the corresponding \"catch\" or \"finally\" blocks. For example, the following code does not compile:\ntry {\n String s = \"test\";\n // (more code...)\n}\ncatch... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.