instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
I've got a menu in Python. That part was easy. I'm using raw_input() to get the selection from the user. The problem is that raw_input (and input) require the user to press Enter after they make a selection. Is there any way to make the program act immediately upon a keystroke? Here's what I've got so far: import sys ...
To achieve immediate action upon keystrokes in a console application, you can use libraries that allow you to capture keyboard input without needing to press Enter. A popular library for this purpose is `keyboard`, which allows you to listen for keyboard events. First, you'll need to install the `keyboard` library if ...
726
[ { "from": "human", "value": "I've got a menu in Python. That part was easy. I'm using raw_input() to get the selection from the user. \nThe problem is that raw_input (and input) require the user to press Enter after they make a selection. Is there any way to make the program act immediately upon a keystroke...
I'm using Microsoft AjaxControlToolkit for modal popup window. And on a modal popup window, when a postback occurred, the window was closing. How do I prevent from the closing action of the modal popup?
When you're using the `AjaxControlToolkit`'s modal popup in an ASP.NET application, the modal will typically close if there's a postback, especially if you're using controls that trigger a postback (like buttons or links). To prevent the modal popup from closing on postback, you can take the following approaches: ###...
101
[ { "from": "human", "value": "I'm using Microsoft AjaxControlToolkit for modal popup window.\nAnd on a modal popup window, when a postback occurred, the window was closing. How do I prevent from the closing action of the modal popup?\n" }, { "from": "gpt", "value": "When you're using the `AjaxCon...
In a machine with AIX without PERL I need to filter records that will be considered duplicated if they have the same id and if they were registered between a period of four hours. I implemented this filter using AWK and work pretty well but I need a solution much faster: # Generar lista de Duplicados awk 'BEGIN { FS...
To speed up the process of filtering duplicate records based on the criteria you've outlined (same ID and registration within a 4-hour window), you can consider a few optimization strategies and adjustments to your `awk` script. Here are some recommendations: 1. **Optimize mktime Function**: If your date parsing is re...
893
[ { "from": "human", "value": "In a machine with AIX without PERL I need to filter records that will be considered duplicated if they have the same id and if they were registered between a period of four hours. \nI implemented this filter using AWK and work pretty well but I need a solution much faster: \n\n#...
It seems to me obfuscation is an idea that falls somewhere in the "security by obscurity" or "false sense of protection" camp. To protect intellectual property, there's copyright; to prevent security issues from being found, there's fixing those issues. In short, I regard it as a technical solution to a social problem....
You're raising some important points about obfuscation and its place in software development, particularly regarding intellectual property protection and security. Let’s break down your concerns and consider both the arguments for and against obfuscation, including the engineering benefits it might provide. ### Argume...
890
[ { "from": "human", "value": "It seems to me obfuscation is an idea that falls somewhere in the \"security by obscurity\" or \"false sense of protection\" camp. To protect intellectual property, there's copyright; to prevent security issues from being found, there's fixing those issues. In short, I regard it...
Are there any good online resources for how to create, maintain and think about writing test routines for numerical analysis code? One of the limitations I can see for something like testing matrix multiplication is that the obvious tests (like having one matrix being the identity) may not fully test the functionality ...
Creating and maintaining test routines for numerical analysis code is indeed challenging, particularly when dealing with floating-point operations and large data structures. Here are some online resources and ideas to help you design effective test routines: ### Online Resources 1. **Software Testing Books and Articl...
835
[ { "from": "human", "value": "Are there any good online resources for how to create, maintain and think about writing test routines for numerical analysis code?\nOne of the limitations I can see for something like testing matrix multiplication is that the obvious tests (like having one matrix being the ident...
I'm asking this question purely from a usability standpoint! Should a website expand/stretch to fill the viewing area when you resize a browser window? I know for sure there are the obvious cons: Wide columns of text are hard to read. Writing html/css using percents can be a pain. It makes you vulnerable to having you...
Your question about whether a website should expand or stretch to fill the viewing area when resizing a browser window is an important one, particularly from a usability and user experience perspective. Here are some key points to consider, including pros and cons: ### Pros of Responsive/Fluid Design: 1. **Improved R...
303
[ { "from": "human", "value": "I'm asking this question purely from a usability standpoint!\nShould a website expand/stretch to fill the viewing area when you resize a browser window?\nI know for sure there are the obvious cons:\n\nWide columns of text are hard to read.\nWriting html/css using percents can be...
Is there a way to export a simple HTML page to Word (.doc format, not .docx) without having Microsoft Word installed?
Yes, you can export a simple HTML page to the Word (.doc) format without having Microsoft Word installed by using various methods and tools. Here are some options: ### 1. **Using Online Converters** There are several online services that can convert HTML to .doc format. Here are a few popular ones: - **Zamzar**: (zam...
1,444
[ { "from": "human", "value": "Is there a way to export a simple HTML page to Word (.doc format, not .docx) without having Microsoft Word installed?\n" }, { "from": "gpt", "value": "Yes, you can export a simple HTML page to the Word (.doc) format without having Microsoft Word installed by using va...
Why does the order in which libraries are linked sometimes cause errors in GCC?
In GCC (GNU Compiler Collection) and other linkers, the order in which libraries are linked can affect the success of the build process due to the way symbol resolution works during the linking phase. Here are some reasons why the order of linking libraries can lead to errors: 1. **Symbol Resolution**: When the linker...
1,420
[ { "from": "human", "value": "Why does the order in which libraries are linked sometimes cause errors in GCC?\n" }, { "from": "gpt", "value": "In GCC (GNU Compiler Collection) and other linkers, the order in which libraries are linked can affect the success of the build process due to the way sym...
I have an actionscript file that defines a class that I would like to use inside a Flex application. I have defined some custom controls in a actionscript file and then import them via the application tag: <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:scorecard="com.apterasoftware.scorecard...
To import a regular ActionScript class into a Flex application (which is typically used for UI components), you just need to ensure the class is available in your Flex application's classpath. You do not need to use the `xmlns` attribute to import a non-visual ActionScript class. Instead, you can import the class in yo...
866
[ { "from": "human", "value": "I have an actionscript file that defines a class that I would like to use inside a Flex application. \nI have defined some custom controls in a actionscript file and then import them via the application tag:\n\n\n<mx:Application\n xmlns:mx=\"http://www.adobe.com/2006/mxml\"\n...
I mostly use Java and generics are relatively new. I keep reading that Java made the wrong decision or that .NET has better implementations etc. etc. So, what are the main differences between C++, C#, Java in generics? Pros/cons of each?
Generics are a powerful feature in programming languages that allow for the creation of classes, interfaces, and methods with type parameters. Here's a breakdown of how generics are implemented in C++, C#, and Java, along with the pros and cons of each approach. ### 1. **Java Generics** #### Implementation: - Introdu...
414
[ { "from": "human", "value": "I mostly use Java and generics are relatively new. I keep reading that Java made the wrong decision or that .NET has better implementations etc. etc.\nSo, what are the main differences between C++, C#, Java in generics? Pros/cons of each?\n" }, { "from": "gpt", "valu...
How much should one DataSet represent? Using the example of an ordering system: While showing your order I also show a list of items similar to one of yours as well as a list of our most popular items. While your items are tangled in a web of relationships involving you and your past orders, preferred suppliers, and t...
The design of your DataSets for an ordering system hinges on the balance between complexity, maintainability, and performance. Here are some considerations to guide you in structuring your DataSets effectively: ### 1. **Understanding Data Relationships**: - **Unique Relationships**: If the items associated with a s...
1,081
[ { "from": "human", "value": "How much should one DataSet represent? Using the example of an ordering system: While showing your order I also show a list of items similar to one of yours as well as a list of our most popular items.\nWhile your items are tangled in a web of relationships involving you and yo...
I've used Trac/Subversion before and really like the integration. My current project is using Mercurial for distributed development and it'd be nice to be able to track issues/bugs and have this be integrated with Mercurial. I realized this could be tricky with the nature of DVCS.
Integrating issue tracking with Mercurial (Hg) can be a great way to streamline your development workflow, even if it's a distributed version control system. There are several options available to achieve this integration, including dedicated issue trackers and tools that can bridge the gap between Mercurial and issue ...
1,757
[ { "from": "human", "value": "I've used Trac/Subversion before and really like the integration. My current project is using Mercurial for distributed development and it'd be nice to be able to track issues/bugs and have this be integrated with Mercurial. I realized this could be tricky with the nature of DVC...
I understand how I can change the dns settings for my domains by editing my bind configs, when I run my own name-servers. I know that I can define the name-servers with my registrar via their online control panels. But I have no idea how that part works... How does my registrar store the data about the name-servers? Is...
Certainly! Understanding how domain name registrars store and manage name server information can be a bit complex, but I'll break it down for you. ### Overview of DNS and Registrars 1. **Domain Name System (DNS)**: The DNS is essentially the phone book of the internet, translating human-friendly domain names (like `e...
1,298
[ { "from": "human", "value": "I understand how I can change the dns settings for my domains by editing my bind configs, when I run my own name-servers. I know that I can define the name-servers with my registrar via their online control panels. But I have no idea how that part works...\nHow does my registrar...
Does SQL Server 2008 ship with the .NET 3.5 CLR, so that stored procedures written in CLR can use 3.5 features?
SQL Server 2008 does indeed support the .NET Framework 3.5 Common Language Runtime (CLR). This means that you can write CLR stored procedures and other CLR objects in SQL Server 2008 using the features available in .NET Framework 3.5. When you create CLR stored procedures or functions for SQL Server 2008, you can leve...
1,968
[ { "from": "human", "value": "Does SQL Server 2008 ship with the .NET 3.5 CLR, so that stored procedures written in CLR can use 3.5 features?\n" }, { "from": "gpt", "value": "SQL Server 2008 does indeed support the .NET Framework 3.5 Common Language Runtime (CLR). This means that you can write CL...
I have a set of base filenames, for each name 'f' there are exactly two files, 'f.in' and 'f.out'. I want to write a batch file (in Windows XP) which goes through all the filenames, for each one it should: Display the base name 'f' Perform an action on 'f.in' Perform another action on 'f.out' I don't have any way to...
You can create a batch file to loop through all the `.in` files in a directory, extract the base filenames, and perform actions on both the `.in` and `.out` files accordingly. Here's a simple example of what the batch file might look like: ```batch @echo off setlocal enabledelayedexpansion :: Loop through all .in fil...
682
[ { "from": "human", "value": "I have a set of base filenames, for each name 'f' there are exactly two files, 'f.in' and 'f.out'. I want to write a batch file (in Windows XP) which goes through all the filenames, for each one it should:\n\nDisplay the base name 'f'\nPerform an action on 'f.in'\nPerform anoth...
In Java, there is no such thing as an unsigned byte. Working with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which causes Java to interpret them as a negative number due to the MSB being used for sign. What's a good way to work around this? (Saying don't us...
In Java, the `byte` type is signed and can hold values from -128 to 127. If you need to work with bytes that represent unsigned values in the range of 0 to 255, you can work around this limitation by using the `int` type to represent the unsigned byte values. Here are several approaches to deal with this issue: ### 1...
983
[ { "from": "human", "value": "In Java, there is no such thing as an unsigned byte.\nWorking with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which causes Java to interpret them as a negative number due to the MSB being used for sign.\nWhat's a goo...
A Windows process created from an exe file has access to the command string that invoked it, including its file's path and filename. eg. C:\MyApp\MyApp.exe --help. But this is not so for a DLL invoked via LoadLibrary. Does anyone know of a way for a function loaded via DLL to find out what its path and filename are? Sp...
In Delphi, if you want to determine the path and filename of a DLL that's loaded via `LoadLibrary`, you can use the Windows API function `GetModuleFileName`. This function retrieves the full path of the executable file of a specified module (which can be a DLL). Here's a step-by-step solution to get the path and file...
1,235
[ { "from": "human", "value": "A Windows process created from an exe file has access to the command string that invoked it, including its file's path and filename. eg. C:\\MyApp\\MyApp.exe --help.\nBut this is not so for a DLL invoked via LoadLibrary. Does anyone know of a way for a function loaded via DLL to...
I'd like to make a debug logging function with the same parameters as printf. But one that can be removed by the pre-processor during optimized builds. For example: Debug_Print("Warning: value %d > 3!\n", value); I've looked at variadic macros but those aren't available on all platforms. gcc supports them, msvc does ...
To create a debug logging function that mimics the behavior of `printf`, can take a variable number of arguments, and can be removed in optimized builds, you can use a combination of macros and inline functions. Since you want a solution that is compatible across platforms, we can make use of preprocessor directives an...
1,765
[ { "from": "human", "value": "I'd like to make a debug logging function with the same parameters as printf. But one that can be removed by the pre-processor during optimized builds.\nFor example:\nDebug_Print(\"Warning: value %d > 3!\\n\", value);\n\nI've looked at variadic macros but those aren't available...
Is there an easy way to find the storage card's path on a Windows Mobile device when there is a storage card and a bluetooth ftp connection?
Finding the storage card's path on a Windows Mobile device can vary slightly depending on the specific version of the OS and the device model. However, there are general steps you can follow to locate the storage card's path, especially when you are connected via Bluetooth FTP. Here’s a basic outline you can use: ###...
1,363
[ { "from": "human", "value": "Is there an easy way to find the storage card's path on a Windows Mobile device\nwhen there is a storage card and a bluetooth ftp connection?\n" }, { "from": "gpt", "value": "Finding the storage card's path on a Windows Mobile device can vary slightly depending on th...
The official guidelines suggest that there can be very few practical uses for these. Does anyone have examples of where they've put them to good use?
It seems like you're referring to a specific technology, tool, or method, but it's not clear which one you're talking about. Could you please specify what you're referring to? This way, I can provide relevant examples of practical uses or applications.
4,425
[ { "from": "human", "value": "The official guidelines suggest that there can be very few practical uses for these. Does anyone have examples of where they've put them to good use?\n" }, { "from": "gpt", "value": "It seems like you're referring to a specific technology, tool, or method, but it's ...
If you add a image to your browser's DOM, IE6 will not check its cache to see if it already downloaded the image but will, instead, re-retrieve it from the server. I have not found any combination of HTTP response headers (of the ensuing image request) to convince IE6 that it can cache the image: Cache-control, Expir...
Internet Explorer 6 (IE6) is known for its peculiar caching behavior, especially when it comes to dynamically added images in the DOM. When you programmatically add an image to the DOM, IE6 often treats it differently compared to images added in the HTML markup initially. As a result, it may not check its cache and ins...
1,785
[ { "from": "human", "value": "If you add a image to your browser's DOM, IE6 will not check its cache to see if it already downloaded the image but will, instead, re-retrieve it from the server. I have not found any combination of HTTP response headers (of the ensuing image request) to convince IE6 that it c...
What is the best way to upload a file to a Document Library on a SharePoint server through the built-in web services that version WSS 3.0 exposes? Following the two initial answers... We definitely need to use the Web Service layer as we will be making these calls from remote client applications. The WebDAV method wou...
Yes, you are correct that the "Copy" web service in WSS 3.0 is the recommended way to upload files to a Document Library programmatically. The `CopyIntoItems` method is specifically designed for this purpose and works well for uploading files to SharePoint from remote client applications. Here’s a general outline of h...
857
[ { "from": "human", "value": "What is the best way to upload a file to a Document Library on a SharePoint server through the built-in web services that version WSS 3.0 exposes?\nFollowing the two initial answers...\n\nWe definitely need to use the Web Service layer as we will be making these calls from remot...
Should the folders in a solution match the namespace? In one of my teams projects, we have a class library that has many sub-folders in the project. Project Name and Namespace: MyCompany.Project.Section. Within this project, there are several folders that match the namespace section: Folder Vehicles has classes in the...
In software development, particularly in C# and other languages that use namespaces, it's generally considered a best practice for the folder structure in a project to correspond to the namespace structure. This approach provides several benefits: 1. **Clarity and Consistency**: When folder structure matches the names...
881
[ { "from": "human", "value": "Should the folders in a solution match the namespace?\nIn one of my teams projects, we have a class library that has many sub-folders in the project.\nProject Name and Namespace: MyCompany.Project.Section.\nWithin this project, there are several folders that match the namespace ...
I need to create an XML schema that looks something like this: <xs:element name="wrapperElement"> <xs:complexType> <xs:sequence> <xs:element type="el1"> <xs:element type="el2"> </xs:sequence> <xs:WhatGoesHere?> <xs:element type="el3"> <xs:element type="el4"> <xs:ele...
To allow for any number of elements (`el3`, `el4`, and `el5`) to appear in any order within your XML schema, you can use the `<xs:choice>` element in conjunction with the `<xs:sequence>` element. The `<xs:choice>` element allows you to specify that any of the contained elements may appear in any order, and you can use ...
782
[ { "from": "human", "value": "I need to create an XML schema that looks something like this:\n<xs:element name=\"wrapperElement\">\n<xs:complexType>\n <xs:sequence>\n <xs:element type=\"el1\">\n <xs:element type=\"el2\">\n </xs:sequence>\n\n <xs:WhatGoesHere?>\n <xs:element type...
My C code snippet takes the address of an argument and stores it in a volatile memory location (preprocessed code): void foo(unsigned int x) { *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)(&x); } int main() { foo(1); while(1); } I used an SVN version of GCC for compiling this code. At the e...
The behavior you're observing when compiling with optimization flags (`-O1`) is indeed related to how the compiler optimizes the function `foo()`. When optimizations are applied, the compiler is free to make decisions about how to handle variable storage and usage, potentially leading to unexpected behaviors if you rel...
347
[ { "from": "human", "value": "My C code snippet takes the address of an argument and stores it in a volatile memory location (preprocessed code):\nvoid foo(unsigned int x) {\n *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)(&x);\n}\n\nint main() {\n foo(1);\n while(1);\n}\n\nI used an S...
Depending on my mood I seem to waffle back and forth between wanting a Lisp-1 and a Lisp-2. Unfortunately beyond the obvious name space differences, this leaves all kinds of amusing function name/etc problems you run into. Case in point, trying to write some code tonight I tried to do (map #'function listvar) which, ...
Dealing with the differences between Lisp-1 and Lisp-2 systems can indeed be a source of confusion, particularly in the context of Common Lisp, which is a Lisp-2. Here are some strategies to help minimize the confusion and streamline your experience when switching between Lisp dialects: 1. **Familiarize Yourself with ...
157
[ { "from": "human", "value": "Depending on my mood I seem to waffle back and forth between wanting a Lisp-1 and a Lisp-2. Unfortunately beyond the obvious name space differences, this leaves all kinds of amusing function name/etc problems you run into. Case in point, trying to write some code tonight I tri...
I'd like to learn how to program in Assembler. I've done a bit of assembly before (during my A-Level Computing course) but that was very definitely a simplified 'pseudo-assembler'. I've borrowed my Dad's old Z80 Assembler reference manual, and that seems quite interesting so if possible I'd like to have a go with Z80 a...
Getting started with Z80 assembly programming on a PC is a great choice, especially if you're looking to learn the nuances of low-level programming. Here are some suggestions for assemblers and simulators that should help you get started on either Windows or Linux. ### Z80 Simulators and Development Environments 1. *...
427
[ { "from": "human", "value": "I'd like to learn how to program in Assembler. I've done a bit of assembly before (during my A-Level Computing course) but that was very definitely a simplified 'pseudo-assembler'. I've borrowed my Dad's old Z80 Assembler reference manual, and that seems quite interesting so if ...
If I call finalize() on an object from my program code, will the JVM still run the method again when the garbage collector processes this object? This would be an approximate example: MyObject m = new MyObject(); m.finalize(); m = null; System.gc() Would the explicit call to finalize() make the JVM's garbage collec...
In Java, calling the `finalize()` method explicitly on an object does not prevent the garbage collector from running the `finalize()` method on that object when it is being collected. This is because the `finalize()` method is part of the object lifecycle as managed by the garbage collector. In your example: ```java ...
2,228
[ { "from": "human", "value": "If I call finalize() on an object from my program code, will the JVM still run the method again when the garbage collector processes this object?\nThis would be an approximate example:\nMyObject m = new MyObject();\n\nm.finalize();\n\nm = null;\n\nSystem.gc()\n\nWould the explic...
I have a C++ app that needs to connect to a JAVA web app, are there any good, open source SOAP packages for this, or would it be easier to just roll my own?
Connecting a C++ application to a Java web application using SOAP can be accomplished using various open-source libraries. Here are some popular options for both C++ and Java that can facilitate SOAP communication: ### C++ SOAP Libraries: 1. **gSOAP**: - **Description**: gSOAP is a popular toolkit for C/C++ that a...
1,232
[ { "from": "human", "value": "I have a C++ app that needs to connect to a JAVA web app, are there any good, open source SOAP packages for this, or would it be easier to just roll my own?\n" }, { "from": "gpt", "value": "Connecting a C++ application to a Java web application using SOAP can be acco...
Large pages are available in Windows Server 2003 and Windows Vista. But how do I enable large pages for my application?
Enabling large pages for an application in Windows Server 2003 and Windows Vista involves several steps, both at the application level and, potentially, at the system level. Here's how to do it: ### 1. Enable the Large Page Memory Option for Your Application You need to modify your application to use large pages. Thi...
34
[ { "from": "human", "value": "Large pages are available in Windows Server 2003 and Windows Vista. \nBut how do I enable large pages for my application? \n" }, { "from": "gpt", "value": "Enabling large pages for an application in Windows Server 2003 and Windows Vista involves several steps, both a...
Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE and through the Tools -> Options I changed the homepage to iGoogle.com. Clicked okay and then clicked the homepage button. IE crashes. Now you'd think that I could just remove iGoogle as the homepage but when I open IE it immediately g...
Yes, you can change the Internet Explorer homepage without opening the browser by modifying the Windows Registry. Here’s how to do it: ### Method 1: Modify the Registry 1. **Open the Registry Editor**: - Press `Win + R` to open the Run dialog. - Type `regedit` and press `Enter`. - If prompted by User Account...
2,483
[ { "from": "human", "value": "Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE and through the Tools -> Options I changed the homepage to iGoogle.com. Clicked okay and then clicked the homepage button. IE crashes.\nNow you'd think that I could just remove iGoogle as the ho...
I need to create a backup of a SQL Server 2005 Database that's only the structure...no records, just the schema. Is there any way to do this? EDIT: I'm trying to create a backup file to use with old processes, so a script wouldn't work for my purposes, sorry
Creating a backup of a SQL Server 2005 database that includes only the schema (no data) while generating a backup file is a bit tricky, as SQL Server does not directly support creating a backup of only the schema. However, you can achieve this through a combination of tasks. Here’s a method that allows you to create a...
2,392
[ { "from": "human", "value": "I need to create a backup of a SQL Server 2005 Database that's only the structure...no records, just the schema. Is there any way to do this?\nEDIT: I'm trying to create a backup file to use with old processes, so a script wouldn't work for my purposes, sorry\n" }, { "fr...
I'm looking to add a testing suite to my application, however I can't move to the newer testing frameworks for .NET 3.5. Does anyone have a suggestion about good testing frameworks to use?
For .NET 3.5, there are a few reliable testing frameworks that you can consider to set up a testing suite for your application: 1. **NUnit**: NUnit is one of the most popular testing frameworks for .NET and supports .NET 3.5. It provides a rich set of assertions and test attributes to help you write and organize your ...
2,132
[ { "from": "human", "value": "I'm looking to add a testing suite to my application, however I can't move to the newer testing frameworks for .NET 3.5. \nDoes anyone have a suggestion about good testing frameworks to use?\n" }, { "from": "gpt", "value": "For .NET 3.5, there are a few reliable test...
I want to print HTML from a C# web service. The web browser control is overkill, and does not function well in a service environment, nor does it function well on a system with very tight security constraints. Is there any sort of free .NET library that will support the printing of a basic HTML page? Here is the cod...
Printing HTML directly from a C# application in a non-UI environment (such as a Windows service) is indeed challenging due to the limitations of the `WebBrowser` control and the need for an STA (Single Threaded Apartment) thread. Since you want a solution that works without the overhead of a full browser control or GUI...
1,307
[ { "from": "human", "value": "I want to print HTML from a C# web service. The web browser control is overkill, and does not function well in a service environment, nor does it function well on a system with very tight security constraints. Is there any sort of free .NET library that will support the printi...
One of the articles I really enjoyed reading recently was Quality Control by Last.FM. In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't believe in Log Monitoring, why? I'm looking for a mix of opinion slash experience here I gue...
It's great to hear that you enjoyed the article on Quality Control by Last.FM! Monitoring setups for web applications can be crucial for ensuring performance, reliability, and user satisfaction. Here are some common strategies and tools people often use, as well as some opinions on the topic of log monitoring. ### Pop...
1,091
[ { "from": "human", "value": "One of the articles I really enjoyed reading recently was Quality Control by Last.FM. In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't believe in Log Monitoring, why?\nI'm looking for a ...
As I learn more and more about OOP, and start to implement various design patterns, I keep coming back to cases where people are hating on Active Record. Often, people say that it doesn't scale well (citing Twitter as their prime example) -- but nobody actually explains why it doesn't scale well; and / or how to achiev...
Active Record is a popular design pattern in Object-Relational Mapping (ORM) frameworks, where an object is directly linked to a database table, and each object instance corresponds to a row in the table. While Active Record has its advantages, such as simplicity and ease of use, it also has several drawbacks, particul...
675
[ { "from": "human", "value": "As I learn more and more about OOP, and start to implement various design patterns, I keep coming back to cases where people are hating on Active Record.\nOften, people say that it doesn't scale well (citing Twitter as their prime example) -- but nobody actually explains why it ...
I'm creating an automated installation of Office 2007. To customise your Office 2007 installation the Office Customization Tool (OCT) does most of the work for you. One the OCT's features is the ability to run additional programs during the Office installation. However it is pretty poor at it. Fortunately by editi...
The error message you're encountering indicates that there is a problem with the parsing of the `config.xml` file, likely due to incorrect formatting or escaping of characters. When it comes to using double-quotation marks in XML attributes, it’s important to ensure that you follow proper XML syntax and escaping rules....
3,132
[ { "from": "human", "value": "I'm creating an automated installation of Office 2007. To customise your Office 2007 installation the Office Customization Tool (OCT) does most of the work for you. One the OCT's features is the ability to run additional programs during the Office installation. However it is ...
The need arose, in our product, to determine how long the current user has been logged on to Windows (specifically, Vista). It seems there is no straight forward API function for this and I couldn't find anything relevant with WMI (although I'm no expert with WMI, so I might have missed something). Any ideas?
To determine how long a user has been logged onto a Windows Vista system, you can achieve this by using the Windows API to access system information. While there isn't a direct API function that provides the login duration, you can use a combination of the `GetSystemTimes` function and the `GetTickCount` function to ca...
730
[ { "from": "human", "value": "The need arose, in our product, to determine how long the current user has been logged on to Windows (specifically, Vista). It seems there is no straight forward API function for this and I couldn't find anything relevant with WMI (although I'm no expert with WMI, so I might hav...
Personally I like this one: P.S. Do not hotlink the cartoon without the site's permission please.
It sounds like you’re sharing or referring to a specific cartoon or image. Hotlinking refers to the practice of linking directly to an image or file on someone else’s server, which can take bandwidth away from the original site. It’s always best to share content by linking back to the original source or obtaining permi...
4,255
[ { "from": "human", "value": "Personally I like this one:\n\nP.S. Do not hotlink the cartoon without the site's permission please. \n" }, { "from": "gpt", "value": "It sounds like you’re sharing or referring to a specific cartoon or image. Hotlinking refers to the practice of linking directly to ...
I've recently switched to Linux on my work machine and, new to the Linux desktop environment, I'd like to find a decent ERD tool for database design. Booting back into my Windows partition every time I need to create a diagram is going to get unpleasant quickly. I looked at Dia, but didn't see any DB tools - only UML...
Welcome to the world of Linux! There are several ERD (Entity-Relationship Diagram) tools you can use on Ubuntu that will help you with database design. Here are some popular options: 1. **MySQL Workbench**: This is a powerful tool that provides a visual interface for database design, including ERD capabilities. It sup...
1,663
[ { "from": "human", "value": "I've recently switched to Linux on my work machine and, new to the Linux desktop environment, I'd like to find a decent ERD tool for database design. Booting back into my Windows partition every time I need to create a diagram is going to get unpleasant quickly. I looked at Di...
Has anyone used the lockfile utility that ships with procmail in conjunction with NFS mounted directories? The lockfile man page states that "Lockfile is NFS-resistant and eight-bit clean."
Yes, the `lockfile` utility that comes with `procmail` is designed to manage concurrent access to files and ensure that operations are performed safely, especially in environments like NFS (Network File System) where traditional file locking mechanisms may not work as reliably. The statement in the man page that "Lock...
1,289
[ { "from": "human", "value": "Has anyone used the lockfile utility that ships with procmail in conjunction with NFS mounted directories?\nThe lockfile man page states that \"Lockfile is NFS-resistant and eight-bit clean.\"\n" }, { "from": "gpt", "value": "Yes, the `lockfile` utility that comes wi...
As per this comment in a related thread, I'd like to know why Levenshtein distance based methods are better than Soundex.
Levenshtein distance and Soundex are both algorithms used for comparing strings, but they have different purposes and strengths. Here are some reasons why Levenshtein distance methods might be considered better than Soundex in certain contexts: 1. **Flexibility**: Levenshtein distance calculates the minimum number of ...
1,009
[ { "from": "human", "value": "As per this comment in a related thread, I'd like to know why Levenshtein distance based methods are better than Soundex.\n" }, { "from": "gpt", "value": "Levenshtein distance and Soundex are both algorithms used for comparing strings, but they have different purpose...
I need debug some old code that uses a Hashtable to store response from various threads. I need a way to go through the entire Hashtable and print out both keys and the data in the Hastable. How can this be done?
You can iterate through a `Hashtable` in Java using the `keys()` method and `elements()` method. Below is a simple example of how to go through the entire `Hashtable` and print out both keys and their associated values: ```java import java.util.Hashtable; import java.util.Enumeration; public class HashtableExample { ...
2,293
[ { "from": "human", "value": "I need debug some old code that uses a Hashtable to store response from various threads.\nI need a way to go through the entire Hashtable and print out both keys and the data in the Hastable.\nHow can this be done?\n" }, { "from": "gpt", "value": "You can iterate thr...
I'm working on an internal project for my company, and part of the project is to be able to parse various "Tasks" from an XML file into a collection of tasks to be ran later. Because each type of Task has a multitude of different associated fields, I decided it would be best to represent each type of Task with a sepera...
Certainly! The `TaskFactory.CreateTask` method can be improved by leveraging a more extensible design, allowing you to avoid the cumbersome switch statement. One common approach is to use a dictionary to map XML element names to corresponding task classes. This method will make it easy to add new task types in the futu...
241
[ { "from": "human", "value": "I'm working on an internal project for my company, and part of the project is to be able to parse various \"Tasks\" from an XML file into a collection of tasks to be ran later.\nBecause each type of Task has a multitude of different associated fields, I decided it would be best ...
I'm currently implementing a raytracer. Since raytracing is extremely computation heavy and since I am going to be looking into CUDA programming anyway, I was wondering if anyone has any experience with combining the two. I can't really tell if the computational models match and I would like to know what to expect. I g...
Using CUDA to accelerate a raytracer can indeed yield significant performance improvements, especially given the highly parallel nature of raytracing algorithms. While there are some challenges, the overall benefits often outweigh them. Here are several considerations to keep in mind when combining raytracing with CUDA...
572
[ { "from": "human", "value": "I'm currently implementing a raytracer. Since raytracing is extremely computation heavy and since I am going to be looking into CUDA programming anyway, I was wondering if anyone has any experience with combining the two. I can't really tell if the computational models match and...
I can do an eval("something()"); to execute the code dynamically in JavaScript. Is there a way for me to do the same thing in C#? An example of what I am trying to do is: I have an integer variable (say i) and I have multiple properties by the names: "Property1", "Property2", "Property3", etc. Now, I want to perform so...
In C#, you cannot directly execute a string as code like you can with `eval` in JavaScript. However, you can achieve similar behavior using reflection. Reflection allows you to inspect and interact with objects at runtime, which can be useful for accessing properties dynamically based on their names. Here's how you co...
594
[ { "from": "human", "value": "I can do an eval(\"something()\"); to execute the code dynamically in JavaScript. Is there a way for me to do the same thing in C#?\nAn example of what I am trying to do is: I have an integer variable (say i) and I have multiple properties by the names: \"Property1\", \"Property...
I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits. I ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing the case where sealed classes will give better results? Has anyone run te...
The idea behind marking classes as `sealed` in C# (or other languages that support similar concepts) is primarily about enabling the compiler and the runtime to perform optimizations related to polymorphism and virtual method dispatch. When a class is marked as `sealed`, it cannot be inherited from, which means the run...
1,301
[ { "from": "human", "value": "I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits.\nI ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing the case where sealed classes w...
The ASP page gets data uses that to draw a graph, I then need to save the image created to JPEG to be displayed on the browser and also used in PDF and other format. What is the best way to compress the image? I am currently porting a JPEG compression library to ASP but I think it will be too slow on this ARM device ru...
To efficiently create and compress a bitmap image to JPEG on an ASP page running on Windows CE 6.0, you'll need to consider several factors, including the limitations of the platform and the available libraries for image manipulation and compression. Here's a general approach you can follow: ### Steps to Create and Co...
929
[ { "from": "human", "value": "The ASP page gets data uses that to draw a graph, I then need to save the image created to JPEG to be displayed on the browser and also used in PDF and other format. What is the best way to compress the image? I am currently porting a JPEG compression library to ASP but I think ...
With the increased power of JavaScript frameworks like YUI, JQuery, and Prototype, and debugging tools like Firebug, doing an application entirely in browser-side JavaScript looks like a great way to make simple applications like puzzle games and specialized calculators. Is there any downside to this other than exposin...
Using JavaScript frameworks and browser-side scripting for applications can indeed provide a powerful and responsive user experience. However, there are some notable downsides and considerations to keep in mind, aside from just exposing your source code: ### Downsides of Client-Side Applications: 1. **Limited Access ...
576
[ { "from": "human", "value": "With the increased power of JavaScript frameworks like YUI, JQuery, and Prototype, and debugging tools like Firebug, doing an application entirely in browser-side JavaScript looks like a great way to make simple applications like puzzle games and specialized calculators.\nIs the...
SQL Experts, Is there an efficient way to group runs of data together using SQL? Or is it going to be more efficient to process the data in code. For example if I have the following data: ID|Name 01|Harry Johns 02|Adam Taylor 03|John Smith 04|John Smith 05|Bill Manning 06|John Smith I need to display this: Harry Joh...
To achieve the desired output where you group consecutive occurrences of the same name together with a count, you can use SQL's window functions along with some conditional logic. Here's a step-by-step approach to solve your problem using SQL: ### Step 1: Create a Table First, let's assume you have a table `people` wi...
993
[ { "from": "human", "value": "SQL Experts,\nIs there an efficient way to group runs of data together using SQL?\nOr is it going to be more efficient to process the data in code. \nFor example if I have the following data:\nID|Name\n01|Harry Johns\n02|Adam Taylor\n03|John Smith\n04|John Smith\n05|Bill Mannin...
I use emacs to edit my xml files (nxml-mode) and the files were generated by machine don't have any pretty formatting of the tags. I have searched for pretty printing the entire file with indentation and saving it, but wasn't able to find an automatic way. Is there a way? Or atleast some editor on linux which can do i...
Yes, you can pretty-print XML files in Emacs using `nxml-mode`. There are built-in functions in Emacs that can help you format the XML. Here’s how you can do it: ### Pretty-Printing XML in Emacs 1. **Open your XML file in Emacs**: Open your XML file in Emacs using `C-x C-f` (or `M-x find-file`). 2. **Switch to `n...
1,712
[ { "from": "human", "value": "I use emacs to edit my xml files (nxml-mode) and the files were generated by machine don't have any pretty formatting of the tags. \nI have searched for pretty printing the entire file with indentation and saving it, but wasn't able to find an automatic way.\nIs there a way? Or ...
Anybody have a script or alias to find untracked (really: unadded) files in a Perforce tree? EDIT: I updated the accepted answer on this one since it looks like P4V added support for this in the January 2009 release.
To find untracked (or unadded) files in a Perforce tree, you can use the `p4` command-line tool. An effective way to identify files that are not added to Perforce (i.e., untracked files) is to use the `p4 status` command. Here's a simple shell script or alias you can use: ### Shell Script ```bash #!/bin/bash # Navi...
729
[ { "from": "human", "value": "Anybody have a script or alias to find untracked (really: unadded) files in a Perforce tree?\nEDIT: I updated the accepted answer on this one since it looks like P4V added support for this in the January 2009 release.\n" }, { "from": "gpt", "value": "To find untracke...
I'm using Intridea's Acts as Readable Rails plugin for a messaging system I'm currently building. I've defined my message class accordingly: class Post < ActiveRecord::Base acts-as-readable end And everything seems to be working according to plan, but when trying to make the app show unread messages in my message vi...
It seems like you're trying to count the unread messages for a user in your view, but you're running into issues. Let's go through a few common pitfalls and ensure everything is set up correctly. 1. **Ensure `current_user` is defined properly:** Make sure that `current_user` is actually returning the user object you e...
1,795
[ { "from": "human", "value": "I'm using Intridea's Acts as Readable Rails plugin for a messaging system I'm currently building.\nI've defined my message class accordingly:\nclass Post < ActiveRecord::Base\n acts-as-readable\nend\n\nAnd everything seems to be working according to plan, but when trying to mak...
I've been reading a lot about closures and I think I understand them, but without clouding the picture for myself and others, I am hoping someone can explain closures as succinctly and clearly as possible. I'm looking for a simple explanation that might help me understand where and why I would want to use them.
A **closure** is a function that retains access to its lexical scope, even when the function is executed outside that scope. This means that a closure can "remember" the variables from the context in which it was created. ### Key Points: 1. **Function + Scope**: A closure is formed when a function is defined inside a...
1,332
[ { "from": "human", "value": "I've been reading a lot about closures and I think I understand them, but without clouding the picture for myself and others, I am hoping someone can explain closures as succinctly and clearly as possible. I'm looking for a simple explanation that might help me understand where...
I completely understand the concept of expression trees, but I am having a hard time trying to find situations in which they are useful. Is there a specific instance in which expression trees can be applied? Or is it only useful as a transport mechanism for code? I feel like I am missing something here. Thanks!
Expression trees are versatile data structures that represent expressions in a hierarchical form, where nodes typically denote operators and leaves represent operands. They have a variety of applications beyond simply serving as a transport mechanism for code. Here are several scenarios where expression trees can be pa...
612
[ { "from": "human", "value": "I completely understand the concept of expression trees, but I am having a hard time trying to find situations in which they are useful. Is there a specific instance in which expression trees can be applied? Or is it only useful as a transport mechanism for code? I feel like I a...
I know there's a bug with conditional visibility and page breaks with SQL 2005, but I wonder if anyone has come up with a work around. I have a table that has a conditional visibility expression, and I need a page break at the end of the table. If I set the PageBreakAtEnd property to true. It is ignored no matter what...
This issue with conditional visibility and page breaks in SQL Server Reporting Services (SSRS) can be quite challenging to navigate, especially in SQL Server 2005. Here are a few workarounds you might consider: 1. **Use Multiple Tables/Groups**: Instead of placing the table within a rectangle with a visibility conditi...
2,171
[ { "from": "human", "value": "I know there's a bug with conditional visibility and page breaks with SQL 2005, but I wonder if anyone has come up with a work around.\nI have a table that has a conditional visibility expression, and I need a page break at the end of the table.\n\nIf I set the PageBreakAtEnd pr...
I've just been learning about master pages in ASP.NET 2.0. They sound great, but how well do they work in practice? Does anybody have experience of using them for a large web site?
Master pages in ASP.NET 2.0 are a powerful feature that can significantly improve the development and maintenance of web applications, especially large sites. Here's a summary of their practicality and common experiences based on real-world usage: ### Benefits of Using Master Pages: 1. **Consistent Layout**: Master p...
1,447
[ { "from": "human", "value": "I've just been learning about master pages in ASP.NET 2.0. \nThey sound great, but how well do they work in practice? \nDoes anybody have experience of using them for a large web site?\n" }, { "from": "gpt", "value": "Master pages in ASP.NET 2.0 are a powerful feat...
Curious if others feel the same as me. To me, controls such as datagrid/gridview/formview/etc. are great for presentations or demo's only. To take the time and tweak this controls, override their default behavior (hooking into their silly events etc.) is a big headache. The only control that I use is the repeater, si...
Your perspective on data-bound controls in .NET is quite valid and resonates with many developers who prioritize flexibility and control over pre-built solutions. Here are some thoughts on your viewpoint: 1. **Flexibility vs. Abstraction**: Many developers prefer the granular control of hand-coding HTML and CSS becaus...
2,398
[ { "from": "human", "value": "Curious if others feel the same as me. To me, controls such as datagrid/gridview/formview/etc. are great for presentations or demo's only. To take the time and tweak this controls, override their default behavior (hooking into their silly events etc.) is a big headache. The on...
I'm working on an open source project that uses SQL Server 2005 as the data store. We need a DB compare tool to generate diff scripts to be able to upgrade a DB from one version to another. Is there an open source or free SQL Server DB diff tool out there that generates a convert script?
Yes, there are several open-source and free tools that can help you compare SQL Server databases and generate scripts to apply differences. Here are a few options you might consider: 1. **SQL Server Data Tools (SSDT)**: While SSDT is part of Visual Studio, it provides a free edition and supports database project funct...
1,001
[ { "from": "human", "value": "I'm working on an open source project that uses SQL Server 2005 as the data store. We need a DB compare tool to generate diff scripts to be able to upgrade a DB from one version to another.\nIs there an open source or free SQL Server DB diff tool out there that generates a conve...
I can't seem to find Developer Express' version of the LinkButton. (The Windows Forms linkbutton, not the ASP.NET linkbutton.) HyperLinkEdit doesn't seem to be what I'm looking for since it looks like a TextEdit/TextBox. Anyone know what their version of it is? I'm using the latest DevX controls: 8.2.1.
In Developer Express's WinForms controls, there isn't a direct equivalent of a standard LinkButton like the one you might find in other UI frameworks. However, you can use the **SimpleButton** or the **HyperlinkLabelControl** to achieve similar functionality. Here are two options you can consider: 1. **SimpleButton**...
2,506
[ { "from": "human", "value": "I can't seem to find Developer Express' version of the LinkButton. (The Windows Forms linkbutton, not the ASP.NET linkbutton.) HyperLinkEdit doesn't seem to be what I'm looking for since it looks like a TextEdit/TextBox.\nAnyone know what their version of it is? I'm using the...
"Microsoft SQL Server Profiler is a graphical user interface to SQL Trace for monitoring an instance of the Database Engine or Analysis Services." I find using SQL Server Profiler extremely useful during development, testing and when I am debugging database application problems. Does anybody know if there is an equival...
Yes, there are several tools available for MySQL that provide similar functionality to SQL Server Profiler for monitoring and analyzing queries. Here are a few options: 1. **MySQL Workbench**: MySQL Workbench is an official integrated development environment (IDE) for MySQL. It includes features for visual database de...
2,215
[ { "from": "human", "value": "\"Microsoft SQL Server Profiler is a graphical user interface to SQL Trace for monitoring an instance of the Database Engine or Analysis Services.\"\nI find using SQL Server Profiler extremely useful during development, testing and when I am debugging database application proble...
OK, I know what you're thinking, "why write a method you do not want people to use?" Right? Well, in short, I have a class that needs to be serialized to XML. In order for the XmlSerializer to do its magic, the class must have a default, empty constructor: public class MyClass { public MyClass() { // required f...
Using the `Obsolete` attribute is indeed one common approach to indicate that a method (or constructor) should not be used, but as you pointed out, it does carry the implication that the method will eventually be removed. In your case, you're required to keep the empty constructor for XML serialization purposes, which ...
634
[ { "from": "human", "value": "OK, I know what you're thinking, \"why write a method you do not want people to use?\" Right?\nWell, in short, I have a class that needs to be serialized to XML. In order for the XmlSerializer to do its magic, the class must have a default, empty constructor:\npublic class MyCla...
My group is developing a service-based (.NET WCF) application and we're trying to decide how to handle exceptions in our internal services. Should we throw exceptions? Return exceptions serialized as XML? Just return an error code? Keep in mind that the user will never see these exceptions, it's only for other parts...
When developing a service-based application using .NET WCF, handling exceptions appropriately is crucial for maintaining the reliability and clarity of your service. Here are some best practices and approaches to consider for handling exceptions in your internal services: ### 1. **Use Structured Exception Handling** ...
667
[ { "from": "human", "value": "My group is developing a service-based (.NET WCF) application and we're trying to decide how to handle exceptions in our internal services. Should we throw exceptions? Return exceptions serialized as XML? Just return an error code?\nKeep in mind that the user will never see t...
In C#, int and Int32 are the same thing, but I've read a number of times that int is preferred over Int32 with no reason given. Is there a reason, and should I care?
In C#, `int` and `Int32` are indeed synonymous. `int` is an alias for `Int32`, which is a struct defined in the `System` namespace. The reasons why `int` is often preferred over `Int32` are mostly related to readability, conciseness, and common practice in C# code. Here are some points to consider: 1. **Readability**:...
1,761
[ { "from": "human", "value": "In C#, int and Int32 are the same thing, but I've read a number of times that int is preferred over Int32 with no reason given. Is there a reason, and should I care?\n" }, { "from": "gpt", "value": "In C#, `int` and `Int32` are indeed synonymous. `int` is an alias fo...
We are investigating using CruiseControl.NET as both a Continues Integration build provider, as well as automating the first part of our deployment process. Has anyone modified CruiseControl.NET's dashboard to add custom login and user roles (IE, Separate out access to forcing a build to only certain individuals on a p...
Yes, you can modify CruiseControl.NET's dashboard to add custom user roles and manage access control, but it will require some understanding of how to work with the nVelocity view engine as well as the overall architecture of the CruiseControl.NET system. ### Customizing the Dashboard 1. **Understanding nVelocity**: ...
244
[ { "from": "human", "value": "We are investigating using CruiseControl.NET as both a Continues Integration build provider, as well as automating the first part of our deployment process.\nHas anyone modified CruiseControl.NET's dashboard to add custom login and user roles (IE, Separate out access to forcing ...
I have a "showall" query string parameter in the url, the parameter is being added dynamically when "Show All/Show Pages" button is clicked. I want the ability to toggle "showall" query string parameter value depending on user clicking the "Show All/Show Pages" button. I'm doing some nested "if's" and string.Replace()...
Certainly! Instead of manipulating the URL string manually with nested `if` statements and `string.Replace()`, you can use a more structured approach with a query string parsing library or built-in capabilities to simplify the process. Here’s a clean approach in C# (assuming you're working in an ASP.NET environment) to...
853
[ { "from": "human", "value": "I have a \"showall\" query string parameter in the url, the parameter is being added dynamically when \"Show All/Show Pages\" button is clicked. \nI want the ability to toggle \"showall\" query string parameter value depending on user clicking the \"Show All/Show Pages\" button....
What is the "purist" or "correct" way to access an object's properties from within an object method that is not a getter/setter method? I know that from outside of the object you should use a getter/setter, but from within would you just do: Java: String property = this.property; PHP: $property = $this->property; or ...
Your question touches on some important principles of object-oriented programming (OOP) regarding encapsulation and how to access properties (fields) within an object. Let's clarify the best practices for accessing properties in both Java and PHP, especially in the context of encapsulation. ### Accessing Properties in...
833
[ { "from": "human", "value": "What is the \"purist\" or \"correct\" way to access an object's properties from within an object method that is not a getter/setter method?\nI know that from outside of the object you should use a getter/setter, but from within would you just do:\nJava:\nString property = this.p...
Is there a way to specify a child's initial window position in Qt? I have an application that runs on Linux and Windows and it looks like the default behavior of Qt lets the Window Manager determine the placement of the child windows. On Windows, this is in the center of the screen the parent is on which seems reaso...
Yes, you can specify the initial position of a child window in Qt, overriding the default behavior determined by the window manager. When you create a child window in Qt, you can set its position explicitly using the `move()` method before showing the window. Here's a basic approach to achieve this: ### Example Code ...
1,093
[ { "from": "human", "value": "Is there a way to specify a child's initial window position in Qt?\nI have an application that runs on Linux and Windows and it looks like the default behavior of Qt lets the Window Manager determine the placement of the child windows. \nOn Windows, this is in the center of th...
I searched for this subject on Google and got some website about an experts exchange...so I figured I should just ask here instead. How do you embed a JApplet in HTML on a webpage?
To embed a `JApplet` in an HTML webpage, you typically use the `<applet>` tag, which is an HTML tag specifically designed for embedding Java applets. However, it's worth noting that applets have been deprecated in modern browsers due to security concerns and lack of support for Java in web environments. Therefore, usin...
1,375
[ { "from": "human", "value": "I searched for this subject on Google and got some website about an experts exchange...so I figured I should just ask here instead.\nHow do you embed a JApplet in HTML on a webpage?\n" }, { "from": "gpt", "value": "To embed a `JApplet` in an HTML webpage, you typical...
In SQL Server how do you query a database to bring back all the tables that have a field of a specific name?
In SQL Server, you can query the system catalog views to find all tables that contain a specific column name. The following SQL query will help you achieve this. Replace `'YourColumnName'` with the name of the column you are looking for: ```sql SELECT t.name AS TableName, c.name AS ColumnName FROM sys.ta...
2,320
[ { "from": "human", "value": "In SQL Server how do you query a database to bring back all the tables that have a field of a specific name?\n" }, { "from": "gpt", "value": "In SQL Server, you can query the system catalog views to find all tables that contain a specific column name. The following S...
I find that getting Unicode support in my cross-platform apps a real pain in the butt. I need strings that can go from C code, to a database, to a Java application and into a Perl module. Each of these use a different Unicode encodings (UTF8, UTF16) or some other code page. The biggest thing that I need is a cross-pl...
Handling Unicode across different programming languages and platforms can indeed be challenging, especially given the variety of encodings and libraries available. However, there are several strategies, libraries, and tools that you can use to facilitate Unicode handling and conversions. Here are some recommendations: ...
23
[ { "from": "human", "value": "I find that getting Unicode support in my cross-platform apps a real pain in the butt.\nI need strings that can go from C code, to a database, to a Java application and into a Perl module. Each of these use a different Unicode encodings (UTF8, UTF16) or some other code page. T...
I have heard umpteen times that we 'should not mix business logic with other code' or statements like that. I think every single code I write (processing steps I mean) consists of logic that is related to the business requirements.. Can anyone tell me what exactly consists of business logic? How can it be distinguished...
The concept of "business logic" can indeed be nuanced, and it can vary somewhat depending on the context and the specific application. However, some general principles can help you distinguish business logic from other types of code. ### What is Business Logic? **Business logic** refers to the rules, calculations, an...
147
[ { "from": "human", "value": "I have heard umpteen times that we 'should not mix business logic with other code' or statements like that. I think every single code I write (processing steps I mean) consists of logic that is related to the business requirements..\nCan anyone tell me what exactly consists of b...
I have a column which is of type nvarchar(max). How do I find the length of the string (or the number of bytes) for the column for each row in the table?
To find the length of a string or the number of bytes for a column of type `nvarchar(max)` in SQL Server, you can use the `LEN()` function to get the number of characters and the `DATALENGTH()` function to get the number of bytes. Here's how you can do it for each row in your table: 1. **Length of the string in chara...
2,452
[ { "from": "human", "value": "I have a column which is of type nvarchar(max). How do I find the length of the string (or the number of bytes) for the column for each row in the table?\n" }, { "from": "gpt", "value": "To find the length of a string or the number of bytes for a column of type `nva...
I have decided that all my WPF pages need to register a routed event. Rather than include public static readonly RoutedEvent MyEvent= EventManager.RegisterRoutedEvent("MyEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(BasePage)); on every page, I decided to create a base page (named BasePage). I p...
The error you're encountering is due to the way you've defined your `BasePage` in XAML. In WPF, a class that derives from `Page` (or any element that is defined using XAML) cannot be directly referenced as the base of another XAML-defined class unless it's designed as a proper `UserControl` or `Page` in a specific way....
848
[ { "from": "human", "value": "I have decided that all my WPF pages need to register a routed event. Rather than include\npublic static readonly RoutedEvent MyEvent= EventManager.RegisterRoutedEvent(\"MyEvent\", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(BasePage));\n\non every page, I decide...
As far as I know, foreign keys (FK) are used to aid the programmer to manipulate data in the correct way. Suppose a programmer is actually doing this in the right manner already, then do we really need the concept of foreign keys? Are there any other uses for foreign keys? Am I missing something here?
You raise an important point about the role of foreign keys (FKs) in relational databases. While it's true that a skilled programmer may manipulate data correctly without the use of foreign keys, there are several reasons why foreign keys are still beneficial and often essential in database design: 1. **Data Integrity...
1,470
[ { "from": "human", "value": "As far as I know, foreign keys (FK) are used to aid the programmer to manipulate data in the correct way. Suppose a programmer is actually doing this in the right manner already, then do we really need the concept of foreign keys?\nAre there any other uses for foreign keys? Am I...
In the case of languages that support single decision and action without brackets, such as the following example: if (var == true) doSomething(); What is the preferred way of writing this? Should brackets always be used, or should their usage be left as a preference of the individual developer? Additionally, does ...
The preferred way of writing conditional statements often depends on coding style guidelines, team conventions, and individual developer preferences. However, there are some widely accepted best practices that can help improve code readability and maintainability. ### Bracket Usage 1. **Always Use Brackets**: A commo...
984
[ { "from": "human", "value": "In the case of languages that support single decision and action without brackets, such as the following example:\nif (var == true)\n doSomething();\n\nWhat is the preferred way of writing this? Should brackets always be used, or should their usage be left as a preference of ...
I often encounter the following scenario where I need to offer many different types of permissions. I primarily use ASP.NET / VB.NET with SQL Server 2000. Scenario I want to offer a dynamic permission system that can work on different parameters. Let's say that I want to give either a department or just a specific pers...
Creating a flexible and scalable permission system is crucial for managing user access effectively, especially as your applications grow. Both of the approaches you mentioned have their advantages and disadvantages, but there are alternative strategies that may suit your needs better. Let's explore some of them: ### 1...
250
[ { "from": "human", "value": "I often encounter the following scenario where I need to offer many different types of permissions. I primarily use ASP.NET / VB.NET with SQL Server 2000.\nScenario\nI want to offer a dynamic permission system that can work on different parameters. Let's say that I want to give ...
I have a collection of classes that inherit from an abstract class I created. I'd like to use the abstract class as a factory for creating instances of concrete implementations of my abstract class. Is there any way to hide a constructor from all code except a parent class. I'd like to do this basically public abstrac...
In C#, there is a way to control the visibility of constructors to prevent direct instantiation of concrete classes, ensuring that they can only be created through a factory method in the abstract base class. You can do this by using the `protected` access modifier on the constructors of the concrete classes. This allo...
2,094
[ { "from": "human", "value": "I have a collection of classes that inherit from an abstract class I created. I'd like to use the abstract class as a factory for creating instances of concrete implementations of my abstract class. \nIs there any way to hide a constructor from all code except a parent class.\nI...
Have just started using Google Chrome, and noticed in parts of our site, e.g. all the links on the page, are bright red. They should be black with a dotted underline. Is there some gotcha in WebKit rendering that turns all links red regardless of the style?
The issue you're encountering with link colors in Google Chrome could be due to a few reasons. Here are some possible explanations and solutions: 1. **User-Agent Stylesheet**: Browsers come with a default stylesheet known as the User-Agent stylesheet. This can sometimes override your CSS. However, links should not be ...
822
[ { "from": "human", "value": "Have just started using Google Chrome, and noticed in parts of our site, e.g. all the links on the page, are bright red. They should be black with a dotted underline.\nIs there some gotcha in WebKit rendering that turns all links red regardless of the style?\n" }, { "fro...
What is BODMAS and why is it useful in programming?
BODMAS is an acronym that stands for Brackets, Orders (i.e., powers and square roots, etc.), Division and Multiplication, Addition and Subtraction. It represents the order of operations that should be followed when evaluating mathematical expressions to ensure that calculations are performed correctly. ### Breakdown o...
1,944
[ { "from": "human", "value": "What is BODMAS and why is it useful in programming?\n" }, { "from": "gpt", "value": "BODMAS is an acronym that stands for Brackets, Orders (i.e., powers and square roots, etc.), Division and Multiplication, Addition and Subtraction. It represents the order of operati...
Is there an easy way to iterate over an associative array of this structure in PHP: The array $searches has a numbered index, with between 4 and 5 associative parts. So I not only need to iterate over $searches[0] through $searches[n], but also $searches[0]["part0"] through $searches[n]["partn"]. The hard part is that ...
Certainly! You can iterate over an associative array in PHP using nested loops, where the outer loop goes through each index of the `$searches` array and the inner loop goes through the parts of each associative array. Given that the number of parts can vary from one indexed element to another, you can check if a part...
2,054
[ { "from": "human", "value": "Is there an easy way to iterate over an associative array of this structure in PHP:\nThe array $searches has a numbered index, with between 4 and 5 associative parts. So I not only need to iterate over $searches[0] through $searches[n], but also $searches[0][\"part0\"] through $...
I was just looking through some information about Google's protocol buffers data interchange format. Has anyone played around with the code or even created a project around it? I'm currently using XML in a Python project for structured content created by hand in a text editor, and I was wondering what the general opin...
Google's Protocol Buffers (protobufs) are indeed a powerful and efficient method for serializing structured data. They are particularly well-suited for scenarios where performance and bandwidth are critical, such as in network communications, data storage, and inter-service communication in distributed systems. ### Ad...
527
[ { "from": "human", "value": "I was just looking through some information about Google's protocol buffers data interchange format. Has anyone played around with the code or even created a project around it?\nI'm currently using XML in a Python project for structured content created by hand in a text editor,...
I've recently had a need to do a bit of lisp editing and I found the nifty Ready Lisp package for OS X, which is great, except Aquamacs automatically uses a proportional font (which is idiotic, IMHO) and I want to change it to a monospace font. However, I'm not really much of an EMACS user, and the preferences menu in ...
Changing the font in Aquamacs to a monospace font is quite straightforward. Here’s how you can do it: 1. **Open Aquamacs**. 2. From the menu bar at the top of the screen, click on **"Aquamacs"** and then select **"Preferences..."**. 3. In the Preferences window, look for the **"Fonts"** section. You might find it on t...
2,664
[ { "from": "human", "value": "I've recently had a need to do a bit of lisp editing and I found the nifty Ready Lisp package for OS X, which is great, except Aquamacs automatically uses a proportional font (which is idiotic, IMHO) and I want to change it to a monospace font. However, I'm not really much of an...
I have a problem with my Visual Studio installation. When I got an exception I always have incorrect line numbers in it's stack trace. There are always point to last line of each method in my codebase. At the same time it's OK when I'm tracing programs with debugger. What's happed with PDBs? No, I'm not re-throwing exc...
The issue you're encountering with incorrect line numbers in the stack trace when exceptions are thrown typically indicates a problem with the Program Database (PDB) files that are used for debugging in Visual Studio. Here are several possible causes and solutions you can try: ### 1. **Outdated or Missing PDB Files** ...
657
[ { "from": "human", "value": "I have a problem with my Visual Studio installation. When I got an exception I always have incorrect line numbers in it's stack trace. There are always point to last line of each method in my codebase. At the same time it's OK when I'm tracing programs with debugger. What's happ...
I have a template class that I serialize (call it C), for which I want to specify a version for boost serialization. As BOOST_CLASS_VERSION does not work for template classes. I tried this: namespace boost { namespace serialization { template< typename T, typename U > struct version< C<T,U> > { type...
The problem you're encountering is related to the way you are trying to specialize the `boost::serialization::version` template. The `version` struct in the Boost Serialization library is actually a class template itself, and it needs to be specialized in a specific way. To declare a version for a template class `C<T,...
2,845
[ { "from": "human", "value": "I have a template class that I serialize (call it C), for which I want to specify a version for boost serialization. As BOOST_CLASS_VERSION does not work for template classes. I tried this:\nnamespace boost {\nnamespace serialization {\n template< typename T, typename U >\n ...
I have worked for 5 years mainly in java desktop applications accessing Oracle databases and I have never used regular expressions. Now I enter Stack Overflow and I see a lot of questions about them; I feel like I missed something. For what do you use regular expressions? P.S. sorry for my bad english
No need to apologize; your English is great! Regular expressions (often abbreviated as "regex") are a powerful tool for working with text. They allow you to define complex search patterns to match strings in a flexible way. Here are some common use cases for regular expressions: 1. **Input Validation**: You can use re...
1,898
[ { "from": "human", "value": "I have worked for 5 years mainly in java desktop applications accessing Oracle databases and I have never used regular expressions. Now I enter Stack Overflow and I see a lot of questions about them; I feel like I missed something. \nFor what do you use regular expressions?\nP.S...
C++ 0x has template aliases (sometimes referred to as template typedefs). See here. Current spec of C++ does not. What do you like to use as work around ? Container objects or Macros ? Do you feel its worth it ?
In C++11 (often referred to as C++0x), template aliases were introduced, allowing for a more elegant way to create aliases for templated types. The syntax is straightforward and much clearer than using traditional typedefs with templates or macros. For instance: ```cpp template <typename T> using Vec = std::vector<T>;...
2,575
[ { "from": "human", "value": "C++ 0x has template aliases (sometimes referred to as template typedefs). See here. Current spec of C++ does not. \nWhat do you like to use as work around ? Container objects or Macros ?\nDo you feel its worth it ?\n" }, { "from": "gpt", "value": "In C++11 (often ref...
I write tools that are used in a shared workspace. Since there are multiple OS's working in this space, we generally use Python and standardize the version that is installed across machines. However, if I wanted to write some things in C, I was wondering if maybe I could have the application wrapped in a Python script,...
Your approach to wrapping C applications with Python to handle different operating systems is indeed a valid and effective strategy in a cross-platform environment. Here are several considerations and potential methodologies for your scenario: ### Option 1: Compile per OS and Select Executable 1. **Separate Compilati...
849
[ { "from": "human", "value": "I write tools that are used in a shared workspace. Since there are multiple OS's working in this space, we generally use Python and standardize the version that is installed across machines. However, if I wanted to write some things in C, I was wondering if maybe I could have th...
In Windows, in any windows form or web browser, you can use the tab button to switch focus through all of the form fields. It will stop on textboxes, radiobuttons, checkboxes, dropdown menus, etc. However, in Mac OSX, tab skips dropdown menus. Is there anyway to change this behavior, or access the above items mention...
In macOS, the behavior of the Tab key for navigating through form elements such as text boxes, radio buttons, checkboxes, and dropdown menus can be adjusted in the system preferences. Here’s how you can change the settings to allow the Tab key to navigate through dropdown menus: 1. **Open System Preferences**: Click ...
2,182
[ { "from": "human", "value": "In Windows, in any windows form or web browser, you can use the tab button to switch focus through all of the form fields. \nIt will stop on textboxes, radiobuttons, checkboxes, dropdown menus, etc. \nHowever, in Mac OSX, tab skips dropdown menus. Is there anyway to change this ...
Is it possible for gcc to link against a library that was created with Visual C++? If so, are there any conflicts/problems that might arise from doing so?
Linking against a library created with Visual C++ (MSVC) while using GCC (GNU Compiler Collection) is technically possible, but it generally comes with significant challenges and potential issues. Here are the main points to consider: ### 1. **Binary Compatibility**: - **ABI Differences**: GCC and MSVC use differen...
377
[ { "from": "human", "value": "Is it possible for gcc to link against a library that was created with Visual C++? If so, are there any conflicts/problems that might arise from doing so? \n" }, { "from": "gpt", "value": "Linking against a library created with Visual C++ (MSVC) while using GCC (GN...
I've been searching (with little success) for a free/opensource session clustering and replication solution for asp.net. I've run across the usual suspects (indexus sharedcache, memcached), however, each has some limitations. Indexus - Very immature, stubbed session interface implementation. Its otherwise a great ca...
It can indeed be challenging to find open-source solutions in the .NET ecosystem that provide robust session clustering and replication features, especially when compared to the Java world. However, here are a few alternatives you might want to consider: 1. **NCache**: Although NCache has a commercial version, it offe...
977
[ { "from": "human", "value": "I've been searching (with little success) for a free/opensource session clustering and replication solution for asp.net. I've run across the usual suspects (indexus sharedcache, memcached), however, each has some limitations.\n\nIndexus - Very immature, stubbed session interfac...
I like a bit of TiVo hacking in spare time - TiVo uses a Linux variant and TCL. I'd like to write TCL scripts on my Windows laptop, test them and then FTP them over to my TiVo. Can I have a recommendation for a TCL debugging environment for Windows, please?
Certainly! If you want to develop and test TCL scripts on your Windows laptop before transferring them to your TiVo, here are a few options for TCL environments that you can use: 1. **Tclkit**: This is a standalone executable that comes bundled with Tcl and Tk. You can run your scripts directly without the need to ins...
449
[ { "from": "human", "value": "I like a bit of TiVo hacking in spare time - TiVo uses a Linux variant and TCL. I'd like to write TCL scripts on my Windows laptop, test them and then FTP them over to my TiVo.\nCan I have a recommendation for a TCL debugging environment for Windows, please?\n" }, { "fro...
My designer keeps throwing out the term "liquid" layout. What does this mean? Thanks for the clarification, I have always just called this a percentage layout, and thought he was saying that the pieces could be moved around, and that was liquid
The term "liquid layout" refers to a web design technique where the width of a layout is defined in relative units, such as percentages, rather than fixed units like pixels. This allows the layout to adjust fluidly to the size of the browser window, making it responsive to different screen sizes and resolutions. As the...
3,500
[ { "from": "human", "value": "My designer keeps throwing out the term \"liquid\" layout. What does this mean?\nThanks for the clarification, I have always just called this a percentage layout, and thought he was saying that the pieces could be moved around, and that was liquid\n" }, { "from": "gpt", ...
I need to make a WebCast presentation soon and need to do some "whiteboarding" during that WebCast. Does anyone have any stylus/tablet input device recommendations? Anyone ever used such an input device with WebEx's whiteboard feature? rp
When it comes to creating a WebCast presentation with whiteboarding features, there are several stylus and tablet input devices that are highly recommended. Here are some options that you may find useful, particularly when using WebEx's whiteboard feature: ### Stylus/Tablet Input Devices: 1. **Wacom Intuos Pro**: ...
1,146
[ { "from": "human", "value": "I need to make a WebCast presentation soon and need to do some \"whiteboarding\" during that WebCast. Does anyone have any stylus/tablet input device recommendations? Anyone ever used such an input device with WebEx's whiteboard feature?\nrp\n" }, { "from": "gpt", "v...
What Firefox add-ons do you use that are useful for programmers?
There are several Firefox add-ons that can be particularly useful for programmers. Here are some of the most popular ones: 1. **Web Developer**: This add-on adds a menu and a toolbar with various web developer tools, helping you inspect and debug web pages efficiently. 2. **Firebug**: Although Firebug has been integr...
1,311
[ { "from": "human", "value": "What Firefox add-ons do you use that are useful for programmers?\n" }, { "from": "gpt", "value": "There are several Firefox add-ons that can be particularly useful for programmers. Here are some of the most popular ones:\n\n1. **Web Developer**: This add-on adds a me...
How much do you rely on database transactions? Do you prefer small or large transaction scopes ? Do you prefer client side transaction handling (e.g. TransactionScope in .NET) over server side transactions or vice-versa? What about nested transactions? Do you have some tips&tricks related to transactions ? A...
Database transactions are a critical aspect of ensuring data integrity, consistency, and reliability in applications. Below are some insights and considerations regarding transactions, including scopes, handling, nested transactions, and best practices: ### Relying on Database Transactions 1. **Importance**: I rely on...
641
[ { "from": "human", "value": "How much do you rely on database transactions? \nDo you prefer small or large transaction scopes ? \nDo you prefer client side transaction handling (e.g. TransactionScope in .NET) over server \nside transactions or vice-versa? \nWhat about nested transactions? \nDo you hav...
In my engine I have a need to be able to detect DXT1 textures that have texels with 0 alpha (e.g. a cutout for a window frame). This is easy for textures I compress myself, but I'm not sure about textures that are already compressed. Is there an easy way to tell from the header whether a DDS image contains alpha?
In a DDS (DirectDraw Surface) file, you can check if the texture contains alpha information by examining the header. Specifically, you'll need to look at the `dwFlags` and `dwRGBBitCount` fields in the DDS header. Here's a basic outline of what to check: 1. **DDS Header (DDS_HEADER structure)**: The DDS file starts wi...
699
[ { "from": "human", "value": "In my engine I have a need to be able to detect DXT1 textures that have texels with 0 alpha (e.g. a cutout for a window frame). This is easy for textures I compress myself, but I'm not sure about textures that are already compressed.\nIs there an easy way to tell from the header...
Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default Apache? I'd like to keep our development server running fully chrooted just like our Production server so that we make sure our code runs just fine chrooted.
Running Xinc (or similar PHP applications) under a chrooted environment in OpenBSD with Apache can be challenging due to the restrictions and requirements of both the chroot and the software. Here are some steps and considerations that might help you get Xinc running properly in a chrooted Apache environment: 1. **Set...
1,847
[ { "from": "human", "value": "Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default Apache? I'd like to keep our development server running fully chrooted just like our Production server so that we make sure our code runs just fine chrooted.\n" }, { "from": "gpt", "va...
I've written a Python package that includes a bsddb database of pre-computed values for one of the more time-consuming computations. For simplicity, my setup script installs the database file in the same directory as the code which accesses the database (on Unix, something like /usr/lib/python2.5/site-packages/mypacka...
Your approach using `__file__` is indeed a common practice in Python to get the directory of the currently executing module. However, your idea of creating a dedicated configuration file (like `dbconfig.py`) to store the database path is a good alternative, as it separates configuration from logic and can make your cod...
42
[ { "from": "human", "value": "I've written a Python package that includes a bsddb database of pre-computed values for one of the more time-consuming computations. For simplicity, my setup script installs the database file in the same directory as the code which accesses the database (on Unix, something like...
In a SQL server database, I have a table which contains a TEXT field which is set to allow NULLs. I need to change this to not allow NULLs. I can do this no problem via Enterprise Manager, but when I try to run the following script, alter table dbo.[EventLog] Alter column [Message] text Not null, I get an error: Cannot...
In SQL Server, `TEXT`, `NTEXT`, and `IMAGE` data types are deprecated and can't be altered directly in terms of nullability. To change the column to not allow NULLs, you need to follow these steps: 1. **Create a new column** of a different data type (such as `VARCHAR(MAX)` or `NVARCHAR(MAX)`, depending on your needs) ...
2,939
[ { "from": "human", "value": "In a SQL server database, I have a table which contains a TEXT field which is set to allow NULLs. I need to change this to not allow NULLs. I can do this no problem via Enterprise Manager, but when I try to run the following script, alter table dbo.[EventLog] Alter column [Messa...