instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
Can anyone tell me if there are RDBMSs that allow me to create a separate database for every user so that there is full separation of users' data?
Are there any?
I know I can add UID to every table but this solution has its own problems (for example per user database schema changes are impossible).
| Yes, several relational database management systems (RDBMS) support the ability to create separate databases for each user, allowing for complete separation of users' data. This approach can simplify data access control and schema management but comes with trade-offs, such as potential overhead in managing multiple dat... | 14,830 | [
{
"from": "human",
"value": "Can anyone tell me if there are RDBMSs that allow me to create a separate database for every user so that there is full separation of users' data?\nAre there any?\nI know I can add UID to every table but this solution has its own problems (for example per user database schema ch... |
I'm not talking about the kind you get in college, but rather implementing progress reports on the Job for developers.
My thoughts in organizing a development team is encouraging and, to some extend, requiring regular progress updates were developers would report on what they did in the last hour or few hours and how l... | Your approach to implementing regular progress reports in a development team has both pros and cons. Below is a breakdown of the advantages and disadvantages, along with some personal insights based on common experiences in software development.
### Pros
1. **Visibility and Accountability**:
- Regular updates crea... | 14,646 | [
{
"from": "human",
"value": "I'm not talking about the kind you get in college, but rather implementing progress reports on the Job for developers.\nMy thoughts in organizing a development team is encouraging and, to some extend, requiring regular progress updates were developers would report on what they d... |
Question says it all, really.
My application is a time tracker. It's currently written as a spreadsheet, but there's just too much data and I would like to impose a bit more structure on it.
SQLite seems like a neat way to go.
I would be open to other suggestions, too.
| Using SQLite for your time tracker application is a great idea, especially if you're looking for a lightweight, serverless database that can handle structured data effectively. SQLite offers a simple and efficient way to store, query, and manage your data without the overhead of setting up a traditional database server... | 15,198 | [
{
"from": "human",
"value": "Question says it all, really. \nMy application is a time tracker. It's currently written as a spreadsheet, but there's just too much data and I would like to impose a bit more structure on it. \nSQLite seems like a neat way to go.\nI would be open to other suggestions, too. \... |
I have here 300 lines long NAnt file and it is quite a messy. I am wondering if there is a any style guide for writing NAnt scripts and what are the best practices for doing so.
Any tips?
| When working with NAnt (a build automation tool for .NET), adhering to a style guide and best practices can help make your build scripts more readable, maintainable, and efficient. Here are some guidelines and tips to consider when writing NAnt scripts:
### General Style Guidelines
1. **Consistent Indentation**:
-... | 10,507 | [
{
"from": "human",
"value": "I have here 300 lines long NAnt file and it is quite a messy. I am wondering if there is a any style guide for writing NAnt scripts and what are the best practices for doing so.\nAny tips?\n"
},
{
"from": "gpt",
"value": "When working with NAnt (a build automation to... |
I have an entity that contains many of itself, how do I map this in LINQ to SQl such that it does not do an infinite loop of getting e1 then all its children then their parents (e1) then its children and repeat? Now I know I can do this if I set the child property to false, however that is the most important property (... | To manage self-referencing entities in LINQ to SQL while preventing infinite loops during data retrieval, you can use lazy loading or explicit loading strategies. Below are some approaches you can consider:
### 1. Use Lazy Loading
If you have navigation properties in your entity model, lazy loading allows you to load... | 5,650 | [
{
"from": "human",
"value": "I have an entity that contains many of itself, how do I map this in LINQ to SQl such that it does not do an infinite loop of getting e1 then all its children then their parents (e1) then its children and repeat? Now I know I can do this if I set the child property to false, howe... |
If I'm running a signed Java applet. Can I load additional classes from remote sources, in the same domain or maybe even the same host, and run them?
I'd like to do this without changing pages or even stopping the current applet. Of course, the total size of all classes is too large to load them all at once.
Is there a... | Yes, in a signed Java applet, you can load additional classes from remote sources, provided they are in the same domain or the same host. This feature is made possible through the use of the `ClassLoader` in conjunction with some Java networking capabilities.
### Dynamic Class Loading
To dynamically load classes duri... | 12,458 | [
{
"from": "human",
"value": "If I'm running a signed Java applet. Can I load additional classes from remote sources, in the same domain or maybe even the same host, and run them?\nI'd like to do this without changing pages or even stopping the current applet. Of course, the total size of all classes is too ... |
I need a quick easy way to get a string from a file in standard C++. I can write my own, but just want to know if there is already a standard way, in C++.
Equivalent of this if you know Cocoa:
NSString *string = [NSString stringWithContentsOfFile:file];
| In standard C++, you can read a file into a string using file streams from the `<fstream>` library. While there's no single function equivalent to `NSString`'s `stringWithContentsOfFile`, you can achieve this in a few lines of code. Here is a simple example:
```cpp
#include <fstream>
#include <sstream>
#include <strin... | 16,753 | [
{
"from": "human",
"value": "I need a quick easy way to get a string from a file in standard C++. I can write my own, but just want to know if there is already a standard way, in C++.\nEquivalent of this if you know Cocoa:\nNSString *string = [NSString stringWithContentsOfFile:file];\n\n"
},
{
"fro... |
Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc.
Here is an example:
def args_as_ints(f):
def g(*args, **kwargs):
args = [int(x) for x in args]
kwargs = dict((k, int(v)) f... | To address the issue of retaining the original function's signature while using decorators in Python, you can utilize the `functools.wraps` decorator, which is specifically designed to help with this problem. The `wraps` function updates the wrapper function (`g` in your example) to look more like the original function... | 14,847 | [
{
"from": "human",
"value": "Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc.\nHere is an example:\ndef args_as_ints(f):\n def g(*args, **kwargs):\n args = [int(x) for x... |
I have a bad habit of using the cursor keys of my keyboard to navigate source code. It's something I've done for 15 years and this of course means that my navigating speed is limited by the speed of the keyboard. On both Vista and OS X (I dual boot a MacBook), I have my key repeat rate turned all the way up. But in Vis... | To increase the key repeat rate specifically in Visual Studio and other text editors, you can try the following methods:
### 1. Adjust System Key Repeat Settings
While you've mentioned adjusting the key repeat settings, make sure you've done the following for both Windows (Vista) and macOS (OS X):
#### For Windows Vi... | 14,739 | [
{
"from": "human",
"value": "I have a bad habit of using the cursor keys of my keyboard to navigate source code. It's something I've done for 15 years and this of course means that my navigating speed is limited by the speed of the keyboard. On both Vista and OS X (I dual boot a MacBook), I have my key repe... |
Is there a tool (preferably free) which will translate Oracle's PL/SQL stored procedure language into Postgresql's PL/pgSQL stored procedure language?
| There are no perfect tools that can fully automate the translation from Oracle's PL/SQL to PostgreSQL's PL/pgSQL due to differences in syntax, features, and behaviors between the two languages. However, there are some tools and resources that can assist in the process of converting stored procedures and SQL code from O... | 13,842 | [
{
"from": "human",
"value": "Is there a tool (preferably free) which will translate Oracle's PL/SQL stored procedure language into Postgresql's PL/pgSQL stored procedure language?\n"
},
{
"from": "gpt",
"value": "There are no perfect tools that can fully automate the translation from Oracle's PL... |
From what I know, the em keyword in CSS means the current size of a font.
So if you put 1.2 em, it means 120% of the font height.
It doesn't seem right though that em is used for setting the width of divs etc like YUI grids does:
margin-right:24.0769em;*margin-right:23.62em;
Everytime I read about em, I forget what it... | You're on the right track with your understanding of `em` in CSS! Let's break it down to clarify how it works and why it's used, including its application in widths and margins.
### What is `em`?
- **Definition**: The `em` unit in CSS is a relative unit of measurement that is based on the font size of the element in ... | 12,213 | [
{
"from": "human",
"value": "From what I know, the em keyword in CSS means the current size of a font.\nSo if you put 1.2 em, it means 120% of the font height.\nIt doesn't seem right though that em is used for setting the width of divs etc like YUI grids does:\nmargin-right:24.0769em;*margin-right:23.62em;\... |
Alright, so maybe I shouldn't have shrunk this question sooo much... I have seen the post on the most efficient way to find the first 10000 primes. I'm looking for all possible ways. The goal is to have a one stop shop for primality tests. Any and all tests people know for finding prime numbers are welcome.
And so:
... | Finding prime numbers is a fundamental problem in number theory and there are numerous methods and algorithms to identify prime numbers. Here’s a comprehensive list of various approaches, ranging from basic methods to more advanced algorithms:
### Basic Methods
1. **Trial Division**: Check each number for primality b... | 2,847 | [
{
"from": "human",
"value": "Alright, so maybe I shouldn't have shrunk this question sooo much... I have seen the post on the most efficient way to find the first 10000 primes. I'm looking for all possible ways. The goal is to have a one stop shop for primality tests. Any and all tests people know for fi... |
I'm currently writing an interface to allow applications to send exception data to a central repository for support purposes. I'm at a quandary about how to pass extra contextual data:
public interface IExceptionNotifier
{
void Notify(Exception ex, NameValueCollection context); //this
void Notify(Exceptio... | When choosing between `NameValueCollection` and `IDictionary<string, string>`, there are several factors to consider based on your specific use case and requirements. Here’s a breakdown of the two options:
### NameValueCollection
1. **Specialized Purpose**: `NameValueCollection` is specifically designed to hold key-v... | 12,410 | [
{
"from": "human",
"value": "I'm currently writing an interface to allow applications to send exception data to a central repository for support purposes. I'm at a quandary about how to pass extra contextual data:\npublic interface IExceptionNotifier\n{\n void Notify(Exception ex, NameValueCollection con... |
I have to work on an old 1.3 JVM and I'm asked to create a secure connection to another server. Unfortunately the HttpsURLConnection only appears sinc JVM 1.4.
Is there another way to create a secure connection? Is there a library that I could you to add this fonctionnality?
| Working with a Java 1.3 JVM presents a significant challenge, especially in the context of security and HTTPS, given that many of the modern libraries and features available in later versions of Java are simply not present. However, there are some alternative approaches you could consider for creating a secure connecti... | 13,399 | [
{
"from": "human",
"value": "I have to work on an old 1.3 JVM and I'm asked to create a secure connection to another server. Unfortunately the HttpsURLConnection only appears sinc JVM 1.4. \nIs there another way to create a secure connection? Is there a library that I could you to add this fonctionnality?\n... |
On a cross platform c/c++ project (Win32, Linux, OSX), I need to use the *printf functions to print some variables of type size_t. In some environments size_t's are 8 bytes and on others they are 4. On glibc I have %zd, and on Win32 I can use %Id. Is there an elegant way to handle this?
| To handle the printing of `size_t` variables across different platforms, you can use a preprocessor directive to define a suitable format specifier based on the platform you're compiling for. This will allow you to maintain readability and portability in your code.
Here's an approach that you can use:
1. **Define a m... | 15,766 | [
{
"from": "human",
"value": "On a cross platform c/c++ project (Win32, Linux, OSX), I need to use the *printf functions to print some variables of type size_t. In some environments size_t's are 8 bytes and on others they are 4. On glibc I have %zd, and on Win32 I can use %Id. Is there an elegant way to h... |
Which Ajax framework/toolkit can you recommend for building the GUI of web applications that are using struts?
| When building the GUI of web applications using Struts, there are several Ajax frameworks and toolkits that you can consider. Here are some popular options:
1. **jQuery**:
- jQuery is one of the most widely used JavaScript libraries. It simplifies HTML document traversal, event handling, and Ajax interactions, mak... | 13,486 | [
{
"from": "human",
"value": "Which Ajax framework/toolkit can you recommend for building the GUI of web applications that are using struts?\n"
},
{
"from": "gpt",
"value": "When building the GUI of web applications using Struts, there are several Ajax frameworks and toolkits that you can conside... |
I have been having some issues with LINQ-To-SQL around memory usage. I'm using it in a Windows Service to do some processing, and I'm looping through a large amount of data that I'm pulling back from the context. Yes - I know I could do this with a stored procedure but there are reasons why that would be a less than ... | When working with LINQ-to-SQL and especially when dealing with a large amount of data, memory management becomes crucial. Here are some strategies to help ensure that memory is managed effectively and that you minimize memory usage in your Windows Service:
1. **Using `DataContext`**: Each `DataContext` instance mainta... | 13,354 | [
{
"from": "human",
"value": "I have been having some issues with LINQ-To-SQL around memory usage. I'm using it in a Windows Service to do some processing, and I'm looping through a large amount of data that I'm pulling back from the context. Yes - I know I could do this with a stored procedure but there a... |
I'm currently generating SQL insert statements from more than one tables, and in the generated data I need to use a CASE statement, like this:
select 'INSERT INTO TABLE1 (f1, f2, f3, f4 ...) values ('
||t.f1||','
||CASE
WHEN t.f2 > 0 THEN '1'
ELSE '0'
END CASE
from tab... | It looks like there might be a syntax issue in your SQL statement, particularly with the `CASE` statement usage. The `CASE` statement in SQL does not have an `END CASE` construct; instead, you simply use `END` to close it. Additionally, you need to ensure that your concatenation is structured correctly.
Here's how you... | 15,743 | [
{
"from": "human",
"value": "I'm currently generating SQL insert statements from more than one tables, and in the generated data I need to use a CASE statement, like this:\nselect 'INSERT INTO TABLE1 (f1, f2, f3, f4 ...) values ('\n ||t.f1||','\n ||CASE\n WHEN t.f2 > 0 THEN '1'\n ... |
Would it be useful to be able to provide method return value for null objects?
For a List the null return values might be:
get(int) : null
size() : 0
iterator() : empty iterator
That would allow the following code that has less null checks.
List items = null;
if(something) {
items = ...
}
for(int index = 0; inde... | The idea of providing method return values for null objects can be beneficial in certain scenarios, especially when trying to avoid null pointer exceptions and reducing the need for null checks in your code. This approach aligns with the Null Object Pattern, where you provide a default behavior for cases that would typ... | 14,009 | [
{
"from": "human",
"value": "Would it be useful to be able to provide method return value for null objects?\nFor a List the null return values might be:\nget(int) : null\nsize() : 0\niterator() : empty iterator\n\nThat would allow the following code that has less null checks.\nList items = null;\n\nif(somet... |
I'm still trying to get my head around LINQ and accessing a SQL Database.
I was always taught that you should only have execute permissions of stored procedures to your data.
You should never have select / insert / update / delete.
(This is because of performance and security)
To get the data out of LINQ you obviously ... | You're touching on some important concepts regarding security, performance, and data access patterns when using LINQ and SQL databases. Let's break down some of these points.
### Security and Permissions
1. **Stored Procedures**: It's common practice to limit direct access to tables and instead provide stored procedu... | 13,778 | [
{
"from": "human",
"value": "I'm still trying to get my head around LINQ and accessing a SQL Database.\nI was always taught that you should only have execute permissions of stored procedures to your data.\nYou should never have select / insert / update / delete.\n(This is because of performance and security... |
I am parsing text that has a heading and then data that applies to that heading. I need to break each data field into groups, and have the heading also apply to those groups. Here's an example:
(Update: The text below has been updated to better reflect it's current layout, and to indicate an annotation.)
Heading 1... | It looks like you are trying to parse a structured text format into a more condensed format using regular expressions in .NET. The task involves capturing groups of data that are associated with changing headers, while ignoring certain labels like "(Group 1)", "(Group 2)", etc.
You can achieve this by creating a regex... | 11,942 | [
{
"from": "human",
"value": "I am parsing text that has a heading and then data that applies to that heading. I need to break each data field into groups, and have the heading also apply to those groups. Here's an example:\n(Update: The text below has been updated to better reflect it's current layout, ... |
What Javascript libraries can you recommend for syntax highlighting <code> blocks in HTML?
(One suggestion per answer please).
| One popular library for syntax highlighting in HTML is **Prism.js**. It is lightweight, extensible, and supports a wide range of languages and themes. | 20,103 | [
{
"from": "human",
"value": "What Javascript libraries can you recommend for syntax highlighting <code> blocks in HTML?\n(One suggestion per answer please).\n"
},
{
"from": "gpt",
"value": "One popular library for syntax highlighting in HTML is **Prism.js**. It is lightweight, extensible, and su... |
I've been reading through a lot of the rookie Java questions on finalize() and find it kind of bewildering that no one has really made it plain that finalize() is an unreliable way to clean up resources. I saw someone comment that they use it to clean up Connections, which is really scary since the only way to come as... | Your observations regarding the `finalize()` method in Java are indeed well-founded. The method has historically been misunderstood and misused, leading to the general consensus that it should be avoided in favor of more reliable resource management strategies.
### Issues with `finalize()`
1. **Unpredictability**: T... | 13,710 | [
{
"from": "human",
"value": "I've been reading through a lot of the rookie Java questions on finalize() and find it kind of bewildering that no one has really made it plain that finalize() is an unreliable way to clean up resources. I saw someone comment that they use it to clean up Connections, which is r... |
I'm working with ASP.NET 3.5.
I have a list box that users must add items to (I've written the code for this). My requirement is that at least one item must be added to the listbox or they cannot submit the form. I have several other validators on the page and they all write to a ValidationSummary control. I would like... | To enforce that at least one item is added to a ListBox in your ASP.NET 3.5 web application, you can create a custom validator. This custom validator will check whether any items have been added to the ListBox and, if not, will trigger a validation error that will be displayed in your ValidationSummary control.
Here's... | 10,819 | [
{
"from": "human",
"value": "I'm working with ASP.NET 3.5.\nI have a list box that users must add items to (I've written the code for this). My requirement is that at least one item must be added to the listbox or they cannot submit the form. I have several other validators on the page and they all write to... |
This is something simple I came up with for this question. I'm not entirely happy with it and I saw it as a chance to help improve my use of STL and streams based programming.
std::wifstream file(L"\\Windows\\myini.ini");
if (file)
{
bool section=false;
while (!file.eof())
{
std::wstring line;
std::getlin... | It's a good start for reading an INI file using `std::wifstream` and stream-based programming in C++. There are a few improvements and best practices you can apply to enhance readability, efficiency, and correctness. Here’s a revised version with explanations for each improvement:
1. **Use `std::getline` for Reading L... | 12,736 | [
{
"from": "human",
"value": "This is something simple I came up with for this question. I'm not entirely happy with it and I saw it as a chance to help improve my use of STL and streams based programming.\nstd::wifstream file(L\"\\\\Windows\\\\myini.ini\");\nif (file)\n{\n bool section=false;\n while (!fi... |
Is it possible to create Selenium tests using the Firefox plugin that use randomly generated values to help do regression tests?
The full story:
I would like to help my clients do acceptance testing by providing them with a suite of tests that use some smarts to create random (or at least pseudo-random) values for the ... | Yes, it is indeed possible to create Selenium tests using the Firefox plugin (Selenium IDE) that utilize randomly generated values for regression testing. While Selenium IDE does not natively support complex scripting or data manipulation as you would find in more advanced frameworks like Selenium WebDriver, there are ... | 13,707 | [
{
"from": "human",
"value": "Is it possible to create Selenium tests using the Firefox plugin that use randomly generated values to help do regression tests?\nThe full story:\nI would like to help my clients do acceptance testing by providing them with a suite of tests that use some smarts to create random ... |
Why can I not see an option for copying database objects when I right click > tasks on my database?
| If you do not see the option to "Copy" or "Copy Database" when you right-click on your database in SQL Server Management Studio (SSMS), there could be several reasons for this. Here are some possibilities:
1. **SSMS Version**: Ensure you are using a version of SQL Server Management Studio that supports the features yo... | 15,566 | [
{
"from": "human",
"value": "Why can I not see an option for copying database objects when I right click > tasks on my database? \n"
},
{
"from": "gpt",
"value": "If you do not see the option to \"Copy\" or \"Copy Database\" when you right-click on your database in SQL Server Management Studio (... |
I saw this over on slashdot and realized if I could program in dns control into some of my apps it would make life a lot easier. Someone over there recommended dynect which apparently had a wonderful api. Unfortunately not a lot else was recomended. I don't know anything about managing dns servers I mostly work with th... | There are several DNS services that offer APIs and are user-friendly for developers looking to manage DNS records programmatically. Here are some options you might consider:
1. **Cloudflare**:
- **API**: Cloudflare provides a robust API for DNS management, allowing you to add, update, and delete DNS records program... | 14,163 | [
{
"from": "human",
"value": "I saw this over on slashdot and realized if I could program in dns control into some of my apps it would make life a lot easier. Someone over there recommended dynect which apparently had a wonderful api. Unfortunately not a lot else was recomended. I don't know anything about m... |
I have a basic ActiveRecord model in which i have two fields that i would like to validate. The requirement is that at least one of the fields must have a value. Both can have values, but at least one needs a value.
How do i express this with
validates_presence_of
statements? For example:
validates_presence_of :main... | To validate that at least one of the two fields (`main_file` or `alt_file`) is present in an ActiveRecord model, you cannot use `validates_presence_of` directly since it checks the presence of each field individually. Instead, you can create a custom validation method to enforce your requirement.
Here’s how you can do... | 14,220 | [
{
"from": "human",
"value": "I have a basic ActiveRecord model in which i have two fields that i would like to validate. The requirement is that at least one of the fields must have a value. Both can have values, but at least one needs a value.\nHow do i express this with \nvalidates_presence_of \n\nstateme... |
I just came across an interesting situation in JavaScript. I have a class with a method that defines several objects using object-literal notation. Inside those objects, the this pointer is being used. From the behavior of the program, I have deduced that the this pointer is referring to the class on which the metho... | In JavaScript, the behavior of `this` can sometimes be confusing, especially when dealing with methods and object literals. Let’s break down how `this` works in the context of your example.
### `this` in JavaScript
1. **Method Context**: When a method is called on an object, `this` refers to the object that the metho... | 14,981 | [
{
"from": "human",
"value": "I just came across an interesting situation in JavaScript. I have a class with a method that defines several objects using object-literal notation. Inside those objects, the this pointer is being used. From the behavior of the program, I have deduced that the this pointer is ... |
Is there anyway to upgrade the installed JRE in the system? We are having 1.5.0_08 installed in out HP Unix system.We have to upgrade this to 1.5.0_15.Is there a way to patch up the existing JRE and upgrade to a newer version.Or can this only be achieved by installing the newer JRE and set this in the system PATH.
| Upgrading the Java Runtime Environment (JRE) on a Unix system typically involves installing the new version rather than simply patching the existing installation. In your case, upgrading from JRE 1.5.0_08 to 1.5.0_15 can be done by following these steps:
1. **Download the New JRE**:
- Obtain the JRE 1.5.0_15 from t... | 15,319 | [
{
"from": "human",
"value": "Is there anyway to upgrade the installed JRE in the system? We are having 1.5.0_08 installed in out HP Unix system.We have to upgrade this to 1.5.0_15.Is there a way to patch up the existing JRE and upgrade to a newer version.Or can this only be achieved by installing the newer ... |
In my PHP web app, I want to be notified via email whenever certain errors occur. I'd like to use my Gmail account for sending these. How could this be done?
| To set up error notifications in your PHP web application using your Gmail account, you can use the PHPMailer library, which makes sending emails easier. Below is a step-by-step guide on how to implement this:
### Step 1: Install PHPMailer
You can install PHPMailer using Composer. If you haven't already set up Compos... | 10,424 | [
{
"from": "human",
"value": "In my PHP web app, I want to be notified via email whenever certain errors occur. I'd like to use my Gmail account for sending these. How could this be done?\n"
},
{
"from": "gpt",
"value": "To set up error notifications in your PHP web application using your Gmail a... |
I've come across a rather interesing (and frustrating) problem with IE6. We are serving up some server generated pdfs and then simply setting headers in PHP to force a browser download of the file. Works fine and all, except in IE6 but only if the windows user account is set to standard user (ie. not administrator).
Si... | The issue you're experiencing with Internet Explorer 6 (IE6) and PDF downloads for standard user accounts is known to be a frustrating one, particularly due to the quirks and limitations of that browser. IE6 has several peculiarities, especially around file downloads, and handling of content types can be problematic. H... | 10,103 | [
{
"from": "human",
"value": "I've come across a rather interesing (and frustrating) problem with IE6. We are serving up some server generated pdfs and then simply setting headers in PHP to force a browser download of the file. Works fine and all, except in IE6 but only if the windows user account is set to ... |
Every time I call this method my NSMutableData is leaking and I cannot figure out how to plug it. theData's retain count is upped by one after the decoder is allocated and initialized and I have no idea why. I am stuck with a retain count of 2 at the end of the method and attempting to release it causes an app crash.
-... | The issue you're encountering with memory management is due to the way you're initializing `theData`. You're using `[NSData dataWithContentsOfFile:]`, which returns an autoreleased instance of `NSData`. When you assign this to your `NSMutableData *theData` variable, you're not retaining it, and thus when the method com... | 15,637 | [
{
"from": "human",
"value": "Every time I call this method my NSMutableData is leaking and I cannot figure out how to plug it. theData's retain count is upped by one after the decoder is allocated and initialized and I have no idea why. I am stuck with a retain count of 2 at the end of the method and attemp... |
Do you know any libraries similar to java.util.Properties that support more advanced features like grouping properties, storing arrays, etc?
I am not looking for some heavy super-advanced solution, just something light and useful for any project.
Thanks.
| Yes, there are several lightweight libraries in Java that provide more advanced features than `java.util.Properties`. Here are a few options that you might find useful for your project:
1. **Apache Commons Configuration**:
- **Website**: [Apache Commons Configuration](https://commons.apache.org/proper/commons-confi... | 13,445 | [
{
"from": "human",
"value": "Do you know any libraries similar to java.util.Properties that support more advanced features like grouping properties, storing arrays, etc? \nI am not looking for some heavy super-advanced solution, just something light and useful for any project.\nThanks.\n"
},
{
"from... |
I really want to be able to have a way to take an app that currently gets its settings using ConfigurationManager.AppSettings["mysettingkey"] to actually have those settings come from a centralized database instead of the app.config file. I can make a custom config section for handling this sort of thing, but I really... | To achieve the goal of centralizing your configuration settings while still allowing your team to access them via the traditional `ConfigurationManager.AppSettings` mechanism, you can create a custom `ConfigurationSection` that hooks into the existing configuration system. Here’s a step-by-step approach to implement th... | 14,103 | [
{
"from": "human",
"value": "I really want to be able to have a way to take an app that currently gets its settings using ConfigurationManager.AppSettings[\"mysettingkey\"] to actually have those settings come from a centralized database instead of the app.config file. I can make a custom config section fo... |
I've seen lots of descriptions how anonymous types work, but I'm not sure how they're really useful. What are some scenarios that anonymous types can be used to address in a well-designed program?
| Anonymous types in C# provide a convenient way to encapsulate a set of properties into a single object without having to explicitly define a class for that object. Here are some scenarios where using anonymous types can be beneficial in a well-designed program:
1. **Quick Data Transfer:** When you need to return a sma... | 6,946 | [
{
"from": "human",
"value": "I've seen lots of descriptions how anonymous types work, but I'm not sure how they're really useful. What are some scenarios that anonymous types can be used to address in a well-designed program?\n"
},
{
"from": "gpt",
"value": "Anonymous types in C# provide a conv... |
LEt's say I want to have a subfolder called- http://www.foo.com/news/ but I actually want that news folder on a different server. I realize it can be done easily with subdomains, but I was really hoping for the subfolder thing.
Is it possible? How?
| Yes, it's possible to serve content from a subfolder (like `http://www.foo.com/news/`) on a different server, but it requires some configuration. There are several approaches to achieve this, including using reverse proxies or URL rewriting. Here are two common methods:
### Method 1: Reverse Proxy
1. **Use a Web Serv... | 14,161 | [
{
"from": "human",
"value": "LEt's say I want to have a subfolder called- http://www.foo.com/news/ but I actually want that news folder on a different server. I realize it can be done easily with subdomains, but I was really hoping for the subfolder thing.\nIs it possible? How?\n"
},
{
"from": "gp... |
Possible Duplicate:
What does map(&:name) mean in Ruby?
I was watching a railscast and saw this code.
[Category, Product].(&:delete_all)
In regards to clearing a database.
I asked about the line in IRC and was told
(&:delete_all)
was a shortcut for
{|model| model.delete_all}
I tested this with the following
cla... | The shorthand syntax `(&:method_name)` in Ruby is a way to call a method on each element of a collection, using `Symbol#to_proc`.
When you use `&:delete_all`, you are effectively passing a block to the method that expects a block (like `each`, `map`, etc.), where that block calls `delete_all` on each element of the c... | 14,657 | [
{
"from": "human",
"value": "\nPossible Duplicate:\nWhat does map(&:name) mean in Ruby? \n\nI was watching a railscast and saw this code.\n[Category, Product].(&:delete_all)\n\nIn regards to clearing a database.\nI asked about the line in IRC and was told \n(&:delete_all)\n\nwas a shortcut for \n{|model| mo... |
I want to create a keyboard and mouse hook which will be started as a windows service. I want to monitor the activity of the various users who use the system throughout the day. i.e. which users are active at what times.
Is is possible to determine which user will be receiving the events? (The service will be running a... | Creating a keyboard and mouse hook within a Windows service to monitor user activity is a complex task and raises several important considerations, both technical and ethical. While it's technically feasible to capture user input in a Windows service, monitoring activity across multiple users presents additional challe... | 11,506 | [
{
"from": "human",
"value": "I want to create a keyboard and mouse hook which will be started as a windows service. I want to monitor the activity of the various users who use the system throughout the day. i.e. which users are active at what times.\nIs is possible to determine which user will be receiving ... |
I have a weird problem with a dropdownbox selectedIndex always being set to 0 upon postback. I'm not accidentally rebinding it in my code. In fact I've placed a breakpoint at the very first line of the page_load event and the value is already set to zero. The dropdown is in the master page of my project, I don't know i... | The issue you're experiencing with the dropdown box (`ddlSalesType` or `ddlTerms`) always being set to the first index (0) upon postback likely stems from how you are handling the control's data binding and the page's lifecycle. Here are a few key considerations and potential solutions to address the problem:
### Key ... | 9,215 | [
{
"from": "human",
"value": "I have a weird problem with a dropdownbox selectedIndex always being set to 0 upon postback. I'm not accidentally rebinding it in my code. In fact I've placed a breakpoint at the very first line of the page_load event and the value is already set to zero. The dropdown is in the ... |
I code C++ using MS Dev Studio and I work from home two days per week. I use CVS to keep my sources synchronized between the two computers but there are difference between the environments the machines are in.
Can anyone suggest a way I can conditionally modify constants in my code depending on whether I am compiling o... | You can achieve this by defining a preprocessor macro in your project settings in MS Visual Studio, based on your development environment. This way, you can conditionally include or exclude code based on whether you are compiling on your home machine or a different machine.
Here's how you can set it up:
### Step 1: D... | 13,508 | [
{
"from": "human",
"value": "I code C++ using MS Dev Studio and I work from home two days per week. I use CVS to keep my sources synchronized between the two computers but there are difference between the environments the machines are in.\nCan anyone suggest a way I can conditionally modify constants in my ... |
Has anyone used ADO.NET Data Services as a data source for Adobe Flex applications? If so, any success stories or tragedies to avoid? If you did use it, how did you handle security?
| Yes, some developers have successfully used ADO.NET Data Services (now known as WCF Data Services) as a data source for Adobe Flex applications. However, there are both success stories and challenges to consider when integrating these technologies. Here are some insights:
### Success Stories:
1. **Seamless Integration... | 12,838 | [
{
"from": "human",
"value": "Has anyone used ADO.NET Data Services as a data source for Adobe Flex applications? If so, any success stories or tragedies to avoid? If you did use it, how did you handle security?\n"
},
{
"from": "gpt",
"value": "Yes, some developers have successfully used ADO.NE... |
I'm trying to send an email in Java but when I read the body of the email in Outlook, it's gotten rid of all my linebreaks. I'm putting \n at the ends of the lines but is there something special I need to do other than that? The receivers are always going to be using Outlook.
I found a page on microsoft.com that says ... | When sending emails, especially HTML emails, the handling of line breaks can be tricky, particularly when the recipient is using Outlook. Here are a few suggestions to ensure that your line breaks are preserved:
### 1. Use HTML Format
If you're sending plain text emails, consider switching to HTML format. This allows ... | 14,097 | [
{
"from": "human",
"value": "I'm trying to send an email in Java but when I read the body of the email in Outlook, it's gotten rid of all my linebreaks. I'm putting \\n at the ends of the lines but is there something special I need to do other than that? The receivers are always going to be using Outlook. \... |
I want to separate concerns here. Create and embed all the UI logic for the Custom XML designer, object model, validations etc in to a separate assembly. Then the Package framework should only register the designer information and ask for a UI Service and everything works magically.
This way I don't need to play with t... | It sounds like you're looking for a robust architecture that allows for separation of concerns, particularly regarding the UI logic in a Visual Studio Package context. Here are some suggestions and patterns to consider that can help you achieve that goal:
### 1. **Service Locator Pattern**
A Service Locator can help y... | 13,893 | [
{
"from": "human",
"value": "I want to separate concerns here. Create and embed all the UI logic for the Custom XML designer, object model, validations etc in to a separate assembly. Then the Package framework should only register the designer information and ask for a UI Service and everything works magica... |
Ideally something that will work with Oracle, MS SQL Server, MySQL and Posgress.
| If you're looking for a solution that can work across multiple database management systems like Oracle, MS SQL Server, MySQL, and PostgreSQL, here are a few options to consider:
### 1. **Database Abstraction Layer**
Using an abstraction layer can help interact with different databases without changing the underlying c... | 14,248 | [
{
"from": "human",
"value": "Ideally something that will work with Oracle, MS SQL Server, MySQL and Posgress.\n"
},
{
"from": "gpt",
"value": "If you're looking for a solution that can work across multiple database management systems like Oracle, MS SQL Server, MySQL, and PostgreSQL, here are a ... |
I can't use the Get*Profile functions because I'm using an older version of the Windows CE platform SDK which doesn't have those. It doesn't have to be too general.
[section]
name = some string
I just need to open the file, check for the existence of "section", and the value associated with "name". Standard C++ is pre... | To read a configuration file and check for the existence of a specific section and a value associated with a key (in this case, `name`), you can use standard C++ to handle file I/O operations. Below is an example of how you might implement such a function in C++:
```cpp
#include <iostream>
#include <fstream>
#include ... | 12,522 | [
{
"from": "human",
"value": "I can't use the Get*Profile functions because I'm using an older version of the Windows CE platform SDK which doesn't have those. It doesn't have to be too general.\n[section]\nname = some string\n\nI just need to open the file, check for the existence of \"section\", and the va... |
I have several sources of tables with personal data, like this:
SOURCE 1
ID, FIRST_NAME, LAST_NAME, FIELD1, ...
1, jhon, gates ...
SOURCE 2
ID, FIRST_NAME, LAST_NAME, ANOTHER_FIELD1, ...
1, jon, gate ...
SOURCE 3
ID, FIRST_NAME, LAST_NAME, ANOTHER_FIELD1, ...
2, jhon, ballmer ...
So, assuming that records with ID 1,... | When dealing with the challenge of matching records across different data sources, especially with the potential for typos and variations in names, you'll want to employ a combination of exact matching, relaxed matching techniques, and potentially some machine learning approaches. Below are some suggestions and methodo... | 13,065 | [
{
"from": "human",
"value": "I have several sources of tables with personal data, like this:\nSOURCE 1\nID, FIRST_NAME, LAST_NAME, FIELD1, ...\n1, jhon, gates ...\n\nSOURCE 2\nID, FIRST_NAME, LAST_NAME, ANOTHER_FIELD1, ...\n1, jon, gate ...\n\nSOURCE 3\nID, FIRST_NAME, LAST_NAME, ANOTHER_FIELD1, ...\n2, jho... |
I'm running into an unusual problem in my unit tests. The class I'm testing creates a dependency property dynamically at runtime and the type of that dependency property can vary depending on the circumstances. While writing my unit tests, I need to create the dependency property with different types and that leads to ... | It sounds like you've encountered a common challenge when dealing with dynamically created dependency properties in unit tests. Unfortunately, in WPF (Windows Presentation Foundation), once a dependency property is registered, its type and certain other characteristics cannot be changed or unregistered. The `OverrideMe... | 12,521 | [
{
"from": "human",
"value": "I'm running into an unusual problem in my unit tests. The class I'm testing creates a dependency property dynamically at runtime and the type of that dependency property can vary depending on the circumstances. While writing my unit tests, I need to create the dependency propert... |
What is the best way to store a large amount of text in a table in SQL server?
Is varchar(max) reliable?
| When storing large amounts of text in a SQL Server database, `varchar(max)` is a common and reliable choice. Here are some key points to consider when using `varchar(max)` and other alternatives:
### 1. **Using `varchar(max)`**
- **Capacity**: `varchar(max)` can store up to 2 GB of variable-length character data. Thi... | 12,879 | [
{
"from": "human",
"value": "What is the best way to store a large amount of text in a table in SQL server?\nIs varchar(max) reliable?\n"
},
{
"from": "gpt",
"value": "When storing large amounts of text in a SQL Server database, `varchar(max)` is a common and reliable choice. Here are some key p... |
I understand, in a fuzzy sort of way, how regular ACID transactions work. You perform some work on a database in such a way that the work is not confirmed until some kind of commit flag is set. The commit part is based on some underlying assumption (like a single disk block write is atomic). In the event of a catast... | Distributed transactions allow multiple resources, such as databases and file systems, to participate in a single transaction, ensuring that either all changes are committed, or none are. This is essential in scenarios where maintaining consistency across disparate systems is critical. The most common protocol used for... | 12,954 | [
{
"from": "human",
"value": "I understand, in a fuzzy sort of way, how regular ACID transactions work. You perform some work on a database in such a way that the work is not confirmed until some kind of commit flag is set. The commit part is based on some underlying assumption (like a single disk block wr... |
I'm auditing our existing web application, which makes heavy use of HTML frames. I would like to download all of the HTML in each frame, is there a method of doing this with wget or a little bit of scripting?
| Yes, you can use `wget` along with some scripting to download the HTML content of each frame in your web application. Here's how to go about it:
### Step 1: Download the main page
Use `wget` to download the main page of your application first. This will allow you to extract the frame URLs later.
```bash
wget -O main... | 13,069 | [
{
"from": "human",
"value": "I'm auditing our existing web application, which makes heavy use of HTML frames. I would like to download all of the HTML in each frame, is there a method of doing this with wget or a little bit of scripting?\n"
},
{
"from": "gpt",
"value": "Yes, you can use `wget` a... |
I am evaluating WF for use in line of business applications on the web, and I would love to hear some recent first-hand accounts of this technology.
My main interest here is in improving the maintainability of projects and maybe in increasing developer productivity when working on complex processes that change frequent... | Windows Workflow Foundation (WF) has indeed been around since 2006, and it has evolved significantly over the years. Many developers have found value in its capabilities for managing workflows, especially in applications with complex business processes. However, as with any technology, there are both strengths and weak... | 14,990 | [
{
"from": "human",
"value": "I am evaluating WF for use in line of business applications on the web, and I would love to hear some recent first-hand accounts of this technology.\nMy main interest here is in improving the maintainability of projects and maybe in increasing developer productivity when working... |
I have been working on a ImageRotator control and finished weeding out any oddities with it tonight, and it works great. However, there is one thing that is bugging me with it. It doesn't display anything at design time (I just get the image placeholder).
I have been Googling, and came across a good article from Rick S... | It sounds like you're on the right track thinking about how to display images in the design-time experience for your `ImageRotator` control. You're correct that the design environment doesn't always permit access to the filesystem, which is typically the reason why your control displays only a placeholder at design tim... | 14,536 | [
{
"from": "human",
"value": "I have been working on a ImageRotator control and finished weeding out any oddities with it tonight, and it works great. However, there is one thing that is bugging me with it. It doesn't display anything at design time (I just get the image placeholder).\nI have been Googling, ... |
I'm building a PHP site, but for now the only PHP I'm using is a half-dozen or so includes on certain pages. (I will probably use some database queries eventually.)
Are simple include() statements a concern for speed or scaling, as opposed to static HTML? What kinds of things tend to cause a site to bog down?
| Using `include()` statements in PHP can be an efficient way to manage your code, especially for smaller sites or during the early stages of development. However, there are a few considerations regarding speed and scalability when comparing dynamic PHP includes to static HTML.
### Performance Considerations
1. **Execu... | 11,834 | [
{
"from": "human",
"value": "I'm building a PHP site, but for now the only PHP I'm using is a half-dozen or so includes on certain pages. (I will probably use some database queries eventually.)\nAre simple include() statements a concern for speed or scaling, as opposed to static HTML? What kinds of things t... |
Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I do think there are times when you could possibly not want pieces of your site being easily ripped off into someone else's arbitrary web aggregator. At least enough so they'd need to be arsed to do it by hand if they really wanted it.
My id... | Your thoughts on protecting web content from scraping are certainly intriguing, and the desire to keep your content secure is completely valid, especially in an age where automated scrapers can easily harvest information from websites. However, the approach you're considering could lead to a range of complications and ... | 13,188 | [
{
"from": "human",
"value": "Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I do think there are times when you could possibly not want pieces of your site being easily ripped off into someone else's arbitrary web aggregator. At least enough so they'd need to be arsed to do i... |
I've discovered that any time I do the following:
echo '<a href="http://" title="bla">huzzah</a>';
I end up with the following being rendered to the browser:
<a href="http:///" title="bla">huzzah</a>
This is particularly annoying when I link to a file with an extension, as it breaks the link.
Any ideas why this is ha... | It sounds like you've encountered an issue with how URLs are being processed after being run through `rawurlencode()`. This is a common scenario when dealing with URLs in PHP and it can indeed lead to unexpected rendering in browsers, particularly with how the URLs are formed and how browsers interpret them.
### Expla... | 13,659 | [
{
"from": "human",
"value": "I've discovered that any time I do the following:\necho '<a href=\"http://\" title=\"bla\">huzzah</a>';\n\nI end up with the following being rendered to the browser:\n<a href=\"http:///\" title=\"bla\">huzzah</a>\n\nThis is particularly annoying when I link to a file with an ext... |
Ruby setters—whether created by (c)attr_accessor or manually—seem to be the only methods that need self. qualification when accessed within the class itself. This seems to put Ruby alone the world of languages:
All methods need self/this (like Perl, and I think Javascript)
No methods require self/this is (C#, Java)
O... | You've presented a thoughtful analysis of how different programming languages handle method invocation and variable assignment, particularly focusing on Ruby and C#. Your question dives deep into the semantics of language design and the decisions that affect how methods and variables interact in the context of their re... | 12,382 | [
{
"from": "human",
"value": "Ruby setters—whether created by (c)attr_accessor or manually—seem to be the only methods that need self. qualification when accessed within the class itself. This seems to put Ruby alone the world of languages:\n\nAll methods need self/this (like Perl, and I think Javascript)\n... |
Does anyone know of any software or a good way for developers to build up a knowledge base of business rules that are built in to the software for help desk to use?
We already have a helpdesk software but we are not looking to replace this.
| Building a knowledge base of business rules for a help desk can be a great way to ensure consistency and clarity in support operations. Here are some software options and approaches that you can use to create and manage a knowledge base without replacing your existing help desk software:
### 1. **Documentation Tools**... | 12,586 | [
{
"from": "human",
"value": "Does anyone know of any software or a good way for developers to build up a knowledge base of business rules that are built in to the software for help desk to use?\nWe already have a helpdesk software but we are not looking to replace this.\n"
},
{
"from": "gpt",
"v... |
What is the difference between #include and #import in C++?
| In C++, `#include` and `#import` are both preprocessor directives used for including files, but they have different purposes and behaviors.
### `#include`
- **Purpose**: The `#include` directive is used to include the contents of a file (usually a header file) into another file. This is common for including function d... | 15,569 | [
{
"from": "human",
"value": "What is the difference between #include and #import in C++?\n"
},
{
"from": "gpt",
"value": "In C++, `#include` and `#import` are both preprocessor directives used for including files, but they have different purposes and behaviors.\n\n### `#include`\n- **Purpose**: ... |
I have the following style in an external CSS file called first.css
table { width: 100%; }
This makes the tables fill their container. If there are only two small columns they appear too far from each other.
To force the columns to appear nearer I have added this style
table { width: 50%; }
to a new file called secon... | Yes, you can override the `width` property from `first.css` without specifying a new width in `second.css`. To do this, you can use the CSS `initial` value or the `unset` value, depending on the behavior you desire.
1. **Using `initial`:**
This resets the property to its default value, which is `auto` for the `widt... | 16,152 | [
{
"from": "human",
"value": "I have the following style in an external CSS file called first.css\ntable { width: 100%; }\n\nThis makes the tables fill their container. If there are only two small columns they appear too far from each other.\nTo force the columns to appear nearer I have added this style\ntab... |
Working with python interactively, it's sometimes necessary to display a result which is some arbitrarily complex data structure (like lists with embedded lists, etc.)
The default way to display them is just one massive linear dump which just wraps over and over and you have to parse carefully to read it.
Is there some... | Yes, in Python, there are several ways to display complex data structures in a more readable format. One of the most popular and useful libraries for this purpose is `pprint`, which stands for "pretty-print." This module can help format and display Python objects in a more organized and visually appealing manner.
Here... | 13,214 | [
{
"from": "human",
"value": "Working with python interactively, it's sometimes necessary to display a result which is some arbitrarily complex data structure (like lists with embedded lists, etc.)\nThe default way to display them is just one massive linear dump which just wraps over and over and you have to... |
It seems that C# 3 hit me without me even noticing, could you guys tell me about good in depth guides to C# 3? from lambda to linq to everything else that was introduced with the third version of the language.
Printed books would be nice, but online guides would be even better!
| C# 3.0 introduced several significant features, including Language Integrated Query (LINQ), lambda expressions, and automatic properties, which greatly improved the language's expressiveness and functionality. Here are some recommended books and online resources to help you dive deep into C# 3.0:
### Books
1. **"C# 3... | 14,363 | [
{
"from": "human",
"value": "It seems that C# 3 hit me without me even noticing, could you guys tell me about good in depth guides to C# 3? from lambda to linq to everything else that was introduced with the third version of the language.\nPrinted books would be nice, but online guides would be even better!... |
Has anyone seen a Yahoo YUI validation framework that I could implement into asp.net MVC? I've seen a jQuery one but I want to work wit YUI.
| The Yahoo User Interface (YUI) library is not as widely used today as it once was, especially with the rise of more modern libraries like jQuery and others. However, if you still want to implement YUI for validation in an ASP.NET MVC application, you can definitely do that.
Here's a basic guide on how to set up YUI va... | 10,839 | [
{
"from": "human",
"value": "Has anyone seen a Yahoo YUI validation framework that I could implement into asp.net MVC? I've seen a jQuery one but I want to work wit YUI.\n"
},
{
"from": "gpt",
"value": "The Yahoo User Interface (YUI) library is not as widely used today as it once was, especiall... |
What do you think the next evolution of languages will look like?
| The evolution of languages is influenced by various factors, including technology, culture, and social interactions. While predicting the future of languages is inherently uncertain, several trends and potential directions can be identified:
1. **Increased Use of Technology**: As communication increasingly takes place... | 15,103 | [
{
"from": "human",
"value": "What do you think the next evolution of languages will look like?\n"
},
{
"from": "gpt",
"value": "The evolution of languages is influenced by various factors, including technology, culture, and social interactions. While predicting the future of languages is inheren... |
I would like to know how much disk space a directory is going to consume before I bring it over from the Perforce server. I don't see any way to do this other than getting the files and looking at the size of the directory in a file manager. This, of course, defeats the purpose.
Is there a way to get file size info... | Yes, you can obtain information about the size of files in a Perforce depot without actually downloading the files. Perforce provides the `p4 sizes` command, which you can use to retrieve the sizes of files in a specific directory or path in the depot.
Here's how you can use it:
1. **Use the `p4 sizes` Command**:
... | 15,507 | [
{
"from": "human",
"value": "I would like to know how much disk space a directory is going to consume before I bring it over from the Perforce server. I don't see any way to do this other than getting the files and looking at the size of the directory in a file manager. This, of course, defeats the purpos... |
How would one configurably set http-headers to cache files in IIS >= 6?
Example:
*.cache.* => cache nearly forever
*.nocache.* => never cache
An example framework using this naming would be the GWT framework.
| To configure HTTP headers to manage caching for specific file types in IIS (Internet Information Services) version 6 and above, you can utilize the IIS Manager or modify the `metabase.xml` file directly. Below are steps to set up caching for files that match specific patterns (e.g., `*.cache.*` for nearly permanent cac... | 9,539 | [
{
"from": "human",
"value": "How would one configurably set http-headers to cache files in IIS >= 6?\nExample:\n\n*.cache.* => cache nearly forever\n*.nocache.* => never cache\n\nAn example framework using this naming would be the GWT framework.\n"
},
{
"from": "gpt",
"value": "To configure HTTP... |
I've got a utility that outputs a list of files required by a game. How can I run that utility within a C program and grab its output so I can act on it within the same program?
UPDATE: Good call on the lack of information. The utility spits out a series of strings, and this is supposed to be portable across Mac/Wind... | To run an external utility within a C program and capture its output, you can use pipes. The approach is portable across macOS, Windows, and Linux, but you'll need to handle the specifics of the process creation and pipe management differently depending on the operating system.
Here's a general overview of how you cou... | 8,754 | [
{
"from": "human",
"value": "I've got a utility that outputs a list of files required by a game. How can I run that utility within a C program and grab its output so I can act on it within the same program?\nUPDATE: Good call on the lack of information. The utility spits out a series of strings, and this ... |
I have a generic list, i.e. List<myclass>. Here myclass contains two string properties.
How can I assign a datasource to the list collection?
| In C#, you can assign a data source to a `List<MyClass>` by populating the list with instances of `MyClass`. Here's how you can do it step-by-step:
1. **Define your class**: Ensure that your `MyClass` is defined with the required string properties.
```csharp
public class MyClass
{
public string Property1 { get; s... | 14,541 | [
{
"from": "human",
"value": "I have a generic list, i.e. List<myclass>. Here myclass contains two string properties. \nHow can I assign a datasource to the list collection?\n"
},
{
"from": "gpt",
"value": "In C#, you can assign a data source to a `List<MyClass>` by populating the list with insta... |
Is it possible to write to the windows logs in python?
| Yes, it is possible to write to Windows Event Logs using Python. One of the commonly used libraries for this purpose is the `pywin32` library, which provides access to many of the Windows APIs from Python.
Here's a step-by-step guide on how to write to the Windows Event Log using Python:
1. **Install the `pywin32` li... | 13,815 | [
{
"from": "human",
"value": "Is it possible to write to the windows logs in python?\n"
},
{
"from": "gpt",
"value": "Yes, it is possible to write to Windows Event Logs using Python. One of the commonly used libraries for this purpose is the `pywin32` library, which provides access to many of the... |
<div id="myDiv">
<a>...</a>
<a>...</a>
<a>...</a>
<a>...</a>
<a>...</a>
<a>...</a>
</div>
If you wanted to select the 2nd, 3rd and 4th a tags in the above example, how would you do that? The only thing I can think of is:
$("#myDiv a:eq(1), #myDiv a:eq(2), #myDiv a:eq(3)")
But that doesn'... | You can select the 2nd, 3rd, and 4th `<a>` tags more efficiently by using the `.slice()` method provided by jQuery. This method allows you to specify a range of elements to select from a jQuery collection. Here's how you can do it:
```javascript
$("#myDiv a").slice(1, 4)
```
This will select the `<a>` elements starti... | 19,065 | [
{
"from": "human",
"value": "<div id=\"myDiv\">\n <a>...</a>\n <a>...</a>\n <a>...</a>\n <a>...</a>\n <a>...</a>\n <a>...</a>\n</div>\n\nIf you wanted to select the 2nd, 3rd and 4th a tags in the above example, how would you do that? The only thing I can think of is:\n$(\"#myDiv a:eq... |
I've asked this question over on the MSDN forums also and haven't found a resolution:
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3686852&SiteID=1
The basic problem here as I see it is that an interop assembly doesn't actually contain any IL that can be instrumented (except for maybe a few delegates). So, alt... | It sounds like you're tackling a challenging problem of testing a complex interop layer between managed code and COM components. Here are some strategies that may help you achieve your goal of getting code coverage for the interop layer:
1. **Use a Code Coverage Tool**: While traditional code coverage tools won't trac... | 15,139 | [
{
"from": "human",
"value": "I've asked this question over on the MSDN forums also and haven't found a resolution:\nhttp://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3686852&SiteID=1\nThe basic problem here as I see it is that an interop assembly doesn't actually contain any IL that can be instrumented ... |
Short Q.: What does this exception mean? "EXC_BAD_ACCESS (0x0001)"
Full Q.: How can I use this error log info (and thread particulars that I omitted here) to diagnosis this app crash? (NB: I have no expertise with crash logs or OS kernels.)
In this case, my email client (Eudora) crashes immediately on launch, every tim... | The exception "EXC_BAD_ACCESS (0x0001)" typically indicates that the application attempted to access a memory location that it is not allowed to access. In this case, the specific code "KERN_PROTECTION_FAILURE" suggests that the application tried to read or write to an invalid memory address, which caused the crash.
H... | 12,965 | [
{
"from": "human",
"value": "Short Q.: What does this exception mean? \"EXC_BAD_ACCESS (0x0001)\"\nFull Q.: How can I use this error log info (and thread particulars that I omitted here) to diagnosis this app crash? (NB: I have no expertise with crash logs or OS kernels.)\nIn this case, my email client (Eud... |
While creating a file synchronization program in C# I tried to make a method copy in LocalFileItem class that uses System.IO.File.Copy(destination.Path, Path, true) method where Path is a string.
After executing this code with destination. Path = "C:\\Test2" and this.Path = "C:\\Test\\F1.txt" I get an exception saying ... | The issue you're experiencing with file permissions when trying to copy files using `System.IO.File.Copy` can be caused by various factors, even if you're the owner of the directory. Let's walk through some potential causes and solutions:
### 1. **File Permissions**
Ensure that your user account has the necessary perm... | 5,406 | [
{
"from": "human",
"value": "While creating a file synchronization program in C# I tried to make a method copy in LocalFileItem class that uses System.IO.File.Copy(destination.Path, Path, true) method where Path is a string.\nAfter executing this code with destination. Path = \"C:\\\\Test2\" and this.Path =... |
I have a C++ template class that gets instantiated with 3 different type parameters. There's a method that the class needs to have for only one of those types and that isn't ever called with the two other types.
Will object code for that method be generated thrice (for all types for which the template is instantiated),... | In C++, when you instantiate a template class with different type parameters, the compiler generates code for methods only when they are actually used. If a method is specific to one of those types and is never called for the other types, the object code for that method will be generated only once — only for the instan... | 16,285 | [
{
"from": "human",
"value": "I have a C++ template class that gets instantiated with 3 different type parameters. There's a method that the class needs to have for only one of those types and that isn't ever called with the two other types.\nWill object code for that method be generated thrice (for all type... |
Has anyone actually shipped an Entity Framework project that does O/R mapping into conceptual classes that are quite different from the tables in the datastore?
I mean collapse junction (M:M) tables into other entities to form Conceptual classes that exist in the business domain but are organized as multiple tables in ... | Yes, it is indeed possible to ship an Entity Framework project that employs Object/Relational (O/R) mapping strategies to create conceptual classes that represent business domain models that are quite distinct from the underlying database tables. This approach is commonly known as "domain-driven design" and involves co... | 8,538 | [
{
"from": "human",
"value": "Has anyone actually shipped an Entity Framework project that does O/R mapping into conceptual classes that are quite different from the tables in the datastore?\nI mean collapse junction (M:M) tables into other entities to form Conceptual classes that exist in the business domai... |
We have a large C# (.net 2.0) app which uses our own C++ COM component and a 3rd party fingerprint scanner library also accessed via COM. We ran into an issue where in production some events from the fingerprint library do not get fired into the C# app, although events from our own C++ COM component fired and were rece... | The `stdole.dll` file is an important component for handling Automation types in COM and is especially relevant when working with OLE (Object Linking and Embedding) and COM objects in Windows. In essence, `stdole.dll` defines the standard OLE types, such as `IPicture` and `IEnumVARIANT`, which are commonly used by many... | 13,871 | [
{
"from": "human",
"value": "We have a large C# (.net 2.0) app which uses our own C++ COM component and a 3rd party fingerprint scanner library also accessed via COM. We ran into an issue where in production some events from the fingerprint library do not get fired into the C# app, although events from our ... |
I am going to install SVN for my personal projects. Is it better to install it on a spare machine(Win XP) or will I save myself grief if I install it on the machine I use for development(Vista).
| When deciding where to install SVN (Subversion) for your personal projects, there are a few factors to consider:
1. **Resource Usage**: SVN is not resource-intensive, so it can run effectively on either a spare machine with Windows XP or your development machine running Vista. However, if you're concerned about the re... | 15,342 | [
{
"from": "human",
"value": "I am going to install SVN for my personal projects. Is it better to install it on a spare machine(Win XP) or will I save myself grief if I install it on the machine I use for development(Vista). \n"
},
{
"from": "gpt",
"value": "When deciding where to install SVN (Su... |
In HTML forms, buttons can be disabled by defining the "disabled" attribute on them, with any value:
<button name="btn1" disabled="disabled">Hello</button>
If a button is to be enabled, the attribute should not exist as there is no defined value that the disabled attribute can be set to that would leave the button ena... | In JSP documents (especially when dealing with XML/XHTML), you can't conditionally add attributes directly within an element in the way you've described. However, there are some alternatives you can consider to keep your code clean while achieving your goal of conditionally enabling or disabling a button.
### Option 1... | 13,131 | [
{
"from": "human",
"value": "In HTML forms, buttons can be disabled by defining the \"disabled\" attribute on them, with any value:\n<button name=\"btn1\" disabled=\"disabled\">Hello</button>\n\nIf a button is to be enabled, the attribute should not exist as there is no defined value that the disabled attri... |
I frequently start with a simple console application to try out an idea, then create a new GUI based project and copy the code in. Is there a better way? Can I convert my existing console application easily?
| Yes, converting a console application to a GUI-based application can be done effectively, and there are several approaches you can take to streamline the process. Here are some strategies:
### 1. Use a GUI Framework:
Choose a GUI framework that supports your language (e.g., Tkinter for Python, Windows Forms or WPF for... | 12,529 | [
{
"from": "human",
"value": "I frequently start with a simple console application to try out an idea, then create a new GUI based project and copy the code in. Is there a better way? Can I convert my existing console application easily?\n"
},
{
"from": "gpt",
"value": "Yes, converting a console ... |
I am having some 10 lac records in my single SQL Table. I need to load this much record in my record. I need to know whether this will load. when i tried loading to report its showing out of memory exception.
| When dealing with a large SQL table containing millions of records, it is common to encounter performance issues, such as running out of memory, especially when trying to load all records at once. Here are some strategies you can use to address this issue:
### 1. **Pagination**
Instead of loading all 10 lakh (1 millio... | 11,853 | [
{
"from": "human",
"value": "I am having some 10 lac records in my single SQL Table. I need to load this much record in my record. I need to know whether this will load. when i tried loading to report its showing out of memory exception.\n"
},
{
"from": "gpt",
"value": "When dealing with a large... |
How would I go about creating multiple documents when a single file is opening in a MFC application?
We have an aggregate file format which can contain information for multiple documents. When this file is opened, I would like multiple CDocuments created for each record in the file. We already have a extended CDocMan... | Creating multiple documents from a single file in an MFC application involves modifying the way your `CDocManager` handles the opening of documents. Since you mentioned that you already have an extended `CDocManager`, you can indeed implement the logic in the `OpenDocumentFile` method.
Here’s a step-by-step approach t... | 13,400 | [
{
"from": "human",
"value": "How would I go about creating multiple documents when a single file is opening in a MFC application?\nWe have an aggregate file format which can contain information for multiple documents. When this file is opened, I would like multiple CDocuments created for each record in the... |
With which tool / library it is possible to update an existing database structure. On the update of the software it is also needed to change the database. Because there can be different versions of the software it should compare the current status with the target status of the database. It should:
add table columns, f... | For your requirements, there are a few tools and libraries that can help you manage database migrations in a way that fits the Java ecosystem and supports the specified DBMS (MS SQL Server, Oracle, and MySQL). Here are some recommendations:
### 1. **Liquibase**
Liquibase is a popular open-source library that supports ... | 7,886 | [
{
"from": "human",
"value": "With which tool / library it is possible to update an existing database structure. On the update of the software it is also needed to change the database. Because there can be different versions of the software it should compare the current status with the target status of the d... |
As a follow up to my previous question, I am wondering how to use transparent windows correctly. If I have set my window to use transparency, the UI will occasionally appear to stop responding. What is actually happening is that the UI simply is not updating as it should. Animations do not occur, pages do not appear... | Using transparent windows in WPF applications can sometimes introduce performance issues, especially when it comes to UI updates and responsiveness. The problems you're experiencing with the UI not updating properly when using transparency can arise from several factors. Here are some potential causes and solutions to ... | 12,188 | [
{
"from": "human",
"value": "As a follow up to my previous question, I am wondering how to use transparent windows correctly. If I have set my window to use transparency, the UI will occasionally appear to stop responding. What is actually happening is that the UI simply is not updating as it should. Ani... |
From what I can gather, there are three categories:
Never use GET and use POST
Never use POST and use GET
It doesn't matter which one you use.
Am I correct in assuming those three cases? If so, what are some examples from each case?
| Yes, your understanding is correct in identifying three general categories regarding the use of HTTP methods GET and POST. Each method has its intended use cases and best practices. Let’s break down each category with examples:
### 1. **Never use GET and use POST**
**When to Use:**
- When you are sending sensitive in... | 8,905 | [
{
"from": "human",
"value": "From what I can gather, there are three categories:\n\nNever use GET and use POST\nNever use POST and use GET\nIt doesn't matter which one you use.\n\nAm I correct in assuming those three cases? If so, what are some examples from each case?\n"
},
{
"from": "gpt",
"va... |
I want to run javascript/Python/Ruby inside my application.
I have an application that creates process automatically based on user's definition. The process is generated in C#. I want to enable advanced users to inject script in predefined locations. Those scripts should be run from the C# process.
For example, the cr... | Yes, you can run scripts written in JavaScript, Python, and Ruby from a C# application using various mechanisms. Below, I outline some ways to accomplish this for each of the scripting languages:
### 1. **Running JavaScript**
For JavaScript, you can use the **Duktape**, **V8**, or **Jint** libraries to embed JavaScri... | 12,409 | [
{
"from": "human",
"value": "I want to run javascript/Python/Ruby inside my application. \nI have an application that creates process automatically based on user's definition. The process is generated in C#. I want to enable advanced users to inject script in predefined locations. Those scripts should be ru... |
can anyone please suggest a good code example of vb.net/c# code to put the application in system tray when minized.
| Certainly! Below is an example of how to implement a simple Windows Forms application that minimizes to the system tray using C# and VB.NET.
### C# Example
1. Create a new Windows Forms Application in Visual Studio.
2. Add a `NotifyIcon` control to the form.
3. Implement the following code.
```csharp
using System;
... | 8,267 | [
{
"from": "human",
"value": "can anyone please suggest a good code example of vb.net/c# code to put the application in system tray when minized.\n"
},
{
"from": "gpt",
"value": "Certainly! Below is an example of how to implement a simple Windows Forms application that minimizes to the system tra... |
Does anybody know of a method for creating custom Performance Counters using ordinary unmanaged Visual C++?
I know that it can be done easily using managed C++, but I need to do it using an unmanaged Windows service.
I also know that you can retrieve performance counter data, but I need to create some custom counters a... | Creating custom performance counters in unmanaged Visual C++ can be achieved using the Windows Performance Counters API, specifically through the use of the Performance Data Helper (PDH) functions. Here’s a step-by-step guide to help you create custom performance counters in an unmanaged Windows service:
### Step 1: I... | 12,231 | [
{
"from": "human",
"value": "Does anybody know of a method for creating custom Performance Counters using ordinary unmanaged Visual C++?\nI know that it can be done easily using managed C++, but I need to do it using an unmanaged Windows service.\nI also know that you can retrieve performance counter data, ... |
I have a web page which contains a select box. When I open a jQuery Dialog it is displayed partly behind the select box.
How should I approach this problem? Should I hide the select box or does jQuery offer some kind of 'shim' solution. (I have Googled but didn't find anything)
Here is some code:
<!DOCTYPE html>
<html... | The issue of jQuery dialog displaying behind a select box is a common one in web development, especially because of how certain elements render in the browser. This is particularly prominent in browsers like IE and Firefox where select boxes can have a higher z-index than other elements, including modal dialogs.
Here ... | 15,256 | [
{
"from": "human",
"value": "I have a web page which contains a select box. When I open a jQuery Dialog it is displayed partly behind the select box.\nHow should I approach this problem? Should I hide the select box or does jQuery offer some kind of 'shim' solution. (I have Googled but didn't find anything... |
What's the difference between eruby and erb? What considerations would drive me to choose one or the other?
My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within the source... | The terms **ERB** (Embedded Ruby) and **eRuby** (Embedded Ruby) are sometimes used interchangeably, but there are some distinctions worth noting:
### ERB (Embedded Ruby)
- **Definition**: ERB is a templating system that allows you to embed Ruby code into a text document. It is included in the standard library of Ruby ... | 13,956 | [
{
"from": "human",
"value": "What's the difference between eruby and erb? What considerations would drive me to choose one or the other?\nMy application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (... |
I'm trying to store a password in a file that I'd like to retrieve for later. Hashing is not an option as I need the password for connecting to a remote server for later.
The following code works well, but it creates a different output each time even though the key is the same. This is bad as when the application shuts... | When storing passwords securely, it’s important to use a method that allows you to retrieve the password later. Your current implementation of encryption using `TripleDESCryptoServiceProvider` is capable of encrypting the password, but the key management is crucial for consistently encrypting and decrypting the passwor... | 11,867 | [
{
"from": "human",
"value": "I'm trying to store a password in a file that I'd like to retrieve for later. Hashing is not an option as I need the password for connecting to a remote server for later.\nThe following code works well, but it creates a different output each time even though the key is the same.... |
I am a AS3 novice learning PureMVC and want to write code following best practices so that any other AS3 developer can pick up my code and easily understand what I did, I am tempted to do stuff as I would in JavaScript or Asp.Net/C#, but I have a feeling that might not be the best approach.
Thoughts? Links?
| It's great to hear that you're diving into ActionScript 3 (AS3) and PureMVC! Following best practices will definitely help others (and your future self) understand your code better. Here are some guidelines and resources to consider as you develop your skills:
### Best Practices for AS3 and PureMVC
1. **Understand th... | 12,185 | [
{
"from": "human",
"value": "I am a AS3 novice learning PureMVC and want to write code following best practices so that any other AS3 developer can pick up my code and easily understand what I did, I am tempted to do stuff as I would in JavaScript or Asp.Net/C#, but I have a feeling that might not be the be... |
Yesterday, I asked this question and never really got an answer I was really happy with. I really would like to know how to generate a list of N unique random numbers using a functional language such as Ruby without having to be extremely imperative in style.
Since I didn't see anything I really liked, I've written the... | Sure! Let's translate your LINQ code into Ruby and Python, adhering to a more functional style while avoiding excessive loops and conditionals.
### Ruby
In Ruby, you can achieve a similar result using the `Enumerable` module, which provides a variety of useful methods that can help maintain a functional style. Here's... | 14,703 | [
{
"from": "human",
"value": "Yesterday, I asked this question and never really got an answer I was really happy with. I really would like to know how to generate a list of N unique random numbers using a functional language such as Ruby without having to be extremely imperative in style.\nSince I didn't see... |
We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that).
When we modify a value in database, we have to reload the web server to display the new value on the web app.
Is there any simple way to use the new value without restarting the web server ?
(We do no... | To allow your web application to reload resource bundles without restarting the server, you can implement a cache invalidation strategy that involves storing your custom resource bundle in a way that can be refreshed when needed. Here’s a general approach to achieve this:
1. **Implement a Custom ResourceBundle**: Sinc... | 12,846 | [
{
"from": "human",
"value": "We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that).\nWhen we modify a value in database, we have to reload the web server to display the new value on the web app.\nIs there any simple way to use the new value wi... |
I work on Linux all the time and I'm clueless about Windows, not even having a Windows box. Is Git nowadays working on Windows? Or am I making problems for my Windows pals by using it?
| Yes, Git works perfectly well on Windows! In fact, Git for Windows is a popular choice for developers who work in a Windows environment. It provides a native Windows experience for Git and includes a Bash emulation called Git Bash, which allows users to use Git commands similar to how they would on a Linux system.
Her... | 17,218 | [
{
"from": "human",
"value": "I work on Linux all the time and I'm clueless about Windows, not even having a Windows box. Is Git nowadays working on Windows? Or am I making problems for my Windows pals by using it?\n"
},
{
"from": "gpt",
"value": "Yes, Git works perfectly well on Windows! In fact... |
I would like to use javascript to develop general-purpose GUI applications. Initially these are to run on Windows, but I would like them to ultimately be cross-platform.
Is there a way to do this without having to make the application run in a browser?
| Yes, you can develop general-purpose GUI applications in JavaScript without running them in a browser by using frameworks that allow you to build cross-platform desktop applications. Here are some popular options:
### 1. **Electron**
- **Description**: Electron is a popular framework for building cross-platform deskto... | 12,505 | [
{
"from": "human",
"value": "I would like to use javascript to develop general-purpose GUI applications. Initially these are to run on Windows, but I would like them to ultimately be cross-platform. \nIs there a way to do this without having to make the application run in a browser? \n"
},
{
"from... |
I want to do this:
e.className = t;
Where t is the name of a style I have defined in a stylesheet.
| To change the class of an HTML element in JavaScript so that it applies a style defined in a stylesheet, you can simply assign the class name to the `className` property of the element, as you've shown in your code. Here's a basic example demonstrating how to do this:
### HTML
```html
<!DOCTYPE html>
<html lang="en">
... | 8,455 | [
{
"from": "human",
"value": "I want to do this:\ne.className = t;\n\nWhere t is the name of a style I have defined in a stylesheet.\n"
},
{
"from": "gpt",
"value": "To change the class of an HTML element in JavaScript so that it applies a style defined in a stylesheet, you can simply assign the ... |
I am creating a user control in C# and I am adding my own border and background. Currently the background is 16 small images that I change depending on the status of the object. Performance wise, would I be better off using GDI+ instead of the images?
| When considering performance for drawing backgrounds and borders in a user control in C#, there are a few factors to keep in mind when deciding between using GDI+ (via `System.Drawing`) or using multiple images:
### Performance Considerations:
1. **Image Loading and Memory Usage:**
- If you are using 16 small imag... | 16,473 | [
{
"from": "human",
"value": "I am creating a user control in C# and I am adding my own border and background. Currently the background is 16 small images that I change depending on the status of the object. Performance wise, would I be better off using GDI+ instead of the images?\n"
},
{
"from": "gp... |
I have an int array as a property of a Web User Control. I'd like to set that property inline if possible using the following syntax:
<uc1:mycontrol runat="server" myintarray="1,2,3" />
This will fail at runtime because it will be expecting an actual int array, but a string is being passed instead. I can make myintarr... | In ASP.NET Web User Controls, you can't directly bind an `int[]` property using a string in the markup, since the markup parser expects the type to match exactly. However, you can achieve a similar effect by defining a custom property for the string representation and then converting it to an integer array internally i... | 12,980 | [
{
"from": "human",
"value": "I have an int array as a property of a Web User Control. I'd like to set that property inline if possible using the following syntax:\n<uc1:mycontrol runat=\"server\" myintarray=\"1,2,3\" />\n\nThis will fail at runtime because it will be expecting an actual int array, but a str... |
I a working in VisualStudio 2005. I have a dataset with sevaral datatables in it already. I had to modify the database to add a new foreign key that I forgot about. How do I get visual studio to recognize the new relationship?
| In Visual Studio 2005, if you have modified your database to add a new foreign key and you want Visual Studio to recognize the new relationship in your dataset, you will need to update the DataSet designer. Here are the steps you can follow:
1. **Open Your DataSet Designer**:
- In Solution Explorer, locate your Dat... | 16,962 | [
{
"from": "human",
"value": "I a working in VisualStudio 2005. I have a dataset with sevaral datatables in it already. I had to modify the database to add a new foreign key that I forgot about. How do I get visual studio to recognize the new relationship?\n"
},
{
"from": "gpt",
"value": "In Vi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.