instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
When restoring a SQL Server Database, I notice that there are 3 different Recovery States to choose from: Restore with Recovery Restore with No Recovery Restore with Standby I've always left it at it's default value, but what do they all mean? (Preferably in layman's terms)
Certainly! Here’s a simple explanation of the three recovery states for restoring a SQL Server database: 1. **Restore with Recovery**: - **What it means**: This option means you want to complete the restore process and bring the database back online so that it can be used immediately. - **When to use it**: Use t...
1,256
[ { "from": "human", "value": "When restoring a SQL Server Database, I notice that there are 3 different Recovery States to choose from:\n\nRestore with Recovery\nRestore with No Recovery\nRestore with Standby\n\nI've always left it at it's default value, but what do they all mean?\n(Preferably in layman's te...
How do you retrieve selected text using Regex in C#? I am looking for C# code that is equivalent to this Perl code: $indexVal = 0; if($string =~ /Index: (\d*)/){$indexVal = $1;}
You can achieve similar functionality in C# using the `Regex` class, which is part of the `System.Text.RegularExpressions` namespace. The following C# code demonstrates how to retrieve the selected text using a regular expression, equivalent to the Perl code you provided. Here's the C# code: ```csharp using System; u...
1,049
[ { "from": "human", "value": "How do you retrieve selected text using Regex in C#?\nI am looking for C# code that is equivalent to this Perl code:\n$indexVal = 0;\nif($string =~ /Index: (\\d*)/){$indexVal = $1;}\n\n" }, { "from": "gpt", "value": "You can achieve similar functionality in C# using ...
I'm not sure what the correct size should be. Many sites seem to repeat that the apple-touch-icon should be 57x57 pixels but cite a broken link as their source. Hanselman's and playgroundblues's comments suggest different sizes including 163x163 and 60x60. Apple's own apple.com icon is 129x129! See my related question:...
When creating an icon for use on iOS devices (such as iPhones and iPads), it’s essential to include multiple sizes to ensure proper display across various devices and scenarios. The following sizes are recommended for the `apple-touch-icon`: 1. **180x180 pixels** - iPhone 6 Plus, 7 Plus, 8 Plus 2. **167x167 pixels** -...
405
[ { "from": "human", "value": "I'm not sure what the correct size should be.\nMany sites seem to repeat that the apple-touch-icon should be 57x57 pixels but cite a broken link as their source.\nHanselman's and playgroundblues's comments suggest different sizes including 163x163 and 60x60.\nApple's own apple.c...
I am looking for a text editor to be used in a web page. Where users can format the text and get a WYSIWYG experience. Doesn't need to be too fancy. But has to be easy to use and integrate into the page. Has to generate HTML as output. Support AJAX (one I checked works only with standard form submit) and has to be smal...
There are several lightweight WYSIWYG text editors that meet your criteria. Below are some popular options: 1. **TinyMCE**: - **Description**: A well-known WYSIWYG editor that is highly customizable and easy to integrate. It allows you to format text and generates clean HTML output. - **Size**: TinyMCE can be sl...
530
[ { "from": "human", "value": "I am looking for a text editor to be used in a web page. Where users can format the text and get a WYSIWYG experience. Doesn't need to be too fancy. But has to be easy to use and integrate into the page. Has to generate HTML as output. Support AJAX (one I checked works only with...
So I'm not quite convinced about OpenID yet, and here is why: I already have an OpenID because I have a Blogger account. But I discovered that Blogger seems to be a poor provider when I tried to identify myself on the altdotnet page and recieved the following message: You must use an OpenID persona that specifies a v...
Switching your StackOverflow account from one OpenID provider to another can be a bit tricky since StackOverflow accounts are tied to specific OpenID identities. However, here's how you can go about it: 1. **Sign Up with a New OpenID Provider**: Create an account with your new OpenID provider and obtain your new OpenI...
1,100
[ { "from": "human", "value": "So I'm not quite convinced about OpenID yet, and here is why:\nI already have an OpenID because I have a Blogger account. But I discovered that Blogger seems to be a poor provider when I tried to identify myself on the altdotnet page and recieved the following message: \n\nYou m...
Within an application, I've got Secret Keys uses to calculate a hash for an API call. In a .NET application it's fairly easy to use a program like Reflector to pull out information from the assembly to include these keys. Is obfuscating the assembly a good way of securing these keys?
Obfuscating your .NET assembly is a commonly used technique to make it more difficult for an attacker to reverse engineer your application and extract sensitive information, including secret keys. While obfuscation can be a good step towards improving security, it's important to understand its limitations and consider ...
227
[ { "from": "human", "value": "Within an application, I've got Secret Keys uses to calculate a hash for an API call. In a .NET application it's fairly easy to use a program like Reflector to pull out information from the assembly to include these keys.\nIs obfuscating the assembly a good way of securing thes...
If I run the following query in SQL Server 2000 Query Analyzer: BULK INSERT OurTable FROM 'c:\OurTable.txt' WITH (CODEPAGE = 'RAW', DATAFILETYPE = 'char', FIELDTERMINATOR = '\t', ROWS_PER_BATCH = 10000, TABLOCK) On a text file that conforms to OurTable's schema for 40 lines, but then changes format for the last 20 ...
In SQL Server, the `BULK INSERT` statement is not transactional by default, meaning that if an error occurs while processing the data file, any rows that have already been successfully inserted will remain in the table, and only the failed insertions will be rolled back. This behavior is not specific to how you are cal...
265
[ { "from": "human", "value": "If I run the following query in SQL Server 2000 Query Analyzer:\nBULK INSERT OurTable \nFROM 'c:\\OurTable.txt' \nWITH (CODEPAGE = 'RAW', DATAFILETYPE = 'char', FIELDTERMINATOR = '\\t', ROWS_PER_BATCH = 10000, TABLOCK)\n\nOn a text file that conforms to OurTable's schema for 40...
Lutz Roeder's Reflector, that is. Its obfuscated. I still don't understand this. Can somebody please explain?
Lutz Roeder's Reflector is a tool used primarily for decompiling .NET assemblies, allowing developers to examine the code and structure of compiled .NET applications. When you say it is "obfuscated," you are referring to the practice of deliberately making the code difficult to understand, typically to protect intellec...
456
[ { "from": "human", "value": "Lutz Roeder's Reflector, that is.\nIts obfuscated.\n\nI still don't understand this. Can somebody please explain?\n" }, { "from": "gpt", "value": "Lutz Roeder's Reflector is a tool used primarily for decompiling .NET assemblies, allowing developers to examine the co...
I'm trying to get the following bit of code to work in LINQPad but am unable to index into a var. Anybody know how to index into a var in LINQ? string[] sa = {"one", "two", "three"}; sa[1].Dump(); var va = sa.Select( (a,i) => new {Line = a, Index = i}); va[1].Dump(); // Cannot apply indexing with [] to an expression o...
In LINQ, when you use the `Select` method, it returns an `IEnumerable<T>` which does not support indexing directly with square brackets (`[]`). This is why you are encountering the error message when trying to access `va[1]`. To access a specific element, you have a couple of options. Here are two common methods to ac...
731
[ { "from": "human", "value": "I'm trying to get the following bit of code to work in LINQPad but am unable to index into a var. Anybody know how to index into a var in LINQ?\nstring[] sa = {\"one\", \"two\", \"three\"};\nsa[1].Dump();\n\nvar va = sa.Select( (a,i) => new {Line = a, Index = i});\nva[1].Dump();...
When I am writing code in Python, I often need to remove items from a list or other sequence type based on some criteria. I haven't found a solution that is elegant and efficient, as removing items from a list you are currently iterating through is bad. For example, you can't do this: for name in names: if name[-5...
You're correct that removing items from a list while iterating through it can lead to issues. Instead of collecting items to remove in a separate list, a more elegant and efficient approach is to create a new list that contains only the items you want to keep. This can be achieved using list comprehensions or the `filt...
533
[ { "from": "human", "value": "When I am writing code in Python, I often need to remove items from a list or other sequence type based on some criteria. I haven't found a solution that is elegant and efficient, as removing items from a list you are currently iterating through is bad. For example, you can't d...
In Visual Basic, is there a performance difference when using the IIf function instead of the If statement?
Yes, there is a performance difference between using the `IIf` function and the `If` statement in Visual Basic. ### `IIf` Function: - The `IIf` function is a built-in function that evaluates both the true and false parts regardless of the condition. This means that if you have side effects in either part, both will be...
1,743
[ { "from": "human", "value": "In Visual Basic, is there a performance difference when using the IIf function instead of the If statement?\n" }, { "from": "gpt", "value": "Yes, there is a performance difference between using the `IIf` function and the `If` statement in Visual Basic.\n\n### `IIf` F...
What is a data binding?
Data binding is a programming technique used to connect data sources and UI components so that changes in one are reflected in the other. It is commonly used in various frameworks and technologies for building user interfaces, such as web applications, desktop applications, and mobile applications. In data binding, th...
1,589
[ { "from": "human", "value": "What is a data binding?\n" }, { "from": "gpt", "value": "Data binding is a programming technique used to connect data sources and UI components so that changes in one are reflected in the other. It is commonly used in various frameworks and technologies for building ...
I'm learning about table design in SQL and I'm wonder how to create a mapping table in order to establish a many-to-many relationship between two other tables? I think the mapping table needs two primary keys - but I can't see how to create that as it appears there can only be 1 primary key column? I'm using the Databa...
In SQL, to create a many-to-many relationship between two tables, you'll typically use a third table, often called a "mapping table" or "junction table." This mapping table will contain foreign keys referencing the primary keys of the two tables you're connecting. The mapping table can also have its own primary key, bu...
361
[ { "from": "human", "value": "I'm learning about table design in SQL and I'm wonder how to create a mapping table in order to establish a many-to-many relationship between two other tables?\nI think the mapping table needs two primary keys - but I can't see how to create that as it appears there can only be ...
I can't seem to find details on how to unsubscribe from ubiquity commands. The command list page only seems to have information about the installed commands and there are no links to deleting them. Am I missing something?
To unsubscribe or delete custom commands in Ubiquity (the command line interface for Ubuntu), you typically need to follow these steps: 1. **Open the Ubiquity directory**: Custom commands are usually stored in your home directory under `.local/share/ubiquity/`. You can navigate to this directory using the terminal: ...
710
[ { "from": "human", "value": "I can't seem to find details on how to unsubscribe from ubiquity commands. The command list page only seems to have information about the installed commands and there are no links to deleting them. Am I missing something?\n" }, { "from": "gpt", "value": "To unsubs...
I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia here and here)? How do they interact? Thanks. Anybody have a good, short example?
Certainly! **Cohesion** refers to how closely related and focused the responsibilities of a single module or component are. High cohesion means a module has a well-defined purpose and all its elements work together to fulfill that purpose. **Coupling** refers to the degree of interdependence between modules. Low cou...
1,418
[ { "from": "human", "value": "I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia here and here)? How do they interact?\nThanks.\nAnybody have a good, short example?\n" }...
If I have a trigger before the update on a table, how can I throw an error that prevents the update on that table?
To throw an error that prevents an update in a trigger, you can use the `RAISE` statement in a `BEFORE UPDATE` trigger. The specific syntax might vary slightly depending on the database system you are using (e.g., PostgreSQL, MySQL, SQL Server, etc.). Below, I'll provide examples for PostgreSQL and MySQL. ### PostgreS...
127
[ { "from": "human", "value": "If I have a trigger before the update on a table, how can I throw an error that prevents the update on that table?\n" }, { "from": "gpt", "value": "To throw an error that prevents an update in a trigger, you can use the `RAISE` statement in a `BEFORE UPDATE` trigger....
I have a friend that has a little bit of a holiday coming up and they want ideas on what they should do during the holiday, I plan to suggest programming to them, what are the pros and cons that I need to mention? I'll add to the list below as people reply, I apologise if I duplicate any entries. Pros I have so far Mi...
Here are some additional pros and cons of programming that you can consider adding to your list: ### Pros 1. **Variety of Learning Resources**: There are countless online resources, tutorials, and communities (e.g., freeCodeCamp, Codecademy, Stack Overflow) that provide support and learning opportunities for all skil...
774
[ { "from": "human", "value": "I have a friend that has a little bit of a holiday coming up and they want ideas on what they should do during the holiday, I plan to suggest programming to them, what are the pros and cons that I need to mention?\nI'll add to the list below as people reply, I apologise if I dup...
I'm doing some PHP stuff on an Ubuntu server. The path I'm working in is /mnt/dev-windows-data/Staging/mbiek/test_list but the PHP call getcwd() is returning /mnt/dev-windows/Staging/mbiek/test_list (notice how it's dev-windows instead of dev-windows-data). There aren't any symbolic links anywhere. Are there any other...
It's great to hear that you've figured out the issue! Just to clarify for others who might encounter similar situations, here’s a brief overview of what might cause `getcwd()` to return a different path than expected in a PHP environment on an Ubuntu server: 1. **Document Root**: As you discovered, the `$_SERVER['DOCU...
712
[ { "from": "human", "value": "I'm doing some PHP stuff on an Ubuntu server.\nThe path I'm working in is /mnt/dev-windows-data/Staging/mbiek/test_list but the PHP call getcwd() is returning /mnt/dev-windows/Staging/mbiek/test_list (notice how it's dev-windows instead of dev-windows-data).\nThere aren't any sy...
I have been doing some java development lately and have started using Eclipse. For the most part, I think it is great, but being a C/C++ guy used to doing all of his editing in vim, I find myself needlessly hitting the Esc key over and over. It would be really nice if I got all the nice features of Eclipse, but still ...
If you're looking for a way to integrate Vim-like editing into Eclipse, you have a couple of options: 1. **Eclipse Vimperator (Vim plugin)**: This plugin provides a Vim-like editing experience in Eclipse. It offers key bindings and modes similar to Vim. You can install it via the Eclipse Marketplace by searching for "...
1,849
[ { "from": "human", "value": "I have been doing some java development lately and have started using Eclipse. For the most part, I think it is great, but being a C/C++ guy used to doing all of his editing in vim, I find myself needlessly hitting the Esc key over and over.\nIt would be really nice if I got al...
My project is based on spring framework 2.5.4. And I try to add aspects for some controllers (I use aspectj 1.5.3). I've enabled auto-proxy in application-servlet.xml, just pasted these lines to the end of the xml file: <aop:aspectj-autoproxy /> <bean id="auditLogProcessor" class="com.example.bg.web.utils.AuditLogProce...
The issue you are facing where only `afterHandleRequest()` is being executed and not `afterRebuildThumbnail()` can be attributed to the way your pointcut expressions are defined. Both methods have the same pointcut expression targeting `rebuildThumbnail`, which means that both are associated with the same join point (t...
691
[ { "from": "human", "value": "My project is based on spring framework 2.5.4. And I try to add aspects for some controllers (I use aspectj 1.5.3).\nI've enabled auto-proxy in application-servlet.xml, just pasted these lines to the end of the xml file:\n<aop:aspectj-autoproxy />\n<bean id=\"auditLogProcessor\"...
In one of my VB6 forms, I create several other Form objects and store them in member variables. Private m_frm1 as MyForm Private m_frm2 as MyForm // Later... Set m_frm1 = New MyForm Set m_frm2 = New MyForm I notice that I'm leaking memory whenever this (parent) form is created and destroyed. Is it necessary for me t...
In VB6, managing memory effectively is crucial to avoid leaks, especially when working with forms and class modules. ### Unloading Forms When you create an instance of a form and assign it to a variable, that instance consumes memory. To free that memory when you're done with the form, you should use the `Unload` sta...
793
[ { "from": "human", "value": "In one of my VB6 forms, I create several other Form objects and store them in member variables.\nPrivate m_frm1 as MyForm\nPrivate m_frm2 as MyForm\n\n// Later...\nSet m_frm1 = New MyForm\nSet m_frm2 = New MyForm\n\nI notice that I'm leaking memory whenever this (parent) form is...
Is there any way to capture the MouseDown even from the .NET 2.0 TextBox control? I know the inherited Control class has the event, but it's not exposed in TextBox. Is there a way to override the event handler? I also tried the OpenNETCF TextBox2 control which does have the MouseDown event exposed, but no matter what I...
You are correct in your understanding that while the `TextBox` control in .NET does inherit from the `Control` class and has access to mouse events, the `MouseDown` event is overridden in the `TextBox` control, which can lead to unexpected behavior. In Windows Forms, the `TextBox` control does not expose mouse events ...
295
[ { "from": "human", "value": "Is there any way to capture the MouseDown even from the .NET 2.0 TextBox control?\nI know the inherited Control class has the event, but it's not exposed in TextBox.\nIs there a way to override the event handler?\nI also tried the OpenNETCF TextBox2 control which does have the M...
Does the Java language have delegate features, similar to how C# has support for delegates?
Java does not have a direct equivalent to C# delegates, but it provides similar functionality through the use of functional interfaces and lambda expressions, especially starting from Java 8. In C#, delegates are a type that represents references to methods with a specific signature. You can invoke methods through a d...
536
[ { "from": "human", "value": "Does the Java language have delegate features, similar to how C# has support for delegates?\n" }, { "from": "gpt", "value": "Java does not have a direct equivalent to C# delegates, but it provides similar functionality through the use of functional interfaces and lam...
If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be? I expect this list to be varied and to cover a wide range of things. To search: Use the search box in the upper-right corner. To search the answers of the current question, use ...
If I could go back in time and recommend specific books to read at the beginning of a developer's career, I would suggest a varied list that covers different aspects of software development, programming practices, and personal growth. Here are some top choices: 1. **"Code Complete" by Steve McConnell** This book ...
501
[ { "from": "human", "value": "If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be?\nI expect this list to be varied and to cover a wide range of things.\nTo search: Use the search box in the upper-right corner. To searc...
Everyone remembers google browser sync right? I thought it was great. Unfortunately Google decided not to upgrade the service to Firefox 3.0. Mozilla is developing a replacement for google browser sync which will be a part of the Weave project. I have tried using Weave and found it to be very very slow or totally inope...
Your thoughts on a self-hosted server/client package for browser synchronization are quite insightful. There are indeed several factors to consider when it comes to user-controlled synchronization solutions. 1. **Self-Hosting Benefits**: Having a self-hosted solution would give users greater control over their data an...
313
[ { "from": "human", "value": "Everyone remembers google browser sync right? I thought it was great. Unfortunately Google decided not to upgrade the service to Firefox 3.0. Mozilla is developing a replacement for google browser sync which will be a part of the Weave project. I have tried using Weave and found...
Does anyone have any recommendations of tools that can be of assistance with moving literal values into resource files for localization? I've used a resharper plugin called RGreatX but was wondering if there is anything else out there. It's one heck of a long manual process for moving the strings across and think there...
There are several tools and methods that can help streamline the process of extracting strings for localization and managing resource files. Here are some alternatives to RGreatX and other strategies you might find useful: 1. **LocLabs Multilizer**: A localization management tool that integrates well with various deve...
575
[ { "from": "human", "value": "Does anyone have any recommendations of tools that can be of assistance with moving literal values into resource files for localization?\nI've used a resharper plugin called RGreatX but was wondering if there is anything else out there.\nIt's one heck of a long manual process fo...
Is this type of control only available in a 3rd-party library? Has someone implemented an open source version?
To provide a more accurate response, I would need to know specifically which type of control you are referring to. There are many types of controls in programming and software development, such as UI controls, data controls, etc. In general, many controls can be found in both third-party libraries and open-source imp...
2,711
[ { "from": "human", "value": "Is this type of control only available in a 3rd-party library? Has someone implemented an open source version?\n" }, { "from": "gpt", "value": "To provide a more accurate response, I would need to know specifically which type of control you are referring to. There a...
Today I was listening to the Hanselminutes show about .NET 3.5 SP1...What's inside, and they twice mentioned the Office 2007-like Ribbon control that is included in Visual Studio 2008 Service Pack 1. I am very interested about this, as I was previously looking at purchasing this from a 3rd party vendor (likely DevCom...
The Ribbon control you're referring to was indeed introduced with Visual Studio 2008 SP1, but it primarily applies to Windows Forms (WinForms) applications rather than WPF (Windows Presentation Foundation). The Ribbon control in Visual Studio provides a way to create Office-style user interfaces, but as of that release...
2,087
[ { "from": "human", "value": "Today I was listening to the Hanselminutes show about .NET 3.5 SP1...What's inside, and they twice mentioned the Office 2007-like Ribbon control that is included in Visual Studio 2008 Service Pack 1. \nI am very interested about this, as I was previously looking at purchasing t...
Possible Duplicate: Configure Eclipse to use VS.Net shortcuts? I mostly work in VS2008 but I need to do some java work in Eclipse. Is there an easy and fast way to map the VS2008 keyboard shortcuts to Eclipse? For example, I want to map F11 in Eclipse to "step info" instead of its default of F5 but don't want to hav...
To map Visual Studio (VS2008) keyboard shortcuts to Eclipse, you can follow these steps: 1. **Install the Eclipse Plugin for VS Key Bindings**: - There is an Eclipse plugin called "Eclipse Visual Studio Key Bindings" that can help you with this. You can find it in the Eclipse Marketplace: - Go to `Help` -> `Ec...
1,417
[ { "from": "human", "value": "\nPossible Duplicate:\nConfigure Eclipse to use VS.Net shortcuts? \n\nI mostly work in VS2008 but I need to do some java work in Eclipse. Is there an easy and fast way to map the VS2008 keyboard shortcuts to Eclipse?\nFor example, I want to map F11 in Eclipse to \"step info\" in...
Here is the issue I am having: I have a large query that needs to compare datetimes in the where clause to see if two dates are on the same day. My current solution, which sucks, is to send the datetimes into a UDF to convert them to midnight of the same day, and then check those dates for equality. When it comes to ...
It looks like you're trying to optimize a SQL query that compares datetime values to determine if they fall on the same day. Using a User Defined Function (UDF) can indeed lead to performance issues, especially in JOINs or WHERE clauses, because the SQL optimizer may not be able to efficiently leverage indexes. Your a...
195
[ { "from": "human", "value": "Here is the issue I am having: I have a large query that needs to compare datetimes in the where clause to see if two dates are on the same day. My current solution, which sucks, is to send the datetimes into a UDF to convert them to midnight of the same day, and then check tho...
When coding web services, how do you structure your return values? How do you handle error conditions (expected ones and unexpected ones)? If you are returning something simple like an int, do you just return it, or embed it in a more complex object? Do all of the web methods within one service return an instance of...
When coding web services, structuring return values effectively is crucial for clarity, maintainability, and user experience. Here’s how you can approach return values and error handling in web services: ### Structuring Return Values 1. **Standard Response Format**: - A common practice is to use a standard respons...
642
[ { "from": "human", "value": "When coding web services, how do you structure your return values? How do you handle error conditions (expected ones and unexpected ones)? If you are returning something simple like an int, do you just return it, or embed it in a more complex object? Do all of the web methods...
Imagine you homebrew a custom gui framework that doesn't use windows handles (compact framework, so please don't argue with "whys"). One of the main disadvantages of developing such a framework is that you lose compatability with the winform designer. So my question is to all of you who know a lot about VS customisatio...
Integrating a custom GUI framework into the Visual Studio WinForms designer so that it generates your specific code instead of standard Windows Forms code can be a complex task. However, it is feasible with some creativity. Here’s a general outline of how you might approach this problem: ### 1. Create a Custom Control...
177
[ { "from": "human", "value": "Imagine you homebrew a custom gui framework that doesn't use windows handles (compact framework, so please don't argue with \"whys\"). One of the main disadvantages of developing such a framework is that you lose compatability with the winform designer.\nSo my question is to all...
I frequently work with multiple instances of Visual Studio, often working on different branches of the same solution. Visual C++ 6.0 used to display the full path of the current source file in its title bar, but Visual Studio 2005 doesn't appear to do this. This makes it slightly more awkward than it should be to work ...
In Visual Studio 2005, there isn't a built-in option to display the full path of the current source file in the title bar directly. However, there are a few workarounds that you can use to help identify which instance of Visual Studio you are working with: ### 1. **Use the "Window" Menu to Set Custom Titles** You can ...
1,015
[ { "from": "human", "value": "I frequently work with multiple instances of Visual Studio, often working on different branches of the same solution.\nVisual C++ 6.0 used to display the full path of the current source file in its title bar, but Visual Studio 2005 doesn't appear to do this. This makes it slight...
My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time. However, for reasons...
Yes, there is a standard way to gracefully restart Mongrel servers without interrupting ongoing requests. To achieve this, you can use the `USR2` signal, which allows you to gracefully restart the server. Here’s a step-by-step guide on how to implement this: ### 1. Sending the USR2 Signal You can send the `USR2` sig...
621
[ { "from": "human", "value": "My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel pr...
The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object instance. Although I know how to code the singleton pattern in C++ and Java, I was wondering if anyone know how to implement it in Ruby?
Certainly! The Singleton pattern in Ruby can be implemented using the built-in `Singleton` module, which provides a straightforward way to create a singleton class. Here’s how you can do it: ### Using the Singleton Module You can include the `Singleton` module in your class, which handles the details of ensuring that...
888
[ { "from": "human", "value": "The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object instance. Although I know how to code the singleton pattern in C++ and Java, I was wondering if anyone know how to implement it in Ruby?\n" }, { "from": "gpt", "...
Is it possible to embed a PowerPoint presentation (.ppt) into a webpage (.xhtml)? This will be used on a local intranet where there is a mix of Internet Explorer 6 and Internet Explorer 7 only, so no need to consider other browsers. I've given up... I guess Flash is the way forward.
Yes, it is possible to embed a PowerPoint presentation (.ppt) into a webpage (.xhtml), particularly if you're working within a local intranet and targeting Internet Explorer 6 and 7. While you mentioned considering Flash, here are a couple of methods to directly embed PowerPoint presentations without relying on Flash: ...
865
[ { "from": "human", "value": "Is it possible to embed a PowerPoint presentation (.ppt) into a webpage (.xhtml)?\nThis will be used on a local intranet where there is a mix of Internet Explorer 6 and Internet Explorer 7 only, so no need to consider other browsers.\n\nI've given up... I guess Flash is the way ...
In .net frameworks 1.1, I use System.Configuration.ConfigurationSettings.AppSettings["name"]; for application settings. But in .Net 2.0, it says ConfigurationSettings is obsolete and to use ConfigurationManager instead. So I swapped it out with this: System.Configuration.ConfigurationManager.AppSettings["name"]; Th...
It sounds like you're on the right track in trying to switch from `ConfigurationSettings` to `ConfigurationManager` in .NET 2.0. However, if you are encountering an issue where `ConfigurationManager` is not found in the `System.Configuration` namespace, it's likely due to one of the following reasons: 1. **Missing Ref...
728
[ { "from": "human", "value": "In .net frameworks 1.1, I use \nSystem.Configuration.ConfigurationSettings.AppSettings[\"name\"];\n\nfor application settings. But in .Net 2.0, it says ConfigurationSettings is obsolete and to use ConfigurationManager instead. So I swapped it out with this:\nSystem.Configuratio...
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the best build tool for .NET? I currently use NAnt but only because I have experience with Ant. Is MSBuild preferred?
When it comes to choosing a build tool for .NET, both NAnt and MSBuild have their advantages and may be preferred in different scenarios. Here’s a comparison to help you decide: ### MSBuild - **Integration**: MSBuild is tightly integrated with the .NET ecosystem and is the default build tool for Visual Studio and .NET...
1,241
[ { "from": "human", "value": "\nPossible Duplicate:\nNAnt or MSBuild, which one to choose and when? \n\nWhat is the best build tool for .NET?\nI currently use NAnt but only because I have experience with Ant. Is MSBuild preferred?\n" }, { "from": "gpt", "value": "When it comes to choosing a build...
I'm starting a new web project and I am considering two presentation frameworks. I am thinking either about ASP.NET MVC or Silverlight. I would tend toward Silverlight since I'm quite experienced .NET developer while I have just a basic knowledge of ASP.NET controls.
When considering a new web project and deciding between ASP.NET MVC and Silverlight, there are several factors to consider: ### ASP.NET MVC 1. **Web Standards**: ASP.NET MVC is built on web standards and is focused on creating robust web applications that can run in any modern web browser. It uses HTML, CSS, and Java...
395
[ { "from": "human", "value": "I'm starting a new web project and I am considering two presentation frameworks. I am thinking either about ASP.NET MVC or Silverlight. I would tend toward Silverlight since I'm quite experienced .NET developer while I have just a basic knowledge of ASP.NET controls.\n" }, {...
input: phrase 1, phrase 2 output: semantic similarity value (between 0 and 1), or the probability these two phrases are talking about the same thing
Sure! Please provide the two phrases you want to compare, and I'll generate a semantic similarity value for them.
3,499
[ { "from": "human", "value": "input: phrase 1, phrase 2\noutput: semantic similarity value (between 0 and 1), or the probability these two phrases are talking about the same thing\n" }, { "from": "gpt", "value": "Sure! Please provide the two phrases you want to compare, and I'll generate a semant...
Details: Only disable after user clicks the submit button, but before the posting back to the server ASP.NET Webforms (.NET 1.1) Prefer jQuery (if any library at all) Must be enabled if form reloads (i.e. credit card failed) This isn't a necessity that I do this, but if there is a simple way to do it without having t...
To achieve the requirement of disabling the submit button after it has been clicked, but before posting back to the server, you can use jQuery with a simple approach. The goal is to ensure that the button is disabled only once it is clicked, and it should be re-enabled when the form reloads, such as after a failed cred...
90
[ { "from": "human", "value": "Details:\n\nOnly disable after user clicks the submit button, but before the posting back to the server\nASP.NET Webforms (.NET 1.1)\nPrefer jQuery (if any library at all)\nMust be enabled if form reloads (i.e. credit card failed)\n\nThis isn't a necessity that I do this, but if...
How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e., simply changing the http:// in the URL t...
It appears you’ve already identified a solution to your issue regarding the `If-Modified-Since` header not being sent in HTTPS requests by Firefox 3.0.1. To summarize and elaborate on your findings: 1. **Browser Cache Settings**: The behavior you encountered can be influenced by the way the browser handles caching for...
847
[ { "from": "human", "value": "How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e.,...
I'm currently trying out db4o (the java version) and I pretty much like what I see. But I cannot help wondering how it does perform in a real live (web-)environment. Does anyone have any experiences (good or bad) to share about running db4o?
db4o (database for objects) is an object-oriented database that allows you to store and retrieve Java objects directly, making it a unique choice for Java developers who want to avoid the complexities of traditional relational databases. Here are some insights based on experiences shared by users in various environment...
237
[ { "from": "human", "value": "I'm currently trying out db4o (the java version) and I pretty much like what I see. But I cannot help wondering how it does perform in a real live (web-)environment. Does anyone have any experiences (good or bad) to share about running db4o? \n" }, { "from": "gpt", ...
Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single dimension arrays are the same?
In ColdFusion Markup Language (CFML), you can compare two single-dimensional arrays to check if they are the same by using the following approach: 1. **Check the array lengths**: If the lengths are not the same, the arrays cannot be the same. 2. **Compare each element**: Loop through the arrays and compare each corres...
653
[ { "from": "human", "value": "Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single dimension arrays are the same?\n" }, { "from": "gpt", "value": "In ColdFusion Markup Language (CFML), you can compare two single-dimensional arrays to check if they are the sam...
I'm about to start a fairly Ajax heavy feature in my company's application. What I need to do is make an Ajax callback every few minutes a user has been on the page. I don't need to do any DOM updates before, after, or during the callbacks. I don't need any information from the page, just from a site cookie which sh...
Using jQuery for your AJAX requests is a solid choice, especially since your site is already leveraging it. It simplifies the AJAX process and offers good cross-browser compatibility. Let's address your questions regarding data transfer and security concerns. ### Sending Data to IHttpHandler **1. Query String vs. POS...
142
[ { "from": "human", "value": "I'm about to start a fairly Ajax heavy feature in my company's application. What I need to do is make an Ajax callback every few minutes a user has been on the page. \n\nI don't need to do any DOM updates before, after, or during the callbacks. \nI don't need any information fro...
There are two popular closure styles in javascript. The first I call anonymous constructor: new function() { var code... } and the inline executed function: (function() { var code... })(); are there differences in behaviour between those two? Is one "better" over the other?
Yes, there are differences in behavior between the two styles of closures you've mentioned in JavaScript: the anonymous constructor (often used with the `new` keyword) and the immediately invoked function expression (IIFE). Let's break down the key differences and considerations for each. ### 1. Syntax and Usage **An...
380
[ { "from": "human", "value": "There are two popular closure styles in javascript. The first I call anonymous constructor:\nnew function() { \n var code...\n}\n\nand the inline executed function:\n(function() {\n var code...\n})();\n\nare there differences in behaviour between those two? Is one \"better\" o...
You should be able to create a generic form: public partial class MyGenericForm<T> : Form where T : class { /* form code */ public List<T> TypedList { get; set; } } Is valid C#, and compiles. However the designer won't work and the form will throw a runtime exception if you have any images stating that it...
Your observation is correct. When you create a generic form in Windows Forms, the designer faces issues with resource management. Specifically, the designer expects a non-generic type to manage resources properly, and since generic types can have multiple instantiations, the designer cannot resolve resource references ...
801
[ { "from": "human", "value": "You should be able to create a generic form:\npublic partial class MyGenericForm<T> :\n Form where T : class\n{\n /* form code */\n public List<T> TypedList { get; set; }\n}\n\nIs valid C#, and compiles. However the designer won't work and the form will throw a runtime...
If I have a variable in C# that needs to be checked to determine if it is equal to one of a set of variables, what is the best way to do this? I'm not looking for a solution that stores the set in an array. I'm more curious to see if there is a solution that uses boolean logic in some way to get the answer. I know I co...
In C#, if you want to check if a variable is equal to any one of a set of values without using an array or collection (while also avoiding repetition), your options are somewhat limited in pre-.NET 3.5 contexts. However, you can still achieve a more concise solution using the following approach, which employs a bit of ...
531
[ { "from": "human", "value": "If I have a variable in C# that needs to be checked to determine if it is equal to one of a set of variables, what is the best way to do this?\nI'm not looking for a solution that stores the set in an array. I'm more curious to see if there is a solution that uses boolean logic ...
I think the file that is produced is an .asm file, any idea how to produce this in Visual Studio when you do a build?
To produce an assembly language (.asm) file in Visual Studio when you build a project, you can follow these steps: ### Method 1: Using Project Properties 1. **Open your project in Visual Studio**. 2. **Right-click on the project** in the Solution Explorer and select **Properties**. 3. Navigate to **Configuration Prop...
1,161
[ { "from": "human", "value": "I think the file that is produced is an .asm file, any idea how to produce this in Visual Studio when you do a build?\n" }, { "from": "gpt", "value": "To produce an assembly language (.asm) file in Visual Studio when you build a project, you can follow these steps:\n...
I've heard of the idea of bootstrapping a language, that is, writing a compiler/interpreter for the language in itself. I was wondering how this could be accomplished and looked around a bit, and saw someone say that it could only be done by either writing an initial compiler in a different language. hand-coding an i...
Bootstrapping a programming language is indeed a fascinating concept in computer science, and you're correct that it involves writing a compiler or interpreter for a language in that same language. However, the process often starts with some external support, which is why people mention writing an initial compiler in a...
509
[ { "from": "human", "value": "I've heard of the idea of bootstrapping a language, that is, writing a compiler/interpreter for the language in itself. I was wondering how this could be accomplished and looked around a bit, and saw someone say that it could only be done by either\n\nwriting an initial compile...
I have a recursive algorithm which steps through a string, character by character, and parses it to create a tree-like structure. I want to be able to keep track of the character index the parser is currently at (for error messages as much as anything else) but am not keen on implementing something like a tuple to han...
Yes, you can achieve the desired functionality without heavily polluting your code or using complex data structures. Since you're using recursion and want to maintain the index across recursive calls, one approach you can take is to use an instance variable (if you are working within a class) to keep track of the index...
1,199
[ { "from": "human", "value": "I have a recursive algorithm which steps through a string, character by character, and parses it to create a tree-like structure. I want to be able to keep track of the character index the parser is currently at (for error messages as much as anything else) but am not keen on i...
Could someone tell me what the units the SetTimeout(int) method in the ICriteria interface uses? Is it milliseconds, seconds, minutes or other?
The `SetTimeout(int)` method in the `ICriteria` interface typically uses milliseconds as its unit of measurement. This is a common standard in programming for specifying timeouts, especially in contexts like database queries, where precise timing is crucial. If you're working with a specific framework or library, it's...
2,965
[ { "from": "human", "value": "Could someone tell me what the units the SetTimeout(int) method in the ICriteria interface uses?\nIs it milliseconds, seconds, minutes or other?\n" }, { "from": "gpt", "value": "The `SetTimeout(int)` method in the `ICriteria` interface typically uses milliseconds as ...
I cannot figure out how to change the title bar icon (the icon in the furthest top left corner of the application) in Adobe AIR. It is currently displaying the default 'Adobe AIR' red icon. I have been able to change it in the system tray, however.
To change the title bar icon (also known as the application icon) in an Adobe AIR application, you need to specify the appropriate icon in your `application.xml` file. Here's how to do that: ### Step 1: Create Your Icon Make sure you have an icon file ready. Ideally, you should have a PNG file that is 128x128 pixels ...
372
[ { "from": "human", "value": "I cannot figure out how to change the title bar icon (the icon in the furthest top left corner of the application) in Adobe AIR. It is currently displaying the default 'Adobe AIR' red icon. \nI have been able to change it in the system tray, however.\n" }, { "from": "gpt...
I'm looking for a presentation, PDF, blog post, or whitepaper discussing the technical details of how to filter down and display massive amounts of information for individual users in an intelligent (possibly machine learning) kind of way. I've had coworkers hear presentations on the Facebook news feed but I can't find...
Building a personalized content recommendation system like Facebook's News Feed involves several technical components, including data collection, filtering, ranking, and personalization using machine learning. Here are some resources and concepts that might help you get started on understanding and implementing a simil...
360
[ { "from": "human", "value": "I'm looking for a presentation, PDF, blog post, or whitepaper discussing the technical details of how to filter down and display massive amounts of information for individual users in an intelligent (possibly machine learning) kind of way. I've had coworkers hear presentations o...
I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL: http://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html Now I can transform an 8x8 section of a black a...
The Discrete Cosine Transform (DCT) is a powerful tool in image processing and compression, particularly in standards like JPEG and MPEG. Here's how you can leverage the DCT and some insights into the transformation you applied: ### How to Detect Similar 8x8 Blocks 1. **DCT Coefficients Analysis**: The DCT converts s...
235
[ { "from": "human", "value": "I've implemented an image/video transformation technique called discrete cosine transform. This technique is used in MPEG video encoding. I based my algorithm on the ideas presented at the following URL:\nhttp://vsr.informatik.tu-chemnitz.de/~jan/MPEG/HTML/mpeg_tech.html\nNow ...
I have an absolutely positioned div containing several children, one of which is a relatively positioned div. When I use a percentage-based width on the child div, it collapses to 0 width on IE7, but not on Firefox or Safari. If I use pixel width, it works. If the parent is relatively positioned, the percentage width o...
The issue you're encountering with percentage-based widths in Internet Explorer 7 (IE7) is a known problem with how that browser handles percentage widths in certain situations, especially when dealing with absolutely and relatively positioned elements. ### Explanation of the Issue 1. **Positioning Context**: In CSS,...
59
[ { "from": "human", "value": "I have an absolutely positioned div containing several children, one of which is a relatively positioned div. When I use a percentage-based width on the child div, it collapses to 0 width on IE7, but not on Firefox or Safari.\nIf I use pixel width, it works. If the parent is rel...
Is there a good, native Mac tool to view Mercurial repositories, similar to gitnub for Git?
Yes, there are several native Mac tools for viewing and managing Mercurial repositories. One popular option is **SourceTree**, which provides a user-friendly interface for both Git and Mercurial repositories. It offers features like branch visualization, commit history, and staging, making it easier to manage your code...
2,616
[ { "from": "human", "value": "Is there a good, native Mac tool to view Mercurial repositories, similar to gitnub for Git?\n" }, { "from": "gpt", "value": "Yes, there are several native Mac tools for viewing and managing Mercurial repositories. One popular option is **SourceTree**, which provides ...
I'm used to the Vi(m) editor and am using MS Visual Studio 2005 at work. I couldn't find a free Vi add-in (there's only one for the 2003 version). I googled a bit, saw that there was a 'Google summer of code' project this year to write such an add-in, and am eagerly awaiting the result. I've also heard of ViEmu (not fr...
It sounds like you're in a bit of a bind without a suitable Vi add-in for MS Visual Studio 2005. Here are a few suggestions that might help you find a solution: 1. **ViEmu**: Although you mentioned that you can't test it at work, if your workplace allows you to use it after going through the proper channels, it might ...
1,190
[ { "from": "human", "value": "I'm used to the Vi(m) editor and am using MS Visual Studio 2005 at work. I couldn't find a free Vi add-in (there's only one for the 2003 version). I googled a bit, saw that there was a 'Google summer of code' project this year to write such an add-in, and am eagerly awaiting the...
I'm attempting to create a dataset based on the properties of an object. For example, I have an instance of a Person class with properties including ID, Forename, Surname, DOB etc. Using reflection, I'm adding columns to a new dataset based on the object properties: For Each pi As PropertyInfo In person.GetType().GetPr...
Yes, you can extract the underlying type from a nullable type in .NET using the `Nullable.GetUnderlyingType` method. This method returns the underlying type of a nullable type or `null` if the type is not nullable. You can use this to determine the correct type to use when creating your `DataColumn`. Here's how you ca...
1,448
[ { "from": "human", "value": "I'm attempting to create a dataset based on the properties of an object. For example, I have an instance of a Person class with properties including ID, Forename, Surname, DOB etc. Using reflection, I'm adding columns to a new dataset based on the object properties:\nFor Each pi...
What Windows code editors allow the use of elastic tabstops, either natively or through a plugin? I know about a gedit plugin, but it only works on Linux.
Elastic tabstops are an interesting concept for managing indentation in code. They allow for more flexible alignment of code by adjusting tab widths based on the content of the lines. While many popular editors have not adopted elastic tabstops natively, some support them through plugins or extensions. Here are some Wi...
1,126
[ { "from": "human", "value": "What Windows code editors allow the use of elastic tabstops, either natively or through a plugin?\nI know about a gedit plugin, but it only works on Linux.\n" }, { "from": "gpt", "value": "Elastic tabstops are an interesting concept for managing indentation in code. ...
Despite primarily being a windows user, I am a huge fan of rsync. Now, I don't want to argue the virtues of rsync vs any other tool...this is not my point. The only way I've ever found of running rsync on windows is via a version that is built to run on top of Cygwin, and as Cygwin has issues with Unicode, so does rsy...
Porting `rsync` to a native Win32 binary is indeed possible, and the main hurdles you'd face would be related to platform differences, rather than insurmountable technical challenges. Here are some considerations to keep in mind if you're thinking of taking on this task: 1. **File System Differences**: Windows uses a ...
184
[ { "from": "human", "value": "Despite primarily being a windows user, I am a huge fan of rsync. Now, I don't want to argue the virtues of rsync vs any other tool...this is not my point.\nThe only way I've ever found of running rsync on windows is via a version that is built to run on top of Cygwin, and as C...
Is there a performance difference between i++ and ++i if the resulting value is not used?
In languages like C, C++, and Java, the performance difference between `i++` (post-increment) and `++i` (pre-increment) is generally negligible when the resulting value is not used. Both operations increment the value of `i` by one, but they do so in slightly different ways: - `i++` returns the current value of `i` an...
2,149
[ { "from": "human", "value": "Is there a performance difference between i++ and ++i if the resulting value is not used?\n" }, { "from": "gpt", "value": "In languages like C, C++, and Java, the performance difference between `i++` (post-increment) and `++i` (pre-increment) is generally negligible ...
I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command: SELECT HashBytes('MD5', 'HelloWorld') However, this returns a VarBinary instead of a VarChar value. If I attempt to convert 0x68E109F0F40CA72A15E05CC22786F8E6 into a VarChar I get há ðô§*à\Â'†øæ instead of 68E109F0F4...
In SQL Server 2005, the `HashBytes` function returns a `VARBINARY` result. To convert this `VARBINARY` result into a hexadecimal string representation, you can use the `CONVERT` function along with the `style` parameter set to 1 for hexadecimal format. However, SQL Server does not have a built-in function to directly c...
1,270
[ { "from": "human", "value": "I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command:\nSELECT HashBytes('MD5', 'HelloWorld')\n\nHowever, this returns a VarBinary instead of a VarChar value. If I attempt to convert 0x68E109F0F40CA72A15E05CC22786F8E6 into a VarCha...
I love list comprehensions in Python, because they concisely represent a transformation of a list. However, in other languages, I frequently find myself writing something along the lines of: foreach (int x in intArray) if (x > 3) //generic condition on x x++ //do other processing This example is in C#, wher...
Yes, you're right that in C# and many other languages, there are more elegant ways to handle list transformations and filtering beyond using traditional loops. In C#, LINQ (Language Integrated Query) is indeed a powerful tool that can help with this, allowing you to manipulate collections more concisely. In your examp...
84
[ { "from": "human", "value": "I love list comprehensions in Python, because they concisely represent a transformation of a list.\nHowever, in other languages, I frequently find myself writing something along the lines of:\nforeach (int x in intArray)\n if (x > 3) //generic condition on x\n x++ \n //do...
I have a project that I'm currently working on but it currently only supports the .net framework 2.0. I love linq, but because of the framework version I can't use it. What I want isn't so much the ORM side of things, but the "queryability" (is that even a word?) of Linq. So far the closest is llblgen but if there was...
While LINQ (Language Integrated Query) is a powerful feature available in later versions of the .NET Framework, you won't be able to use it directly in .NET Framework 2.0. However, there are alternative ways to achieve similar "queryability" without adopting a full ORM solution like NHibernate or LLBLGen. Here are a f...
224
[ { "from": "human", "value": "I have a project that I'm currently working on but it currently only supports the .net framework 2.0. I love linq, but because of the framework version I can't use it. What I want isn't so much the ORM side of things, but the \"queryability\" (is that even a word?) of Linq. \nSo...
Disclaimer: This is not actually a programming question, but I feel the audience on stackoverflow is more likely to have an answer than most question/answer sites out there. Please forgive me, Joel, for stealing your question. Joel asked this question on a podcast a while back but I don't think it ever got resolved. ...
Hi Kurt, I understand your frustration with the reminder system across multiple devices when using Microsoft Outlook and Exchange. This is a common issue that many users face when dealing with reminders that sync across various platforms. Here's a breakdown of the issue and some potential solutions you might consider...
300
[ { "from": "human", "value": "Disclaimer: This is not actually a programming question, but I feel the audience on stackoverflow is more likely to have an answer than most question/answer sites out there.\nPlease forgive me, Joel, for stealing your question. Joel asked this question on a podcast a while back...
I was recently tasked with coming up with an offsite backup strategy. We have about 2TB of data that would need to be backed up so our needs are a little out of the norm. I looked into Iron Mountain and they wanted $12,000 a month! Does anyone have any suggestions on how best to handle backing up this much data on a ...
It's unfortunate that you had such a critical failure, but it sounds like you're now in a position to prioritize and implement a robust backup strategy. Here are some budget-friendly options for offsite backups for your 2TB of data: ### 1. **Cloud Storage Solutions** - **Backblaze B2**: A cost-effective cloud stora...
443
[ { "from": "human", "value": "I was recently tasked with coming up with an offsite backup strategy. We have about 2TB of data that would need to be backed up so our needs are a little out of the norm. \nI looked into Iron Mountain and they wanted $12,000 a month! \nDoes anyone have any suggestions on how bes...
I'm using the RESTful authentication Rails plugin for an app I'm developing. I'm having a strange issue I can't get to the bottom of. Essentially, the first time I log into the app after a period of inactivity (the app is deployed in production, but only being used by me), I will be brought to a 404 page, but if I go b...
This issue you're experiencing could be caused by a few different factors related to session handling and authentication state in your Rails application. Here are several possibilities to investigate: 1. **Session Expiry**: If your session times out after a period of inactivity, the first login attempt may not be prop...
16
[ { "from": "human", "value": "I'm using the RESTful authentication Rails plugin for an app I'm developing.\nI'm having a strange issue I can't get to the bottom of.\nEssentially, the first time I log into the app after a period of inactivity (the app is deployed in production, but only being used by me), I w...
When editing XAML in VS2008 SP1, the editor is really slow. devenv process seems to be around at 40% CPU (the machine I’m using at the moment is only dual core, so that’s almost maxing out one core) most of the time. It spikes up a bit more when I switch to another XAML file. I do also have ReSharper installed, but I t...
If you are experiencing slowness when editing XAML files in Visual Studio 2008 SP1, especially with ReSharper installed, there are several strategies you can try to improve the performance: 1. **Disable ReSharper Features**: Since ReSharper can add overhead, you might want to selectively disable some of its features. ...
31
[ { "from": "human", "value": "When editing XAML in VS2008 SP1, the editor is really slow. devenv process seems to be around at 40% CPU (the machine I’m using at the moment is only dual core, so that’s almost maxing out one core) most of the time. It spikes up a bit more when I switch to another XAML file. I ...
#if SYMBOL //code #endif what values does C# predefine for use?
In C#, the `#if` directive is used in preprocessor directives to conditionally include or exclude code based on the defined symbols. While C# does not come with predefined symbols like some other languages (e.g., C/C++), there are a few common predefined symbols that you might encounter. However, these are usually prov...
990
[ { "from": "human", "value": "#if SYMBOL\n //code\n#endif\n\nwhat values does C# predefine for use?\n" }, { "from": "gpt", "value": "In C#, the `#if` directive is used in preprocessor directives to conditionally include or exclude code based on the defined symbols. While C# does not come with pr...
I know in certain circumstances, such as long running processes, it is important to lock ASP.NET cache in order to avoid subsequent requests by another user for that resource from executing the long process again instead of hitting the cache. What is the best way in c# to implement cache locking in ASP.NET?
Implementing cache locking in ASP.NET is important when dealing with long-running processes that may populate the cache. The goal is to ensure that if one request is populating the cache, other requests for the same resource will wait for it to finish rather than starting another expensive process. One way to achieve ...
45
[ { "from": "human", "value": "I know in certain circumstances, such as long running processes, it is important to lock ASP.NET cache in order to avoid subsequent requests by another user for that resource from executing the long process again instead of hitting the cache.\nWhat is the best way in c# to imple...
I've written a stored proc that will do an update if a record exists, otherwise it will do an insert. It looks something like this: update myTable set Col1=@col1, Col2=@col2 where ID=@ID if @@rowcount = 0 insert into myTable (Col1, Col2) values (@col1, @col2) My logic behind writing it in this way is that the update w...
Your logic regarding the approach to combining an `UPDATE` and `INSERT` operation in a stored procedure is generally sound. You are aiming to handle both the cases of an existing record (to update) and a non-existing record (to insert) efficiently. However, there are some nuances and optimizations you may want to consi...
510
[ { "from": "human", "value": "I've written a stored proc that will do an update if a record exists, otherwise it will do an insert. It looks something like this:\nupdate myTable set Col1=@col1, Col2=@col2 where ID=@ID\nif @@rowcount = 0\ninsert into myTable (Col1, Col2) values (@col1, @col2)\n\nMy logic behi...
I work on a large Visual C++ (MFC) project in VS.NET 2005. I have noticed strange behavior in Visual C++ 2005. Often, I will change one line of code in a .CPP file but many .CPP files will compile as a result of this. I have never seen this until VS.NET 2005. Theortically, changing a line of code in a .CPP file should ...
In Visual C++ (MFC) projects and in general C++ projects, the build system operates on a set of rules related to dependencies. When you modify a .CPP file, it may trigger a recompilation of other files based on several factors related to the way dependencies are structured in your project. Here are some common reasons ...
1,613
[ { "from": "human", "value": "I work on a large Visual C++ (MFC) project in VS.NET 2005.\nI have noticed strange behavior in Visual C++ 2005. Often, I will change one line of code in a .CPP file but many .CPP files will compile as a result of this. I have never seen this until VS.NET 2005. Theortically, chan...
I know I can figure out the name of the method as its being executed, just wondering if there is a way from the setup method. I guess an attribute method would work but from the setup method it would be the best. EDIT NUnit
In NUnit, if you want to retrieve the name of the currently executing test method from the `SetUp` method, you can use the `TestContext` class, which provides various properties related to the test execution context. Here's an example of how you can access the name of the currently running test within the `SetUp` meth...
522
[ { "from": "human", "value": "I know I can figure out the name of the method as its being executed, just wondering if there is a way from the setup method. I guess an attribute method would work but from the setup method it would be the best.\nEDIT NUnit\n" }, { "from": "gpt", "value": "In NUnit,...
SHA Hash functions
SHA (Secure Hash Algorithm) is a family of cryptographic hash functions designed by the National Security Agency (NSA) and published by the National Institute of Standards and Technology (NIST). They are widely used in various security applications and protocols, including SSL/TLS, PGP, SSH, and more. Here’s an overv...
384
[ { "from": "human", "value": "SHA Hash functions\n" }, { "from": "gpt", "value": "SHA (Secure Hash Algorithm) is a family of cryptographic hash functions designed by the National Security Agency (NSA) and published by the National Institute of Standards and Technology (NIST). They are widely used...
I am trying to implement string unescaping with Python regex and backreferences, and it doesn't seem to want to work very well. I'm sure it's something I'm doing wrong but I can't figure out what... >>> import re >>> mystring = r"This is \n a test \r" >>> p = re.compile( "\\\\(\\S)" ) >>> p.sub( "\\1", mystring ) 'This...
In Python's regex handling, backreferences and replacement strings can sometimes be a bit confusing, especially when dealing with escape sequences. Let's clarify what you're trying to achieve: you want to replace instances of `\\[char]` with `\[char]`, effectively removing one backslash before a character. Here's how...
1,186
[ { "from": "human", "value": "I am trying to implement string unescaping with Python regex and backreferences, and it doesn't seem to want to work very well. I'm sure it's something I'm doing wrong but I can't figure out what...\n>>> import re\n>>> mystring = r\"This is \\n a test \\r\"\n>>> p = re.compile( ...
In Perl, an object is just a reference to any of the basic Perl data types that has been blessed into a particular class. When you use the ref() function on an unblessed reference, you are told what data type the reference points to. However, when you call ref() on a blessed reference, you are returned the name of th...
In Perl, when you have a blessed reference and want to find out the underlying type of the reference, you can use the `ref` function to check if it is blessed. If it is blessed, you can dereference it to find out its underlying type. Here’s how you can do this: 1. Use the `ref` function to check if the reference is b...
982
[ { "from": "human", "value": "In Perl, an object is just a reference to any of the basic Perl data types that has been blessed into a particular class. When you use the ref() function on an unblessed reference, you are told what data type the reference points to. However, when you call ref() on a blessed r...
Warning - I am very new to NHibernate. I know this question seems simple - and I'm sure there's a simple answer, but I've been spinning my wheels for some time on this one. I am dealing with a legacy db which really can't be altered structurally. I have a details table which lists payment plans that have been accepted ...
You're encountering a common situation when working with NHibernate and legacy databases, especially when dealing with relationships between entities. Given your scenario, here's a clearer breakdown of how to manage the relationship without unnecessarily creating parent objects. ### Key Concepts 1. **Many-to-One Rela...
802
[ { "from": "human", "value": "Warning - I am very new to NHibernate. I know this question seems simple - and I'm sure there's a simple answer, but I've been spinning my wheels for some time on this one. I am dealing with a legacy db which really can't be altered structurally. I have a details table which lis...
So, we have coding books, coding RSS feeds, and music to code by. Are there any coding magazines that anyone would recommend?
Yes, there are several coding magazines that you might find interesting and helpful for staying updated on programming trends, techniques, and technologies. Here are some popular ones: 1. **Linux Journal** - Focused on Linux programming and open-source software, it includes tutorials, articles, and news relevant to th...
1,617
[ { "from": "human", "value": "So, we have coding books, coding RSS feeds, and music to code by. Are there any coding magazines that anyone would recommend?\n" }, { "from": "gpt", "value": "Yes, there are several coding magazines that you might find interesting and helpful for staying updated on ...
I'm a software engineer, not a lawyer, and my university doesn't offer any courses geared toward licensing software. In fact, their law-related courses are lacking (but slowly growing in number). Where can I go to learn about open-source licenses and how to choose them?
Learning about open-source licenses is a valuable skill for software engineers, especially if you're working on projects that may be open-sourced or interact with existing open-source software. Here are several resources where you can learn about open-source licenses and how to choose them: 1. **Online Courses**: -...
273
[ { "from": "human", "value": "I'm a software engineer, not a lawyer, and my university doesn't offer any courses geared toward licensing software. In fact, their law-related courses are lacking (but slowly growing in number). Where can I go to learn about open-source licenses and how to choose them?\n" }, ...
What particular method/application are you using to communicate between your application and a database? Custom code with stored procedures? SubSonic? nHibernate? Entity Framework? LINQ?
As an AI language model, I don't have a specific application or a direct connection to a database. However, I can provide an overview of the common methods and applications used to communicate between an application and a database: 1. **Custom Code with Stored Procedures**: This approach involves writing custom code (...
1,515
[ { "from": "human", "value": "What particular method/application are you using to communicate between your application and a database? Custom code with stored procedures? SubSonic? nHibernate? Entity Framework? LINQ?\n" }, { "from": "gpt", "value": "As an AI language model, I don't have a sp...
I'm thinking of starting a wiki, probably on a low cost LAMP hosting account. I'd like the option of exporting my content later in case I want to run it on IIS/ASP.NET down the line. I know in the weblog world, there's an open standard called BlogML which will let you export your blog content to an XML based format on ...
Yes, there are several options for exporting and migrating wiki content, which can help you transition from a LAMP stack to an IIS/ASP.NET environment in the future. While there isn’t a single standard equivalent to BlogML specifically for wikis, many popular wiki engines offer their own export/import capabilities that...
7
[ { "from": "human", "value": "I'm thinking of starting a wiki, probably on a low cost LAMP hosting account. I'd like the option of exporting my content later in case I want to run it on IIS/ASP.NET down the line. I know in the weblog world, there's an open standard called BlogML which will let you export you...
I recently ran out of disk space on a drive on a FreeBSD server. I truncated the file that was causing problems but I'm not seeing the change reflected when running df. When I run du -d0 on the partition it shows the correct value. Is there any way to force this information to be updated? What is causing the output...
The issue you're encountering on your FreeBSD server is likely related to the way file deletions and truncations work in the filesystem. When you truncate a file, the space it occupies is not released until all processes that have it open are closed. This is especially relevant for log files, database files, or any oth...
1,341
[ { "from": "human", "value": "I recently ran out of disk space on a drive on a FreeBSD server. I truncated the file that was causing problems but I'm not seeing the change reflected when running df. When I run du -d0 on the partition it shows the correct value. Is there any way to force this information t...
Whats the best/easiest way to obtain a count of items within an IEnumerable collection without enumerating over all of the items in the collection? Possible with LINQ or Lambda?
In C#, if you have an `IEnumerable<T>` collection and you want to obtain a count of items without enumerating over all of the items, you can use the `ICollection<T>` interface instead, which provides a direct `Count` property. However, if you are working specifically with `IEnumerable<T>`, you do not have direct access...
1,482
[ { "from": "human", "value": "Whats the best/easiest way to obtain a count of items within an IEnumerable collection without enumerating over all of the items in the collection?\nPossible with LINQ or Lambda?\n" }, { "from": "gpt", "value": "In C#, if you have an `IEnumerable<T>` collection and y...
According to the PHP Safe Mode Docs on safe_mode_gid: By default, Safe Mode does a UID compare check when opening files. If you want to relax this to a GID compare, then turn on safe_mode_gid. Whether to use UID (FALSE) or GID (TRUE) checking upon file access. To a PHP script running on a web server, what is the diff...
In the context of PHP Safe Mode (which is a deprecated feature and has been removed as of PHP 5.4.0), the distinction between UID (User Identifier) checking and GID (Group Identifier) checking pertains to how permissions are evaluated when a PHP script attempts to access files. ### UID (User Identifier) Check - **Defi...
674
[ { "from": "human", "value": "According to the PHP Safe Mode Docs on safe_mode_gid:\n\nBy default, Safe Mode does a UID compare check when opening files. If you want to relax this to a GID compare, then turn on safe_mode_gid. Whether to use UID (FALSE) or GID (TRUE) checking upon file access.\n\nTo a PHP scr...
I have a table in a SQL Server 2005 database with a trigger that is supposed to add a record to a different table whenever a new record is inserted. It seems to work fine, but if I execute an Insert Into on the master table that uses a subquery as the source of the values, the trigger only inserts one record in the oth...
In SQL Server, triggers that operate on a set of records can behave differently than you might expect if they are not designed to handle multiple rows. In your case, the trigger is currently only fetching a single record from the `Inserted` pseudo-table, which contains all the records that are affected by the `INSERT` ...
334
[ { "from": "human", "value": "I have a table in a SQL Server 2005 database with a trigger that is supposed to add a record to a different table whenever a new record is inserted. It seems to work fine, but if I execute an Insert Into on the master table that uses a subquery as the source of the values, the t...
Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D control) looks extremely ugly because it is by default not antialiased as the rest of the WPF graphics are. Especially at lower resolution the experience is so bad that it can not be used in production code. I have managed to force an...
Unfortunately, WPF on Windows XP has inherent limitations when it comes to true 3D rendering and antialiasing, primarily due to the graphics stack in XP and how WPF was designed to work with DirectX. Since Windows XP was released before WPF, the support for certain graphics capabilities, including true 3D antialiasing,...
550
[ { "from": "human", "value": "Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D control) looks extremely ugly because it is by default not antialiased as the rest of the WPF graphics are. Especially at lower resolution the experience is so bad that it can not be used in pr...
What's the best way to import a CSV file into a strongly-typed data structure?
Importing a CSV file into a strongly-typed data structure typically involves a few key steps: reading the CSV file, parsing the data, and mapping the data to a predefined structure. The method may vary slightly depending on the programming language you are using, but the general approach remains consistent. Below are e...
871
[ { "from": "human", "value": "What's the best way to import a CSV file into a strongly-typed data structure?\n" }, { "from": "gpt", "value": "Importing a CSV file into a strongly-typed data structure typically involves a few key steps: reading the CSV file, parsing the data, and mapping the data ...
Recently, I started changing some of our applications to support MS SQL Server as an alternative back end. One of the compatibility issues I ran into is the use of MySQL's CREATE TEMPORARY TABLE to create in-memory tables that hold data for very fast access during a session with no need for permanent storage. What is ...
In MS SQL Server, you can create temporary tables using the `CREATE TABLE` statement with a special naming convention. There are two types of temporary tables you can use: 1. **Local Temporary Tables**: These tables are prefixed with a single `#` (hash sign). They are scoped to the session that created them and are au...
950
[ { "from": "human", "value": "Recently, I started changing some of our applications to support MS SQL Server as an alternative back end. \nOne of the compatibility issues I ran into is the use of MySQL's CREATE TEMPORARY TABLE to create in-memory tables that hold data for very fast access during a session wi...
I'd like to have a python program alert me when it has completed its task by making a beep noise. Currently, I use import os and then use a command line speech program to say "Process complete". I much rather it be a simple "bell." I know that there's a function that can be used in Cocoa apps, NSBeep, but I don't th...
To make a beep sound in a Python program running on a Mac, you can use the `os` module to call a simple system command that plays the system beep sound. Here’s a simple way to do it using `os.system`: ```python import os def beep(): os.system('afplay /System/Library/Sounds/Glass.aiff') # Example task def main_ta...
1,655
[ { "from": "human", "value": "I'd like to have a python program alert me when it has completed its task by making a beep noise. Currently, I use import os and then use a command line speech program to say \"Process complete\". I much rather it be a simple \"bell.\"\nI know that there's a function that can...
I am using MSBuild to build my stuff. I want to use CruiseControl.net as by Build Server. Now, CCNET refers nAnt a lot, but it looks as if ccnet can do most of the stuff nant could do through the project configuration and msbuild. Also, nAnt seems a bit unsupported, with a Beta release that is almost a year old now. In...
Using MSBuild over nAnt or vice versa depends on a variety of factors, including your specific project requirements, team familiarity with the tools, and the overall build process. Here are some reasons you might consider using nAnt over MSBuild, despite your current comfort with MSBuild: ### 1. Existing Infrastructur...
113
[ { "from": "human", "value": "I am using MSBuild to build my stuff. I want to use CruiseControl.net as by Build Server.\nNow, CCNET refers nAnt a lot, but it looks as if ccnet can do most of the stuff nant could do through the project configuration and msbuild. Also, nAnt seems a bit unsupported, with a Beta...
I've just come across this in a WHERE clause: AND NOT (t.id = @id) How does this compare with: AND t.id != @id Or with: AND t.id <> @id I'd always write the latter myself, but clearly someone else thinks differently. Is one going to perform any better than the other? I know that using <> or != is going to bust any h...
The three conditions you've presented in the `WHERE` clause are functionally equivalent, meaning they all check whether `t.id` is not equal to the parameter `@id`. Here’s a breakdown of each: 1. **`AND NOT (t.id = @id)`**: This condition explicitly checks if `t.id` is not equal to `@id` by negating the equality check....
738
[ { "from": "human", "value": "I've just come across this in a WHERE clause:\nAND NOT (t.id = @id)\n\nHow does this compare with:\nAND t.id != @id\n\nOr with:\nAND t.id <> @id\n\nI'd always write the latter myself, but clearly someone else thinks differently. Is one going to perform any better than the other?...
I have a setup project created by Visual Studio 2005, and consists of both a C# .NET 2.0 project and C++ MFC project, and the C++ run time. It works properly when run from the main console, but when run over a Terminal Server session on a Windows XP target, the install fails in the following way - When the Setup.exe...
Troubleshooting installation issues over Terminal Server can be challenging, especially when the problem only occurs on certain machines. Here are some steps to help you identify and resolve the issue: ### 1. Check Event Viewer Inspect the Windows Event Viewer on the failing machine. Look for any error messages relate...
563
[ { "from": "human", "value": "I have a setup project created by Visual Studio 2005, and consists of both a C# .NET 2.0 project and C++ MFC project, and the C++ run time. It works properly when run from the main console, but when run over a Terminal Server session on a Windows XP target, the install fails in...
Say I have a site on http://example.com. I would really like allowing bots to see the home page, but any other page need to blocked as it is pointless to spider. In other words http://example.com & http://example.com/ should be allowed, but http://example.com/anything and http://example.com/someendpoint.aspx should be...
To configure your site to allow web crawlers (bots) to access the homepage and block all other pages while also allowing certain query strings on the homepage, you can use the `robots.txt` file. Here’s how you can structure your `robots.txt` file: ```plaintext User-agent: * Allow: / Disallow: /*/ # Block all pages ex...
1,454
[ { "from": "human", "value": "Say I have a site on http://example.com. I would really like allowing bots to see the home page, but any other page need to blocked as it is pointless to spider. In other words\nhttp://example.com & http://example.com/ should be allowed, but \nhttp://example.com/anything and htt...
I have a bunch of files that I need to be able to transport and install quickly. My current method for doing so is moving a flash drive with a readme file of where stuff goes whenever I need to move stuff, which is rather inelegant and cumbersome. My idea for a solution would be to write up a quick script to move files...
If you're looking to streamline your process of moving and installing files, a custom script is a great approach. While you mentioned having some experience with Bash scripting, diving into Batch scripting for Windows is not too difficult, and there are many resources available to help you get started. ### Batch Scrip...
461
[ { "from": "human", "value": "I have a bunch of files that I need to be able to transport and install quickly. My current method for doing so is moving a flash drive with a readme file of where stuff goes whenever I need to move stuff, which is rather inelegant and cumbersome.\nMy idea for a solution would b...
I am using the ODBC connector to access a MySQL db from Visual Studio 2008 and I'm facing performance problems when dealing with crystal reports and to solve this I need a native connector to visual studio. If someone has had a similar problem and knows a solution or tools (freeware preferable), I would be really grate...
If you're experiencing performance issues with the ODBC connector while accessing a MySQL database from Visual Studio 2008, switching to a native connector can indeed help improve the efficiency and performance of your application, especially when using Crystal Reports. Here are some options you might consider: ### 1....
271
[ { "from": "human", "value": "I am using the ODBC connector to access a MySQL db from Visual Studio 2008 and I'm facing performance problems when dealing with crystal reports and to solve this I need a native connector to visual studio. If someone has had a similar problem and knows a solution or tools (free...
When I want to make a copy of a database, I always create a new empty database, and then restore a backup of the existing database into it. However, I'm wondering if this is really the least error-prone, least complicated, and most efficient way to do this?
Creating a copy of a database is a common task, and there are several methods you can use depending on the database management system (DBMS) you are using and your specific requirements. The method you've described—creating a new empty database and restoring a backup—is certainly one of the most straightforward approac...
406
[ { "from": "human", "value": "When I want to make a copy of a database, I always create a new empty database, and then restore a backup of the existing database into it. However, I'm wondering if this is really the least error-prone, least complicated, and most efficient way to do this?\n" }, { "from...
Is there any free or commercial component written in .NET (no COM interop) that will work with most twain scanners?
Yes, there are several free and commercial .NET libraries and components that can interface with TWAIN scanners without requiring COM interop. Here are some options you can explore: ### Free Options: 1. **TwainDotNet**: - **Description**: An open-source .NET library that wraps the TWAIN API, allowing for the integ...
134
[ { "from": "human", "value": "Is there any free or commercial component written in .NET (no COM interop) that will work with most twain scanners?\n" }, { "from": "gpt", "value": "Yes, there are several free and commercial .NET libraries and components that can interface with TWAIN scanners withou...
I am writing a query in which I have to get the data for only the last year. What is the best way to do this? SELECT ... FROM ... WHERE date > '8/27/2007 12:00:00 AM'
To retrieve data from the last year in SQL, you should use the current date and time as a reference. The specific function to use can vary based on the SQL database you are using (e.g., MySQL, PostgreSQL, SQL Server, Oracle, etc.). Here are some examples for different SQL dialects: ### MySQL ```sql SELECT ... FROM ...
345
[ { "from": "human", "value": "I am writing a query in which I have to get the data for only the last year. What is the best way to do this?\nSELECT ... FROM ... WHERE date > '8/27/2007 12:00:00 AM'\n\n" }, { "from": "gpt", "value": "To retrieve data from the last year in SQL, you should use the c...
I am trying to learn the keyboard shortcuts in Visual Studio in order to be more productive. So I downloaded a document showing many of the default keybindings in Visual Basic when using the VS 2008 IDE from Microsoft. When I tried what they say is the keyboard shortcut to view all open documents (CTRL + ALT + DOWN AR...
It sounds like you accidentally triggered a feature in your graphics driver that rotates the screen display rather than executing a command in Visual Studio. This behavior can often happen when certain combinations of keyboard shortcuts are set up to control screen orientation. In Visual Studio 2008, the default keybo...
2,478
[ { "from": "human", "value": "I am trying to learn the keyboard shortcuts in Visual Studio in order to be more productive. So I downloaded a document showing many of the default keybindings in Visual Basic when using the VS 2008 IDE from Microsoft.\nWhen I tried what they say is the keyboard shortcut to vie...