instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
I have a website that works correctly under IIS 6.0: It authenticates users with windows credentials, and then when talking to the service that hits the DB, it passes the credentials.
In IIS 7.0, the same config settings do not pass the credentials, and the DB gets hit with NT AUTHORITY\ANONYMOUS.
Is there something I'... | The transition from IIS 6.0 to IIS 7.0 introduced several significant changes, particularly in how authentication and authorization are handled. Here are a few areas you might need to check to resolve the issue with Windows authentication and impersonation:
### 1. **Authentication Settings:**
IIS 7.0 introduces a new ... | 5,189 | [
{
"from": "human",
"value": "I have a website that works correctly under IIS 6.0: It authenticates users with windows credentials, and then when talking to the service that hits the DB, it passes the credentials.\nIn IIS 7.0, the same config settings do not pass the credentials, and the DB gets hit with NT ... |
This is kind of a weird question and more of an annoyance than technical brick wall.
When I'm adding tables and such using the Linq-to-SQL designer and I want to create an association using the dialogs. I right click on one of the target tables and choose Add > Association as normal and I am presented with the Associat... | In the LINQ to SQL designer, the order of tables and classes in the Association Editor’s combo boxes is determined by the order in which they were added to the designer. Unfortunately, there isn't a built-in feature to manually sort these combo boxes or to change the order after the tables have been added.
However, y... | 10,500 | [
{
"from": "human",
"value": "This is kind of a weird question and more of an annoyance than technical brick wall.\nWhen I'm adding tables and such using the Linq-to-SQL designer and I want to create an association using the dialogs. I right click on one of the target tables and choose Add > Association as n... |
I sent 3 emails last week as replies from our website. None received them! One was yahoo, hotmail and an overseas domain. I am wondering if it's not a good idea to open a yahoo account with our domain name as the user just to reply to prospective buyers.
| It sounds like you're facing some issues with email deliverability. Here are a few considerations and recommendations for your situation:
1. **Email Deliverability Issues**: If your emails are not being received by common providers like Yahoo and Hotmail, it could be due to several factors:
- **Spam Filters**: Your... | 9,027 | [
{
"from": "human",
"value": "I sent 3 emails last week as replies from our website. None received them! One was yahoo, hotmail and an overseas domain. I am wondering if it's not a good idea to open a yahoo account with our domain name as the user just to reply to prospective buyers. \n"
},
{
"from":... |
I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help menu... | To determine if the search box in the Help menu is focused, you'll have to approach the problem differently, as AppleScript does not directly support querying the focused state of UI elements in menus. Instead, a workaround is needed.
One common method is to check if the Help menu is open and then detect if the search... | 5,930 | [
{
"from": "human",
"value": "I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, t... |
Is there a way to access Visual Studio's built-in ASP.NET Development Server over HTTPS?
| Yes, while the built-in ASP.NET Development Server (also known as Cassini) primarily supports HTTP, you can configure HTTPS support for it with a few additional steps. However, note that the ASP.NET Development Server is largely obsolete and has been replaced by IIS Express, which has better support for SSL.
Here are ... | 8,824 | [
{
"from": "human",
"value": "Is there a way to access Visual Studio's built-in ASP.NET Development Server over HTTPS?\n"
},
{
"from": "gpt",
"value": "Yes, while the built-in ASP.NET Development Server (also known as Cassini) primarily supports HTTP, you can configure HTTPS support for it with a... |
I have a table in a MySql database that stores user accounts. One of the columns, expires, stores an expiration date but defaults to NULL. I need to be able to remove an expiration date and set it back to the default value.
Currently, all of my CRUD routines are written using MySqlCommand with parameters. Can this be d... | You can set a column value to `NULL` directly using a `MySqlParameter` in your `MySqlCommand`. You do not need to create an alternate command object to handle this situation. Instead, you can simply use a parameterized query where you specify the value as `DBNull.Value` when you want to remove the expiration date and s... | 9,590 | [
{
"from": "human",
"value": "I have a table in a MySql database that stores user accounts. One of the columns, expires, stores an expiration date but defaults to NULL. I need to be able to remove an expiration date and set it back to the default value.\nCurrently, all of my CRUD routines are written using M... |
I'm currently working on a quite large library (5M lines of code, in C++ under VS2005, 1 solution and close to 100 projects). Even though we distribute compilation, and use incremental linking, recompilation and relinking after small source modifications takes between a few minutes (usually at least 3) and close to one... | Dealing with long build times in a large C++ codebase, especially one as extensive as yours, can be challenging. Here are several strategies you can implement to optimize your workflow and reduce build times:
### 1. **Modularization**
- **Refactor into Smaller Libraries**: If possible, break your large library into... | 5,978 | [
{
"from": "human",
"value": "I'm currently working on a quite large library (5M lines of code, in C++ under VS2005, 1 solution and close to 100 projects). Even though we distribute compilation, and use incremental linking, recompilation and relinking after small source modifications takes between a few minu... |
I want to expand my programming horizons to Linux. A good, dependable basic toolset is important, and what is more basic than an IDE?
I could find these SO topics:
Lightweight IDE for linux and
What tools do you use to develop
C++ applications on Linux?
I'm not looking for a lightweight IDE. If an IDE is worth the mo... | When it comes to C++ programming on Linux, there are several IDEs that stand out, each with its own strengths and weaknesses. Below are some of the top contenders, along with their advantages and disadvantages:
### 1. **CLion**
- **Pros:**
- Smart code analysis and refactoring capabilities.
- Great integrated debu... | 5,052 | [
{
"from": "human",
"value": "I want to expand my programming horizons to Linux. A good, dependable basic toolset is important, and what is more basic than an IDE?\nI could find these SO topics:\n\nLightweight IDE for linux and\nWhat tools do you use to develop\nC++ applications on Linux?\n\nI'm not looking ... |
How do you back up your development machine so that in the event of a catastrophic hardware malfunction, you are up and running in the least amount of time possible?
| Backing up your development machine effectively involves a combination of regular backups, proper tools, and recovery strategies to minimize downtime in the event of a hardware malfunction. Here's a comprehensive approach:
### 1. **Establish a Backup Strategy**
- **Determine Backup Frequency**: Decide how often you n... | 6,289 | [
{
"from": "human",
"value": "How do you back up your development machine so that in the event of a catastrophic hardware malfunction, you are up and running in the least amount of time possible?\n"
},
{
"from": "gpt",
"value": "Backing up your development machine effectively involves a combinati... |
The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C
| If you're looking to bridge the gap between Python and C, a great language to consider is **Rust**. Here are a few reasons why Rust can be a beneficial choice:
1. **Performance**: Rust offers performance comparable to C and C++, allowing you to write efficient systems-level code while maintaining safety features.
2. ... | 8,676 | [
{
"from": "human",
"value": "The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to ... |
We develop custom survey web sites and I am looking for a way to automate the pattern testing of these sites. Surveys often contain many complex rules and branches which are triggered on how items are responded too. All surveys are rigorously tested before being released to clients. This testing results in a lot of ... | Hello Brett,
Automating the testing of your custom survey web applications can significantly streamline your process and reduce manual workload. Below are some suggestions and approaches to consider for implementing an automation solution for your survey testing:
### 1. **Automated Testing Frameworks**
You can lever... | 6,840 | [
{
"from": "human",
"value": "We develop custom survey web sites and I am looking for a way to automate the pattern testing of these sites. Surveys often contain many complex rules and branches which are triggered on how items are responded too. All surveys are rigorously tested before being released to cl... |
In ASP.net Webforms how do you detect which Textbox someone pressed enter?
Please no Javascript answers.
I need to handle it all in the code behind using VB.NET.
| In ASP.NET Web Forms, you cannot directly detect the Enter key press in a TextBox control without using client-side JavaScript. However, you can use the `TextChanged` event of the TextBox in combination with the `AutoPostBack` property to achieve similar functionality.
Here's how to do it in VB.NET in the code behind:... | 7,866 | [
{
"from": "human",
"value": "In ASP.net Webforms how do you detect which Textbox someone pressed enter?\nPlease no Javascript answers.\nI need to handle it all in the code behind using VB.NET.\n"
},
{
"from": "gpt",
"value": "In ASP.NET Web Forms, you cannot directly detect the Enter key press i... |
What does a JIT compiler specifically do as opposed to a non-JIT compiler? Can someone give a succinct and easy to understand description?
| A JIT (Just-In-Time) compiler and a non-JIT (also known as an ahead-of-time or AOT) compiler differ mainly in when they compile code.
### JIT Compiler:
- **Compiles at Runtime**: A JIT compiler translates code while the program is running. It takes high-level code (like Java bytecode) and compiles it into machine code... | 9,078 | [
{
"from": "human",
"value": "What does a JIT compiler specifically do as opposed to a non-JIT compiler? Can someone give a succinct and easy to understand description?\n"
},
{
"from": "gpt",
"value": "A JIT (Just-In-Time) compiler and a non-JIT (also known as an ahead-of-time or AOT) compiler di... |
I'm writing a C parser using PLY, and recently ran into a problem.
This code:
typedef int my_type;
my_type x;
Is correct C code, because my_type is defined as a type previously to
being used as such. I handle it by filling a type symbol table in the
parser that gets used by the lexer to differentiate between types and... | It sounds like you've encountered a common issue when implementing a parser with PLY, particularly when dealing with type definitions. The problem arises from how the PLY parser processes tokens and the timing of when you can update your symbol table.
Since you've already mentioned that you've found a solution, I can ... | 8,462 | [
{
"from": "human",
"value": "I'm writing a C parser using PLY, and recently ran into a problem.\nThis code:\ntypedef int my_type;\nmy_type x;\n\nIs correct C code, because my_type is defined as a type previously to\nbeing used as such. I handle it by filling a type symbol table in the\nparser that gets used... |
I'm planning on creating a social networking + MP3 lecture downloading / browsing / commenting / discovery website using Ruby on Rails. Partially for fun and also as a means to learn some Ruby on Rails. I'm looking for a social networking framework that I can use as a basis for my site. I don't want to re-invent the wh... | All three of the frameworks you've mentioned have their strengths and can serve as good starting points for building a social networking site in Ruby on Rails. Here's a brief overview of each, along with recommendations based on your goals:
### 1. Insoshi
- **Overview**: Insoshi is a social networking framework that i... | 5,678 | [
{
"from": "human",
"value": "I'm planning on creating a social networking + MP3 lecture downloading / browsing / commenting / discovery website using Ruby on Rails. Partially for fun and also as a means to learn some Ruby on Rails. I'm looking for a social networking framework that I can use as a basis for ... |
My guess is that class variables ("class var") are truly global in storage (that is, one instance for the entire application).
But I am wondering whether this is the case, or whether they are thread in storage (eg similar to a "threadvar") - once instance per thread.
Anyone know?
Edit: changed "scope" to "storage" as t... | In most programming languages, class variables (or class attributes) are shared across all instances of that class, meaning there is one instance of the variable for the entire application, not one per instance or thread. This is in contrast to instance variables, which are unique to each instance of a class.
For exam... | 8,804 | [
{
"from": "human",
"value": "My guess is that class variables (\"class var\") are truly global in storage (that is, one instance for the entire application).\nBut I am wondering whether this is the case, or whether they are thread in storage (eg similar to a \"threadvar\") - once instance per thread.\nAnyon... |
Lisp developed a set of interesting language features quite early on in the academic world, but most of them never caught on in production environments.
Some languages, like JavaScript, adapted basic features like garbage collection and lexical closures, but all the stuff that might actually change how you write progra... | The adoption of advanced features from languages like Lisp into mainstream programming languages has been a complex and often slow process. Several factors contribute to this phenomenon:
### 1. **Cultural Resistance:**
- **Conservative Mindset:** Many developers and organizations are accustomed to established parad... | 6,734 | [
{
"from": "human",
"value": "Lisp developed a set of interesting language features quite early on in the academic world, but most of them never caught on in production environments.\nSome languages, like JavaScript, adapted basic features like garbage collection and lexical closures, but all the stuff that ... |
I've been programming in C,C++,C# and a few other languages for many years, mainly for Windows and Linux but also embedded platforms. Recently started to do some iPhone programming as a side project so I'm using Apple platforms for the first time since my Apple II days. I'm wondering what other developers that are comi... | Hi Andrew,
It sounds like you’re navigating quite a transition from your established environments to the Apple ecosystem! Here are some thoughts based on your impressions:
### Mac OS X
Your experience of finding Mac OS X a bit confusing is quite common for newcomers. The window management can be daunting, especially ... | 8,171 | [
{
"from": "human",
"value": "I've been programming in C,C++,C# and a few other languages for many years, mainly for Windows and Linux but also embedded platforms. Recently started to do some iPhone programming as a side project so I'm using Apple platforms for the first time since my Apple II days. I'm wond... |
I am a C/C++ programmer professionally, but I've created a couple of personal web sites using PHP and MySQL.
They're pretty basic, and I'd like to jazz them up using Ajax, but I've never done any Ajax. I've done all the development so far manually, i.e. no IDE or anything like that.
Does anyone have suggestions on Aja... | Ajax is a powerful technique for creating interactive web applications, and while you can certainly build Ajax functionality manually, using the right tools can help speed up your development process and improve your workflow. Here are some suggestions for environments and tools that can assist you in developing Ajax a... | 3,009 | [
{
"from": "human",
"value": "I am a C/C++ programmer professionally, but I've created a couple of personal web sites using PHP and MySQL. \nThey're pretty basic, and I'd like to jazz them up using Ajax, but I've never done any Ajax. I've done all the development so far manually, i.e. no IDE or anything like... |
When doing small icons, header graphics and the like for websites, is it better to use GIFs or PNGs?
Obviously if transparency effects are required, then PNGs are definitely the way to go, and for larger, more photographic images I'd use JPEGs - but for normal web "furniture", which would you recommend and why? It may... | When deciding between GIFs and PNGs for small icons and header graphics on websites, it generally comes down to the specific use case, file size considerations, and quality requirements. Here's a breakdown of the two formats:
### PNG
1. **Quality**: PNG supports lossless compression, which means it maintains image qua... | 9,292 | [
{
"from": "human",
"value": "When doing small icons, header graphics and the like for websites, is it better to use GIFs or PNGs?\nObviously if transparency effects are required, then PNGs are definitely the way to go, and for larger, more photographic images I'd use JPEGs - but for normal web \"furniture\... |
We're storing some Guid's in a MS SQL database. There's some legacy code that does Guid.ToString() and then passes them in to a varchar(64) and there's some newer code that passes them in using a unique identifier parameter. When you look at the results using MS SQL Management studio they look different. The byte order... | The difference in the appearance of GUIDs when stored and displayed in Microsoft SQL Server is primarily due to the way that GUIDs (also known as UniqueIdentifiers) are represented and the internal byte ordering used by different systems and contexts.
### Explanation of GUID Representation
A GUID (Globally Unique Ide... | 6,709 | [
{
"from": "human",
"value": "We're storing some Guid's in a MS SQL database. There's some legacy code that does Guid.ToString() and then passes them in to a varchar(64) and there's some newer code that passes them in using a unique identifier parameter. When you look at the results using MS SQL Management s... |
Is there a way to get a DrawingContext (or something similar) for a WriteableBitmap? I.e. something to allow you to call simple DrawLine/DrawRectangle/etc kinds of methods, rather than manipulate the raw pixels directly.
| In WPF (Windows Presentation Foundation), `WriteableBitmap` doesn't directly provide a `DrawingContext` for drawing operations like you would have with a `DrawingVisual`. However, there are ways to achieve similar functionality.
One common approach is to create a `DrawingVisual` or `RenderTargetBitmap`, perform your d... | 7,509 | [
{
"from": "human",
"value": "Is there a way to get a DrawingContext (or something similar) for a WriteableBitmap? I.e. something to allow you to call simple DrawLine/DrawRectangle/etc kinds of methods, rather than manipulate the raw pixels directly.\n"
},
{
"from": "gpt",
"value": "In WPF (Wind... |
I assumed that the C# margin property had a meaning like in CSS - the spacing around the outside of the control. But Margin values seem to be ignored to matter what values I enter.
Then I read on the SDK:
Setting the Margin property on a
docked control has no effect on the
distance of the control from the the
e... | In C#, specifically in the context of WinForms or WPF, the `Margin` property does indeed refer to the spacing around the control, similar to CSS. However, the way this property is applied can vary based on how the control is laid out within its container, particularly with regards to layout managers and docking.
### K... | 7,341 | [
{
"from": "human",
"value": "I assumed that the C# margin property had a meaning like in CSS - the spacing around the outside of the control. But Margin values seem to be ignored to matter what values I enter.\nThen I read on the SDK: \n\nSetting the Margin property on a\n docked control has no effect on t... |
we have several "production environments" (three servers each, with the same version of our system. Each one has a SQL Server Database as production database).
In one of this environment the tempdb transaction log starts to grow fast and infinitely, we can´t find why. Same version of SO, SQL Server, application. No ch... | The issue of a growing `tempdb` transaction log in SQL Server can be challenging to troubleshoot, especially if you have identical production environments where the issue appears in only one of them. Below are several steps you can take to diagnose and potentially fix the issue.
### Diagnosis Steps:
1. **Check for Op... | 7,403 | [
{
"from": "human",
"value": "we have several \"production environments\" (three servers each, with the same version of our system. Each one has a SQL Server Database as production database). \nIn one of this environment the tempdb transaction log starts to grow fast and infinitely, we can´t find why. Same v... |
I'm working in VS 2008 and have three projects in one solution. I'm debugging by attaching to a .net process invoked by a third party app (SalesLogix, a CRM app).
Once it has attached to the process and I attempt to set a breakpoint in one of the projects, it doesn't set a breakpoint in that file. It actually switc... | Hi Jeff,
This behavior you're experiencing in Visual Studio 2008 while debugging can indeed be quite perplexing. Let's break down some potential causes and solutions.
### Possible Causes
1. **Symbol Files Mismatch**:
- Even though the `.pdb` and `.dll` files are timestamped the same, it's possible they don't mat... | 4,464 | [
{
"from": "human",
"value": "I'm working in VS 2008 and have three projects in one solution. I'm debugging by attaching to a .net process invoked by a third party app (SalesLogix, a CRM app). \nOnce it has attached to the process and I attempt to set a breakpoint in one of the projects, it doesn't set a b... |
Below I present three options for simplifying my database access when only a single connection is involved (this is often the case for the web apps I work on).
The general idea is to make the DB connection transparent, such that it connects the first time my script executes a query, and then it remains connected until ... | All three options you've proposed have their merits and trade-offs, and your evaluation of them highlights the essential considerations when simplifying database access in PHP. Here's an analysis of each option along with some suggestions.
### Option 1: Static Wrapper
```php
class DB {
private static $connection;... | 6,522 | [
{
"from": "human",
"value": "Below I present three options for simplifying my database access when only a single connection is involved (this is often the case for the web apps I work on).\nThe general idea is to make the DB connection transparent, such that it connects the first time my script executes a q... |
I would like to read the text and binary attachments in a saved Outlook message (.msg file) from a Java application, without resorting to native code (JNI, Java Native Interface).
Apache POI-HSMF seems to be in the right direction, but it's in very early stages of development...
| If you're looking to read text and binary attachments from a saved Outlook message (.msg file) using Java without resorting to JNI, you're correct that Apache POI-HSMF is a potential library, but as you noted, it may not be fully mature for all use cases.
However, there are some other options you can consider that mig... | 5,387 | [
{
"from": "human",
"value": "I would like to read the text and binary attachments in a saved Outlook message (.msg file) from a Java application, without resorting to native code (JNI, Java Native Interface). \nApache POI-HSMF seems to be in the right direction, but it's in very early stages of development.... |
Is this function declaration in C#:
void foo(string mystring)
the same as this one in C:
void foo(char *)
i.e. In C#, does the called function receive a pointer behind the scenes?
| In C#, the function declaration `void foo(string mystring)` and the C function declaration `void foo(char *)` are conceptually similar in that they both handle strings, but there are important differences in how they work under the hood.
### C:
In C, `char *` is a pointer to a character, which represents a string as a... | 9,755 | [
{
"from": "human",
"value": "Is this function declaration in C#:\nvoid foo(string mystring)\n\nthe same as this one in C:\nvoid foo(char *)\n\ni.e. In C#, does the called function receive a pointer behind the scenes?\n"
},
{
"from": "gpt",
"value": "In C#, the function declaration `void foo(stri... |
I'm doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tokenizer. Does it? Where is it? How do I use it?
| C# does not have a dedicated `StringTokenizer` class like Java, but you can achieve similar functionality using the `String.Split` method or by utilizing the `System.String` class methods and LINQ for more complex parsing.
### Using `String.Split()`
The simplest way to tokenize a string in C# is to use the `Split` me... | 8,389 | [
{
"from": "human",
"value": "I'm doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tokenizer. Does it? Where is it? How do I use it?\n"
},
{
"from": "gpt",
"value": "C# does not hav... |
For example,
Look at the code that calculates the n-th Fibonacci number:
fib(int n)
{
if(n==0 || n==1)
return 1;
return fib(n-1) + fib(n-2);
}
The problem with this code is that it will generate stack overflow error for any number greater than 15 (in most computers).
Assume that we are calculating fib(... | Yes, what you're describing is a technique known as **memoization**. Memoization is a common optimization technique used to improve the performance of recursive algorithms by storing previously computed results so they can be reused in future calculations, thus avoiding repeated work.
In the case of your Fibonacci fu... | 4,737 | [
{
"from": "human",
"value": "For example,\nLook at the code that calculates the n-th Fibonacci number:\nfib(int n)\n{\n if(n==0 || n==1)\n return 1;\n return fib(n-1) + fib(n-2);\n}\n\nThe problem with this code is that it will generate stack overflow error for any number greater than 15 (in mo... |
I need to write a Java Comparator class that compares Strings, however with one twist. If the two strings it is comparing are the same at the beginning and end of the string are the same, and the middle part that differs is an integer, then compare based on the numeric values of those integers. For example, I want th... | Your approach of using a character-by-character comparison to find the matching prefix and suffix is a good one. You can start by iterating from both ends of the strings towards the center, identifying where they differ. Once you find the differing part, you'll need to check if it's an integer and then perform the appr... | 6,916 | [
{
"from": "human",
"value": "I need to write a Java Comparator class that compares Strings, however with one twist. If the two strings it is comparing are the same at the beginning and end of the string are the same, and the middle part that differs is an integer, then compare based on the numeric values o... |
If all you see is the ugly no-char boxes, what tools or strategies do you use to figure out what went wrong?
(The specific scenario I'm facing is no-char boxes within a <select> when it should be showing Japanese chars.)
| When you encounter "no-char boxes" (often referred to as "tofu") in a `<select>` element where you expect to see Japanese characters, it typically indicates an issue with font rendering or character encoding. Here are several strategies and tools you can use to diagnose and resolve the problem:
### 1. **Check Characte... | 6,106 | [
{
"from": "human",
"value": "If all you see is the ugly no-char boxes, what tools or strategies do you use to figure out what went wrong?\n(The specific scenario I'm facing is no-char boxes within a <select> when it should be showing Japanese chars.)\n"
},
{
"from": "gpt",
"value": "When you enc... |
In addition, are there any performance advantages to static methods over instance methods?
I came across the following recently: http://www.cafeaulait.org/course/week4/22.html :
When should a method be static?
Neither reads from nor writes to instance fields
Independent of the state of the object
Mathematical methods... | There are several performance advantages to using static methods over instance methods, although the differences may vary depending on the specific programming language and runtime environment. Here are some potential benefits of using static methods:
1. **No Overhead of Instance Creation**: Static methods do not requ... | 7,202 | [
{
"from": "human",
"value": "In addition, are there any performance advantages to static methods over instance methods?\nI came across the following recently: http://www.cafeaulait.org/course/week4/22.html :\n\nWhen should a method be static?\n\nNeither reads from nor writes to instance fields\nIndependent ... |
I am working on the issue of testing my GUI and I am not entirely sure of the best approach here. My GUI is built using a traditional MVC framework so I am easily able to test the logic parts of the GUI without bringing up the GUI itself. However, when it comes to testing the functionality of the GUI, I am not really s... | You raise a valid point regarding GUI testing, especially in the context of a complex system built using the MVC framework. Here are some considerations that might help you shape your testing strategy:
### 1. **Functional Testing as a Priority**
Given that your GUI relies heavily on interaction with a server and the r... | 7,673 | [
{
"from": "human",
"value": "I am working on the issue of testing my GUI and I am not entirely sure of the best approach here. My GUI is built using a traditional MVC framework so I am easily able to test the logic parts of the GUI without bringing up the GUI itself. However, when it comes to testing the fu... |
I've always been told that adding an element to an array happens like this:
An empty copy of the array+1element is
created and then the data from the
original array is copied into it then
the new data for the new element is
then loaded
If this is true, then using an array within a scenario that requires a lot... | Your understanding of how dynamic arrays typically work in many programming languages is fundamentally correct. When you add an element to a dynamically sized array, the typical process involves:
1. Allocating a new array of greater size.
2. Copying the existing elements to the new array.
3. Adding the new element to ... | 7,958 | [
{
"from": "human",
"value": "I've always been told that adding an element to an array happens like this:\n\nAn empty copy of the array+1element is\n created and then the data from the\n original array is copied into it then\n the new data for the new element is\n then loaded\n\nIf this is true, then usi... |
The title should say it all, then I can solidify 2 more ticks on the Joel test.
I've implemented build automation using a makefile and a python script already and I understand the basics and the options.
But how can I, the new guy who reads the blogs, convince my cohort of its inherent efficacy?
| Convincing your team of the efficacy of build automation using a Makefile and a Python script involves a mix of demonstrating tangible benefits, addressing potential concerns, and showcasing best practices. Here are some strategies to help you articulate your case effectively:
### 1. **Highlight the Benefits**
- **Co... | 7,019 | [
{
"from": "human",
"value": "The title should say it all, then I can solidify 2 more ticks on the Joel test. \nI've implemented build automation using a makefile and a python script already and I understand the basics and the options. \nBut how can I, the new guy who reads the blogs, convince my cohort of i... |
I am pulling a long timestamp from a database, but want to present it as a Date using Tags only, no embedded java in the JSP. I've created my own tag to do this because I was unable to get the parseDate and formatDate tags to work, but that's not to say they don't work.
Any advice?
Thanks.
| Certainly! If you're looking to display a long timestamp as a formatted date using custom tags in JSP, you can achieve this by creating a custom JSP tag that handles the date formatting. Below, I'll guide you through the process of creating a simple custom tag to format the timestamp.
### Step 1: Create a Custom Tag
... | 7,023 | [
{
"from": "human",
"value": "I am pulling a long timestamp from a database, but want to present it as a Date using Tags only, no embedded java in the JSP. I've created my own tag to do this because I was unable to get the parseDate and formatDate tags to work, but that's not to say they don't work.\n\nAny a... |
I am using ActiveScaffold in a Ruby on Rails app, and have replaced the default "actions" text in the table (ie. "edit", "delete", "show") with icons using CSS. I have also added a couple of custom actions with action_link.add ("move" and "copy").
For clarity, I would like to have the icons displayed in a different ord... | To achieve the desired order of action icons in ActiveScaffold, you can indeed redefine the "edit" action as a custom action. This way, it allows you to place it wherever you want among your custom actions. Here's a step-by-step guide on how to do it:
1. **Remove Default Actions**: First, you will need to exclude all ... | 7,328 | [
{
"from": "human",
"value": "I am using ActiveScaffold in a Ruby on Rails app, and have replaced the default \"actions\" text in the table (ie. \"edit\", \"delete\", \"show\") with icons using CSS. I have also added a couple of custom actions with action_link.add (\"move\" and \"copy\").\nFor clarity, I wou... |
I have an application, built using MVC, that produces a view which delivers summary information across a number of models. Further to that, some calculations are performed across the different sets of data.
There's no clear single model (that maps to a table at least) that seems to make sense as the starting point for ... | In an MVC architecture, maintaining a clean separation of concerns is crucial, and it's understandable that you're looking for a better way to handle your summary information and calculations across different models. Here's a breakdown of options and recommendations for structuring this logic in your Rails application:... | 6,410 | [
{
"from": "human",
"value": "I have an application, built using MVC, that produces a view which delivers summary information across a number of models. Further to that, some calculations are performed across the different sets of data.\nThere's no clear single model (that maps to a table at least) that seem... |
I have a script that works fine on my test server (using IIS6). The script processes an ajax request and sends a response with the following line:
header( 'application/javascript' );
But on my live server, this line crashes the page and causes a 500 error.
Do I need to allow PHP to send different MIME types in IIS7? I... | In IIS7 (and later versions), you might encounter issues with certain MIME types if they are not configured correctly. To resolve the 500 Internal Server Error when using the `header('application/javascript');` line in your PHP script, you need to ensure that IIS recognizes this MIME type.
Here’s how to configure the ... | 7,920 | [
{
"from": "human",
"value": "I have a script that works fine on my test server (using IIS6). The script processes an ajax request and sends a response with the following line:\nheader( 'application/javascript' );\n\nBut on my live server, this line crashes the page and causes a 500 error.\nDo I need to allo... |
In trying to figure out this problem (which is still unsolved and I still have no clue what is going on), I am wondering if maybe an external reference to the table in question is causing the problem. For example, a trigger or view or some other such thing.
Is there an easy way to find all references to a given databa... | In DB2, you can find references to a given database table, including views, triggers, and constraints, using system catalog tables. Below are some SQL queries that can help you identify these references. You can execute these queries directly in the command line interface for DB2.
1. **Find Views that reference the ta... | 6,012 | [
{
"from": "human",
"value": "In trying to figure out this problem (which is still unsolved and I still have no clue what is going on), I am wondering if maybe an external reference to the table in question is causing the problem. For example, a trigger or view or some other such thing.\nIs there an easy wa... |
I am trying to write a C# client to a server that is written in Java. The server expects a 4 byte (DataInputStread readInt() in Java) message header followed by the actual message.
I am absolutely new to C#, how can I send this message header over to the Java Server? I tried it several ways (mostly trial and error with... | To send a message header to a Java server from a C# client, you'll want to ensure that the header is formatted correctly as a 4-byte integer. In Java, the `DataInputStream.readInt()` method reads the first 4 bytes as a big-endian integer, which is the default byte order in Java.
Here’s how to implement a C# client tha... | 8,023 | [
{
"from": "human",
"value": "I am trying to write a C# client to a server that is written in Java. The server expects a 4 byte (DataInputStread readInt() in Java) message header followed by the actual message.\nI am absolutely new to C#, how can I send this message header over to the Java Server? I tried it... |
I have a website in which I want to be able to detect a certain user based upon a permanent attribute of a specific user.
My original plan was to use an ip address but those are difficult to maintain since they can change frequently.
Cookie's and Sessions are almost out of question because they expire and tend to be di... | Detecting a specific user reliably without using logins, passwords, or ephemeral mechanisms like cookies and sessions can be quite challenging, especially due to privacy concerns and browser restrictions. Here are a few approaches you could consider:
### 1. Browser Fingerprinting:
Browser fingerprinting involves colle... | 7,038 | [
{
"from": "human",
"value": "I have a website in which I want to be able to detect a certain user based upon a permanent attribute of a specific user.\nMy original plan was to use an ip address but those are difficult to maintain since they can change frequently.\nCookie's and Sessions are almost out of que... |
Given the following JSON Date representation:
"\/Date(1221644506800-0700)\/"
How do you deserialize this into it's JavaScript Date-type form?
I've tried using MS AJAX JavaScrioptSerializer as shown below:
Sys.Serialization.JavaScriptSerializer.deserialize("\/Date(1221644506800-0700)\/")
However, all I get back is the... | The JSON Date representation you provided is a format used by some .NET libraries to serialize dates. Unfortunately, JavaScript's native JSON parsing does not automatically convert this format into a Date object. To deserialize this into a JavaScript `Date`, you will need to manually extract the timestamp and timezone ... | 8,639 | [
{
"from": "human",
"value": "Given the following JSON Date representation:\n\"\\/Date(1221644506800-0700)\\/\"\n\nHow do you deserialize this into it's JavaScript Date-type form?\nI've tried using MS AJAX JavaScrioptSerializer as shown below:\nSys.Serialization.JavaScriptSerializer.deserialize(\"\\/Date(122... |
Somehow my FireFox 2 got corrupted, and the status bar is about 3/4" above the bottom window border.
Anyone have an idea on how to get it back to being flush with the bottom window border?
| It sounds like you're experiencing a layout issue with your Firefox 2 installation. Here are a few steps you can try to resolve the issue and restore the status bar to its proper position:
1. **Restart Firefox**: Sometimes a simple restart can fix minor display issues.
2. **Reset the Status Bar**:
- Right-click on... | 8,215 | [
{
"from": "human",
"value": "Somehow my FireFox 2 got corrupted, and the status bar is about 3/4\" above the bottom window border.\nAnyone have an idea on how to get it back to being flush with the bottom window border?\n"
},
{
"from": "gpt",
"value": "It sounds like you're experiencing a layout... |
In Prototype I can show a "loading..." image with this code:
var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars,
onLoading: showLoad, onComplete: showResponse} );
function showLoad () {
...
}
In jQuery, I can load a server page into an element with this:
$('#message').load('index.php?pg=ajaxFla... | In jQuery, you can easily attach a loading spinner to the `.load()` method by using the `beforeSend` and `complete` callbacks. Here's how you can modify your code to include a loading spinner:
```javascript
// Show loading spinner function
function showLoad() {
$('#spinner').show(); // Show the loading spinner
}
... | 9,026 | [
{
"from": "human",
"value": "In Prototype I can show a \"loading...\" image with this code:\nvar myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, \nonLoading: showLoad, onComplete: showResponse} );\n\nfunction showLoad () {\n ...\n}\n\nIn jQuery, I can load a server page into an element ... |
At the company I work for we have a "Utility" project that is referenced by pretty much ever application we build. It's got lots of things like NullHelpers, ConfigSettingHelpers, Common ExtensionMethods etc.
The way we work is that when we want to make a new project, we get the latest version of the project from source... | Your situation is a common challenge faced by many development teams, especially as projects grow and more applications rely on shared libraries. Transitioning from project references to a versioned library (DLL) approach can help mitigate breaking changes and increase stability across your projects. Here are some alte... | 6,676 | [
{
"from": "human",
"value": "At the company I work for we have a \"Utility\" project that is referenced by pretty much ever application we build. It's got lots of things like NullHelpers, ConfigSettingHelpers, Common ExtensionMethods etc.\nThe way we work is that when we want to make a new project, we get t... |
While browsing with Chrome, I noticed that it responds extremely fast (in comparison with IE and Firefox on my laptop) in terms of rendering pages, including JavaScript heavy sites like gmail.
This is what googlebook on Chrome has to say
tabs are hosted in process rather than thread.
compile javascript using V8 engin... | Google Chrome has indeed implemented several innovative techniques that contribute to its performance, particularly with JavaScript-heavy applications. While many of the concepts you've mentioned are not entirely unique to Chrome, its implementation and combination of these techniques have made it particularly effectiv... | 6,264 | [
{
"from": "human",
"value": "While browsing with Chrome, I noticed that it responds extremely fast (in comparison with IE and Firefox on my laptop) in terms of rendering pages, including JavaScript heavy sites like gmail.\nThis is what googlebook on Chrome has to say \n\ntabs are hosted in process rather th... |
By default netbeans stores it's settings in a directory called .netbeans under the user's home directory. Is it possible to change the location of this directory (especially under Windows)?
Thanks to James Schek I now know the answer (change the path in netbeans.conf) but that leads me to another question:
Is there a ... | In NetBeans, you can change the default user directory by modifying the `netbeans.conf` file, as you've mentioned. However, when it comes to incorporating environment variables like the current username into the path, the `netbeans.conf` file itself does not directly support variable expansion in the way you're trying ... | 10,153 | [
{
"from": "human",
"value": "By default netbeans stores it's settings in a directory called .netbeans under the user's home directory. Is it possible to change the location of this directory (especially under Windows)?\nThanks to James Schek I now know the answer (change the path in netbeans.conf) but that ... |
I'm trying to come up with a design for a thread pool with a lot of design requirements for my job. This is a real problem for working software, and it's a difficult task. I have a working implementation but I'd like to throw this out to SO and see what interesting ideas people can come up with, so that I can compare ... | Designing a thread pool that meets your outlined requirements is a complex task, but it can be broken down into several key components and considerations. Below is an outline of a potential design that incorporates your specifications, along with some notes on each aspect of the implementation.
### Overall Structure
... | 5,998 | [
{
"from": "human",
"value": "I'm trying to come up with a design for a thread pool with a lot of design requirements for my job. This is a real problem for working software, and it's a difficult task. I have a working implementation but I'd like to throw this out to SO and see what interesting ideas people... |
When a user goes to my site, my script checks for 2 cookies which store the user id + part of the password, to automatically log them in.
It's possible to edit the contents of cookies via a cookie editor, so I guess it's possible to add some malicious content to a written cookie?
Should I add mysql_real_escape_string ... | Using cookies to store sensitive information such as user IDs and passwords is generally not a good practice, as it can expose users to various security vulnerabilities, including cookie tampering. Let's discuss some best practices for handling authentication and cookies.
### Security Concerns with Cookies
1. **Cooki... | 6,534 | [
{
"from": "human",
"value": "When a user goes to my site, my script checks for 2 cookies which store the user id + part of the password, to automatically log them in. \nIt's possible to edit the contents of cookies via a cookie editor, so I guess it's possible to add some malicious content to a written cook... |
Better yet, how can I make My Computer always open in Explorer as well?
I usually make a shortcut to my programming directories on my quick launch bar, but I'd love for them to open in Explorer.
| To ensure that your folders always open in Windows Explorer instead of any other application, you can adjust the settings or create shortcuts that explicitly open folders in Explorer. Here’s how to do it:
### 1. **Set Folder Options**
- **Open File Explorer:** Open any folder or press `Win + E`.
- **Access Optio... | 6,544 | [
{
"from": "human",
"value": "Better yet, how can I make My Computer always open in Explorer as well?\nI usually make a shortcut to my programming directories on my quick launch bar, but I'd love for them to open in Explorer.\n"
},
{
"from": "gpt",
"value": "To ensure that your folders always ope... |
I'm about to start a project that will record and edit audio files, and I'm looking for a good library (preferably Ruby, but will consider anything other than Java or .NET) for on-the-fly visualization of waveforms.
Does anybody know where I should start my search?
| For audio recording, editing, and visualization in Ruby, you have a few options to consider. Since you're specifically looking for libraries that can visualize waveforms on-the-fly, here are some recommendations:
### Ruby Libraries
1. **WaveFile**: This library can read and write WAV files. While it doesn’t directly p... | 6,014 | [
{
"from": "human",
"value": "I'm about to start a project that will record and edit audio files, and I'm looking for a good library (preferably Ruby, but will consider anything other than Java or .NET) for on-the-fly visualization of waveforms.\nDoes anybody know where I should start my search?\n"
},
{
... |
Given a datetime.time value in Python, is there a standard way to add an integer number of seconds to it, so that 11:34:59 + 3 = 11:35:02, for example?
These obvious ideas don't work:
>>> datetime.time(11, 34, 59) + 3
TypeError: unsupported operand type(s) for +: 'datetime.time' and 'int'
>>> datetime.time(11, 34, 59) ... | You're correct that `datetime.time` objects in Python do not support direct arithmetic operations like adding integers or `timedelta` objects. The `datetime.time` class represents a time (hour, minute, second) without any associated date, and as such, lacks the context needed for operations that change the time in a wa... | 7,823 | [
{
"from": "human",
"value": "Given a datetime.time value in Python, is there a standard way to add an integer number of seconds to it, so that 11:34:59 + 3 = 11:35:02, for example?\nThese obvious ideas don't work:\n>>> datetime.time(11, 34, 59) + 3\nTypeError: unsupported operand type(s) for +: 'datetime.ti... |
I'm writing an app to help facilitate some research, and part of this involves doing some statistical calculations. Right now, the researchers are using a program called SPSS. Part of the output that they care about looks like this:
They're really only concerned about the F and Sig. values. My problem is that I have n... | It sounds like you're trying to replicate some statistical tests that SPSS performs. In SPSS, the F-value typically comes from analysis of variance (ANOVA) or regression analysis, which are both common statistical tests. Here are a few common contexts in which the F-value and associated significance (Sig.) would be pre... | 479 | [
{
"from": "human",
"value": "I'm writing an app to help facilitate some research, and part of this involves doing some statistical calculations. Right now, the researchers are using a program called SPSS. Part of the output that they care about looks like this:\n\nThey're really only concerned about the F a... |
Seriously, I've trawled MSDN and only got half answers - what do the columns on the Task Manager mean? Why can't I calculate the VM Usage by enumerating threads, modules, heaps &c.? How can I be sure I am accurately reporting to clients of my memory manager how much address space is left? Are their myriad collisions... | Understanding the Task Manager and its memory-related metrics can indeed be a bit tricky. Let’s break down the columns you see in the Task Manager and clarify how to interpret them.
### Task Manager Memory Columns
1. **Memory**: This represents the physical memory (RAM) being used by a process. It can be seen as the ... | 4,006 | [
{
"from": "human",
"value": "Seriously, I've trawled MSDN and only got half answers - what do the columns on the Task Manager mean? Why can't I calculate the VM Usage by enumerating threads, modules, heaps &c.? How can I be sure I am accurately reporting to clients of my memory manager how much address sp... |
Using Oracle 10g with our testing server what is the most efficient/easy way to backup and restore a database to a static point, assuming that you always want to go back to the given point once a backup has been created.
A sample use case would be the following
install and configure all software
Modify data to the bas... | To achieve your goal of backing up and restoring an Oracle 10g database to a static point efficiently, you can utilize RMAN (Recovery Manager). RMAN is a powerful tool that provides a simple and efficient way to manage backups and restores of Oracle databases. Below is a step-by-step guide on how to take a backup and r... | 6,153 | [
{
"from": "human",
"value": "Using Oracle 10g with our testing server what is the most efficient/easy way to backup and restore a database to a static point, assuming that you always want to go back to the given point once a backup has been created.\nA sample use case would be the following\n\ninstall and c... |
Let's say we have the following method declaration:
Public Function MyMethod(ByVal param1 As Integer, _
Optional ByVal param2 As Integer = 0, _
Optional ByVal param3 As Integer = 1) As Integer
Return param1 + param2 + param3
End Function
How does VB.NET make the optional parameters work within the confine... | In VB.NET, optional parameters allow you to omit certain arguments when calling a method, which simplifies method calls when defaults are acceptable. These parameters are specified using the `Optional` keyword, and they can have a default value assigned, as demonstrated in your method declaration.
### How Optional Par... | 8,879 | [
{
"from": "human",
"value": "Let's say we have the following method declaration:\nPublic Function MyMethod(ByVal param1 As Integer, _\n Optional ByVal param2 As Integer = 0, _\n Optional ByVal param3 As Integer = 1) As Integer\n\n Return param1 + param2 + param3\nEnd Function\n\nHow does VB.NET mak... |
How can I add a column with a default value to an existing table in SQL Server 2000 / SQL Server 2005?
| To add a column with a default value to an existing table in SQL Server 2000 or SQL Server 2005, you can use the `ALTER TABLE` statement. Here is the general syntax:
```sql
ALTER TABLE table_name
ADD new_column_name data_type [NULL | NOT NULL]
CONSTRAINT constraint_name DEFAULT default_value;
```
Here's a step-by-st... | 7,744 | [
{
"from": "human",
"value": "How can I add a column with a default value to an existing table in SQL Server 2000 / SQL Server 2005?\n"
},
{
"from": "gpt",
"value": "To add a column with a default value to an existing table in SQL Server 2000 or SQL Server 2005, you can use the `ALTER TABLE` stat... |
How would you design a database to support the following tagging features:
items can have a large number of tags
searches for all items that are tagged with a given set of tags must be quick (the items must have ALL tags, so it's an AND-search, not an OR-search)
creating/writing items may be slower to enable quick loo... | To efficiently support the tagging feature you describe, with a focus on fast AND-searches for items that are tagged with all specified tags, you can design the database using a structure that allows for effective querying while still being mindful of the trade-offs between write speed and read speed. Here’s a potentia... | 6,541 | [
{
"from": "human",
"value": "How would you design a database to support the following tagging features:\n\nitems can have a large number of tags\nsearches for all items that are tagged with a given set of tags must be quick (the items must have ALL tags, so it's an AND-search, not an OR-search)\ncreating/wr... |
I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need something fast and lightweight on the back-end that I can implement using Python that then speaks to the PostgreSQL DB v... | When evaluating web frameworks and ORMs for your project, it’s important to consider the trade-offs between flexibility, ease of use, performance, and community support. Here’s a comparison of CherryPy and Django, along with some ORM options that might fit your needs.
### CherryPy
- **Overview**: CherryPy is a minimal... | 6,628 | [
{
"from": "human",
"value": "I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need something fast and lightweight on the back-end that I can implement using Pytho... |
I am creating a Rails plugin and it is dynamically adding a method to a Helper. I just want to ensure that the method is added. How can I see if the Helper responds to the method name?
| In Ruby on Rails, if you want to check if a helper responds to a dynamically added method, you can use the `respond_to?` method. Here's how you can do this:
1. Make sure you are within the context where the helper is available, such as within a controller or a view.
2. Use the `respond_to?` method on the helper to che... | 7,761 | [
{
"from": "human",
"value": "I am creating a Rails plugin and it is dynamically adding a method to a Helper. I just want to ensure that the method is added. How can I see if the Helper responds to the method name?\n"
},
{
"from": "gpt",
"value": "In Ruby on Rails, if you want to check if a helpe... |
How do i represent CRLF using Hex in C#?
| In C#, the Carriage Return (CR) and Line Feed (LF) characters can be represented in hexadecimal format.
- Carriage Return (CR) is represented by the hexadecimal value `0x0D`.
- Line Feed (LF) is represented by the hexadecimal value `0x0A`.
If you want to represent the combination of CR and LF (which is commonly used... | 7,737 | [
{
"from": "human",
"value": "How do i represent CRLF using Hex in C#?\n"
},
{
"from": "gpt",
"value": "In C#, the Carriage Return (CR) and Line Feed (LF) characters can be represented in hexadecimal format. \n\n- Carriage Return (CR) is represented by the hexadecimal value `0x0D`.\n- Line Feed (... |
I have a web page that I have hooked up to a stored procedure. In this SQL data source, I have a parameter that I'm passing back to the stored procedure of type int.
ASP.NET seems to want to default to int32, but the number won't get higher than 6. Is it ok to override the ASP.NET default and put in 16 or will there... | In your case, it is perfectly fine to use a `short` (Int16) instead of `int` (Int32) in ASP.NET for passing parameters to your stored procedure. Since the maximum value you're dealing with is 6, which is well within the range of a 16-bit integer, there will not be any issues related to the actual data type limits.
###... | 8,717 | [
{
"from": "human",
"value": "I have a web page that I have hooked up to a stored procedure. In this SQL data source, I have a parameter that I'm passing back to the stored procedure of type int. \nASP.NET seems to want to default to int32, but the number won't get higher than 6. Is it ok to override the A... |
Having to upgrade a database schema makes installing a new release of software a lot trickier. What are the best practices for doing this?
I'm looking for a checklist or timeline of action items, such as
8:30 shut down apps
8:45 modify schema
9:15 install new apps
9:30 restart db
etc, showing how to minimize risk an... | Upgrading a database schema while ensuring minimal downtime and risk can be a complex task. Below is a detailed checklist and timeline of action items to facilitate a smooth upgrade process, considering best practices for database upgrades.
### Pre-Upgrade Preparations (Prior to upgrade day)
1. **Plan the Upgrade:**
... | 4,195 | [
{
"from": "human",
"value": "Having to upgrade a database schema makes installing a new release of software a lot trickier. What are the best practices for doing this?\nI'm looking for a checklist or timeline of action items, such as\n\n8:30 shut down apps\n8:45 modify schema\n9:15 install new apps\n9:30 r... |
We help our clients to manage and publish their media online - images, video, audio, whatever. They always ask my boss whether they can stop users from copying their media, and he asks me, and I always tell him the same thing: no. If the users can view the media, then a sufficiently determined user will always be abl... | You're right in saying that if a user can view media, a determined user can find a way to copy it. This is a fundamental limitation of digital media. While there are various Digital Rights Management (DRM) systems and techniques that can help control the distribution and copying of digital content, none of them can gua... | 8,448 | [
{
"from": "human",
"value": "We help our clients to manage and publish their media online - images, video, audio, whatever. They always ask my boss whether they can stop users from copying their media, and he asks me, and I always tell him the same thing: no. If the users can view the media, then a suffic... |
I have inherited a large legacy ColdFusion app. There are hundreds of <cfquery>some sql here #variable#</cfquery> statements that need to be parameterized along the lines of: <cfquery> some sql here <cfqueryparam value="#variable#"/> </cfquery>
How can I go about adding parameterization programmatically?
I have though... | Inheriting a legacy ColdFusion application with unparameterized SQL queries can be a daunting task. While it's true that you can use regular expressions or text processing tools like `sed` or `awk`, it's important to be cautious to avoid breaking any existing functionality in the process.
Here's a general approach you... | 7,024 | [
{
"from": "human",
"value": "I have inherited a large legacy ColdFusion app. There are hundreds of <cfquery>some sql here #variable#</cfquery> statements that need to be parameterized along the lines of: <cfquery> some sql here <cfqueryparam value=\"#variable#\"/> </cfquery>\nHow can I go about adding para... |
I am developing an application, and have URLs in the format www.example.com/some_url/some_parameter/some_keyword. I know by design that there is a maximum length that these URLs will have (and still be valid). Should I validate the URL length with every request in order to protect against buffer overflow/injection atta... | Validating the URL length in your application is indeed an important step in maintaining security and stability, and you're right to consider it as a defense against potential attacks, including buffer overflow and injection attacks. Here are some key points to consider:
1. **Input Validation**: Always validate all in... | 8,881 | [
{
"from": "human",
"value": "I am developing an application, and have URLs in the format www.example.com/some_url/some_parameter/some_keyword. I know by design that there is a maximum length that these URLs will have (and still be valid). Should I validate the URL length with every request in order to prote... |
I'm looking for a tool that will reverse engineer Java into a sequence diagram BUT also provides the ability to filter out calls to certain libraries.
For example, the Netbeans IDE does a fantastic job of this but it includes all calls to String or Integer which clutter up the diagram to the point it is unusable.
Any... | For reverse engineering Java code into sequence diagrams with the ability to filter out specific libraries or classes, there are a few tools you might consider:
1. **PlantUML**:
- PlantUML is a popular tool for creating UML diagrams from plain text descriptions. While it doesn't directly reverse engineer Java code,... | 6,969 | [
{
"from": "human",
"value": "I'm looking for a tool that will reverse engineer Java into a sequence diagram BUT also provides the ability to filter out calls to certain libraries. \nFor example, the Netbeans IDE does a fantastic job of this but it includes all calls to String or Integer which clutter up the... |
When writing database queries in something like TSQL or PLSQL, we often have a choice of iterating over rows with a cursor to accomplish the task, or crafting a single SQL statement that does the same job all at once.
Also, we have the choice of simply pulling a large set of data back into our application and then proc... | When working with databases, it's generally better to use set-based queries instead of cursor-based approaches for several reasons. The main advantages of set-based operations include performance, readability, maintainability, and leveraging the power of the database management system (DBMS). Let's discuss these aspect... | 5,145 | [
{
"from": "human",
"value": "When writing database queries in something like TSQL or PLSQL, we often have a choice of iterating over rows with a cursor to accomplish the task, or crafting a single SQL statement that does the same job all at once.\nAlso, we have the choice of simply pulling a large set of da... |
I have a solution with several projects in Visual 2008, let's say SuggestionProcessor (a class library) and Suggestions (a website) with a webhandler GetSuggestions.ashx. I changed a method in SuggestionProcessor which is used in the webhandler. The call in the webhandler has been adjusted to the changed method.
But no... | It seems like you are encountering a few issues that may stem from project references and build order in Visual Studio 2008. Here are some steps you can follow to troubleshoot and resolve your issue:
1. **Clean Solution**: Start by performing a clean of the solution. Right-click on the solution in Solution Explorer an... | 7,926 | [
{
"from": "human",
"value": "I have a solution with several projects in Visual 2008, let's say SuggestionProcessor (a class library) and Suggestions (a website) with a webhandler GetSuggestions.ashx. I changed a method in SuggestionProcessor which is used in the webhandler. The call in the webhandler has be... |
I have an existing codebase targeting a Windows environment and with an eye to the future, would like to make this as cross platform as possible.
I've had some sucess with standard Linux distributions by using cross platform libraries but would like to extend this to Realtime and or embedded operating systems.
Would it... | Porting a codebase from a Windows environment to real-time and embedded operating systems (RTOS/embedded OS) is certainly feasible, but it often requires careful planning and modifications due to the distinct characteristics and constraints of these environments. Here are some considerations to help guide your efforts:... | 6,877 | [
{
"from": "human",
"value": "I have an existing codebase targeting a Windows environment and with an eye to the future, would like to make this as cross platform as possible.\nI've had some sucess with standard Linux distributions by using cross platform libraries but would like to extend this to Realtime a... |
When I run a Flex application in the debug flash player I get an exception pop up as soon as something unexpected happened. However when a customer uses the application he does not use the debug flash player. In this case he does not get an exception pop up, but he UI is not working.
So for supportability reasons, I wo... | In Flex applications, there's no global try/catch block that you can apply to all UI components or MXML code directly. However, you can implement global error handling in Flex to catch any uncaught exceptions and display a user-friendly error message. Here are some approaches to achieve this:
### 1. Use the `addEventL... | 6,854 | [
{
"from": "human",
"value": "When I run a Flex application in the debug flash player I get an exception pop up as soon as something unexpected happened. However when a customer uses the application he does not use the debug flash player. In this case he does not get an exception pop up, but he UI is not wor... |
With the DataGridView it is possible to display cells containing some long text. The grid just increases the row height to display all the text, taking care of word wrap and linefeeds.
Data entry is possible as well. Control+Return inserts a line feed.
But: if the cell only has one line of text initially, the row heigh... | To make the DataGridView automatically adjust the row height as you enter text into a cell, you can handle the `EditingControlShowing` event of the DataGridView. By doing so, you can access the current editing control (which is usually a `TextBox`), and set its properties to allow for automatic resizing.
Here are the ... | 6,220 | [
{
"from": "human",
"value": "With the DataGridView it is possible to display cells containing some long text. The grid just increases the row height to display all the text, taking care of word wrap and linefeeds.\nData entry is possible as well. Control+Return inserts a line feed.\nBut: if the cell only ha... |
The following XHTML code is not working:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" ... | Based on the provided XHTML code and the error message you encountered, there are several potential issues that could be causing the problem. Here are some suggestions to resolve them:
### 1. Incorrect Usage of `<script>` Tag
In XHTML, self-closing script tags like `<script />` are not valid. Instead, you should use a... | 6,608 | [
{
"from": "human",
"value": "The following XHTML code is not working:\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charse... |
Sure, we can use a simple bulleted list or a mindmap. But, there must be a better, more interactive way. What do you use when starting your website architecture?
| When starting to plan website architecture, there are several interactive and effective methods that can be employed beyond simple lists or mind maps. Here are some options you might consider:
1. **Wireframing Tools**:
- Use tools like Figma, Sketch, or Adobe XD to create wireframes. This allows for visual represen... | 9,457 | [
{
"from": "human",
"value": "Sure, we can use a simple bulleted list or a mindmap. But, there must be a better, more interactive way. What do you use when starting your website architecture?\n"
},
{
"from": "gpt",
"value": "When starting to plan website architecture, there are several interact... |
I'm looking for design\architectual guidance for modern text editors.
Modern text editor means that:
It has support for syntax highlighting
It has auto-completion (something like IntelliSense)
It has advanced navigation capabilities (incremental search, etc.)
Following properties will be a plus:
Implemented in man... | Here are some resources, articles, and open-source projects that focus on the design and architecture of modern text editors, particularly those that meet your specified requirements:
### Design and Architectural Guidance
1. **Text Editor Architectures:**
- **The Architecture of a Text Editor: A Case Study** - Thi... | 6,422 | [
{
"from": "human",
"value": "I'm looking for design\\architectual guidance for modern text editors.\nModern text editor means that: \n\nIt has support for syntax highlighting\nIt has auto-completion (something like IntelliSense)\nIt has advanced navigation capabilities (incremental search, etc.)\n\nFollowi... |
I'm looking for someone reasonably cheap but better than the majority of budget hosts out there. I'm currently with brinkster.net and I've become increasingly annoyed at the their immense unreliability and low available resources.
Fasthosts business plan is close, but has no mysql, only has ASP.NET 2.0 and is maybe sli... | Finding a reliable hosting provider that offers good value for money can be challenging, especially if you've had a negative experience with a previous host. Here are some hosting providers that might meet your requirements—offering reasonable pricing, good performance, and essential features like MySQL support and new... | 9,679 | [
{
"from": "human",
"value": "I'm looking for someone reasonably cheap but better than the majority of budget hosts out there. I'm currently with brinkster.net and I've become increasingly annoyed at the their immense unreliability and low available resources.\nFasthosts business plan is close, but has no my... |
on Windows systems. I get the following NPE with the FileChooser. It is a known bug that is not fixed by sun yet. https://bugs.java.com/bugdatabase/view_bug?bug_id=6342301
Does somebody know a workaround to prevent this exception?
Thanks.
André
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at
j... | The `NullPointerException` (NPE) you are encountering in the `FileChooser` on Windows systems can indeed be frustrating, especially since it's a known bug in certain versions of Java. While there may not be a direct fix, here are some potential workarounds you can consider:
1. **Update Java**: Ensure that you are usin... | 8,306 | [
{
"from": "human",
"value": "on Windows systems. I get the following NPE with the FileChooser. It is a known bug that is not fixed by sun yet. https://bugs.java.com/bugdatabase/view_bug?bug_id=6342301\nDoes somebody know a workaround to prevent this exception?\nThanks.\nAndré\n\nException in thread \"AWT-Ev... |
I'm using Windows and I'm trying to get ANT to work.
When I do an ant build from the command line, I get:
C:\dev\Projects\springapp\${%ANT_HOME%}\lib not found.
I look into the build.xml file and I find:
appserver.home=${user.home}/apache-tomcat-6.0.14 (which I just copied and pasted straight from a tutorial)
I changed... | The issue you're encountering is indeed related to how paths with spaces are handled in XML files, as well as in the command line. To properly handle spaces in paths within your `build.xml` file for Ant, you should use a combination of single quotes, double quotes, and escaped characters.
Here’s how to fix your path:
... | 9,337 | [
{
"from": "human",
"value": "I'm using Windows and I'm trying to get ANT to work.\nWhen I do an ant build from the command line, I get:\nC:\\dev\\Projects\\springapp\\${%ANT_HOME%}\\lib not found.\nI look into the build.xml file and I find:\nappserver.home=${user.home}/apache-tomcat-6.0.14 (which I just cop... |
I'm trying to convince my providers to use ANT instead of Rational Application Development so anyone can recompile, recheck, redeploy the solution anyplace, anytime, anyhow. :P
I started a build.xml for a project that generates a JAR file but stopped there and I need real examples to compare notes. My good friends! I d... | I understand you're looking to migrate from Rational Application Developer (RAD) to Apache Ant for building your Java applications, and you want examples to compare with your `build.xml`. While I can't access external links directly (like pastebin.ca), I can help you by providing a basic `build.xml` template and explai... | 4,314 | [
{
"from": "human",
"value": "I'm trying to convince my providers to use ANT instead of Rational Application Development so anyone can recompile, recheck, redeploy the solution anyplace, anytime, anyhow. :P\nI started a build.xml for a project that generates a JAR file but stopped there and I need real examp... |
I need an algorithm that can determine whether two images are 'similar' and recognizes similar patterns of color, brightness, shape etc.. I might need some pointers as to what parameters the human brain uses to 'categorize' images. ..
I have looked at hausdorff based matching but that seems mainly for matching transfo... | Determining whether two images are similar involves a combination of various techniques from image processing and computer vision. Here are some approaches and parameters that the human brain uses to categorize images, which can guide you in designing an algorithm:
### Key Parameters for Image Similarity
1. **Color F... | 7,687 | [
{
"from": "human",
"value": "I need an algorithm that can determine whether two images are 'similar' and recognizes similar patterns of color, brightness, shape etc.. I might need some pointers as to what parameters the human brain uses to 'categorize' images. .. \nI have looked at hausdorff based matching ... |
How can I get the IDENTITY of an inserted row?
I know about @@IDENTITY and IDENT_CURRENT and SCOPE_IDENTITY, but don't understand the implications or impacts attached to each. How do these differ, and when would each be used?
| When working with SQL Server, obtaining the IDENTITY value of an inserted row can be done using three different methods: `@@IDENTITY`, `IDENT_CURRENT`, and `SCOPE_IDENTITY`. Each of these methods has specific implications and usage scenarios. Here’s a breakdown of each:
### 1. `@@IDENTITY`
- **Definition**: Returns th... | 4,751 | [
{
"from": "human",
"value": "How can I get the IDENTITY of an inserted row?\nI know about @@IDENTITY and IDENT_CURRENT and SCOPE_IDENTITY, but don't understand the implications or impacts attached to each. How do these differ, and when would each be used?\n"
},
{
"from": "gpt",
"value": "When wo... |
As a general rule, I prefer using value rather than pointer semantics in C++ (ie using vector<Class> instead of vector<Class*>). Usually the slight loss in performance is more than made up for by not having to remember to delete dynamically allocated objects.
Unfortunately, value collections don't work when you want to... | In C++, if you want to achieve value semantics with polymorphism for a hierarchy of classes, you cannot directly store objects of derived types in a vector of base class objects (like `std::vector<Parent>`), because that results in object slicing. When you store a derived class object in a container of base class objec... | 5,439 | [
{
"from": "human",
"value": "As a general rule, I prefer using value rather than pointer semantics in C++ (ie using vector<Class> instead of vector<Class*>). Usually the slight loss in performance is more than made up for by not having to remember to delete dynamically allocated objects.\nUnfortunately, val... |
Many applications have grids that display data from a database table one page at a time. Many of them also let the user pick the number of records per page, sort by any column, and navigate back and forth through the results.
What's a good algorithm to implement this pattern without bringing the entire table to the cli... | To implement pagination, sorting, and filtering effectively in a database-backed application without loading the entire dataset into the client, you'll want to utilize server-side processing. The general approach is to craft your database queries to return only the specific subset of records that you need for display. ... | 4,843 | [
{
"from": "human",
"value": "Many applications have grids that display data from a database table one page at a time. Many of them also let the user pick the number of records per page, sort by any column, and navigate back and forth through the results.\nWhat's a good algorithm to implement this pattern wi... |
I started a project a long time ago and created a Data Access Layer project in my solution but have never developed anything in it. What is the purpose of a data access layer? Are there any good sources that I could learn more about the Data Access Layer?
| The Data Access Layer (DAL) is a crucial component of many software applications, particularly in multi-tier architectures. Here are some key purposes and benefits of implementing a DAL:
### Purpose of a Data Access Layer (DAL)
1. **Separation of Concerns**: The DAL separates the business logic of the application fro... | 6,765 | [
{
"from": "human",
"value": "I started a project a long time ago and created a Data Access Layer project in my solution but have never developed anything in it. What is the purpose of a data access layer? Are there any good sources that I could learn more about the Data Access Layer?\n"
},
{
"from... |
Is it possible to detect the HTTP request method (e.g. GET or POST) of a page from JavaScript? If so, how?
| In JavaScript running in a web browser, you cannot directly detect the HTTP request method (GET, POST, etc.) that was used to load the current page. The browser does not expose this information to the JavaScript environment for security and privacy reasons.
However, you can determine the request method for an AJAX req... | 9,694 | [
{
"from": "human",
"value": "Is it possible to detect the HTTP request method (e.g. GET or POST) of a page from JavaScript? If so, how?\n"
},
{
"from": "gpt",
"value": "In JavaScript running in a web browser, you cannot directly detect the HTTP request method (GET, POST, etc.) that was used to ... |
Does anyone know of a good tool to generate the WSDL for a service contract written in C# (i.e. set of methods that are tagged as "[OperationContract]" using WCF)? All the tools I've found work the other way around: create code stubs from a WSDL. I don't want to have to hand-jam a WSDL file. I've found tools for php... | Yes, you can generate the WSDL for a WCF service contract in C# without having to create the WSDL manually. WCF has built-in support for generating WSDL from the service contracts you've defined using `[ServiceContract]` and `[OperationContract]` attributes.
Here’s how you can do it:
1. **Hosting Your WCF Service**: ... | 10,343 | [
{
"from": "human",
"value": "Does anyone know of a good tool to generate the WSDL for a service contract written in C# (i.e. set of methods that are tagged as \"[OperationContract]\" using WCF)? All the tools I've found work the other way around: create code stubs from a WSDL. I don't want to have to hand... |
I have an ASP.net Application that runs on the internal network (well, actually it's running on Sharepoint 2007).
I just wonder:
Can I somehow retrieve the name of the PC the Client is using? I would have access to Active Directory if that helps. The thing is, people use multiple PCs. So, I cannot use any manual/stat... | Retrieving the name of the client PC that is accessing a SharePoint 2007 application (or any ASP.NET application running on an intranet) poses some challenges, especially since you want to avoid using client-side methods, like JavaScript. Unfortunately, obtaining the client PC name directly from the server-side code is... | 6,479 | [
{
"from": "human",
"value": "I have an ASP.net Application that runs on the internal network (well, actually it's running on Sharepoint 2007). \nI just wonder:\nCan I somehow retrieve the name of the PC the Client is using? I would have access to Active Directory if that helps. The thing is, people use mul... |
Speaking as a non-C# savvy programmer, I'm curious as to the evaluation semantics of LINQ queries like the following:
var people = from p in Person
where p.age < 18
select p
var otherPeople = from p in people
where p.firstName equals "Daniel"
select p
Assu... | Great question! The way LINQ queries are evaluated, especially in the context of Entity Framework or other ORM frameworks that interact with databases, can be quite nuanced. Let's break down what happens in your example with `Person`, which you mentioned is an ADO entity.
### Query Evaluation in LINQ
1. **Deferred Ex... | 5,376 | [
{
"from": "human",
"value": "Speaking as a non-C# savvy programmer, I'm curious as to the evaluation semantics of LINQ queries like the following:\nvar people = from p in Person\n where p.age < 18\n select p\n\nvar otherPeople = from p in people\n where p.firstName e... |
We are trying out Visual Studio 2008 and Expression Blend on a new project. The goal is to clearly define the role of the developer and designer as separate, but reap the benefit of the developer being able to directly consume the XAML produced by the designer.
For the most part this has worked great, and I really like... | Creating mock data for use in Expression Blend can greatly enhance the design experience by allowing designers to see how the UI will look with actual data. Here’s a general approach to creating stubbed or mocked data that can be utilized in Expression Blend while still allowing the real data source to be connected at ... | 6,545 | [
{
"from": "human",
"value": "We are trying out Visual Studio 2008 and Expression Blend on a new project. The goal is to clearly define the role of the developer and designer as separate, but reap the benefit of the developer being able to directly consume the XAML produced by the designer.\nFor the most par... |
I have to admit that I always forgot the syntactical intracacies of the naming patterns for Nant (eg. those used in filesets). The double asterisk/single asterisk stuff seems to be very forgettable in my mind.
Can someone provide a definitive guide to the naming patterns?
| Certainly! In Nant (Nant is a build tool for .NET), the file patterns used for file matching can be a bit tricky, especially with the different wildcard characters. Here’s a definitive guide to the naming patterns:
### Wildcard Patterns in Nant
1. **Single Asterisk (`*`)**:
- Matches any number of characters in a ... | 8,303 | [
{
"from": "human",
"value": "I have to admit that I always forgot the syntactical intracacies of the naming patterns for Nant (eg. those used in filesets). The double asterisk/single asterisk stuff seems to be very forgettable in my mind.\nCan someone provide a definitive guide to the naming patterns?\n"
... |
I've installed Ubuntu Server (8.04) into Parallels and found that the system time/clock ran fast to the extent that it would gain hours over time.
| If your Ubuntu Server 8.04 installation in Parallels is experiencing fast clock issues, this is a common problem that can be related to several factors, such as how the virtual machine handles time synchronization. Here are some steps you can take to resolve the issue:
### 1. Use NTP for Time Synchronization
The Netw... | 7,157 | [
{
"from": "human",
"value": "I've installed Ubuntu Server (8.04) into Parallels and found that the system time/clock ran fast to the extent that it would gain hours over time.\n"
},
{
"from": "gpt",
"value": "If your Ubuntu Server 8.04 installation in Parallels is experiencing fast clock issues,... |
I'm using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency file it generates for me?
gcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) >>$(DEP)
| When generating dependency files with GCC, you can use the `-MT` option to specify the target name in the dependency output. This allows you to control the output names for the dependencies, including placing them into subdirectories.
Here is a modified version of your command that utilizes the `-MT` option to include... | 9,568 | [
{
"from": "human",
"value": "I'm using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency file it generates for me?\ngcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) >>$(DEP)\n\n"
},
{
"from": "g... |
Is it possible to get gdb or use some other tools to create a core dump of a running process and it's symbol table? It would be great if there's a way to do this without terminating the process.
If this is possible, what commands would you use? (I'm trying to do this on a Linux box)
| Yes, it is possible to create a core dump of a running process in Linux without terminating the process. You can use `gcore`, which is a tool that comes with GDB (GNU Debugger), to create a core dump of a specified running process. This allows you to capture the memory image of the process along with the symbol table i... | 7,782 | [
{
"from": "human",
"value": "Is it possible to get gdb or use some other tools to create a core dump of a running process and it's symbol table? It would be great if there's a way to do this without terminating the process. \nIf this is possible, what commands would you use? (I'm trying to do this on a L... |
When you call the object.__repr__() method in Python you get something like this back:
<__main__.Test object at 0x2aba1c0cf890>
Is there any way to get a hold of the memory address if you overload __repr__(), other then calling super(Class, obj).__repr__() and regexing it out?
| In Python, the default `__repr__()` method returns a string that includes the memory address of the object. However, if you override `__repr__()`, you lose access to that default representation unless you explicitly call the superclass's `__repr__()` method.
If you want to include the memory address in your custom `__... | 10,348 | [
{
"from": "human",
"value": "When you call the object.__repr__() method in Python you get something like this back: \n\n<__main__.Test object at 0x2aba1c0cf890> \n\n\nIs there any way to get a hold of the memory address if you overload __repr__(), other then calling super(Class, obj).__repr__() and regexing... |
I have VS2005 and I am currently trying to debug an ASP.net web application. I want to change some code around in the code behind file, but every time I stop at a break point and try to edit something I get the following error message: "Changes are not allowed when the debugger has been attached to an already running p... | The error message you're encountering indicates that you cannot modify your code while the debugger is attached and the code is running. This can happen for several reasons, even when you have "Edit and Continue" options enabled. Here are some suggestions to resolve this issue in Visual Studio 2005:
1. **Check Debuggi... | 8,922 | [
{
"from": "human",
"value": "I have VS2005 and I am currently trying to debug an ASP.net web application. I want to change some code around in the code behind file, but every time I stop at a break point and try to edit something I get the following error message: \"Changes are not allowed when the debugger... |
I'm programming in C++ on Visual Studio 2005. My question deals with .rc files. You can manually place include directives like (#include "blah.h"), at the top of an .rc file. But that's bad news since the first time someone opens the .rc file in the resource editor, it gets overwritten. I know there is a place to m... | In Visual Studio, when working with resource files (.rc files), it's indeed important to manage includes and definitions without modifying them directly, as editing the resource file in the resource editor can overwrite manual changes.
To add custom includes or definitions in a way that they are not overwritten, you ... | 9,037 | [
{
"from": "human",
"value": "I'm programming in C++ on Visual Studio 2005. My question deals with .rc files. You can manually place include directives like (#include \"blah.h\"), at the top of an .rc file. But that's bad news since the first time someone opens the .rc file in the resource editor, it gets... |
I've heard that the static_cast function should be preferred to C-style or simple function-style casting. Is this true? Why?
| Yes, it is generally true that `static_cast` (and other C++ cast operators) should be preferred over C-style casts for several reasons. Here are the key points to consider:
1. **Type Safety**: `static_cast`, along with other C++ cast operators like `dynamic_cast`, `const_cast`, and `reinterpret_cast`, provides better ... | 8,182 | [
{
"from": "human",
"value": "I've heard that the static_cast function should be preferred to C-style or simple function-style casting. Is this true? Why?\n"
},
{
"from": "gpt",
"value": "Yes, it is generally true that `static_cast` (and other C++ cast operators) should be preferred over C-styl... |
I have an object in a multi-threaded environment that maintains a collection of information, e.g.:
public IList<string> Data
{
get
{
return data;
}
}
I currently have return data; wrapped by a ReaderWriterLockSlim to protect the collection from sharing violations. However, to be doubly sure, I'd... | Yes, you can definitely return the collection as read-only to ensure that the calling code cannot modify it. This can be achieved by wrapping your list in a read-only collection. In C#, you can use `ReadOnlyCollection<T>` from `System.Collections.ObjectModel` for this purpose.
Here's an example of how you could imple... | 9,496 | [
{
"from": "human",
"value": "I have an object in a multi-threaded environment that maintains a collection of information, e.g.:\npublic IList<string> Data \n{\n get \n {\n return data;\n }\n}\n\nI currently have return data; wrapped by a ReaderWriterLockSlim to protect the collection from sh... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.