instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
I have seen this problem arise in many different circumstances and would like to get the best practices for fixing / debugging it on StackOverflow. To use a real world example this occurred to me this morning: expected announcement.rb to define Announcement The class worked fine in development, testing and from a prod...
Debugging issues in Rails, especially those that result in the error "expected x.rb to define X," can be challenging. Here are some best practices and strategies to effectively troubleshoot and resolve these problems, drawing from the examples you've shared: ### Best Practices for Debugging "expected x.rb to define X"...
9,420
[ { "from": "human", "value": "I have seen this problem arise in many different circumstances and would like to get the best practices for fixing / debugging it on StackOverflow.\nTo use a real world example this occurred to me this morning:\nexpected announcement.rb to define Announcement\n\nThe class worked...
I am considering creating a GUI-based tool that I want to be cross-platform. I've dismissed Java, as I personally do not like Swing. I'm currently considering C# and using Mono to make it cross-platform. However I'm wondering whether new-fangled cross-platform languages like Ruby can offer me a decent GUI development e...
If you're looking for cross-platform GUI development options, there are several modern languages and frameworks to consider, each with its own strengths and weaknesses. Here's a brief overview of the options you're considering, along with some additional suggestions: ### C# with Mono (or .NET Core) - **Pros**: - C...
9,000
[ { "from": "human", "value": "I am considering creating a GUI-based tool that I want to be cross-platform. I've dismissed Java, as I personally do not like Swing. I'm currently considering C# and using Mono to make it cross-platform. However I'm wondering whether new-fangled cross-platform languages like Rub...
Application frameworks such as DotNetNuke, Eclipse, Websphere and so forth are available today which offer customizable frameworks that can be used as dashboard applications. Do you use these or do you and your peers keep writing amazing, modular, maintainable dashboard frameworks which you support yourselves? Are the...
When it comes to building dashboard applications, the choice between using existing application frameworks and creating custom solutions often depends on the specific needs of the project, team capabilities, and long-term maintenance considerations. ### Using Established Frameworks Many organizations opt for establish...
11,298
[ { "from": "human", "value": "Application frameworks such as DotNetNuke, Eclipse, Websphere and so forth are available today which offer customizable frameworks that can be used as dashboard applications. Do you use these or do you and your peers keep writing amazing, modular, maintainable dashboard framewo...
I have an Access 2007 form that is searchable by a combobox. When I add a new record, I need to update the combobox to include the newly added item. I assume that something needs to be done in AfterInsert event of the form but I can't figure out what. How can I rebind the combobox after inserting so that the new it...
To update your ComboBox in Access 2007 after adding a new record, you need to requery the ComboBox after the record has been inserted. You can accomplish this by using the `AfterInsert` event of your form. Here’s how to do it: 1. Open your form in Design View. 2. Make sure that the ComboBox is bound to the appropriate...
12,419
[ { "from": "human", "value": "I have an Access 2007 form that is searchable by a combobox. When I add a new record, I need to update the combobox to include the newly added item. \nI assume that something needs to be done in AfterInsert event of the form but I can't figure out what. \nHow can I rebind the ...
Suppose I have a collection (be it an array, generic List, or whatever is the fastest solution to this problem) of a certain class, let's call it ClassFoo: class ClassFoo { public string word; public float score; //... etc ... } Assume there's going to be like 50.000 items in the collection, all in memory...
To efficiently filter a collection of `ClassFoo` instances based on prefix or suffix matching of the `word` property, especially with a large dataset (around 50,000 items) and frequent search queries, it's important to consider both data structures and algorithms. ### Suggested Approaches: 1. **Use a Trie (Prefix Tre...
9,567
[ { "from": "human", "value": "Suppose I have a collection (be it an array, generic List, or whatever is the fastest solution to this problem) of a certain class, let's call it ClassFoo:\nclass ClassFoo\n{\n public string word;\n public float score;\n //... etc ...\n} \n\nAssume there's going to be l...
Can you create websites with Chinese characters in PHP? UPDATE: Perhaps I should have said - is it straight forward. Because some languages like Java make it extremely easy. Perhaps localisation in PHP isn't as easy as Java???
Yes, you can create websites with Chinese characters in PHP, and it can be straightforward if you follow certain practices. Here are some key points to consider: ### 1. Character Encoding - **Use UTF-8 Encoding**: Make sure your PHP files are saved with UTF-8 encoding without a BOM (Byte Order Mark). Additionally, sp...
13,175
[ { "from": "human", "value": "Can you create websites with Chinese characters in PHP? \nUPDATE: Perhaps I should have said - is it straight forward. Because some languages like Java make it extremely easy. Perhaps localisation in PHP isn't as easy as Java???\n" }, { "from": "gpt", "value": "Yes, ...
Suppose I want to implement in C++ a data-structure to store oriented graphs. Arcs will be stored in Nodes thanks to STL containers. I'd like users to be able to iterate over the arcs of a node, in an STL-like way. The issue I have is that I don't want to expose in the Node class (that will actually be an abstract bas...
To achieve your goal of abstracting away the underlying container type in your `Node` class while allowing iteration over arcs, you can create your own iterator class that works with the specific container type but can be used through the base class interface. Here's a simple example of how you could do this. First, y...
9,964
[ { "from": "human", "value": "Suppose I want to implement in C++ a data-structure to store oriented graphs. Arcs will be stored in Nodes thanks to STL containers. I'd like users to be able to iterate over the arcs of a node, in an STL-like way.\nThe issue I have is that I don't want to expose in the Node cl...
Here's my first question at SO. I have a internal application for my company which I've been recently ask to maintain. The applications is built in PHP and its fairly well coded (OO, DB Abstraction, Smarty) nothing WTF-ish. The problem is the applications is very slow. How do I go about finding out what's slowing the ...
When dealing with performance issues in a PHP application, there are several steps and tools you can utilize to identify bottlenecks. Here’s a strategy you can follow to diagnose and optimize the slow PHP application: ### 1. **Profiling Tools** - **Xdebug**: This is a powerful tool for debugging and profiling PHP a...
11,640
[ { "from": "human", "value": "Here's my first question at SO.\nI have a internal application for my company which I've been recently ask to maintain. The applications is built in PHP and its fairly well coded (OO, DB Abstraction, Smarty) nothing WTF-ish. \nThe problem is the applications is very slow.\nHow d...
I need to add a user defined fields feature to an asp.net c# application that uses NHibernate. The user must be able to add and remove fields from several objects in the system "on the fly", preferably without any system downtime. One important constraint is that the database schema can't be changed by the user - that ...
Implementing a user-defined fields feature in an ASP.NET C# application using NHibernate can be achieved with a flexible design using a key-value pair structure. This allows you to dynamically add and remove fields without altering the database schema. Here’s how you can do it: ### Step 1: Database Schema Design You ...
8,653
[ { "from": "human", "value": "I need to add a user defined fields feature to an asp.net c# application that uses NHibernate.\nThe user must be able to add and remove fields from several objects in the system \"on the fly\", preferably without any system downtime.\nOne important constraint is that the databas...
I want to allow my users to embed their own Flash animations in their posts. Usually the actual file is hosted on some free image hosting site. I wouldn't actually load the flash unless the user clicked a button to play (so that nothing auto-plays on page load). I know people can make some really annoying crap in fl...
Embedding Flash content can present several security risks, even when you take precautions like requiring user interaction to play the content. Here are some key points to consider and steps you can take to mitigate potential risks: ### Risks Associated with Flash 1. **Malicious Actionscript**: Flash files (SWF) can ...
10,334
[ { "from": "human", "value": "I want to allow my users to embed their own Flash animations in their posts. Usually the actual file is hosted on some free image hosting site. I wouldn't actually load the flash unless the user clicked a button to play (so that nothing auto-plays on page load). I know people...
I'd like to learn assembler. However, there are very few resources for doing assembler with OS X. Is there anyone out there who has programmed in assembly on a Mac? Where did you learn? And, is there any reason I shouldn't be doing assembly? Do I risk (significantly) crashing my computer irreparably?
Learning assembly language can be a rewarding experience, especially if you're interested in understanding how computers work at a low level. Although there may be fewer resources for assembly programming on macOS (formerly known as OS X) compared to other operating systems, it's still quite feasible to learn and exper...
10,645
[ { "from": "human", "value": "I'd like to learn assembler. However, there are very few resources for doing assembler with OS X.\nIs there anyone out there who has programmed in assembly on a Mac? Where did you learn?\nAnd, is there any reason I shouldn't be doing assembly? Do I risk (significantly) crashi...
When interviewing college coops/interns or recent graduates it helps to have a Java programming question that they can do on a white board in 15 minutes. Does anyone have examples of good questions like this? A C++ question I was once asked in an interview was to write a string to integer function which is along the ...
Certainly! Here are a few Java programming questions that are suitable for a whiteboard interview with college co-ops, interns, or recent graduates. Each question can typically be solved in about 15 minutes, allowing candidates to demonstrate their problem-solving skills and coding ability. ### 1. FizzBuzz **Question:...
5,446
[ { "from": "human", "value": "When interviewing college coops/interns or recent graduates it helps to have a Java programming question that they can do on a white board in 15 minutes. Does anyone have examples of good questions like this? A C++ question I was once asked in an interview was to write a strin...
In python you can use a tuple in a formatted print statement and the tuple values are used at the indicated positions in the formatted string. For example: >>> a = (1,"Hello",7.2) >>> print "these are the values %d, %s, %f" % a these are the values 1, Hello, 7.200000 Is there some way to use any array or collection i...
In Java, there isn't a built-in mechanism similar to Python's tuple unpacking directly in a `printf` statement. However, you can achieve a similar result by using an array or a collection to store your values, then passing those values individually to the format string using a method that processes the collection. Her...
11,850
[ { "from": "human", "value": "In python you can use a tuple in a formatted print statement and the tuple values are used at the indicated positions in the formatted string. For example:\n>>> a = (1,\"Hello\",7.2)\n>>> print \"these are the values %d, %s, %f\" % a\nthese are the values 1, Hello, 7.200000\n\n...
I'm trying to find a way of finding out who is downloading what image from an image gallery. Users can download using a button beside the thumbnail or right click and use the "save link as" Is it possible to relate a user session or ID to a "save link as" action from all browsers using either PHP or JavaScript.
Tracking file downloads, particularly those that occur through methods like "save link as," is quite challenging. However, there are some strategies you can implement using PHP and JavaScript to associate downloads with user sessions. ### Options to Track Downloads 1. **Direct Download Links**: Instead of allowing d...
10,004
[ { "from": "human", "value": "I'm trying to find a way of finding out who is downloading what image from an image gallery. Users can download using a button beside the thumbnail or right click and use the \"save link as\" Is it possible to relate a user session or ID to a \"save link as\" action from all bro...
I'd like to install some presentation templates, but don't know where to put them... Thanks a lot
The process of installing presentation templates depends on the software you're using. Here are the steps for some common presentation applications: ### Microsoft PowerPoint 1. **Download the Template**: Save the template file (usually in .pptx or .potx format) to your computer. 2. **Open PowerPoint**. 3. **Acce...
12,249
[ { "from": "human", "value": "I'd like to install some presentation templates, but don't know where to put them...\nThanks a lot\n" }, { "from": "gpt", "value": "The process of installing presentation templates depends on the software you're using. Here are the steps for some common presentation ...
What's the difference between "Layers" and "Tiers"?
"Layers" and "Tiers" are terms that can be used in various contexts, and their meanings can differ based on the specific subject matter. Here's a general overview of their distinctions: 1. **Layers**: - **Definition**: Layers typically refer to levels or strata within a single structure. Each layer is often conside...
13,528
[ { "from": "human", "value": "What's the difference between \"Layers\" and \"Tiers\"?\n" }, { "from": "gpt", "value": "\"Layers\" and \"Tiers\" are terms that can be used in various contexts, and their meanings can differ based on the specific subject matter. Here's a general overview of their di...
On a project I'm working on, we use subversion, with tortoiseSVN as a client, under windows XP. As we enter in production and continue development in parallel, many branches are created. Often, we have to backport modifications made on the branch to the trunk, or to older branches. Backporting is a very delicate task, ...
One of my favorite tools for making backporting easier and more secure is **TortoiseSVN's "Merge" feature**. ### Why TortoiseSVN Merge? - **Visual Interface**: TortoiseSVN provides a user-friendly visual interface that allows you to see the changes you're merging clearly, making it easier to select the specific revis...
15,115
[ { "from": "human", "value": "On a project I'm working on, we use subversion, with tortoiseSVN as a client, under windows XP.\nAs we enter in production and continue development in parallel, many branches are created.\nOften, we have to backport modifications made on the branch to the trunk, or to older bran...
I'm just wondering what the optimal solution is here. Say I have a normalized database. The primary key of the whole system is a varchar. What I'm wondering is should I relate this varchar to an int for normalization or leave it? It's simpler to leave as a varchar, but it might be more optimal For instance I can have ...
When designing a database schema, especially regarding primary keys and relationships, there are several factors to consider. Let's compare the two approaches you've outlined: ### Option 1: Using a Varchar as the Primary Key ```sql People ====================== name varchar(10) DoB DateTime Height ...
12,119
[ { "from": "human", "value": "I'm just wondering what the optimal solution is here.\nSay I have a normalized database. The primary key of the whole system is a varchar. What I'm wondering is should I relate this varchar to an int for normalization or leave it? It's simpler to leave as a varchar, but it might...
I have a workbook with 20 different pivot tables. Is there any easy way to find all the pivot tables and refresh them in VBA?
Yes, you can use VBA to find and refresh all pivot tables in a workbook. Below is a simple macro that loops through each worksheet in the workbook and then each pivot table in those worksheets to refresh them. Here’s how you can implement it: 1. Press `ALT + F11` to open the VBA editor in Excel. 2. In the VBA editor...
13,061
[ { "from": "human", "value": "I have a workbook with 20 different pivot tables. Is there any easy way to find all the pivot tables and refresh them in VBA?\n" }, { "from": "gpt", "value": "Yes, you can use VBA to find and refresh all pivot tables in a workbook. Below is a simple macro that loops ...
I haven't been able to find any documentation on hardware access via the iPhone SDK so far. I'd like to be able to send signals via the dock connector to an external hardware device but haven't seen any evidence that this is accessible via the SDK (not interested in possibilities on jailbroken iPhones). Anyone have any...
Accessing hardware via the iPhone SDK (now referred to as the iOS SDK) is generally limited to certain APIs provided by Apple. The iPhone's dock connector (now called the Lightning connector) does allow for communication with external hardware, but this is done through specific protocols and APIs designed by Apple. 1....
9,881
[ { "from": "human", "value": "I haven't been able to find any documentation on hardware access via the iPhone SDK so far. I'd like to be able to send signals via the dock connector to an external hardware device but haven't seen any evidence that this is accessible via the SDK (not interested in possibilitie...
I know there's some JAVA_OPTS to set to remotely debug a Java program. What are they and what do they mean ?
To remotely debug a Java program, you can use the Java Virtual Machine (JVM) options known as `JAVA_OPTS` or `JAVA_TOOL_OPTIONS`. These options allow you to specify debugging settings that enable a remote debugger to connect to a Java application running in the JVM. Here are the commonly used options for remote debugg...
12,004
[ { "from": "human", "value": "I know there's some JAVA_OPTS to set to remotely debug a Java program.\nWhat are they and what do they mean ?\n" }, { "from": "gpt", "value": "To remotely debug a Java program, you can use the Java Virtual Machine (JVM) options known as `JAVA_OPTS` or `JAVA_TOOL_OPTI...
What is the best way to refactor the attached code to accommodate multiple email addresses? The attached HTML/jQuery is complete and works for the first email address. I can setup the other two by copy/pasting and changing the code. But I would like to just refactor the existing code to handle multiple email address fi...
To refactor the provided HTML and jQuery code to handle multiple email addresses more efficiently, we can follow a few steps to remove redundancy and create a dynamic way to handle each email input. We'll use a common class for the email inputs and status icons and then bind the events using jQuery's `.each()` method o...
6,089
[ { "from": "human", "value": "What is the best way to refactor the attached code to accommodate multiple email addresses?\nThe attached HTML/jQuery is complete and works for the first email address. I can setup the other two by copy/pasting and changing the code. But I would like to just refactor the existin...
What are the cases where you'd use a modal popup ? Does it interrupt the user's flow, if it all of a sudden opens up in his face ? Would you avoid modal popups in general ? or when should one be careful of using them ? Edit: To be a bit more specific, the situation here is this : I have a menu on the right, (VisualSt...
Modal popups can be a useful design pattern in user interfaces, but they come with advantages and disadvantages, especially when considering user experience (UX). Here’s a breakdown of when to use them, potential interruptions to user flow, and your specific situation: ### When to Use Modal Popups 1. **Critical Actio...
8,767
[ { "from": "human", "value": "What are the cases where you'd use a modal popup ? \nDoes it interrupt the user's flow, if it all of a sudden opens up in his face ? \nWould you avoid modal popups in general ? or when should one be careful of using them ?\nEdit:\nTo be a bit more specific, the situation here is...
I have a simple asp:menu-item that uses the Web.sitemap to get the menu items. The page will postback but fails to get the page associated to the clicked item. I will mention that the navigation bar code is within the masterpage file. <div> <asp:SiteMapDataSource ID="SiteMapDataSource1" ShowStartingNode="false" runa...
It looks like you've identified and resolved the issue with your `asp:Menu` control not correctly navigating to the specified pages when the menu items are clicked. You're right that the `MenuItemBinding` needs to have the `NavigateUrlField` property set in order for the `Menu` to know where to redirect based on the cl...
11,634
[ { "from": "human", "value": "I have a simple asp:menu-item that uses the Web.sitemap to get the menu items. The page will postback but fails to get the page associated to the clicked item. I will mention that the navigation bar code is within the masterpage file.\n<div>\n <asp:SiteMapDataSource ID=\"SiteMa...
I need to parse a xml file which is practically an image of a really big tree structure, so I'm using the XmlReader class to populate the tree 'on the fly'. Each node is passed just the xml chunk it expects from its parent via the ReadSubtree() function. This has the advantage of not having to worry about when a node h...
It sounds like you're working on a complex XML parsing scenario, and your concerns about performance and memory usage when using `ReadSubtree()` are valid. Let’s break down some points regarding the usage of `ReadSubtree()` and the potential implications for memory and performance: ### Advantages of Using `ReadSubtree...
10,278
[ { "from": "human", "value": "I need to parse a xml file which is practically an image of a really big tree structure, so I'm using the XmlReader class to populate the tree 'on the fly'. Each node is passed just the xml chunk it expects from its parent via the ReadSubtree() function. This has the advantage o...
I'm doing some Objective-C programming that involves parsing an NSXmlDocument and populating an objects properties from the result. First version looked like this: if([elementName compare:@"companyName"] == 0) [character setCorporationName:currentElementText]; else if([elementName compare:@"corporationID"] == 0) ...
In Objective-C, the traditional `if-else-if` pattern can indeed become cumbersome when dealing with a series of string comparisons like you described. While you can't directly use a `switch` statement with strings, there are alternative approaches you can use to improve the readability and maintainability of your code....
9,232
[ { "from": "human", "value": "I'm doing some Objective-C programming that involves parsing an NSXmlDocument and populating an objects properties from the result.\nFirst version looked like this:\nif([elementName compare:@\"companyName\"] == 0) \n [character setCorporationName:currentElementText]; \nelse if(...
Is there something like Python's getattr() in C#? I would like to create a window by reading a list which contains the names of controls to put on the window.
In C#, while there is no direct equivalent of Python's `getattr()` method, you can achieve similar functionality using reflection. Reflection allows you to inspect and interact with object types at runtime, including accessing properties or controls by their names. To dynamically create a window and add controls based...
11,361
[ { "from": "human", "value": "Is there something like Python's getattr() in C#? I would like to create a window by reading a list which contains the names of controls to put on the window.\n" }, { "from": "gpt", "value": "In C#, while there is no direct equivalent of Python's `getattr()` method, ...
I'm specifically looking for one that lets me display a map of US states with each one as it's own "object" in the sense that I can control the color, on click, and on mouseover of each one individually. GTK is my personal preference, but at this point I'd settle for just about anything. The application itself will b...
To create an interactive map of US states where each state can be controlled as an individual object (for coloring, mouseover, and click events) in Python, you have several options. Since you're open to alternatives beyond GTK, I'll mention a few libraries that can help you achieve this: ### 1. **Folium (with GeoJSON)...
9,950
[ { "from": "human", "value": "I'm specifically looking for one that lets me display a map of US states with each one as it's own \"object\" in the sense that I can control the color, on click, and on mouseover of each one individually. GTK is my personal preference, but at this point I'd settle for just abo...
I'm having an annoying problem registering a javascript event from inside a user control within a formview in an Async panel. I go to my formview, and press a button to switch into insert mode. This doesn't do a full page postback. Within insert mode, my user control's page_load event should then register a javascript...
The issue you are experiencing is likely related to the lifecycle of the ASP.NET page and when the JavaScript is being registered. Here are some steps and suggestions that might help you resolve the problem: ### 1. Ensure Registration Happens in the Right Lifecycle Event JavaScript should be registered in the correct...
10,209
[ { "from": "human", "value": "I'm having an annoying problem registering a javascript event from inside a user control within a formview in an Async panel. I go to my formview, and press a button to switch into insert mode. This doesn't do a full page postback. Within insert mode, my user control's page_load...
I want to add a scheduled task to a client's ASP.NET app. These posts cover the idea well: https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/ What is the Best Practice to Kick-off Maintenance Process on ASP.NET "Out of Band" Processing Techiniques for asp.net applications My question has two part...
Your questions about maintaining an ASP.NET application and ensuring it stays active are quite relevant, especially for applications that may not have consistent user traffic. Here’s an overview addressing both of your concerns: ### 1. IIS Application Pool Unloading IIS has mechanisms in place to unload applications ...
10,610
[ { "from": "human", "value": "I want to add a scheduled task to a client's ASP.NET app. These posts cover the idea well:\n\nhttps://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/\nWhat is the Best Practice to Kick-off Maintenance Process on ASP.NET\n\"Out of Band\" Processing Techiniques for...
Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream ? The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*.
Yes, you can convert a C++ `std::fstream` to a C `FILE*` handle, but it requires some platform-specific tricks. The C++ standard library does not provide a direct way to do this, and the approach may vary depending on the operating system. Here's a general outline of how to achieve this on both POSIX-compliant systems...
7,724
[ { "from": "human", "value": "Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream ?\nThe reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*.\n" }, { "from": "gpt", "value": "Yes, you c...
What are the stack and heap? Where are they located physically in a computer's memory? To what extent are they controlled by the OS or language run-time? What is their scope? What determines their sizes? What makes one faster?
The stack and heap are two distinct areas of memory used for different purposes in a computer program. ### Stack 1. **Definition**: The stack is a region of memory that stores temporary variables created by each function (including local variables and function call information such as return addresses). 2. **Physica...
9,980
[ { "from": "human", "value": "\nWhat are the stack and heap?\nWhere are they located physically in a computer's memory?\nTo what extent are they controlled by the OS or language run-time?\nWhat is their scope?\nWhat determines their sizes?\nWhat makes one faster?\n\n" }, { "from": "gpt", "value":...
After I messed up the description of my previous post on this I have sat down and tried to convey my exact intent. I have a class called P which performs some distinct purpose. I also have PW which perform some distinct purpose on P. PW has no member variables, just member functions. From this description you would ass...
It sounds like you are looking for a way to have `PW` conveniently access the member functions of `P` without needing to repeatedly use indirection or explicitly calling through member variables. You can achieve this by using composition and delegation. Specifically, you can implement a technique called "delegation" in...
10,921
[ { "from": "human", "value": "After I messed up the description of my previous post on this I have sat down and tried to convey my exact intent.\nI have a class called P which performs some distinct purpose. I also have PW which perform some distinct purpose on P. PW has no member variables, just member func...
What are the characteristics of a multitasking operating system? What makes it multitasking? Are there non-multitasking operating systems?
### Characteristics of a Multitasking Operating System 1. **Concurrent Execution**: A multitasking operating system allows multiple processes or threads to run concurrently. This means that several tasks can be executed in overlapping time periods. 2. **Process Scheduling**: It incorporates a scheduling mechanism tha...
5,568
[ { "from": "human", "value": "What are the characteristics of a multitasking operating system?\nWhat makes it multitasking?\nAre there non-multitasking operating systems?\n" }, { "from": "gpt", "value": "### Characteristics of a Multitasking Operating System\n\n1. **Concurrent Execution**: A mult...
OK, so things have progressed significantly with my DSL since I asked this question a few days ago. As soon as I've refactored my code, I'll post my own answer to that one, but for now, I'm having another problem. I'm dynamically generating sub-diagrams from a DSL-created model, saving those diagrams as images and then...
It sounds like you're working with a modeling framework and encountering an issue where the contents of a compartment are not being displayed in the generated diagrams. Given that the `ElementListCompartment` contains items, but they are not rendered, there are a few things you can check or try to resolve this: 1. **C...
11,623
[ { "from": "human", "value": "OK, so things have progressed significantly with my DSL since I asked this question a few days ago.\nAs soon as I've refactored my code, I'll post my own answer to that one, but for now, I'm having another problem.\nI'm dynamically generating sub-diagrams from a DSL-created mode...
I recently started using Eclipse at work for my Java servlet projects. I've been using jEdit for years, which is a uber-powerful text editor. It has syntax highlighting, but it doesn't have any language-specific features like code completion and intelligent refactoring. I'm finding that's hindering my productivity. ...
Many developers experience similar challenges when transitioning to Eclipse from lighter-weight editors like jEdit. Here are some common issues and considerations, along with alternatives you might explore: ### Common Issues with Eclipse 1. **Configuration Complexity**: Eclipse's setup for Ant can be complex, particul...
10,420
[ { "from": "human", "value": "I recently started using Eclipse at work for my Java servlet projects. I've been using jEdit for years, which is a uber-powerful text editor. It has syntax highlighting, but it doesn't have any language-specific features like code completion and intelligent refactoring. I'm f...
I have seen another program provide traceroute functionality within it but without needing root (superuser) privileges? I've always assumed that raw sockets need to be root, but is there some other way? (I think somebody mentioned "supertrace" or "tracepath"?) Thanks!
Yes, you're correct that traditional `traceroute` functionality often requires root privileges because it typically uses raw sockets to send custom ICMP packets (or UDP packets, depending on the implementation) to probe the path to a target. However, there are alternative tools and methods that can perform similar func...
12,716
[ { "from": "human", "value": "I have seen another program provide traceroute functionality within it but without needing root (superuser) privileges? I've always assumed that raw sockets need to be root, but is there some other way? (I think somebody mentioned \"supertrace\" or \"tracepath\"?) Thanks!\n" }...
I was wondering if I could access the iPhones Core Location framework over a website? My goal is to build a webapp/website that the iPhone would browse to, then upload its current GPS location. This would be a simple site primary for friends/family so we could locate each other. I can have them manually enter lng/lat b...
Yes, you can access the GPS location of an iPhone through a web app using the Geolocation API, which is supported in most modern web browsers, including Safari on iOS. This allows you to retrieve the user's current location automatically with their permission. Here's a basic outline of how you can create a simple web ...
9,992
[ { "from": "human", "value": "I was wondering if I could access the iPhones Core Location framework over a website?\nMy goal is to build a webapp/website that the iPhone would browse to, then upload its current GPS location. This would be a simple site primary for friends/family so we could locate each other...
I come from the Microsoft world (and I come in peace). I want to rapidly prototype a web app and if it works out, take it live - and I don't want to use ASP.Net. I am not sure which web application toolkit to use though. Should I use GWT, DOJO...other recommendations? I am open to any server-side language but am looki...
Given your background and requirements, here are a few recommendations to consider for rapidly prototyping a web application: ### Frameworks 1. **Ruby on Rails (RoR)**: - **Why**: RoR is known for its convention over configuration, which allows for rapid development. It has a robust community and many gems (librar...
8,826
[ { "from": "human", "value": "I come from the Microsoft world (and I come in peace). I want to rapidly prototype a web app and if it works out, take it live - and I don't want to use ASP.Net.\nI am not sure which web application toolkit to use though. Should I use GWT, DOJO...other recommendations? I am ope...
Basically, something similar to System.Xml.XmlWriter - A streaming XML Writer that doesn't incur much of a memory overhead. So that rules out xml.dom and xml.dom.minidom. Suggestions?
If you're looking for a lightweight and memory-efficient way to write XML in Python, similar to `System.Xml.XmlWriter`, here are several options that might meet your needs: 1. **ElementTree (from xml.etree)**: Python's built-in `xml.etree.ElementTree` module can be used for simple XML writing. While it maintains a ...
11,064
[ { "from": "human", "value": "Basically, something similar to System.Xml.XmlWriter - A streaming XML Writer that doesn't incur much of a memory overhead. So that rules out xml.dom and xml.dom.minidom. Suggestions?\n" }, { "from": "gpt", "value": "If you're looking for a lightweight and memory-eff...
We all know that commenting our code is an important part of coding style for making our code understandable to the next person who comes along, or even ourselves in 6 months or so. However, sometimes a comment just doesn't cut the mustard. I'm not talking about obvious jokes or vented frustraton, I'm talking about co...
Certainly! Poor comments can lead to confusion and make it harder for others (or even yourself) to understand the code later on. Let's take a look at a common example of a bad comment and how it could have been improved. ### Example of Poor Commenting ```python def calc(a, b): # This does stuff return a * b +...
11,595
[ { "from": "human", "value": "We all know that commenting our code is an important part of coding style for making our code understandable to the next person who comes along, or even ourselves in 6 months or so.\nHowever, sometimes a comment just doesn't cut the mustard. I'm not talking about obvious jokes ...
Say I have the following web.config: <?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <authentication mode="Windows"></authentication> </system.web> </configuration> Using ASP.NET C#, how can I detect the Mode value of the Authentication tag?
To detect the value of the `mode` attribute of the `<authentication>` tag in the `web.config` file using ASP.NET C#, you can use the `ConfigurationManager` class from the `System.Configuration` namespace. Here’s a step-by-step guide on how to achieve that: 1. Ensure you have the `System.Configuration` assembly referen...
13,240
[ { "from": "human", "value": "Say I have the following web.config:\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<configuration>\n <system.web>\n <authentication mode=\"Windows\"></authentication>\n </system.web>\n</configuration>\n\nUsing ASP.NET C#, how can I detect the Mode value of the Authen...
The LinearGradientBrush in .net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See here or here - essentially, the first line of a linear gradient is drawn in the endcolor, i.e. a gradient from White to Black will start with a Black line and then with the proper White to ...
The artifact issue you've mentioned with `LinearGradientBrush` in .NET or GDI+ can indeed be frustrating, and it has been a known problem in certain situations, particularly when dealing with complex graphics or certain anti-aliasing settings. Here are some potential workarounds that you could try to mitigate this art...
8,227
[ { "from": "human", "value": "The LinearGradientBrush in .net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See here or here - essentially, the first line of a linear gradient is drawn in the endcolor, i.e. a gradient from White to Black will start with a Blac...
This is obviously a stupid question. I am coding in Eclipse both on Mac and Linux, but I mixed up and used the Mac shortcut to window tabbing (Ctrl-Cmd-F6), but I was using the Linux on uni and screen went black. I've done this before, but this time I can't get back to my desktop. Ctrl-Alt F1-F6 gives me different term...
It sounds like you might have inadvertently entered a state where your graphical user interface (GUI) is not responding properly or has gone into a different mode. Here's how you can troubleshoot this issue: 1. **Switch Virtual Terminals**: On Linux, you can switch between different virtual terminals using `Ctrl + Alt...
12,926
[ { "from": "human", "value": "This is obviously a stupid question.\nI am coding in Eclipse both on Mac and Linux, but I mixed up and used the Mac shortcut to window tabbing (Ctrl-Cmd-F6), but I was using the Linux on uni and screen went black. I've done this before, but this time I can't get back to my deskt...
I need to run an equipment audit and to do that I need to obtain the Windows PC, monitor etc. serial numbers. So I faced with going to each PC and manually writing down the numbers. Is there a way I can get this programmatically so each user can run a small program and email me the results?
Yes, you can create a small script that users can run on their Windows PCs to collect the serial numbers of their equipment, such as the PC itself, monitor, etc. You can use PowerShell to accomplish this task easily. ### PowerShell Script to Retrieve Serial Numbers Here's a simple PowerShell script that collects the ...
11,398
[ { "from": "human", "value": "I need to run an equipment audit and to do that I need to obtain the Windows PC, monitor etc. serial numbers.\nSo I faced with going to each PC and manually writing down the numbers.\nIs there a way I can get this programmatically so each user can run a small program and email m...
From time to time I read that Fortran is or can be faster then C for heavy calculations. Is that really true? I must admit that I hardly know Fortran, but the Fortran code I have seen so far did not show that the language has features that C doesn't have. If it is true, please tell me why. Please don't tell me what lan...
The assertion that Fortran can be faster than C for heavy calculations has some basis in reality, although it depends on multiple factors, including the specific task being performed, the quality of the code written, the compiler optimizations, and the numerical algorithms used. Here are several reasons why Fortran mi...
11,606
[ { "from": "human", "value": "From time to time I read that Fortran is or can be faster then C for heavy calculations. Is that really true? I must admit that I hardly know Fortran, but the Fortran code I have seen so far did not show that the language has features that C doesn't have.\nIf it is true, please ...
What is the best way to disable the warnings generated via _CRT_SECURE_NO_DEPRECATE that allows them to be reinstated with ease and will work across Visual Studio versions?
To manage the warnings generated by `_CRT_SECURE_NO_DEPRECATE` in a way that allows you to easily enable or disable them across different versions of Visual Studio, you can use preprocessor directives in your code. This method ensures that you have fine-grained control over the warnings while maintaining compatibility ...
12,215
[ { "from": "human", "value": "What is the best way to disable the warnings generated via _CRT_SECURE_NO_DEPRECATE that allows them to be reinstated with ease and will work across Visual Studio versions?\n" }, { "from": "gpt", "value": "To manage the warnings generated by `_CRT_SECURE_NO_DEPRECATE...
I have a bunch of PDF files and my Perl program needs to do a full-text search of them to return which ones contain a specific string. To date I have been using this: my @search_results = `grep -i -l \"$string\" *.pdf`; where $string is the text to look for. However this fails for most pdf's because the file format is...
It looks like you've already found a workable solution using a combination of `pdftotext` and `grep`. For clarity and completeness, let's break down the final solution you've mentioned and also explore a few alternative approaches. ### Your Solution Explained The command you provided essentially does the following: 1...
10,555
[ { "from": "human", "value": "I have a bunch of PDF files and my Perl program needs to do a full-text search of them to return which ones contain a specific string.\nTo date I have been using this:\nmy @search_results = `grep -i -l \\\"$string\\\" *.pdf`;\n\nwhere $string is the text to look for.\nHowever th...
I'm trying to detect the size of the screen I'm starting emacs on, and adjust the size and position the window it is starting in (I guess that's the frame in emacs-speak) accordingly. I'm trying to set up my .emacs so that I always get a "reasonably-big" window with it's top-left corner near the top-left of my screen. ...
To adjust the size and position of your Emacs frame based on your screen dimensions, you can use Emacs Lisp in your `.emacs` file. This will allow you to set the frame size and position when Emacs starts. Here is a script that checks the screen size and sets the frame dimensions and position accordingly. This script s...
9,665
[ { "from": "human", "value": "I'm trying to detect the size of the screen I'm starting emacs on, and adjust the size and position the window it is starting in (I guess that's the frame in emacs-speak) accordingly. I'm trying to set up my .emacs so that I always get a \"reasonably-big\" window with it's top-l...
For an image hosting web application: For my stored images, is it feasible to create thumbnails on the fly using PHP (or whatever), or should I save 1 or more different sized thumbnails to disk and just load those? Any help is appreciated.
When considering whether to create thumbnails on the fly or save pre-generated thumbnails for an image hosting web application, there are several factors to take into account. Both methods have their pros and cons, and the best choice depends on your specific requirements, server capabilities, and expected user traffic...
8,517
[ { "from": "human", "value": "For an image hosting web application:\nFor my stored images, is it feasible to create thumbnails on the fly using PHP (or whatever), or should I save 1 or more different sized thumbnails to disk and just load those?\nAny help is appreciated.\n" }, { "from": "gpt", "v...
I am using jQuery and trying to find a cross browser way to get the pixel coordinates of the caret in <textarea>s and input boxes such that I can place an absolutely positioned div around this location. Is there some jQuery plugin? Or JavaScript snippet to do just that?
Getting the pixel coordinates of the caret (cursor) within a `<textarea>` or an `<input>` can be a bit tricky, especially since different browsers handle text selection and input elements slightly differently. However, you can achieve this using a combination of JavaScript (or jQuery) and the DOM. Here's a method to c...
8,531
[ { "from": "human", "value": "I am using jQuery and trying to find a cross browser way to get the pixel coordinates of the caret in <textarea>s and input boxes such that I can place an absolutely positioned div around this location.\nIs there some jQuery plugin? Or JavaScript snippet to do just that?\n" },...
I have a temp table with the exact structure of a concrete table T. It was created like this: select top 0 * into #tmp from T After processing and filling in content into #tmp, I want to copy the content back to T like this: insert into T select * from #tmp This is okay as long as T doesn't have identity column, ...
When you're working with a temporary table that has the same structure as a target table with an identity column, and you want to insert data from the temporary table back into the target table while avoiding specifying every column, you can achieve this by using `INSERT ... SELECT` while excluding the identity column....
11,723
[ { "from": "human", "value": "I have a temp table with the exact structure of a concrete table T. It was created like this: \nselect top 0 * into #tmp from T\n\nAfter processing and filling in content into #tmp, I want to copy the content back to T like this: \ninsert into T select * from #tmp\n\nThis is o...
What's the difference between file and open in Python? When should I use which one? (Say I'm in 2.5)
In Python, particularly in version 2.5, the `file` and `open` functions are closely related, but they have different usages. ### `open` Function - The `open` function is the most commonly used way to open a file in Python. It returns a file object, which allows you to read from or write to the file. ```python ...
13,321
[ { "from": "human", "value": "What's the difference between file and open in Python? When should I use which one? (Say I'm in 2.5)\n" }, { "from": "gpt", "value": "In Python, particularly in version 2.5, the `file` and `open` functions are closely related, but they have different usages.\n\n###...
How would I go about... multiplying two 64-bit numbers multiplying two 16-digit hexadecimal numbers ...using Assembly Language. I'm only allowed to use registers %eax, %ebx, %ecx, %edx, and the stack. EDIT: Oh, I'm using ATT Syntax on the x86 EDIT2: Not allowed to decompile into assembly...
Multiplying two 64-bit numbers and two 16-digit hexadecimal numbers in x86 assembly using only the specified registers and the stack can be quite intricate, as x86 assembly does not directly support 64-bit multiplication in one instruction. Instead, we'll implement the multiplication using a series of steps. ### Multi...
6,231
[ { "from": "human", "value": "How would I go about...\n\nmultiplying two 64-bit numbers \nmultiplying two 16-digit hexadecimal numbers \n\n...using Assembly Language. \nI'm only allowed to use registers %eax, %ebx, %ecx, %edx, and the stack.\nEDIT: Oh, I'm using ATT Syntax on the x86\nEDIT2: Not allowed to d...
Say we have realized a value of TDD too late. Project is already matured, good deal of customers started using it. Say automated testing used are mostly functional/system testing and there is a good deal of automated GUI testing. Say we have new feature requests, and new bug reports (!). So good deal of development ...
Introducing Test-Driven Development (TDD) into a mature product that has minimal automated unit testing and heavy reliance on functional/system testing can be challenging, but it is certainly feasible. TDD can still bring value even to an existing codebase, but it requires careful planning and incremental steps. Here a...
8,314
[ { "from": "human", "value": "\nSay we have realized a value of TDD too late. Project is already matured, good deal of customers started using it. \nSay automated testing used are mostly functional/system testing and there is a good deal of automated GUI testing. \nSay we have new feature requests, and new b...
I'm curious about keeping source code around reliably and securely for several years. From my research/experience: Optical media, such as burned DVD-R's lose bits of data over time. After a couple years, I don't get all the files off that I put on them. Read errors, etc. Hard drives are mechanical and subject to failu...
Your concerns about preserving source code for the long term are valid, and you've already identified many important strategies. Here's a more detailed breakdown and additional suggestions: 1. **Redundancy**: This is crucial. Use a combination of different storage media and locations to store your code. For example, y...
10,774
[ { "from": "human", "value": "I'm curious about keeping source code around reliably and securely for several years. From my research/experience:\n\nOptical media, such as burned DVD-R's lose bits of data over time. After a couple years, I don't get all the files off that I put on them. Read errors, etc.\nHar...
I have a couple applications that I would like to be able to add scheduled tasks from within them. I've been Googling for how to add tasks in both XP and Vista. Apparently, Vista has a new Task Scheduler that is very different from the one in XP. Does anybody know if there is a single API to tackle both of them, or do ...
In Windows, the Task Scheduler API differs significantly between Windows XP and Windows Vista (and later versions). Vista introduced a new Task Scheduler with enhanced features, which means there is no single API that seamlessly handles both versions. ### For Windows XP: Windows XP uses the `Task Scheduler` service wh...
12,663
[ { "from": "human", "value": "I have a couple applications that I would like to be able to add scheduled tasks from within them. I've been Googling for how to add tasks in both XP and Vista. Apparently, Vista has a new Task Scheduler that is very different from the one in XP.\nDoes anybody know if there is a...
In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python ?
In Python, you can perform bit manipulation similarly to how you would do it in C. You can use the bitwise AND operator (`&`) and the bitwise NOT operator (`~`) to zero out a specific bit in an integer. Here's how you can zero out bit #10 in a 32-bit unsigned value in Python: ```python value = 0xdeadbeef value &= ~(1...
14,580
[ { "from": "human", "value": "In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so:\nunsigned long value = 0xdeadbeef;\nvalue &= ~(1<<10);\n\nHow do I do that in Python ?\n" }, { "from": "gpt", "value": "In Python, you can perform bit manipulation similarly to how you wo...
Imagine a web application written in Ruby on Rails. Part of the state of that application is represented in a piece of data which doesn't fit the description of a model. This state descriptor needs to be persisted in the same database as the models. Where it differs from a model is that there needs to be only one inst...
Yes, what you're describing is a common scenario in Ruby on Rails applications. When you need to store a single piece of state or configuration in your database that doesn’t fit the conventional model-relationship paradigm, there are several approaches you can take. Here are a few: ### 1. **Singleton Model** You can c...
9,414
[ { "from": "human", "value": "Imagine a web application written in Ruby on Rails. Part of the state of that application is represented in a piece of data which doesn't fit the description of a model. This state descriptor needs to be persisted in the same database as the models.\nWhere it differs from a mod...
I have tree control object created using CTreeCtrl MFC class. The tree control needs to support rename. When I left click on any of item in Tree the TVN_SELCHANGED event is called from which I can get the selected item of the tree as below : HTREEITEM h = m_moveListTree.GetSelectedItem(); CString s = m_moveListTree...
To properly handle renaming in a CTreeCtrl, you need to manage the selection change correctly when a right-click event occurs. The `TVN_SELCHANGED` notification is only triggered by left-click actions, so when a right-click is performed, it doesn't automatically select the item that was right-clicked. To resolve this ...
8,918
[ { "from": "human", "value": "I have tree control object created using CTreeCtrl MFC class. The tree control needs to support rename.\nWhen I left click on any of item in Tree the TVN_SELCHANGED event is called from which I can get the selected item of the tree as below :\n HTREEITEM h = m_moveListTree.GetS...
After working for a while developing games, I've been exposed to both variable frame rates (where you work out how much time has passed since the last tick and update actor movement accordingly) and fixed frame rates (where you work out how much time has passed and choose either to tick a fixed amount of time or sleep ...
When deciding between variable frame rates (VFR) and fixed frame rates (FFR) for game development, it's crucial to consider the different contexts in which each might excel. Here’s a breakdown of their strengths and weaknesses across the considerations you mentioned: ### Catering to Different System Specifications ##...
6,028
[ { "from": "human", "value": "After working for a while developing games, I've been exposed to both variable frame rates (where you work out how much time has passed since the last tick and update actor movement accordingly) and fixed frame rates (where you work out how much time has passed and choose either...
I'm looking for a graph algorithm with some unusual properties. Each edge in the graph is either an "up" edge or a "down" edge. A valid path can go an indefinite number of "up"'s followed by an indefinite number of "down"'s, or vice versa. However it cannot change direction more than once. E.g., a valid path might be A...
This problem can be viewed as a specialized pathfinding problem in a directed graph where the edges have specific constraints based on their directions. Given the nature of the valid paths defined in your question (where the path can only change direction once), we can effectively break down the problem and utilize a m...
5,010
[ { "from": "human", "value": "I'm looking for a graph algorithm with some unusual properties.\nEach edge in the graph is either an \"up\" edge or a \"down\" edge.\nA valid path can go an indefinite number of \"up\"'s followed by an indefinite number of \"down\"'s, or vice versa. However it cannot change dire...
Anyone know? Want to be able to on the fly stamp an image with another image as a watermark, also to do large batches. Any type of existing library or a technique you know of would be great.
To add a watermark to images on the fly and handle large batches, there are several libraries and tools you can use depending on the programming language and environment you're comfortable with. Here are a few options: ### Python 1. **Pillow**: Pillow is a Python Imaging Library (PIL) fork that is very easy to use...
8,174
[ { "from": "human", "value": "Anyone know? Want to be able to on the fly stamp an image with another image as a watermark, also to do large batches. Any type of existing library or a technique you know of would be great.\n" }, { "from": "gpt", "value": "To add a watermark to images on the fly and...
I've been asked to write a Windows service in C# to periodically monitor an email inbox and insert the details of any messages received into a database table. My instinct is to do this via POP3 and sure enough, Googling for ".NET POP3 component" produces countless (ok, 146,000) results. Has anybody done anything simila...
Creating a Windows service to monitor an email inbox and process incoming messages can be efficiently done using either POP3 or IMAP. Each protocol has its advantages and disadvantages depending on your specific requirements. ### POP3 vs IMAP 1. **POP3**: - **Functionality**: It primarily downloads emails to a loc...
8,722
[ { "from": "human", "value": "I've been asked to write a Windows service in C# to periodically monitor an email inbox and insert the details of any messages received into a database table.\nMy instinct is to do this via POP3 and sure enough, Googling for \".NET POP3 component\" produces countless (ok, 146,00...
I need to do the following for the purposes of paging a query in nHibernate: Select count(*) from (Select e.ID,e.Name from Object as e where...) I have tried the following, select count(*) from Object e where e = (Select distinct e.ID,e.Name from ...) and I get an nHibernate Exception saying I cannot convert Object...
To get the count of distinct records from a subquery in NHibernate while using a paging query, you typically do this by wrapping your subquery in a `select count(*)` query. However, since you're experiencing issues with your original attempt, let's break down the steps clearly. To achieve a count of distinct records b...
9,970
[ { "from": "human", "value": "I need to do the following for the purposes of paging a query in nHibernate:\nSelect count(*) from \n(Select e.ID,e.Name from Object as e where...)\n\nI have tried the following, \nselect count(*) from Object e where e = (Select distinct e.ID,e.Name from ...)\n\nand I get an nHi...
Debugging some finance-related SQL code found a strange issue with numeric(24,8) mathematics precision. Running the following query on your MSSQL you would get A + B * C expression result to be 0.123457 SELECT A, B, C, A + B * C FROM ( SELECT CAST(0.12345678 AS NUMERIC(24,8)) AS A, CAST(0 AS...
The behavior you observed in SQL Server relates to the precision and scale of numeric types, along with how SQL Server handles arithmetic operations and type conversions. ### Explanation of the Behavior 1. **Precision and Scale**: - In SQL Server, when you define a column or variable as `NUMERIC(p, s)`, `p` is th...
11,008
[ { "from": "human", "value": "Debugging some finance-related SQL code found a strange issue with numeric(24,8) mathematics precision.\nRunning the following query on your MSSQL you would get A + B * C expression result to be 0.123457\nSELECT A,\n B,\n C,\n A + B * C\nFROM\n(\nSELECT CAST(0....
In what domains do each of these software architectures shine or fail? Which key requirements would prompt you to choose one over the other? Please assume that you have developers available who can do good object oriented code as well as good database development. Also, please avoid holy wars :) all three technologies ...
Sure! When evaluating software architectures, particularly Object-Oriented Programming (OOP), Service-Oriented Architecture (SOA), and Microservices Architecture, it’s essential to understand their strengths and weaknesses, as well as the key requirements that would prompt a choice between them. Below is an analysis of...
9,156
[ { "from": "human", "value": "In what domains do each of these software architectures shine or fail?\nWhich key requirements would prompt you to choose one over the other?\nPlease assume that you have developers available who can do good object oriented code as well as good database development.\nAlso, pleas...
Whats the best way to bind variable column names to a report field in Access when using a crosstab query?
In Microsoft Access, crosstab queries are useful for summarizing data and can dynamically create columns based on the values in a specific field. However, binding variable column names (i.e., column names that change based on the data) to a report can be a bit tricky. Here’s how you can achieve that: ### Steps to Bind...
10,675
[ { "from": "human", "value": "Whats the best way to bind variable column names to a report field in Access when using a crosstab query? \n" }, { "from": "gpt", "value": "In Microsoft Access, crosstab queries are useful for summarizing data and can dynamically create columns based on the values in...
Suppose I have some code that would, in theory, compile against any version of the .net framework. Think "Hello World", if you like. If I actually compile the code, though, I'll get an executable that runs against one particular version. Is there any way to arrange things so that the compiled exe will just run agains...
You are correct that in the .NET ecosystem, applications compiled against an earlier version of the .NET Framework can typically run on later versions of the framework. This is due to the design of the .NET Framework, which maintains a degree of backward compatibility. However, there are a few nuances to consider: 1....
9,757
[ { "from": "human", "value": "Suppose I have some code that would, in theory, compile against any version of the .net framework. Think \"Hello World\", if you like. \nIf I actually compile the code, though, I'll get an executable that runs against one particular version. \nIs there any way to arrange things ...
What is your favorite method to handle errors in Bash? The best example of handling errors I have found on the web was written by William Shotts, Jr at http://www.linuxcommand.org. He suggests using the following function for error handling in Bash: #!/bin/bash # A slicker error handling routine # I put a variable ...
The error handling routine provided by William Shotts is a solid approach, and it encapsulates many best practices. However, there are additional features you can include for more robust error handling. Below, I present an enhanced version of the error handling routine which includes some improvements: 1. **Capture th...
10,659
[ { "from": "human", "value": "What is your favorite method to handle errors in Bash? \nThe best example of handling errors I have found on the web was written by William Shotts, Jr at http://www.linuxcommand.org. \nHe suggests using the following function for error handling in Bash:\n#!/bin/bash\n\n# A slick...
I am trying to create a subclass of WebPart that will act as a parent to any WebParts we create. If I create an empty class in the same project, I am able to inherit from it as one would expect. However, if I try to place it in another assembly -- one that I've been able to reference and use classes from -- I get the f...
The error you are encountering, "Unable to load one or more of the requested types," typically indicates that there is an issue with loading the assembly or one of its dependencies. This can happen due to a variety of reasons, especially in the context of SharePoint development. Here are several steps you can take to t...
6,340
[ { "from": "human", "value": "I am trying to create a subclass of WebPart that will act as a parent to any WebParts we create. If I create an empty class in the same project, I am able to inherit from it as one would expect. However, if I try to place it in another assembly -- one that I've been able to refe...
In an ideal world, our development processes would be perfect, resulting in regular releases that were so thoroughly tested that it would never be necessary to "hotfix" a running application. But, unfortunately, we live in the real world, and sometimes bugs slip past us and don't rear their ugly heads until we're alrea...
Dealing with the pressures of urgent bug fixes in a production environment while maintaining good coding practices can indeed be challenging. However, there are strategies and techniques that can help strike a balance between the need for quick resolutions and the integrity of the codebase. Here are some suggestions: ...
11,868
[ { "from": "human", "value": "In an ideal world, our development processes would be perfect, resulting in regular releases that were so thoroughly tested that it would never be necessary to \"hotfix\" a running application.\nBut, unfortunately, we live in the real world, and sometimes bugs slip past us and d...
Is there an easier way to step through the code than to start the service through the Windows Service Control Manager and then attaching the debugger to the thread? It's kind of cumbersome and I'm wondering if there is a more straightforward approach.
Yes, there is a more straightforward way to debug a Windows service without having to start the service through the Windows Service Control Manager and then attaching the debugger manually. Here are a couple of methods to make debugging easier: ### 1. Debugging in Console Mode You can modify your Windows service to al...
10,753
[ { "from": "human", "value": "Is there an easier way to step through the code than to start the service through the Windows Service Control Manager and then attaching the debugger to the thread? It's kind of cumbersome and I'm wondering if there is a more straightforward approach.\n" }, { "from": "gp...
When writing an app that one wants to have compile on mac, linux and windows, what is the best way of managing the different libraries that will need to be included on the various operating systems. For example, using the glut opengl toolkit requires different includes on each operating system.
When developing a cross-platform application that relies on different libraries, such as the GLUT OpenGL toolkit, it's important to adopt a systematic approach to managing dependencies and platform-specific code. Here are some best practices to facilitate cross-platform development: ### 1. **Use a Cross-Platform Build...
9,739
[ { "from": "human", "value": "When writing an app that one wants to have compile on mac, linux and windows, what is the best way of managing the different libraries that will need to be included on the various operating systems. For example, using the glut opengl toolkit requires different includes on each o...
How do I figure out if an array contains an element? I thought there might be something like [1, 2, 3].includes(1) which would evaluate as true.
Yes, you're correct! In JavaScript, you can use the `includes()` method to determine if an array contains a specific element. Your example is spot on. Here’s how it works: ```javascript const array = [1, 2, 3]; const containsElement = array.includes(1); // This will evaluate to true console.log(containsElement); // Ou...
15,408
[ { "from": "human", "value": "How do I figure out if an array contains an element? \nI thought there might be something like [1, 2, 3].includes(1) which would evaluate as true.\n" }, { "from": "gpt", "value": "Yes, you're correct! In JavaScript, you can use the `includes()` method to determine if...
I am currently working on a project where a programmer who fancied themselves a graphic designer attempted their hand at ASP.Net themes. The CSS is pretty bad, but that is another question altogether. What I really need help with is the best way to organize ASP.Net Themes and the CSS that lies within them. Imagine that...
When working with ASP.NET themes, organizing your CSS effectively is crucial for maintainability, performance, and scalability. Here are some best practices for handling your theme organization while minimizing AppTurn (server-side processing time) during page loads: ### 1. Use a Common Stylesheet Since you have ident...
8,158
[ { "from": "human", "value": "I am currently working on a project where a programmer who fancied themselves a graphic designer attempted their hand at ASP.Net themes. The CSS is pretty bad, but that is another question altogether.\nWhat I really need help with is the best way to organize ASP.Net Themes and t...
I am debugging some code in the Selenium-rc proxy server. It seems the culprit is the HttpURLConnection object, whose interface for getting at the HTTP headers does not cope with duplicate header names, such as: Set-Cookie: foo=foo; Path=/ Set-Cookie: bar=bar; Path=/ The way of getting at the headers through the HttpU...
Yes, your observation regarding `HttpURLConnection` is correct. The `HttpURLConnection` class has limitations in handling multiple HTTP headers with the same name, such as the `Set-Cookie` header in your case. When you retrieve headers using `getHeaderField(int n)` and `getHeaderFieldKey(int n)`, it only returns a sing...
12,820
[ { "from": "human", "value": "I am debugging some code in the Selenium-rc proxy server. It seems the culprit is the HttpURLConnection object, whose interface for getting at the HTTP headers does not cope with duplicate header names, such as:\nSet-Cookie: foo=foo; Path=/\nSet-Cookie: bar=bar; Path=/\n\nThe wa...
I'm working with a fairly simple database, from a Java application. We're trying to insert about 200k of text at a time, using the standard JDBC mysql adapter. We intermittently get a com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column error. The column type is longtext, and database collati...
The `com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column` error indicates that the data you are attempting to insert into the database is being truncated, despite using a `LONGTEXT` column type, which should allow for a large amount of text data. Here are some potential reasons and solutions ...
8,551
[ { "from": "human", "value": "I'm working with a fairly simple database, from a Java application. We're trying to insert about 200k of text at a time, using the standard JDBC mysql adapter. We intermittently get a com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column error.\nThe col...
If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of elements depend on the specific map implementation that I have for the interface?
When you want to iterate over every key-value pair in a `Map` in Java, the most efficient way to do so is to use the `entrySet()` method. This method returns a set of `Map.Entry` objects, each of which represents a key-value pair in the map. You can then iterate over this set using a for-each loop, which is both effici...
14,360
[ { "from": "human", "value": "If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map?\nWill the ordering of elements depend on the specific map implementation that I have for the interface?...
Given: DateTime.UtcNow How do I get a string which represents the same value in an ISO 8601-compliant format? Note that ISO 8601 defines a number of similar formats. The specific format I am looking for is: yyyy-MM-ddTHH:mm:ssZ
To convert `DateTime.UtcNow` to a string in the specific ISO 8601-compliant format `yyyy-MM-ddTHH:mm:ssZ`, you can use the `ToString` method in C#. Here's how you can do it: ```csharp using System; class Program { static void Main() { DateTime utcNow = DateTime.UtcNow; string iso8601String = u...
13,935
[ { "from": "human", "value": "Given:\nDateTime.UtcNow\n\nHow do I get a string which represents the same value in an ISO 8601-compliant format?\nNote that ISO 8601 defines a number of similar formats. The specific format I am looking for is:\nyyyy-MM-ddTHH:mm:ssZ\n\n" }, { "from": "gpt", "value":...
By default (using the plain style) BibTeX orders citations alphabetically. How to order the citations by order of appearance in the document?
To order citations by their order of appearance in a document when using BibTeX, you can use the `unsrt` BibTeX style. The `unsrt` style (short for "unsorted") will maintain the order of citations as they are first encountered in your LaTeX document. Here is how you can do this: 1. In your LaTeX document, when you a...
12,486
[ { "from": "human", "value": "By default (using the plain style) BibTeX orders citations alphabetically. \nHow to order the citations by order of appearance in the document?\n" }, { "from": "gpt", "value": "To order citations by their order of appearance in a document when using BibTeX, you can u...
While using Struts2, I am using several annotations to do my validations inside the Model class, in the set() methods, like: @RequiredStringValidator(message = "Name is required") @StringLengthFieldValidator(message = "Name must be between 5 and 60 characters", minLength = "5", maxLength ...
In Struts2, you can indeed use the `@StringRegexValidator` to validate that a string does not contain certain characters. You can specify a regular expression that matches the allowed characters. For example, if you want to allow only letters and numbers in the name, you could write the validation like this: ```java ...
12,595
[ { "from": "human", "value": "While using Struts2, I am using several annotations to do my validations inside the Model class, in the set() methods, like:\n@RequiredStringValidator(message = \"Name is required\")\n@StringLengthFieldValidator(message = \"Name must be between 5 and 60 characters\", \n ...
I have an XML file that starts like this: <Elements name="Entities" xmlns="XS-GenerationToolElements"> I'll have to open a lot of these files. Each of these have a different namespace but will only have one namespace at a time (I'll never find two namespaces defined in one xml file). Using XPath I'd like to have an au...
To handle the dynamic namespaces in your XML files while using XPath, you can follow two approaches: ### Option 1: Dynamically Add the Namespace to the Namespace Manager You can extract the namespace directly from the XML using the `XPathNavigator`, and then add it to your `XmlNamespaceManager` dynamically. Here's ho...
11,150
[ { "from": "human", "value": "I have an XML file that starts like this:\n<Elements name=\"Entities\" xmlns=\"XS-GenerationToolElements\">\n\nI'll have to open a lot of these files. Each of these have a different namespace but will only have one namespace at a time (I'll never find two namespaces defined in o...
We've got an Apache instance deployed through Oracle Application Server. It's currently installed with the default wallet, and, the self-signed certificate. We've got a GEOTRUST certificiate, imported the Trusted Roots and imported the new Cert to the Wallet Manager. We've then updated the SSL properties of the VHOST a...
The error message you're encountering (`call to NZ function nzos_Handshake failed`) suggests there might be an issue with the SSL handshake process, potentially related to the configuration of your certificates in the Oracle Wallet. Here are some troubleshooting steps and considerations that may help you resolve this i...
10,627
[ { "from": "human", "value": "We've got an Apache instance deployed through Oracle Application Server. It's currently installed with the default wallet, and, the self-signed certificate. We've got a GEOTRUST certificiate, imported the Trusted Roots and imported the new Cert to the Wallet Manager. We've then ...
If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system? I'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may be more conservative if their current versi...
As of my last update in October 2023, the recommended approach for starting an open-source Python project is to use the latest stable version of Python 3, which would have been Python 3.11 or 3.12. However, there are a few factors to consider when choosing the version: 1. **Adoption of the Latest Versions**: Python 3....
14,416
[ { "from": "human", "value": "If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?\nI'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may b...
We have a couple of ASP.Net dataview column templates that are dynamically added to the dataview depending on columns selected by users. These templated cells need to handle custom databindings: public class CustomColumnTemplate: ITemplate { public void InstantiateIn( Control container ) { //create...
When working with dynamic data-binding in ASP.NET and template controls, managing resources efficiently is key, especially when dealing with a potentially large number of dynamically generated controls. Here are a few suggestions to improve the structure of your `CustomColumnTemplate` and manage resource usage better. ...
10,411
[ { "from": "human", "value": "We have a couple of ASP.Net dataview column templates that are dynamically added to the dataview depending on columns selected by users.\nThese templated cells need to handle custom databindings:\npublic class CustomColumnTemplate: \n ITemplate\n{\n public void Instantiate...
One of the things that get me thoroughly confused is the use of session.Flush,in conjunction with session.Commit, and session.Close. Sometimes session.Close works, e.g., it commits all the changes that I need. I know I need to use commit when I have a transaction, or a unit of work with several creates/updates/deletes,...
In NHibernate, understanding the interaction between `Flush`, `Commit`, and `Close` is crucial for managing database transactions effectively. Let’s break down what each of these methods does and when you should use them: ### 1. **Session.Flush()** - **Purpose:** The `Flush` method is responsible for synchronizing the...
1,018
[ { "from": "human", "value": "One of the things that get me thoroughly confused is the use of session.Flush,in conjunction with session.Commit, and session.Close.\nSometimes session.Close works, e.g., it commits all the changes that I need. I know I need to use commit when I have a transaction, or a unit of ...
I wrote a small PHP application several months ago that uses the WordPress XMLRPC library to synchronize two separate WordPress blogs. I have a general "RPCRequest" function that packages the request, sends it, and returns the server response, and I have several more specific functions that customize the type of reque...
The error message you're encountering, specifically "expat reports error code 5: Invalid document end," indicates that there is an issue with the XML response being processed. The `expat` XML parser used in PHP for XML handling is unable to parse the response from the server because it is likely an empty response or no...
9,497
[ { "from": "human", "value": "I wrote a small PHP application several months ago that uses the WordPress XMLRPC library to synchronize two separate WordPress blogs. I have a general \"RPCRequest\" function that packages the request, sends it, and returns the server response, and I have several more specific...
I am trying to call a webservice using ssl. How do i get the relevant server cert so that i can import it into my truststore? I know about the use of property com.ibm.ssl.enableSignerExchangePrompt from a main method but i would add the server cert to my truststore manually. I dont want this property set in any of my s...
To obtain a server certificate that you can import into your truststore for SSL communication, you can follow these steps: ### Step 1: Obtain the Server Certificate 1. **Use OpenSSL**: If you have OpenSSL installed, you can use it to retrieve the server certificate directly from the web service. Run the following com...
11,847
[ { "from": "human", "value": "I am trying to call a webservice using ssl.\nHow do i get the relevant server cert so that i can import it into my truststore?\nI know about the use of property com.ibm.ssl.enableSignerExchangePrompt from a main method but i would add the server cert to my truststore manually.\n...
I've always been wondering how people use CRC (class responsiblity collaboration) cards. I've read about them in books, found vague information on the internet, but never grasped it really. I think someone ought to make a youtube video showing a session with CRC cards, since one of my books described it as being very h...
CRC (Class Responsibility Collaboration) cards are a powerful tool in object-oriented design, helping teams to think about classes and their interactions in a structured way. Here’s a brief overview of how they work and how to use them effectively. ### What Are CRC Cards? 1. **Class**: Each card represents a class in...
12,964
[ { "from": "human", "value": "I've always been wondering how people use CRC (class responsiblity collaboration) cards. I've read about them in books, found vague information on the internet, but never grasped it really. I think someone ought to make a youtube video showing a session with CRC cards, since one...
I was wondering how to use cin so that if the user does not enter in any value and just pushes ENTER that cin will recognize this as valid input.
In C++, the standard input stream `std::cin` does not directly handle cases where the user just presses ENTER (producing an empty input) as valid input by default. However, you can achieve this by reading the input as a string, and then checking if the string is empty. If it's empty, you can handle it as a special case...
13,849
[ { "from": "human", "value": "I was wondering how to use cin so that if the user does not enter in any value and just pushes ENTER that cin will recognize this as valid input.\n" }, { "from": "gpt", "value": "In C++, the standard input stream `std::cin` does not directly handle cases where the us...
What is the best way to access a running mono application via the command line (Linux/Unix)? Example: a mono server application is running and I want to send commands to it using the command line in the lightest/fastest way possible, causing the server to send back a response (e.g. to stdout).
Accessing a running Mono application via the command line in Linux/Unix can be achieved using several techniques, depending on how the Mono application is designed to accept commands. Here are some common methods: ### 1. Using Standard Input (stdin) If the Mono application is designed to read commands from standard i...
10,497
[ { "from": "human", "value": "What is the best way to access a running mono application via the command line (Linux/Unix)? \nExample: a mono server application is running and I want to send commands to it using the command line in the lightest/fastest way possible, causing the server to send back a response ...
Do you use a formal event to get people talking in your IT department? Like a monthly meetup in a social place, a internal wiki/chat space or just a regular "information market" with some presentations about technology or projects made by your staff for your staff? Do you invite Sales people to participate or is it a c...
Creating a culture of knowledge sharing and collaboration within an IT department can be challenging, especially when you encounter resistance or lack of engagement from team members. Here are several strategies that may help improve participation and foster a more collaborative environment: ### 1. **Formalize Knowled...
10,159
[ { "from": "human", "value": "Do you use a formal event to get people talking in your IT department? Like a monthly meetup in a social place, a internal wiki/chat space or just a regular \"information market\" with some presentations about technology or projects made by your staff for your staff? Do you invi...
The sample below has two TextBoxes. The second TextBox has a handler for the LostFocus event which calls Clear() on itself. Changing focus between the two text boxes works fine; however, if the focus is on the second text box when the window is closed, TextBox.Clear() generates a NullReferenceException. Is this a b...
The issue you're experiencing is likely due to the timing of the `LostFocus` event in relation to the window's closing event. When the `LostFocus` event is triggered on the second `TextBox` while the window is closing, the `TextBox` may not be in a valid state to perform operations such as `Clear()`, which results in t...
12,677
[ { "from": "human", "value": "The sample below has two TextBoxes. The second TextBox has a handler for the LostFocus event which calls Clear() on itself. Changing focus between the two text boxes works fine; however, if the focus is on the second text box when the window is closed, TextBox.Clear() generat...
Quite often in ANSI C code I can see parenthesis sorrounding a single return value. Like this:- int foo(int x) { if (x) return (-1); else return (0); } Why use () around the return value in those cases? Any ideas? I can see no reason for that.
Using parentheses around return values in C, like `return (-1);`, is largely a matter of style and personal preference. It does not change the functionality of the code. Here are a few reasons why some programmers might choose to include parentheses in such cases: 1. **Readability**: Some programmers believe that pare...
13,575
[ { "from": "human", "value": "Quite often in ANSI C code I can see parenthesis sorrounding a single return value. \nLike this:-\nint foo(int x) {\n if (x)\n return (-1);\n else\n return (0);\n}\n\nWhy use () around the return value in those cases? Any ideas? I can see no reason for that.\n" }, { ...
I wonder if They can work perfectly together...
It sounds like you're referring to a potential collaboration or partnership between two entities. Could you provide more context about who or what "they" are? That way, I can offer a more tailored response regarding their potential to work together effectively.
16,590
[ { "from": "human", "value": "I wonder if They can work perfectly together...\n" }, { "from": "gpt", "value": "It sounds like you're referring to a potential collaboration or partnership between two entities. Could you provide more context about who or what \"they\" are? That way, I can offer a m...
Is there any clear documentation on the binary formats used to serialize the various MFC data structures? I've been able to view some of my own classes in a hex editor and use Java's ByteBuffer class to read them in (with automatic endianness conversions, etc). However, I am currently running into issues while trying ...
The serialization of MFC (Microsoft Foundation Class) data structures, such as `CObArray`, is not extensively documented, especially in terms of its binary formats. The MFC serialization mechanism uses a combination of C++ classes, reflection, and type information that is typically stored in a way that is optimized for...
9,195
[ { "from": "human", "value": "Is there any clear documentation on the binary formats used to serialize the various MFC data structures? I've been able to view some of my own classes in a hex editor and use Java's ByteBuffer class to read them in (with automatic endianness conversions, etc).\nHowever, I am c...
I've been building an error logging app recently and was after a way of accurately timestamping the incoming data. When I say accurately I mean each timestamp should be accurate relative to each other (no need to sync to an atomic clock or anything like that). I've been using datetime.now() as a first stab, but this is...
To achieve high-resolution timestamps that remain unique across multiple calls, especially when logging data, you can use the `time.perf_counter()` function from the `time` module. This function provides a high-resolution timer that can be used to measure short durations. By combining this with an initial timestamp, yo...
13,291
[ { "from": "human", "value": "I've been building an error logging app recently and was after a way of accurately timestamping the incoming data. When I say accurately I mean each timestamp should be accurate relative to each other (no need to sync to an atomic clock or anything like that).\nI've been using d...
I am having a problem with deploying a ASP.NET V2 web application to our deployment environment and am having trouble with the sql server setup . When I run the website I get a Login failed for user 'MOETP\MOERSVPWLG$'. error when it tries to connect to the database. This seems to be the network service user which is t...
The "Login failed for user 'MOETP\MOERSVPWLG$'" error indicates that the application is trying to authenticate to SQL Server using the Network Service account that is running the ASP.NET application pool. To resolve this issue, you need to ensure that the Network Service account has the appropriate access permissions t...
10,979
[ { "from": "human", "value": "I am having a problem with deploying a ASP.NET V2 web application to our deployment environment and am having trouble with the sql server setup .\nWhen I run the website I get a Login failed for user 'MOETP\\MOERSVPWLG$'. error when it tries to connect to the database.\nThis see...
Consider the following ruby code test.rb: begin puts thisFunctionDoesNotExist x = 1+1 rescue Exception => e p e end For debugging purposes, I would like the rescue block to know that the error occurred in line 4 of this file. Is there a clean way of doing that?
In Ruby, you can use the `caller` method to obtain the current call stack, which can help you identify where an error occurred. However, if you want to explicitly attach line information to the rescued exception, you can manually include that in the rescue block. Here's an updated version of your `test.rb` code that c...
13,948
[ { "from": "human", "value": "Consider the following ruby code\ntest.rb:\nbegin\n\n puts\n thisFunctionDoesNotExist\n x = 1+1\nrescue Exception => e\n p e\nend\n\nFor debugging purposes, I would like the rescue block to know that the error occurred in line 4 of this file. Is there a clean way of doing t...