instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
We have a question with regards to XML-sig and need detail about the optional elements as well as some of the canonicalization and transform stuff. We're writing a spec for a very small XML-syntax payload that will go into the metadata of media files and it needs to by cryptographically signed. Rather than re-invent ...
When dealing with XML signatures (XML-Signature Syntax and Processing), it's important to understand the roles of canonicalization and transforms, even if your XML structure is simple and specific to your needs. ### Canonicalization Canonicalization is the process of converting an XML document into a standard form. T...
1,533
[ { "from": "human", "value": "We have a question with regards to XML-sig and need detail about the optional elements as well as some of the canonicalization and transform stuff. We're writing a spec for a very small XML-syntax payload that will go into the metadata of media files and it needs to by cryptogr...
We have a remoting singleton server running in a separate windows service (let's call her RemotingService). The clients of the RemotingService are ASP.NET instances (many many). Currently, the clients remoting call RemotingService and blocks while the RemotingService call is serviced. However, the remoting service is g...
You're correct in noting that blocking ASP.NET worker threads can lead to scalability issues, especially with longer running processes like complex remoting calls. To address this and improve the performance and scalability of your application, you can consider a couple of architectural adjustments. ### Understanding...
707
[ { "from": "human", "value": "We have a remoting singleton server running in a separate windows service (let's call her RemotingService). The clients of the RemotingService are ASP.NET instances (many many).\nCurrently, the clients remoting call RemotingService and blocks while the RemotingService call is se...
Is anyone out there using Team Foundation Server within a team that is geographically distributed? We're in the UK, trying work with a team in Australia and we're finding it quite tough. Our main two issues are: Things are being checked out to us without us asking on a get latest. Even when using a proxy, most thin...
Using Team Foundation Server (TFS) in a geographically distributed team can indeed present a number of challenges, especially when it comes to performance and collaboration. Here are some tips, tricks, and best practices to help improve your experience: ### 1. **Optimize Network Performance** - **Use a Proxy Server**:...
811
[ { "from": "human", "value": "Is anyone out there using Team Foundation Server within a team that is geographically distributed? We're in the UK, trying work with a team in Australia and we're finding it quite tough.\nOur main two issues are:\n\nThings are being checked out to us without us asking on a get ...
When a controller renders a view based on a model you can get the properties from the ViewData collection using the indexer (ie. ViewData["Property"]). However, I have a shared user control that I tried to call using the following: return View("Message", new { DisplayMessage = "This is a test" }); and on my Message c...
Yes, your observations are correct, and the behavior you encountered is by design in ASP.NET MVC. Let’s clarify why this happens. When you return a view using an anonymous object like this: ```csharp return View("Message", new { DisplayMessage = "This is a test" }); ``` The properties of the anonymous object are not...
1,522
[ { "from": "human", "value": "When a controller renders a view based on a model you can get the properties from the ViewData collection using the indexer (ie. ViewData[\"Property\"]). However, I have a shared user control that I tried to call using the following:\nreturn View(\"Message\", new { DisplayMessa...
How do you find a memory leak in Java (using, for example, JHat)? I have tried to load the heap dump up in JHat to take a basic look. However, I do not understand how I am supposed to be able to find the root reference (ref) or whatever it is called. Basically, I can tell that there are several hundred megabytes of has...
Finding memory leaks in Java using JHat can indeed be a challenge, especially if you are dealing with complex object graphs. Here’s a step-by-step approach to help you effectively identify potential memory leaks and their root references using JHat: ### Step 1: Generate a Heap Dump Before using JHat, ensure you gener...
663
[ { "from": "human", "value": "How do you find a memory leak in Java (using, for example, JHat)? I have tried to load the heap dump up in JHat to take a basic look. However, I do not understand how I am supposed to be able to find the root reference (ref) or whatever it is called. Basically, I can tell that t...
I saw this in an answer to another question, in reference to shortcomings of the Java spec: There are more shortcomings and this is a subtle topic. Check this out: public class methodOverloading{ public static void hello(Integer x){ System.out.println("Integer"); } public static void hello(lo...
In Java, method overloading can lead to some subtle behavior based on how the Java compiler resolves method calls. Let's break down the example you've provided and clarify the concepts of widening, autoboxing, and method resolution. ### The Code Example: ```java public class MethodOverloading { public static void...
1,592
[ { "from": "human", "value": "I saw this in an answer to another question, in reference to shortcomings of the Java spec:\n\nThere are more shortcomings and this is a subtle topic. Check this out:\npublic class methodOverloading{\n public static void hello(Integer x){\n System.out.println(\"Inte...
So I wrote some perl that would parse results returned from the Amazon Web Services. I am using the XML::Simple package. For the most part, everything worked when I pulled out an element. However, the problem I ran into was when an element had an attribute as well. Then I get an error that the item is a Hash. Here...
When using the `XML::Simple` package to parse XML in Perl, it's important to understand how it handles elements and attributes. If an XML element has attributes, `XML::Simple` will represent that element as a hash reference, where the attributes are stored as keys in the hash. In your case, the `RunningTime` element h...
992
[ { "from": "human", "value": "So I wrote some perl that would parse results returned from the Amazon Web Services. I am using the XML::Simple package. For the most part, everything worked when I pulled out an element. However, the problem I ran into was when an element had an attribute as well. Then I get...
Is it possible to access an element on a Master page from the page loaded within the ContentPlaceHolder for the master? I have a ListView that lists people's names in a navigation area on the Master page. I would like to update the ListView after a person has been added to the table that the ListView is data bound to. ...
To access a control defined in the Master page (like your `ListView`), you need to use the `FindControl` method to locate the control from the content page. This is because controls on a Master page are not directly accessible by their ID from a content page. Here's how you can modify your code to update the `ListView...
468
[ { "from": "human", "value": "Is it possible to access an element on a Master page from the page loaded within the ContentPlaceHolder for the master?\nI have a ListView that lists people's names in a navigation area on the Master page. I would like to update the ListView after a person has been added to the ...
In a world where manual memory allocation and pointers still rule (Borland Delphi) I need a general solution for what I think is a general problem: At a given moment an object can be referenced from multiple places (lists, other objects, ...). Is there a good way to keep track of all these references so that I can upda...
In a world where you are managing manual memory allocation and pointers, keeping track of all references to an object can indeed be a challenge. However, a common approach to manage object references is to implement a reference counting system. Here’s a general solution that you can use in Borland Delphi to track refer...
285
[ { "from": "human", "value": "In a world where manual memory allocation and pointers still rule (Borland Delphi) I need a general solution for what I think is a general problem:\nAt a given moment an object can be referenced from multiple places (lists, other objects, ...). Is there a good way to keep track ...
Python has this wonderful way of handling string substitutions using dictionaries: >>> 'The %(site)s site %(adj)s because it %(adj)s' % {'site':'Stackoverflow', 'adj':'rocks'} 'The Stackoverflow site rocks because it rocks' I love this because you can specify a value once in the dictionary and then replace it all over...
Your implementation of the `sprintf3` function is quite neat and effectively achieves the desired string substitution in PHP using an associative array, similar to Python's string formatting. Here's a quick explanation of how your function works, and I'll also suggest a few improvements and alternatives: ### How `spr...
1,653
[ { "from": "human", "value": "Python has this wonderful way of handling string substitutions using dictionaries:\n>>> 'The %(site)s site %(adj)s because it %(adj)s' % {'site':'Stackoverflow', 'adj':'rocks'}\n'The Stackoverflow site rocks because it rocks'\n\nI love this because you can specify a value once i...
I have multiple selects: <select id="one"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> <select id="two"> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select> What I want is to select "one" from ...
To achieve the desired functionality of removing selected options from one `<select>` when the other is selected, we need to avoid triggering the `change` event when we modify the options dynamically. A common approach is to use a flag that indicates when a change is being made programmatically. Here's an updated versi...
523
[ { "from": "human", "value": "I have multiple selects:\n<select id=\"one\">\n <option value=\"1\">one</option>\n <option value=\"2\">two</option>\n <option value=\"3\">three</option>\n</select>\n<select id=\"two\">\n <option value=\"1\">one</option>\n <option value=\"2\">two</option>\n <option value=\"...
I was just wondering if there is an elegant way to set the maximum CPU load for a particular thread doing intensive calculations. Right now I have located the most time-consuming loop in the thread (it does only compression) and use GetTickCount() and Sleep() with hardcoded values. It makes sure that the loop continues...
Managing CPU load for a specific thread can be tricky, especially when you want a more elegant and efficient solution than manually inserting sleep calls. While your current approach with `GetTickCount()` and `Sleep()` can work, there are more refined strategies you could consider to control CPU usage, regardless of th...
1,109
[ { "from": "human", "value": "I was just wondering if there is an elegant way to set the maximum CPU load for a particular thread doing intensive calculations.\nRight now I have located the most time-consuming loop in the thread (it does only compression) and use GetTickCount() and Sleep() with hardcoded val...
In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not. The requirements are that there should be one single list, with one eleme...
Hi Adam, Creating a dynamic download list component similar to the ones in Firefox or Safari can indeed be a bit tricky in Windows Forms, especially when considering resizing behavior. Here are a few approaches that you can use to achieve the desired functionality: ### Approach 1: Using a `ListView` Using a `ListVie...
588
[ { "from": "human", "value": "In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not.\nThe requirements are that there...
Example: I have two shared objects (same should apply to .dlls). The first shared object is from a third-party library, we'll call it libA.so. I have wrapped some of this with JNI and created my own library, libB.so. Now libB depends on libA. When webstarting, both libraries are places in some webstart working area. My...
When dealing with shared libraries in a Java application, particularly when using JNI (Java Native Interface) to bridge Java with native code, you can encounter issues when dependencies between libraries are not resolved correctly. In your case, `libB.so` depends on `libA.so`, but the Java system loader may not be able...
595
[ { "from": "human", "value": "Example: I have two shared objects (same should apply to .dlls). The first shared object is from a third-party library, we'll call it libA.so. I have wrapped some of this with JNI and created my own library, libB.so. Now libB depends on libA.\nWhen webstarting, both libraries ar...
Do you know of any differences in handling HTML tags/properties in different browsers? For example, I once saw a page with a input tag with a maxlength field set to "2o". Firefox and Opera ignore the "o", and set the max length to 2, while Internet Explorer ignores the field altogether. Do you know of any more? (Note: ...
Certainly! Browsers can exhibit varying behaviors when handling HTML tags and properties. Here are some differences: 1. **Different erratic value handling in tag properties**: - As you mentioned, when an invalid value like "2o" is set for the `maxlength` attribute, some browsers ignore the non-numeric characters an...
861
[ { "from": "human", "value": "Do you know of any differences in handling HTML tags/properties in different browsers? For example, I once saw a page with a input tag with a maxlength field set to \"2o\". Firefox and Opera ignore the \"o\", and set the max length to 2, while Internet Explorer ignores the field...
What are some toolkits for developing 2D games in Python? An option that I have heard of is Pygame, but is there anything that has more range to do more things? What are the good and bad parts about the modules?
There are several toolkits and libraries available for developing 2D games in Python, each with its own strengths and weaknesses. Here are some of the most popular ones, including Pygame and alternatives: ### 1. Pygame **Pros:** - **Easy to Learn:** Pygame has a straightforward API that is beginner-friendly. - **Commu...
664
[ { "from": "human", "value": "What are some toolkits for developing 2D games in Python? An option that I have heard of is Pygame, but is there anything that has more range to do more things? What are the good and bad parts about the modules?\n" }, { "from": "gpt", "value": "There are several tool...
Right, initially ran: c:\regsvr32 Amazing.dll then, (accidentally - I might add) I must have run it again, and (indeed) again when new versions of 'Amazing.dll' were released. Yes - I know now I should've run: c:\regsvr32 /u Amazing.dll beforehand - but hey! I forgot. To cut to the chase, when add the COM reference i...
When you register a COM DLL using `regsvr32`, it creates entries in the Windows Registry that allow applications to recognize the COM components provided by that DLL. If you accidentally register the same DLL multiple times, or register different versions without properly unregistering them first, you may end up with m...
1,475
[ { "from": "human", "value": "Right, initially ran:\nc:\\regsvr32 Amazing.dll\n\nthen, (accidentally - I might add) I must have run it again, and (indeed) again when new versions of 'Amazing.dll' were released. Yes - I know now I should've run:\nc:\\regsvr32 /u Amazing.dll\n\nbeforehand - but hey! I forgot.\...
Some WPF controls (like the Button) seem to happily consume all the available space in its' container if you don't specify the height it is to have. And some, like the ones I need to use right now, the (multiline) TextBox and the ListBox seem more worried about just taking the space necessary to fit their contents, and...
You're right that different WPF controls have different default behaviors when it comes to filling available space in their parent containers. In your case, it sounds like you want certain controls, like a `ListBox` or `TextBox`, to expand and fill the available space in a layout without explicitly setting height or wi...
182
[ { "from": "human", "value": "Some WPF controls (like the Button) seem to happily consume all the available space in its' container if you don't specify the height it is to have.\nAnd some, like the ones I need to use right now, the (multiline) TextBox and the ListBox seem more worried about just taking the ...
I'm working on a project were we need more performance. Over time we've continued to evolve the design to work more in parallel(both threaded and distributed). Then latest step has been to move part of it onto a new machine with 16 cores. I'm finding that we need to rethink how we do things to scale to that many cores ...
It sounds like you're on the right track with the resources you've found. Here are some additional recommendations that could help you improve performance and effectively leverage a 16-core shared memory system: 1. **Books on Parallel Programming**: - **"Parallel Programming in C with MPI and OpenMP" by Michael J. ...
1,845
[ { "from": "human", "value": "I'm working on a project were we need more performance. Over time we've continued to evolve the design to work more in parallel(both threaded and distributed). Then latest step has been to move part of it onto a new machine with 16 cores. I'm finding that we need to rethink how ...
I'm writing an AJAX app, but as the user moves through the app, I'd like the URL in the address bar to update despite the lack of page reloads. Basically, I'd like for them to be able to bookmark at any point and thereby return to the current state. How are people handling maintaining RESTfulness in AJAX apps?
To maintain RESTfulness in AJAX applications while updating the URL in the address bar, you'll want to leverage the History API provided by modern browsers. This API allows you to manipulate the browser history and update the URL without reloading the page. Here are some steps and best practices for implementing this a...
255
[ { "from": "human", "value": "I'm writing an AJAX app, but as the user moves through the app, I'd like the URL in the address bar to update despite the lack of page reloads. Basically, I'd like for them to be able to bookmark at any point and thereby return to the current state. \nHow are people handling mai...
I've been programming for 10+ years now for the same employer and only source code control we've ever used is VSS. (Sorry - That's what they had when I started). There's only ever been a few of us; two right now and we usually work alone, so VSS has worked ok for us. So, I have two questions: 1) Should we switch to som...
You're definitely not beyond hope, but it's clear that transitioning away from Visual SourceSafe (VSS) could significantly benefit your workflow, especially given the concerns you've raised about performance and reliability, particularly when working over a VPN. ### 1) Should you switch to something else? Yes, switch...
239
[ { "from": "human", "value": "I've been programming for 10+ years now for the same employer and only source code control we've ever used is VSS. (Sorry - That's what they had when I started). There's only ever been a few of us; two right now and we usually work alone, so VSS has worked ok for us. So, I have ...
For more information - Personal Software Process on Wikipedia and Team Software Process on Wikipedia. I have two questions: What benefits have you seen from these processes? What tools and/or methods do you use to follow these processes?
### Benefits of Personal Software Process (PSP) and Team Software Process (TSP) 1. **Improved Quality**: Both PSP and TSP focus on defect prevention and quality control. By using defined processes, developers can identify and address issues early, leading to higher quality software. 2. **Increased Productivity**: The...
1,668
[ { "from": "human", "value": "For more information - Personal Software Process on Wikipedia and Team Software Process on Wikipedia.\nI have two questions:\n\nWhat benefits have you seen from\nthese processes?\nWhat tools and/or\nmethods do you use to follow these\nprocesses?\n\n" }, { "from": "gpt", ...
Usually when I'm creating indexes on tables, I generally guess what the Fill Factor should be based on an educated guess of how the table will be used (many reads or many writes). Is there a more scientific way to determine a more accurate Fill Factor value?
Yes, determining an appropriate Fill Factor for database indexes can be approached in a more systematic way rather than relying solely on educated guesses. The Fill Factor setting influences how much space on each page of the index is filled with data, leaving some free space for future growth. A Fill Factor of 100% me...
803
[ { "from": "human", "value": "Usually when I'm creating indexes on tables, I generally guess what the Fill Factor should be based on an educated guess of how the table will be used (many reads or many writes).\nIs there a more scientific way to determine a more accurate Fill Factor value?\n" }, { "fr...
What would be the Master Pages equivalent in the Java web development world? I've heard of Tiles, Tapestry and Velocity but don't know anything about them. Are they as easy to use as Master Pages? I want something as easy as set up one template and subsequent pages derive from the template and override content regi...
In the Java web development ecosystem, there are several templating solutions that can provide functionality similar to ASP.NET Master Pages, allowing you to create a common layout for your web application while enabling individual pages to define their own content regions. Here are a few popular options, along with a ...
439
[ { "from": "human", "value": "What would be the Master Pages equivalent in the Java web development world? I've heard of Tiles, Tapestry and Velocity but don't know anything about them. Are they as easy to use as Master Pages? \nI want something as easy as set up one template and subsequent pages derive f...
I know this isn't strictly a programming question but y'all must have experienced this. So...you have four or five RDP sessions open over the corp VPN, you're bashing away inside your favourite IDE, your VPN to the data centre bounces briefly then recovers, all your RDP sessions start re-establishing their connections...
The behavior you're experiencing with RDP sessions grabbing focus when they reconnect can indeed be frustrating. Here are some potential workarounds and solutions you might consider to mitigate this issue: 1. **Disable RDP Auto-reconnect Notification**: In the Remote Desktop Connection settings, you might find an opti...
1,569
[ { "from": "human", "value": "I know this isn't strictly a programming question but y'all must have experienced this. \nSo...you have four or five RDP sessions open over the corp VPN, you're bashing away inside your favourite IDE, your VPN to the data centre bounces briefly then recovers, all your RDP sessio...
I'm a new Windows programmer and I'm not sure where I should store user configurable application settings. I understand the need to provide a user friendly means for the user to change application settings, like an Edit | Settings form or similar. But where should I store the values after the user hits the Apply butt...
Storing user configurable application settings in a Windows environment can be accomplished in several ways, with the most common methods being the Windows Registry and configuration files (like INI files, JSON, XML, or other formats). Here are the pros and cons of each approach: ### Storing Settings in the Windows Re...
1,155
[ { "from": "human", "value": "I'm a new Windows programmer and I'm not sure where I should store user configurable application settings. I understand the need to provide a user friendly means for the user to change application settings, like an Edit | Settings form or similar. But where should I store the ...
In Java (or any other language with checked exceptions), when creating your own exception class, how do you decide whether it should be checked or unchecked? My instinct is to say that a checked exception would be called for in cases where the caller might be able to recover in some productive way, where as an unchecke...
Your instinct about the distinction between checked and unchecked exceptions in Java (and other languages with similar exception handling paradigms) is indeed aligned with common practices. Here's a more detailed breakdown to help clarify when to use each type: ### Checked Exceptions - **Definition**: Checked exceptio...
452
[ { "from": "human", "value": "In Java (or any other language with checked exceptions), when creating your own exception class, how do you decide whether it should be checked or unchecked?\nMy instinct is to say that a checked exception would be called for in cases where the caller might be able to recover in...
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and int atexit(void (*function)(void)); other than the fact that the function used by on_exit gets the exit status? That is, if I don't care about the exit status, is there any reason to use one or the other? Edit: Many of t...
Yes, there are indeed several differences between `on_exit` and `atexit` beyond the fact that the function used by `on_exit` receives the exit status. Let's summarize the key distinctions: 1. **Function Signature**: - `on_exit`: The function that you register with `on_exit` has the signature `void function(int stat...
717
[ { "from": "human", "value": "Is there any difference between\n int on_exit(void (*function)(int , void *), void *arg);\n\nand\n int atexit(void (*function)(void));\n\nother than the fact that the function used by on_exit gets the exit status?\nThat is, if I don't care about the exit status, is there any...
I'm looking for a quick-and-dirty solution to this, I have to set up a Subversion server really quickly, like by the end of the day tomorrow. My initial thought was to just download a virtual appliance that we could load onto our host machine. The problem I am having however is that all the appliances I have found so...
Hi Wally, If you're looking for a quick way to set up a Subversion server on a Linux-based virtual appliance, here are some steps you can take to get SVN 1.5 or later up and running: ### Option 1: Use an Existing Linux Distro 1. **Choose a Lightweight Linux Distro**: You can use a lightweight distribution like Ubunt...
1,483
[ { "from": "human", "value": "I'm looking for a quick-and-dirty solution to this, I have to set up a Subversion server really quickly, like by the end of the day tomorrow. My initial thought was to just download a virtual appliance that we could load onto our host machine. The problem I am having however i...
I'm having a problem obtaining the total row count for items displayed in a Gridview using Paging and with a LinqDataSource as the source of data. I've tried several approaches: protected void GridDataSource_Selected(object sender, LinqDataSourceStatusEventArgs e) { totalLabel.Text = e.TotalRowCount.ToString();...
When using `LinqDataSource` with paging in a GridView, the `TotalRowCount` property may return `-1` if the data source does not support it. To retrieve the total count of records (not just the current page) while using a `LinqDataSource`, you can perform a separate query to get the total count of records. Here is one ...
611
[ { "from": "human", "value": "I'm having a problem obtaining the total row count for items displayed in a Gridview using Paging and with a LinqDataSource as the source of data.\nI've tried several approaches:\nprotected void GridDataSource_Selected(object sender, LinqDataSourceStatusEventArgs e) \n{ \n ...
What is the easiest way to compare strings in Python, ignoring case? Of course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads). I guess I'm looking for an equivalent to C's stricmp(). [Some more context requested, so I'll demonstr...
In Python, string comparisons inherently create new strings when you apply functions like `.lower()`, which can lead to unnecessary overhead, especially when working with large datasets. However, you can achieve case-insensitive sorting without generating new strings by using the `key` parameter in the `sort()` functi...
1,790
[ { "from": "human", "value": "What is the easiest way to compare strings in Python, ignoring case?\nOf course one can do (str1.lower() <= str2.lower()), etc., but this created two additional temporary strings (with the obvious alloc/g-c overheads).\nI guess I'm looking for an equivalent to C's stricmp().\n[S...
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of data on a web-page with XSL over ASP.NET MVC? The two alternatives are: ASP.NET (MVC/WebForms) with XSL Getting the data from the database and transforming it to XML which is then displayed on the different pages with XSL-template...
When comparing XSL with ASP.NET MVC for handling presentation of data on a web page, there are several factors to consider. Each approach has its strengths and weaknesses. Here are some potential advantages of using XSL (Extensible Stylesheet Language) for presentation, along with some considerations regarding ASP.NET ...
478
[ { "from": "human", "value": "Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of data on a web-page with XSL over ASP.NET MVC?\nThe two alternatives are:\n\nASP.NET (MVC/WebForms) with XSL\nGetting the data from the database and transforming it to XML which is then displ...
I am porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux). I have implemented QueryPerformanceCounter by giving the uSeconds since the process start up: BOOL QueryPerformanceCounter(LARGE_INTEGER* performanceCount) { gettimeofday(&currentTi...
Your implementation of `QueryPerformanceCounter` using `gettimeofday` is mostly appropriate for measuring elapsed time since the program started, but there are some considerations regarding portability and accuracy across different systems and Linux configurations. ### Portability 1. **`gettimeofday` Availability**: ...
558
[ { "from": "human", "value": "I am porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux).\nI have implemented QueryPerformanceCounter by giving the uSeconds since the process start up:\nBOOL QueryPerformanceCounter(LARGE_INTEGER* perf...
I have a Struts + Velocity structure like for example, a Person class, whose one property is a Car object (with its own getter/setter methods) and it is mapped to a Velocity form that submits to an Action, using ModelDriven and getModel structure. I what to put a button on the form that shows "View Car" if car property...
In Velocity templates, working with objects and handling null values can sometimes be tricky, especially when integrating with frameworks like Struts. Let's address your problem step by step. 1. **Make Sure the Car Object is Accessible**: Ensure that your `Car` object is properly accessible from the `Person` object in...
828
[ { "from": "human", "value": "I have a Struts + Velocity structure like for example, a Person class, whose one property is a Car object (with its own getter/setter methods) and it is mapped to a Velocity form that submits to an Action, using ModelDriven and getModel structure.\nI what to put a button on the ...
Is there any difference between a binary semaphore and mutex or are they essentially the same?
Binary semaphores and mutexes are similar in that they are both synchronization primitives used in concurrent programming to manage access to shared resources. However, they have some important differences in their functionality and intended use cases. ### Key Differences: 1. **Ownership**: - **Mutex (Mutual Exclu...
2,009
[ { "from": "human", "value": "Is there any difference between a binary semaphore and mutex or are they essentially the same?\n" }, { "from": "gpt", "value": "Binary semaphores and mutexes are similar in that they are both synchronization primitives used in concurrent programming to manage access ...
I have an Interface called IStep that can do some computation (See "Execution in the Kingdom of Nouns"). At runtime, I want to select the appropriate implementation by class name. // use like this: IStep step = GetStep(sName);
To achieve the behavior you want—selecting an implementation of an interface at runtime by class name—you can utilize reflection in C#. Here's how you can implement this: 1. Define your interface `IStep`. 2. Implement various classes that implement this interface. 3. Create a method `GetStep` that takes a string repre...
1,226
[ { "from": "human", "value": "I have an Interface called IStep that can do some computation (See \"Execution in the Kingdom of Nouns\"). At runtime, I want to select the appropriate implementation by class name.\n\n// use like this:\nIStep step = GetStep(sName);\n\n" }, { "from": "gpt", "value": ...
In TFS whats the easiest way of linking a backlog item to a large number of other backlog items, without doing them one at a time? I do not have access to the underlying database so am unable to write a query to do it.
In Azure DevOps (formerly known as Team Foundation Server or TFS), if you want to link a large number of backlog items without doing it one at a time, you can consider the following approaches: ### 1. **Bulk Edit through Excel** Azure DevOps supports integration with Microsoft Excel, allowing you to perform bulk updat...
703
[ { "from": "human", "value": "In TFS whats the easiest way of linking a backlog item to a large number of other backlog items, without doing them one at a time?\nI do not have access to the underlying database so am unable to write a query to do it.\n" }, { "from": "gpt", "value": "In Azure DevOp...
When writing code do you consciously program defensively to ensure high program quality and to avoid the possibility of your code being exploited maliciously, e.g. through buffer overflow exploits or code injection ? What's the "minimum" level of quality you'll always apply to your code ?
When writing code, it is important to adopt a defensive programming approach to ensure high quality and minimize the risk of vulnerabilities such as buffer overflows, code injection, and other forms of exploitation. Here are some key principles that often guide a defensively programmed codebase: ### Defensive Programm...
1,846
[ { "from": "human", "value": "When writing code do you consciously program defensively to ensure high program quality and to avoid the possibility of your code being exploited maliciously, e.g. through buffer overflow exploits or code injection ?\nWhat's the \"minimum\" level of quality you'll always apply t...
Here's the problem, you include multiple assemblies and add 'using namespaceX' at the top of your code file. Now you want to create a class or use a symbol which is defined in multiple namespaces, e.g. System.Windows.Controls.Image & System.Drawing.Image Now unless you use the fully qualified name, there will be a cri...
When you encounter a situation where there are multiple classes or symbols with the same name in different namespaces, the C# compiler raises an ambiguity error. In your case, `System.Windows.Controls.Image` and `System.Drawing.Image` are causing this issue. The solution is to use **fully qualified names** for one of...
2,956
[ { "from": "human", "value": "Here's the problem, you include multiple assemblies and add 'using namespaceX' at the top of your code file.\nNow you want to create a class or use a symbol which is defined in multiple namespaces, \ne.g. System.Windows.Controls.Image & System.Drawing.Image\nNow unless you use t...
Is there a better way to flash a window in Java than this: public static void flashWindow(JFrame frame) throws InterruptedException { int sleepTime = 50; frame.setVisible(false); Thread.sleep(sleepTime); frame.setVisible(true); Thread.sleep(sleepTime); frame.setVisible(fa...
Your current approach of flashing a window in Java by repeatedly setting its visibility can indeed be made cleaner and more efficient. Using a loop is a good idea, and instead of using `Thread.sleep`, which can block the Event Dispatch Thread (EDT), you should consider using a `javax.swing.Timer`. This approach will al...
1,159
[ { "from": "human", "value": "Is there a better way to flash a window in Java than this:\npublic static void flashWindow(JFrame frame) throws InterruptedException {\n int sleepTime = 50;\n frame.setVisible(false);\n Thread.sleep(sleepTime);\n frame.setVisible(true);\n Threa...
Ultramon is a great program for dual monitors (stretching screen across monitors), but I was wondering if there is any way do to something in Visual Studio like have one tab of code open on one monitor and a second tab of code open on the second monitor with only one instance of Visual Studio running? Or are there any ...
Visual Studio is quite flexible when it comes to window management, and there are several ways to utilize dual monitors effectively. Here are some strategies to open multiple tabs or documents in Visual Studio across two monitors using a single instance: ### 1. **Using Document Windows** Visual Studio allows you to de...
1,858
[ { "from": "human", "value": "Ultramon is a great program for dual monitors (stretching screen across monitors), but I was wondering if there is any way do to something in Visual Studio like have one tab of code open on one monitor and a second tab of code open on the second monitor with only one instance of...
How can I build a loop in JavaScript?
In JavaScript, you can create loops using various constructs. The most common types of loops are `for`, `while`, and `do...while`. Below are examples of each type of loop and how to use them: ### 1. **For Loop** A `for` loop is typically used when the number of iterations is known. ```javascript for (let i = 0; i < 5...
1,718
[ { "from": "human", "value": "How can I build a loop in JavaScript?\n" }, { "from": "gpt", "value": "In JavaScript, you can create loops using various constructs. The most common types of loops are `for`, `while`, and `do...while`. Below are examples of each type of loop and how to use them:\n\n#...
How do I use JUnit to test a class that has internal private methods, fields or nested classes? It seems bad to change the access modifier for a method just to be able to run a test.
You're correct that it's generally not a good practice to change the access modifier of methods or fields just to facilitate testing. Here are several approaches to test classes with private methods, fields, or nested classes using JUnit without changing their access modifiers: ### 1. **Test Public Interfaces** Focus ...
636
[ { "from": "human", "value": "How do I use JUnit to test a class that has internal private methods, fields or nested classes?\nIt seems bad to change the access modifier for a method just to be able to run a test.\n" }, { "from": "gpt", "value": "You're correct that it's generally not a good prac...
From what I've read, VS 2008 SP1 and Team Foundation Server SP1 packages are traditional service packs that require you to first install the original versions before you will be able to install the SP. Is there a way, supported or not, to slipstream the install?
Yes, it is possible to create a slipstream installation for Visual Studio 2008 SP1 and Team Foundation Server SP1, although Microsoft does not officially support this method. However, if you need to combine the installation of Visual Studio 2008 with its Service Pack (SP1) for a more streamlined installation process, y...
1,051
[ { "from": "human", "value": "From what I've read, VS 2008 SP1 and Team Foundation Server SP1 packages are traditional service packs that require you to first install the original versions before you will be able to install the SP.\nIs there a way, supported or not, to slipstream the install?\n" }, { ...
Is it possible to determine the MAC address of the originator of a remote connection under Windows NT 4? The remote PC opens a socket connection into my application and I can get the IP address. However I need to determine the MAC address from the information available from the socket such as the IP address of the remo...
In Windows NT 4, determining the MAC address of a remote device that has connected to your application via a socket is not straightforward, especially since Windows NT 4 does not provide built-in support for higher-level networking functions like those available in more modern Windows versions. You can, however, take ...
2,055
[ { "from": "human", "value": "Is it possible to determine the MAC address of the originator of a remote connection under Windows NT 4? The remote PC opens a socket connection into my application and I can get the IP address. However I need to determine the MAC address from the information available from the ...
Given the following interaction: $ git add foo $ git commit -m "Initial import of 'foo'" $ rm foo # This could be any destructive action on foo, like editing it. How do I restore 'foo' in my working copy? I'm looking for something like: $ git <magic> foo Restored foo to revision <blah>.
To restore the file `foo` in your working copy to the state it was in when you last committed it, you can use the `git checkout` command (or `git restore` in newer versions of Git). Here's how you can do it: If you're using a version of Git that supports `git restore`, you can run: ```bash git restore foo ``` If you...
3,771
[ { "from": "human", "value": "Given the following interaction:\n$ git add foo \n$ git commit -m \"Initial import of 'foo'\"\n$ rm foo # This could be any destructive action on foo, like editing it.\n\nHow do I restore 'foo' in my working copy? I'm looking for something like:\n$ git <magic> foo\nRestored foo ...
Is there a one statement or one line way to accomplish something like this, where the string s is declared AND assigned the first non-null value in the expression? //pseudo-codeish string s = Coalesce(string1, string2, string3); or, more generally, object obj = Coalesce(obj1, obj2, obj3, ...objx);
Yes, you can achieve this in C# using the null-coalescing operator (`??`) for two values, or with the `Enumerable.FirstOrDefault` method combined with LINQ for multiple values. For a single statement with two values, you can use: ```csharp string s = string1 ?? string2; ``` If you want to find the first non-null val...
2,728
[ { "from": "human", "value": "Is there a one statement or one line way to accomplish something like this, where the string s is declared AND assigned the first non-null value in the expression?\n//pseudo-codeish\nstring s = Coalesce(string1, string2, string3);\n\nor, more generally,\nobject obj = Coalesce(ob...
I'm quite used to my IDE setup in Delphi 7, where I have my comments rendered in italics. This doesn't appear to be possible in VS2008. There's only an option for bold font, not italics. Is there some kind of registry hack or font magic I can perform to get it to work? The font I'm using is Consolas, if that makes a di...
In Visual Studio 2008, you cannot natively set the font style (such as italics) for comments specifically within the IDE's settings. You can customize the text color and make it bold, but italics for comments isn't an option provided out-of-the-box. However, you can achieve something similar by modifying the environme...
3,388
[ { "from": "human", "value": "I'm quite used to my IDE setup in Delphi 7, where I have my comments rendered in italics.\nThis doesn't appear to be possible in VS2008. There's only an option for bold font, not italics.\nIs there some kind of registry hack or font magic I can perform to get it to work? The fon...
What is the Reuse/Release Equivalence Principle and why is it important?
The Reuse/Release Equivalence Principle (RREP) is a concept in software engineering and specifically within the realm of software reuse. It posits that the reuse of software components should be equivalent to the release of new software. In other words, the effort and considerations taken to release a new version of a ...
2,378
[ { "from": "human", "value": "What is the Reuse/Release Equivalence Principle and why is it important?\n" }, { "from": "gpt", "value": "The Reuse/Release Equivalence Principle (RREP) is a concept in software engineering and specifically within the realm of software reuse. It posits that the reuse...
I have a need to display a UITableView containing a user's account credentials. For this, I'm using UILabels in UITableViewCell. When I display their password, I'd obviously like to just display a placeholder password character instead of their actual password, similar to a UITextField when it's set to secure text entr...
In iOS, when a `UITextField` is set to secure text entry mode, it uses a specific character to represent the password input, which is typically the bullet character (•). The Unicode scalar for this character is U+2022. To display the bullet character in a `UILabel` in your `UITableViewCell`, you can simply use the fol...
3,669
[ { "from": "human", "value": "I have a need to display a UITableView containing a user's account credentials. For this, I'm using UILabels in UITableViewCell. When I display their password, I'd obviously like to just display a placeholder password character instead of their actual password, similar to a UITe...
I’ve writen a little python script that just pops up a message box containing the text passed on the command line. I want to pop it up only when the window —resulting from a previous call— is not open. from Tkinter import * import tkMessageBox root = Tk() root.withdraw() # TODO not if a window with this title exists...
To achieve your goal of displaying a message box only when a window with a specific title does not already exist, you can use the `win32gui` module from the `pywin32` package, which allows you to interact with Windows GUI elements. You'll need to check if any window with the specified title is currently open before cal...
2,628
[ { "from": "human", "value": "I’ve writen a little python script that just pops up a message box containing the text passed on the command line. I want to pop it up only when the window —resulting from a previous call— is not open.\nfrom Tkinter import *\nimport tkMessageBox\n\nroot = Tk()\nroot.withdraw() \...
Is anyone working on or know if there exists a SQL 2k8 Dialect for NHibernate?
As of my last knowledge update in October 2023, NHibernate does provide support for SQL Server 2008 (SQL 2008) out of the box. NHibernate includes a dialect for SQL Server, and it can handle most features of SQL Server 2008. You can use the existing `MsSql2008Dialect` class in NHibernate, which is specifically design...
1,896
[ { "from": "human", "value": "Is anyone working on or know if there exists a SQL 2k8 Dialect for NHibernate? \n" }, { "from": "gpt", "value": "As of my last knowledge update in October 2023, NHibernate does provide support for SQL Server 2008 (SQL 2008) out of the box. NHibernate includes a dial...
When writing a T-SQL script that I plan on re-running, often times I use temporary tables to store temporary data. Since the temp table is created on the fly, I'd like to be able to drop that table only if it exists (before I create it). I'll post the method that I use, but I'd like to see if there is a better way.
Using temporary tables in T-SQL is a common practice, and ensuring that a temporary table is dropped only if it exists before creating it is a good way to avoid errors. Your approach may involve checking for the existence of the temporary table using a conditional statement. Here's a method you might currently use: ``...
2,415
[ { "from": "human", "value": "When writing a T-SQL script that I plan on re-running, often times I use temporary tables to store temporary data. Since the temp table is created on the fly, I'd like to be able to drop that table only if it exists (before I create it).\nI'll post the method that I use, but I'...
I'm able to connect to and read an excel file no problem. But when importing data such as zipcodes that have leading zeros, how do you prevent excel from guessing the datatype and in the process stripping out leading zeros?
When importing data into Excel, especially numeric fields like zip codes that might have leading zeros, you can prevent Excel from stripping these leading zeros by taking the following approaches: ### Method 1: Import as Text 1. **Open Excel** and go to the **Data** tab. 2. Click on **Get Data** (or **Get External Dat...
1,539
[ { "from": "human", "value": "I'm able to connect to and read an excel file no problem. But when importing data such as zipcodes that have leading zeros, how do you prevent excel from guessing the datatype and in the process stripping out leading zeros?\n" }, { "from": "gpt", "value": "When impo...
I have a standard HTML image tag with an image in it, 100 by 100 pixels in size. I want people to be able to click the image and for that to pass the X and Y that they click into a function. The coordinates need to be relative to the image top and left.
You can achieve this by adding an event listener to the image that listens for the `click` event. When the image is clicked, the event's coordinates can be captured and converted to be relative to the image itself. Here's an example of how to do this using standard HTML and JavaScript: ```html <!DOCTYPE html> <html la...
960
[ { "from": "human", "value": "I have a standard HTML image tag with an image in it, 100 by 100 pixels in size. I want people to be able to click the image and for that to pass the X and Y that they click into a function.\nThe coordinates need to be relative to the image top and left.\n" }, { "from": ...
Are there any tools to effectively compare two XML schema's? I have seen some generic XML diff tools, but I was wondering if there is anything that knows more about schemas.
Yes, there are several tools specifically designed for comparing XML schemas (XSDs) that go beyond generic XML diff tools. These tools often provide features that understand the specific constructs and rules of XML schemas, making them more effective for this task. Here are some options: 1. **XMLSpy**: Altova XMLSpy i...
1,750
[ { "from": "human", "value": "Are there any tools to effectively compare two XML schema's? I have seen some generic XML diff tools, but I was wondering if there is anything that knows more about schemas.\n" }, { "from": "gpt", "value": "Yes, there are several tools specifically designed for comp...
Does anybody know any good resources for learning how to program CIL with in-depth descriptions of commands, etc.? I have looked around but not found anything particularly good.
Common Intermediate Language (CIL), also known as Microsoft Intermediate Language (MSIL), is the low-level programming language used by the .NET framework. Here are some resources that can help you learn about CIL, including descriptions of commands and programming techniques: 1. **Official Documentation**: - [ECMA...
543
[ { "from": "human", "value": "Does anybody know any good resources for learning how to program CIL with in-depth descriptions of commands, etc.? I have looked around but not found anything particularly good.\n" }, { "from": "gpt", "value": "Common Intermediate Language (CIL), also known as Micros...
Where can I find a list of all of the MIME types and the identifying characters for Microsoft Office 2007 files? I have an upload form that is restricting uploads based on the extensions and identifying characters, but I cannot seem to find the Office 2007 MIME types. Can anyone help?
Microsoft Office 2007 introduced a new file format based on the Open Packaging Conventions, which means that many Office documents have a new MIME type and file extension. Below is a list of commonly used Microsoft Office 2007 file types along with their associated MIME types: ### Microsoft Office 2007 File Types and ...
269
[ { "from": "human", "value": "Where can I find a list of all of the MIME types and the identifying characters for Microsoft Office 2007 files?\nI have an upload form that is restricting uploads based on the extensions and identifying characters, but I cannot seem to find the Office 2007 MIME types.\nCan anyo...
I've been told that I should include PAD files with the freeware applications I distribute so hosting sites can list the information correctly and check for updates, etc. Can you give me some info on using PAD files? Here are general questions which come to mind: Is it worth the effort? Do you use PADGen or an online...
Using PAD (Portable Application Description) files for distributing freeware applications can indeed be beneficial. Here’s a breakdown of your questions and some general information about PAD files: ### 1. Is it worth the effort? Yes, using PAD files can be worth the effort for several reasons: - **Standardization**:...
2,217
[ { "from": "human", "value": "I've been told that I should include PAD files with the freeware applications I distribute so hosting sites can list the information correctly and check for updates, etc.\nCan you give me some info on using PAD files? Here are general questions which come to mind:\n\nIs it worth...
I had used Server Explorer and related tools for graphical database development with Microsoft SQL Server in some of my learning projects - and it was a great experience. However, in my work I deal with Oracle DB and SQLite and my hobby projects use MySQL (because they are hosted on Linux). Is there a way to leverage t...
Yes, you can leverage database-related tools in Visual Studio to work with other database providers like Oracle, SQLite, and MySQL. Here’s how you can set up and use these databases within Visual Studio: ### 1. **Oracle Database** To work with Oracle Database in Visual Studio, you need to install the **Oracle Data Pro...
891
[ { "from": "human", "value": "I had used Server Explorer and related tools for graphical database development with Microsoft SQL Server in some of my learning projects - and it was a great experience. However, in my work I deal with Oracle DB and SQLite and my hobby projects use MySQL (because they are hoste...
When I process a cube in Visual Studio 2005 I get following message: Process succeeded. Trace information is still being transferred. If you do not want to wait for all of the information to arrive press Stop. and no trace info is displayed. Cube is processed OK by it is a little bit annoying. Any ideas? I acce...
The message you are encountering in Visual Studio 2005 during the processing of a cube indicates that the processing operation has completed successfully, but that the trace information, which can provide insights into the processing operation, is still being gathered. Here are a few suggestions you can try to address...
2,122
[ { "from": "human", "value": "When I process a cube in Visual Studio 2005 I get following message:\n\nProcess succeeded. Trace information\n is still being transferred. If you do\n not want to wait for all of the\n information to arrive press Stop.\n\nand no trace info is displayed. Cube is processed OK b...
Is it possible for the compiler to remove statements used for debugging purposes (such as logging) from production code? The debug statements would need to be marked somehow, maybe using annotations. It's easy to set a property (debug = true) and check it at each debug statement, but this can reduce performance. It wou...
Yes, it is possible for a compiler or a build tool to remove debug statements from production code. This can enhance performance by eliminating unnecessary logging or debugging code. The typical approach to achieve this involves marking debug statements in a way that they can be identified and subsequently removed duri...
1,152
[ { "from": "human", "value": "Is it possible for the compiler to remove statements used for debugging purposes (such as logging) from production code? The debug statements would need to be marked somehow, maybe using annotations.\nIt's easy to set a property (debug = true) and check it at each debug statemen...
I've played with CVS a little bit and am not the most familiar with all of its capabilities, but a huge annoyance for me is trying to add new directories that contain more directories in them. Running "cvs add" only adds the contents of the current directory, and using "cvs import" didn't look like the right thing eith...
When working with CVS, adding directories recursively can indeed be a bit cumbersome because `cvs add` only works on files and does not automatically create a directory structure in the repository. Here’s a method you can use to add a directory and its contents: ### Adding Directories and Files with CVS 1. **Manually...
1,935
[ { "from": "human", "value": "I've played with CVS a little bit and am not the most familiar with all of its capabilities, but a huge annoyance for me is trying to add new directories that contain more directories in them. Running \"cvs add\" only adds the contents of the current directory, and using \"cvs i...
Does your work environment use Harvest SCM? I've used this now at two different locations and find it appalling. In one situation I wrote a conversion script so I could use CVS locally and then daily import changes to the Harvest system while I was sleeping. The corp was fanatic about using Harvest, despite 80% of the ...
Many developers and teams have had mixed experiences with Harvest SCM (Software Configuration Management). While some organizations may appreciate its features for managing complex projects, many users find it cumbersome and inefficient, as you've described. Common complaints include: 1. **Complexity**: Users often re...
2,743
[ { "from": "human", "value": "Does your work environment use Harvest SCM? I've used this now at two different locations and find it appalling. In one situation I wrote a conversion script so I could use CVS locally and then daily import changes to the Harvest system while I was sleeping. The corp was fanatic...
The Compact Framework doesn't support Assembly.GetEntryAssembly to determine the launching .exe. So is there another way to get the name of the executing .exe? EDIT: I found the answer on Peter Foot's blog: http://peterfoot.net/default.aspx Here is the code: byte[] buffer = new byte[MAX_PATH * 2]; int chars = GetModul...
Yes, you're correct! In the .NET Compact Framework, `Assembly.GetEntryAssembly()` is not available, so using the Win32 API function `GetModuleFileName` is a valid workaround to retrieve the name of the executing executable file. Here's a complete example of how you can implement this in your Compact Framework applicat...
1,888
[ { "from": "human", "value": "The Compact Framework doesn't support Assembly.GetEntryAssembly to determine the launching .exe. So is there another way to get the name of the executing .exe?\nEDIT: I found the answer on Peter Foot's blog: http://peterfoot.net/default.aspx\nHere is the code:\nbyte[] buffer = n...
How do you sort an array of strings naturally in different programming languages? Post your implementation and what language it is in in the answer.
Natural sorting (also known as "human-friendly" sorting) orders strings in a way that is more intuitive for humans, taking into account numeric substrings, case sensitivity, and other factors. Here’s how you can implement natural sorting in various programming languages: ### Python In Python, you can use the `natsor...
579
[ { "from": "human", "value": "How do you sort an array of strings naturally in different programming languages? Post your implementation and what language it is in in the answer.\n" }, { "from": "gpt", "value": "Natural sorting (also known as \"human-friendly\" sorting) orders strings in a way th...
Is there a general way to handle Bluetooth Audio/Video Remote Control Profile (AVRCP) events on a WM device? I'm especially interested in a Compact Framework way, but I would be happy with just a simple P/Invoke API. Update. I've read MSDN articles on this topic, but I still have no idea on how to facilitate this knowl...
Handling Bluetooth Audio/Video Remote Control Profile (AVRCP) events on Windows Mobile (WM) devices can be somewhat complex, especially since the Compact Framework does not provide direct support for Bluetooth or AVRCP out of the box. However, you can achieve this using P/Invoke to interact with the necessary Windows A...
905
[ { "from": "human", "value": "Is there a general way to handle Bluetooth Audio/Video Remote Control Profile (AVRCP) events on a WM device? I'm especially interested in a Compact Framework way, but I would be happy with just a simple P/Invoke API.\nUpdate.\nI've read MSDN articles on this topic, but I still h...
I have a ~23000 line SQL dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. I know both the start and end line numbers of the data that I want. Does anyone know a Unix command (or series of commands) to extr...
Yes, you can use the `sed` command in Unix to extract a specific range of lines from a file and redirect the output to a new file. Here's how you can do it: ```bash sed -n '16224,16482p' input_file.sql > output_file.sql ``` In this command: - `-n` suppresses automatic printing of the pattern space. - `'16224,16482p'`...
3,424
[ { "from": "human", "value": "I have a ~23000 line SQL dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. I know both the start and end line numbers of the data that I want.\nDoes anyone know a Un...
Is it necessary or advantageous to write custom connection pooling code when developing applications in .NET with an SQL Server database? I know that ADO.NET gives you the option to enable/disable connection pooling -- does that mean that it's built into the framework and I don't need to worry about it? Why do people...
In .NET, ADO.NET provides built-in connection pooling for SQL Server. This means that, by default, when you create and open a database connection using ADO.NET, the framework automatically manages a pool of connections for you. This pooling mechanism improves performance by reusing existing connections rather than crea...
2,042
[ { "from": "human", "value": "Is it necessary or advantageous to write custom connection pooling code when developing applications in .NET with an SQL Server database? I know that ADO.NET gives you the option to enable/disable connection pooling -- does that mean that it's built into the framework and I don...
What I'd like to do is something like the following: FooClass.prototype.method = function():String { return "Something"; } var foo:FooClass = new FooClass(); foo.method(); Which is to say, I'd like to extend a generated class with a single method, not via inheritance but via the prototype. The class is generated ...
In ActionScript 3 (AS3), you can indeed extend a class dynamically using the prototype, allowing you to add methods without modifying the original class definition. This is useful, especially when working with auto-generated classes like those from a WSDL. Here’s how you can add a method to an existing class without i...
2,637
[ { "from": "human", "value": "What I'd like to do is something like the following:\nFooClass.prototype.method = function():String\n{\n return \"Something\";\n}\n\nvar foo:FooClass = new FooClass();\nfoo.method();\n\nWhich is to say, I'd like to extend a generated class with a single method, not via inheri...
Does anyone know of any existing packages or libraries that can be used to build a calendar in a django app?
Yes, there are several packages and libraries that you can use to implement a calendar in a Django application. Here are some popular options: 1. **Django Scheduler**: - **Package**: [django-scheduler](https://github.com/jazzband/django-scheduler) - **Description**: A reusable app for Django that provides a way ...
1,696
[ { "from": "human", "value": "Does anyone know of any existing packages or libraries that can be used to build a calendar in a django app? \n" }, { "from": "gpt", "value": "Yes, there are several packages and libraries that you can use to implement a calendar in a Django application. Here are som...
Does anyone know how to get IntelliSense to work reliably when working in C/C++ projects? It seems to work for about 1 in 10 files. Visual Studio 2005 seems to be a lot better than 2008. Edit: Whilst not necessarily a solution, the work-around provided here: How to get IntelliSense to reliably work in Visual Studio 20...
Getting IntelliSense to work reliably in Visual Studio, especially in versions like 2008, can sometimes be challenging due to various factors like project settings, file structure, and configurations. Here are some general tips to help improve IntelliSense functionality: ### Tips to Improve IntelliSense in Visual Stud...
581
[ { "from": "human", "value": "Does anyone know how to get IntelliSense to work reliably when working in C/C++ projects? It seems to work for about 1 in 10 files. Visual Studio 2005 seems to be a lot better than 2008.\nEdit: Whilst not necessarily a solution, the work-around provided here: \nHow to get Intell...
Is there any Visual Studio Express plug ins for source versioning? I am starting a project on my own and only have the Express version of Visual Studio 2008.
Visual Studio Express 2008 does not support plugins in the same way that the full versions of Visual Studio do. However, you can still use version control systems with it, but you may need to rely on external tools. Here are some options for source versioning that can be used alongside Visual Studio Express 2008: 1. ...
2,211
[ { "from": "human", "value": "Is there any Visual Studio Express plug ins for source versioning? I am starting a project on my own and only have the Express version of Visual Studio 2008.\n" }, { "from": "gpt", "value": "Visual Studio Express 2008 does not support plugins in the same way that the...
How can I change the title of the command prompt window every time I execute a dos-based program by double clicking it, in c language. Should I use the Windows API?
Yes, you can change the title of the command prompt window from a C program using the Windows API. Specifically, you can use the `SetConsoleTitle` function, which is designed for this purpose. Here's how you can accomplish this in your C program: 1. Include the necessary headers. 2. Use the `SetConsoleTitle` functio...
1,729
[ { "from": "human", "value": "How can I change the title of the command prompt window every time I execute a dos-based program by double clicking it, in c language. Should I use the Windows API?\n" }, { "from": "gpt", "value": "Yes, you can change the title of the command prompt window from a C p...
I'm working on building an app to scan directly from TWAIN scanner to a Java applet. I'm already aware of Morena and JTwain, but they cost money. I need free. I could re-invent the wheel with JNI, but it seems like someone has probably already done this as a FOSS tool. Is anyone familiar with a free tool that can get a...
While there are a few commercial options for integrating TWAIN scanning into Java applications, finding a free or open-source solution can be challenging. Here are a few options you might want to consider for implementing TWAIN scanning in a Java applet: 1. **JTwain (Open Source Version)**: While you mentioned JTwain,...
1,955
[ { "from": "human", "value": "I'm working on building an app to scan directly from TWAIN scanner to a Java applet. I'm already aware of Morena and JTwain, but they cost money. I need free. I could re-invent the wheel with JNI, but it seems like someone has probably already done this as a FOSS tool.\nIs anyon...
I have been searching everywhere for the following functionality in Lisp, and have gotten nowhere: find the index of something in a list. example: (index-of item InThisList) replace something at a specific spot in a list. example: (replace item InThisList AtThisIndex) ;i think this can be done with 'setf'? return an...
In Common Lisp, there are indeed built-in functions that can help you achieve the functionalities you're looking for. Here are the solutions for each of your requirements: 1. **Finding the index of an item in a list**: You can use the `position` function, which returns the index of the first occurrence of an item in a...
1,585
[ { "from": "human", "value": "I have been searching everywhere for the following functionality in Lisp, and have gotten nowhere:\n\nfind the index of something in a list. example:\n(index-of item InThisList)\n\nreplace something at a specific spot in a list. example:\n(replace item InThisList AtThisIndex) ;i...
I have heard/read the term but don't quite understand what it means. When should I use this technique and how would I use it? Can anyone provide a good code sample?
It looks like you're asking about a specific technique in programming, but you didn't specify which one. Could you please clarify which technique or concept you're referring to? Once I know that, I can provide a thorough explanation, use cases, and a code sample!
4,627
[ { "from": "human", "value": "I have heard/read the term but don't quite understand what it means.\nWhen should I use this technique and how would I use it? Can anyone provide a good code sample?\n" }, { "from": "gpt", "value": "It looks like you're asking about a specific technique in programmin...
What tools are useful for automating clicking through a windows form application? Is this even useful? I see the testers at my company doing this a great deal and it seems like a waste of time.
Automating interactions with Windows Forms applications can indeed be useful for various reasons, such as improving testing efficiency, ensuring consistent execution of repetitive tasks, and reducing the chances of human error. Here are some tools commonly used for automating clicking through Windows Forms applications...
1,805
[ { "from": "human", "value": "What tools are useful for automating clicking through a windows form application? Is this even useful? I see the testers at my company doing this a great deal and it seems like a waste of time.\n" }, { "from": "gpt", "value": "Automating interactions with Windows For...
How can I connect to a remote SQL server using Mac OS X? I don't really need a GUI, but it would be nice to have for the color coding and resultset grid. I'd rather not have to use a VM. Is there a SQL client for Mac OS X that works with MS SQL Server?
Yes, there are several SQL clients for Mac OS X that can connect to Microsoft SQL Server without requiring a VM. Here are some popular options: ### 1. **Azure Data Studio** - **Overview**: A cross-platform database tool from Microsoft that works well with SQL Server, Azure SQL Database, and more. It has a modern inter...
1,511
[ { "from": "human", "value": "How can I connect to a remote SQL server using Mac OS X? I don't really need a GUI, but it would be nice to have for the color coding and resultset grid. I'd rather not have to use a VM.\nIs there a SQL client for Mac OS X that works with MS SQL Server?\n" }, { "from": "...
I am running a Qt 4.5 commercial snapshot and want to use a plugin that I downloaded (it's a .so file) in my QWebView. Is there a specific location where I need to place this file? Can I grab it using the QWebPluginFactory?
In Qt, plugins for `QWebView` (specifically, for web content in `QWebKit`) are typically loaded from certain directories depending on the configuration and environment of your application. For a `QWebView` plugin (which is often used for plugins like Flash or other multimedia plugins), you'll want to follow these steps...
1,869
[ { "from": "human", "value": "I am running a Qt 4.5 commercial snapshot and want to use a plugin that I downloaded (it's a .so file) in my QWebView. Is there a specific location where I need to place this file? Can I grab it using the QWebPluginFactory?\n" }, { "from": "gpt", "value": "In Qt, p...
I was wondering if anyone that has experience in both this stuff can shed some light on the significant difference between the two if any? Any specific strength of each that makes it suitable for any specific case?
It seems you're asking about two topics or technologies, but you didn't specify what they are. If you can provide more context or clarify what "this stuff" refers to, I can offer a more detailed comparison and highlight the strengths of each option. Whether it's related to programming languages, frameworks, tools, or a...
4,385
[ { "from": "human", "value": "I was wondering if anyone that has experience in both this stuff can shed some light on the significant difference between the two if any?\nAny specific strength of each that makes it suitable for any specific case?\n" }, { "from": "gpt", "value": "It seems you're as...
Is there a PDF library that one can use to automate creating PDFs from URLs? The current approach I use is to "Print" a page and select a PDF plugin like PrimoPDF to generate the PDF document but I was wanting to automate that.
Yes, there are several libraries and tools available that can help automate the creation of PDFs from URLs without needing to manually print the page. Here are some popular options: 1. **wkhtmltopdf**: - **Description**: This is a command-line tool that uses the WebKit rendering engine to convert HTML pages to PDF....
217
[ { "from": "human", "value": "Is there a PDF library that one can use to automate creating PDFs from URLs? The current approach I use is to \"Print\" a page and select a PDF plugin like PrimoPDF to generate the PDF document but I was wanting to automate that. \n" }, { "from": "gpt", "value": "Yes...
How do I check whether a file exists or not, without using the try statement?
You can check whether a file exists or not in Python without using a `try` statement by using the `os` module or the `pathlib` module. Here are two methods to achieve this: ### Method 1: Using `os.path` ```python import os file_path = 'your_file.txt' # Replace with your file path if os.path.exists(file_path): ...
2,986
[ { "from": "human", "value": "How do I check whether a file exists or not, without using the try statement?\n" }, { "from": "gpt", "value": "You can check whether a file exists or not in Python without using a `try` statement by using the `os` module or the `pathlib` module. Here are two methods ...
Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type sudo vi filename Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up some stuff about vi a while ago, but now I can't find it.
Yes, you can use a command within `vi` to save the file with elevated privileges without having to exit and reopen the editor with `sudo`. Here’s how to do it: 1. First, open the file with `vi` (without `sudo`, in your case). 2. When you try to save the file and realize you don't have the necessary permissions (e.g., ...
3,261
[ { "from": "human", "value": "Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type\nsudo vi filename\n\nIs there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up some stuff about vi a...
I have a rails application which is still showing the cachebusting numeric string at the end of the URL for static mode, even though I have put it into the production environment. Can someone tell me what config option I need to set to prevent this behaviour...
In a Rails application, if you are seeing the cache-busting numeric strings (also known as fingerprinting) at the end of your asset URLs even in production mode, it likely indicates that the assets are being served with fingerprinting enabled. To disable fingerprinting in your production environment, you can adjust yo...
3,183
[ { "from": "human", "value": "I have a rails application which is still showing the cachebusting numeric string at the end of the URL for static mode, even though I have put it into the production environment. Can someone tell me what config option I need to set to prevent this behaviour...\n" }, { "...
I am getting C++ Compiler error C2371 when I include a header file that itself includes odbcss.h. My project is set to MBCS. C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\odbcss.h(430) : error C2371: 'WCHAR' : redefinition; different basic types 1> C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winn...
The error you are encountering (C2371) indicates that there is a conflict in type definitions for `WCHAR` between the `odbcss.h` and `winnt.h` header files. This can happen if the same type is being defined differently in the two headers, which is not permitted in C++. Since you mentioned that your project is set to u...
1,325
[ { "from": "human", "value": "I am getting C++ Compiler error C2371 when I include a header file that itself includes odbcss.h. My project is set to MBCS.\n\nC:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include\\odbcss.h(430) :\n error C2371: 'WCHAR' : redefinition; different basic types 1>\n C:\\Pro...
I'm generating some XML documents and when it comes to the address part I have fragments that look like this: <Address>15 Sample St Example Bay Some Country</Address> The XSLT that I have for converting this to XHTML has some funky recursive template to convert newline characters within strings to <br/> tags. This is ...
Using line breaks within XML documents to represent multi-line text, like in your first example, is generally considered bad practice for a few reasons: 1. **Readability and Maintainability**: XML is meant to represent structured data. Mixing plain text with line breaks can make the document harder to read and maintai...
2,855
[ { "from": "human", "value": "I'm generating some XML documents and when it comes to the address part I have fragments that look like this:\n<Address>15 Sample St\nExample Bay\nSome Country</Address>\n\nThe XSLT that I have for converting this to XHTML has some funky recursive template to convert newline cha...
When using a Zend_Form, the only way to validate that an input is not left blank is to do $element->setRequired(true); If this is not set and the element is blank, it appears to me that validation is not run on the element. If I do use setRequired(), the element is automatically given the standard NotEmpty validator. ...
You're correct that when using `Zend_Form`, setting an element to required with `$element->setRequired(true)` automatically attaches the `Zend_Validate_NotEmpty` validator, which has a default error message. While you've modified the class directly, it is indeed not the best practice. Instead, you can create your own c...
2,271
[ { "from": "human", "value": "When using a Zend_Form, the only way to validate that an input is not left blank is to do\n$element->setRequired(true);\n\nIf this is not set and the element is blank, it appears to me that validation is not run on the element.\nIf I do use setRequired(), the element is automati...
Can anyone explain this behavior? Running: #!/bin/sh echo "hello world" | read var1 var2 echo $var1 echo $var2 results in nothing being ouput, while: #!/bin/sh echo "hello world" > test.file read var1 var2 < test.file echo $var1 echo $var2 produces the expected output: hello world Shouldn't the pipe do in one step w...
Yes, the behavior you are observing is due to how pipes and the `read` command interact with the shell. In the first example using the pipe: ```sh echo "hello world" | read var1 var2 echo $var1 echo $var2 ``` The `read` command runs in a subshell when it's executed through a pipe. As a result, `var1` and `var2` are ...
2,457
[ { "from": "human", "value": "Can anyone explain this behavior?\nRunning:\n#!/bin/sh\necho \"hello world\" | read var1 var2\necho $var1\necho $var2\n\nresults in nothing being ouput, while:\n#!/bin/sh\necho \"hello world\" > test.file\nread var1 var2 < test.file\necho $var1\necho $var2\n\nproduces the expect...
Right up front: I do not want to start a religious war. I've used vi for as long as I can remember, and the few times I've tried to pick up Emacs I've been so lost that I've quickly given up. Lots of people find Emacs very powerful, however. Its programmability is somewhat legendary. I'm primarily doing Solaris+Java de...
Yes, investing time in learning Emacs can lead to increased productivity, especially if you take advantage of its extensive customization and programmability features. However, this depends on your specific workflow and how much you utilize the unique functionalities that Emacs offers compared to Vim. If you find Emacs...
4,321
[ { "from": "human", "value": "Right up front: I do not want to start a religious war.\nI've used vi for as long as I can remember, and the few times I've tried to pick up Emacs I've been so lost that I've quickly given up. Lots of people find Emacs very powerful, however. Its programmability is somewhat lege...
I have something like this: barProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation( barProgress.Value, dNextProgressValue, new Duration(TimeSpan.FromSeconds(dDuration))); Now, how would you stop that animation (the DoubleAnimation)? The reason I want to do this, is because I would like to sta...
To stop an ongoing `DoubleAnimation` on a `RangeBase` control like a `ProgressBar` in WPF, you need to use the `BeginAnimation` method correctly. Once you begin an animation on a property, you can stop it by calling the `BeginAnimation` method again with `null` for that property. This will effectively stop any currentl...
2,523
[ { "from": "human", "value": "I have something like this:\n\nbarProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation(\n barProgress.Value, dNextProgressValue,\n new Duration(TimeSpan.FromSeconds(dDuration)));\n\nNow, how would you stop that animation (the DoubleAnimation)? The reason I ...
Is there a programmatic way to build htpasswd files, without depending on OS specific functions (i.e. exec(), passthru())?
Yes, you can programmatically create `.htpasswd` files without relying on OS-specific functions like `exec()` or `passthru()`. The `.htpasswd` file format is simply a text file where each line contains a username and a hashed password. The hashing can be done using standard libraries available in many programming langu...
1,344
[ { "from": "human", "value": "Is there a programmatic way to build htpasswd files, without depending on OS specific functions (i.e. exec(), passthru())?\n" }, { "from": "gpt", "value": "Yes, you can programmatically create `.htpasswd` files without relying on OS-specific functions like `exec()` o...
I've been working with providers a fair bit lately, and I came across an interesting situation where I wanted to have an abstract class that had an abstract static method. I read a few posts on the topic, and it sort of made sense, but is there a nice clear explanation?
In Python, there is a distinction between instance methods, class methods, and static methods, but it does not directly support abstract static methods in the same way it does for instance methods. This is because the concept of "abstract" typically involves some form of an instance that is expected to be overridden by...
1,177
[ { "from": "human", "value": "I've been working with providers a fair bit lately, and I came across an interesting situation where I wanted to have an abstract class that had an abstract static method. I read a few posts on the topic, and it sort of made sense, but is there a nice clear explanation?\n" }, ...
How do we create a search plugin for Safari? Like this post
Creating a search plugin for Safari involves using the Safari App Extension framework. Here’s a simplified guide to help you get started with creating a basic search plugin. ### Steps to Create a Search Plugin for Safari: 1. **Set Up Your Development Environment:** - Ensure you have the latest version of Xcode ins...
322
[ { "from": "human", "value": "How do we create a search plugin for Safari? Like this post \n" }, { "from": "gpt", "value": "Creating a search plugin for Safari involves using the Safari App Extension framework. Here’s a simplified guide to help you get started with creating a basic search plugin....
I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like, foo in iter_attr(array of python objects, attribute name) I've looked over the docs but this kind of thing doesn't fall under any obvious listed headers
It sounds like you're referring to a way to iterate over a specific attribute of a collection of Python objects. While there's no built-in function called `iter_attr`, you can achieve the desired effect by using a generator function or a list comprehension. Here's a simple example of how you could implement this using...
2,912
[ { "from": "human", "value": "I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like,\nfoo in iter_attr(array of python objects, attribute name)\nI've looked over the docs but this kind of thing doesn't fall under any obvious listed headers\n" ...
I'm looking for a good article on using emacs as C/C++ IDE. Something like Steve Yegge's "Effective emacs".
While I can't browse the internet for current articles, I can recommend a few resources and concepts that might be helpful for using Emacs as a C/C++ IDE. Here are some general guidelines and references that can provide you with a good starting point: ### 1. **Emacs Configuration for C/C++ Development** - Emacs has...
792
[ { "from": "human", "value": "I'm looking for a good article on using emacs as C/C++ IDE.\nSomething like Steve Yegge's \"Effective emacs\".\n" }, { "from": "gpt", "value": "While I can't browse the internet for current articles, I can recommend a few resources and concepts that might be helpful ...
Having briefly looked at Haskell recently, what would be a brief, succinct, practical explanation as to what a monad essentially is? I have found most explanations I've come across to be fairly inaccessible and lacking in practical detail.
Certainly! At its core, a **monad** is a design pattern used in functional programming (like Haskell) to handle computation in a flexible and composable way. Here’s a practical explanation: ### Key Points: 1. **Contextual Values**: Monads allow you to work with values that are wrapped in a context. For example, the `...
695
[ { "from": "human", "value": "Having briefly looked at Haskell recently, what would be a brief, succinct, practical explanation as to what a monad essentially is?\nI have found most explanations I've come across to be fairly inaccessible and lacking in practical detail.\n" }, { "from": "gpt", "va...
can you recommend some good ASP.NET tutorials or a good book? Should I jump right to ASP.NET MVC/html/javascript or learn web forms first? Thanks
Certainly! When it comes to learning ASP.NET, the path you choose can depend on your goals and the specific applications you want to build. Here's a breakdown of your options and some resources: ### Learning Path 1. **ASP.NET Web Forms vs. ASP.NET MVC**: - **ASP.NET Web Forms**: This is a more traditional way of b...
584
[ { "from": "human", "value": "can you recommend some good ASP.NET tutorials or a good book?\nShould I jump right to ASP.NET MVC/html/javascript or learn web forms first? \nThanks\n" }, { "from": "gpt", "value": "Certainly! When it comes to learning ASP.NET, the path you choose can depend on your ...
I'm using Eclipse 3.4 and have configured the Java code formatter with all of the options on the Comments tab enabled. The problem is that when I format a document comment that contains: * @see <a href="test.html">test</a> the code formatter inserts a space in the closing HTML, breaking it: * @see <a href="test.html">...
The issue you're encountering with the Eclipse code formatter adding a space in your Javadoc comments (specifically in HTML tags) is a known quirk of the Java code formatter in older versions of Eclipse, including 3.4. The behavior you're seeing can be quite frustrating, especially if you're working with inline HTML in...
1,998
[ { "from": "human", "value": "I'm using Eclipse 3.4 and have configured the Java code formatter with all of the options on the Comments tab enabled. The problem is that when I format a document comment that contains:\n* @see <a href=\"test.html\">test</a>\n\nthe code formatter inserts a space in the closing ...
I need to reformat my machine but I have so many user/passwords stored in FF2 that I just keep putting it off. Yes I know about backing up the entire profile and restoring it. But for some reason my profile has many issues and I want to start fresh with that as well. Are the username and passwords stored in a text file...
Firefox stores usernames and passwords in a file called `logins.json`, which is located in your Firefox profile directory. Additionally, passwords are often encrypted, and there's an accompanying file called `key4.db` that contains the encryption keys. If you're looking to start fresh while retaining your usernames a...
1,866
[ { "from": "human", "value": "I need to reformat my machine but I have so many user/passwords stored in FF2 that I just keep putting it off. Yes I know about backing up the entire profile and restoring it. But for some reason my profile has many issues and I want to start fresh with that as well.\nAre the us...