qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
262,966
<p>I have a problem with Gridview sorting that is similar to others but I'm binding to a collection object as opposed to a data table.</p> <p>The existing business rules and data access layers of an application follow the pattern of having an object and, if you need a collection of objects of that type, to have anothe...
[ { "answer_id": 263060, "author": "SecretDeveloper", "author_id": 2720, "author_profile": "https://Stackoverflow.com/users/2720", "pm_score": 0, "selected": false, "text": "<p>I had a similar issue and i needed to implement IComparable on the objects. Basically to sort a collection of ob...
2008/11/04
[ "https://Stackoverflow.com/questions/262966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15891/" ]
I have a problem with Gridview sorting that is similar to others but I'm binding to a collection object as opposed to a data table. The existing business rules and data access layers of an application follow the pattern of having an object and, if you need a collection of objects of that type, to have another class in...
In the year since I originally asked this question, I managed to get a new 'standard' implemented so that collections of business objects were now generic lists. So now a "Collection class" that is little more than a "Inherits List(Of MyBusinessObject)" with a Sort Method that looks like this (performance wasn't an is...
263,005
<p>In Linux When I invoke python from the shell it replicates its environment, and starts the python process. Therefore if I do something like the following:</p> <pre><code>import os os.environ["FOO"] = "A_Value" </code></pre> <p>When the python process returns, FOO, assuming it was undefined originally, will still b...
[ { "answer_id": 263022, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 4, "selected": false, "text": "<p>It's not possible, for any child process, to change the environment of the parent process. The best you can do ...
2008/11/04
[ "https://Stackoverflow.com/questions/263005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34329/" ]
In Linux When I invoke python from the shell it replicates its environment, and starts the python process. Therefore if I do something like the following: ``` import os os.environ["FOO"] = "A_Value" ``` When the python process returns, FOO, assuming it was undefined originally, will still be undefined. Is there a wa...
No process can change its parent process (or any other existing process' environment). You can, however, create a new environment by creating a new interactive shell with the modified environment. You have to spawn a new copy of the shell that uses the upgraded environment and has access to the existing stdin, stdout...
263,013
<p>I'm working on a project for school, and I'm implementing a tool which can be used to download files from the web ( with a throttling option ). The thing is, I'm gonna have a GUI for it, and I will be using a <code>JProgressBar</code> widget, which I would like to show the current progress of the download. For that ...
[ { "answer_id": 263037, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 6, "selected": true, "text": "<p>Any HTTP response is <em>supposed</em> to contain a Content-Length header, so you could query the URLConnection object for ...
2008/11/04
[ "https://Stackoverflow.com/questions/263013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
I'm working on a project for school, and I'm implementing a tool which can be used to download files from the web ( with a throttling option ). The thing is, I'm gonna have a GUI for it, and I will be using a `JProgressBar` widget, which I would like to show the current progress of the download. For that I would need t...
Any HTTP response is *supposed* to contain a Content-Length header, so you could query the URLConnection object for this value. ``` //once the connection has been opened List values = urlConnection.getHeaderFields().get("content-Length") if (values != null && !values.isEmpty()) { // getHeaderFields() returns a Ma...
263,023
<p>I was doing some testing and straight LINQ-to-SQL queries run at least 80% faster than if calling stored procedures via the LINQ query</p> <p>In SQL Server profiler a generic LINQ query </p> <pre><code> var results = from m in _dataContext.Members select m; </code></pre> <p>took only 19 milliseconds as opposed t...
[ { "answer_id": 263066, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>A noted in the comments some of this is that you are not comparing apples to apples. You are trying to compare...
2008/11/04
[ "https://Stackoverflow.com/questions/263023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22093/" ]
I was doing some testing and straight LINQ-to-SQL queries run at least 80% faster than if calling stored procedures via the LINQ query In SQL Server profiler a generic LINQ query ``` var results = from m in _dataContext.Members select m; ``` took only 19 milliseconds as opposed to a stored procedure ``` var re...
1) Compare like with like. Perform exactly the same operation in both cases, rather than fetching all values in one case and doing a query in another. 2) Don't just execute the code once - do it lots of times, so the optimiser has a chance to work and to avoid one-time performance hits. 3) Use a profiler (well, one o...
263,053
<p>So I have a column with different numbers and wish to categorize them by range within 30 minute intervals. So 5 would be 0-30, 697 would be 690-720, and 169 would be 150-180. I was first thinking of doing a case statement, but it doesn't look like Access 2003 supports it. Is there perhaps some sort of algorithm that...
[ { "answer_id": 263079, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Use / (integer division) and * (multiplication).\n5/30*30 = 0\n697/30*30 = 690\n169/30*30 = 150\n...</p>\n" }, { "a...
2008/11/04
[ "https://Stackoverflow.com/questions/263053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25371/" ]
So I have a column with different numbers and wish to categorize them by range within 30 minute intervals. So 5 would be 0-30, 697 would be 690-720, and 169 would be 150-180. I was first thinking of doing a case statement, but it doesn't look like Access 2003 supports it. Is there perhaps some sort of algorithm that co...
Take the integer portion of (number / 30) using the Int function and multiply it by 30 to get your lower bound, then add 30 to that number to get your upper bound. Examples ``` Int(5 / 30) = 0 * 30 = 0 Int(697 / 30) = 23 * 30 = 690 ```
263,069
<p>How can I play two or more video files/streams in different windows with frame-level synchronism?</p> <p>What tools, libraries or APIs could I use to do that?</p> <p>By frame-level synchronism I mean that my solution must guarantee that each frame of each video file must be shown at the same time its corresponding...
[ { "answer_id": 263098, "author": "Barry Wark", "author_id": 2140, "author_profile": "https://Stackoverflow.com/users/2140", "pm_score": 0, "selected": false, "text": "<p>On OS X, the <a href=\"http://developer.apple.com/documentation/GraphicsImaging/Conceptual/CoreVideo/CVProg_Intro/chap...
2008/11/04
[ "https://Stackoverflow.com/questions/263069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16120/" ]
How can I play two or more video files/streams in different windows with frame-level synchronism? What tools, libraries or APIs could I use to do that? By frame-level synchronism I mean that my solution must guarantee that each frame of each video file must be shown at the same time its corresponding frames (from the...
On windows it should be possible to create custom directshow filters/components to do this. We use c# and directshow.net to achieve something similar, however we do not yet have "true" frame synchronization and I am in fact searching for a solution as well. The caveat here is that you can not just use the default/prov...
263,081
<p>I'm using Lucene.net, but I am tagging this question for both .NET and Java versions because the API is the same and I'm hoping there are solutions on both platforms.</p> <p>I'm sure other people have addressed this issue, but I haven't been able to find any good discussions or examples. </p> <p>By default, Lucen...
[ { "answer_id": 263241, "author": "Corey Trager", "author_id": 9328, "author_profile": "https://Stackoverflow.com/users/9328", "pm_score": 1, "selected": false, "text": "<p>I'm in the same situation as you.</p>\n\n<p>Here's what I do. I do catch the exception, but only so that I can make...
2008/11/04
[ "https://Stackoverflow.com/questions/263081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31015/" ]
I'm using Lucene.net, but I am tagging this question for both .NET and Java versions because the API is the same and I'm hoping there are solutions on both platforms. I'm sure other people have addressed this issue, but I haven't been able to find any good discussions or examples. By default, Lucene is very picky ab...
Yo can make Lucene ignore the special characters by sanitizing the query with something like ``` query = QueryParser.Escape(query) ``` If you do not want your users to ever use advanced syntax in their queries, you can do this always. If you want your users to use advanced syntax but you also want to be more forgi...
263,086
<p>I've created a dtsx package with Sql Server Business Intelligence Development studio, and I am executing it using the dtexec utility. Using dtexec I am setting certain properties at runtime using the /set switch. So my command looks something like:</p> <pre><code>dtexec /f "mypackage.dtsx" /set \Package.Connection...
[ { "answer_id": 265086, "author": "baldy", "author_id": 2012, "author_profile": "https://Stackoverflow.com/users/2012", "pm_score": 1, "selected": false, "text": "<p>You'll need to create a deployment utility if you;re moving the package between machines. Your connection information gets...
2008/11/04
[ "https://Stackoverflow.com/questions/263086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2327/" ]
I've created a dtsx package with Sql Server Business Intelligence Development studio, and I am executing it using the dtexec utility. Using dtexec I am setting certain properties at runtime using the /set switch. So my command looks something like: ``` dtexec /f "mypackage.dtsx" /set \Package.Connections[Destination]...
This steps is for creating an XML configuration file (.dtsConfig) which can keep your sensitive data, like the password of your connection string, without having a Protection Level that can make you difficult to move the package from one machine to another. In this example, assumed you have an OLE DB Connection to an ...
263,101
<p>I'm using an Informix (Version 7.32) DB. On one operation I create a temp table with the ID of a regular table and a serial column (so I would have all the IDs from the regular table numbered continuously). But I want to insert the info from the regular table ordered by ID something like: </p> <pre><code>CREATE TE...
[ { "answer_id": 263176, "author": "Dema", "author_id": 407003, "author_profile": "https://Stackoverflow.com/users/407003", "pm_score": 1, "selected": true, "text": "<p>You might try it iterating a cursor over the SELECT ... ORDER BY and doing the INSERTs within the loop.</p>\n" }, { ...
2008/11/04
[ "https://Stackoverflow.com/questions/263101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23146/" ]
I'm using an Informix (Version 7.32) DB. On one operation I create a temp table with the ID of a regular table and a serial column (so I would have all the IDs from the regular table numbered continuously). But I want to insert the info from the regular table ordered by ID something like: ``` CREATE TEMP TABLE tempTa...
You might try it iterating a cursor over the SELECT ... ORDER BY and doing the INSERTs within the loop.
263,116
<p>I'm running into a common pattern in the code that I'm writing, where I need to wait for all threads in a group to complete, with a timeout. The timeout is supposed to be the time required for <em>all</em> threads to complete, so simply doing <code>Thread.Join(timeout)</code> for each thread won't work, since the po...
[ { "answer_id": 263170, "author": "Omer van Kloeten", "author_id": 4979, "author_profile": "https://Stackoverflow.com/users/4979", "pm_score": 3, "selected": false, "text": "<p>Off the top of my head, why don't you just Thread.Join(timeout) and remove the time it took to join from the tot...
2008/11/04
[ "https://Stackoverflow.com/questions/263116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8078/" ]
I'm running into a common pattern in the code that I'm writing, where I need to wait for all threads in a group to complete, with a timeout. The timeout is supposed to be the time required for *all* threads to complete, so simply doing `Thread.Join(timeout)` for each thread won't work, since the possible timeout is the...
I still think using Join is simpler. Record the expected completion time (as Now+timeout), then, in a loop, do ``` if(!thread.Join(End-now)) throw new NotFinishedInTime(); ```
263,121
<p>Is there a way to emulate mixins or traits in java? basically, I need a way to do multiple inheritance so I can add common business logic to several classes</p>
[ { "answer_id": 263174, "author": "David Koelle", "author_id": 2197, "author_profile": "https://Stackoverflow.com/users/2197", "pm_score": 2, "selected": false, "text": "<p>Java's answer to multiple inheritance is the ability to implement multiple interfaces. Of course, this means you'll...
2008/11/04
[ "https://Stackoverflow.com/questions/263121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20641/" ]
Is there a way to emulate mixins or traits in java? basically, I need a way to do multiple inheritance so I can add common business logic to several classes
I would encapsulate all of the business logic into a new class `BusinessLogic` and have each class that needs `BusinessLogic` make calls to the class. If you need a single rooted heirarchy for your classes that make calls to `BusinessLogic`, you'll have to create an interface as well (`BusinessLogicInterface`?) In pse...
263,122
<p>I'm writing an image bank with Django, and I want to add a button to get a hi-res version of an image (the low-res is shown in the details page). If I put just an <code>&lt;a&gt;</code> link, the browser will open the image instead of downloading it. Adding an HTTP header like:</p> <pre><code>Content-Disposition...
[ { "answer_id": 263554, "author": "Andrew Kurinnyi", "author_id": 33887, "author_profile": "https://Stackoverflow.com/users/33887", "pm_score": 2, "selected": false, "text": "<p>I wrote a simple decorator, for django.views.static.serve view</p>\n\n<p>Which works for me perfectly. </p>\n\n...
2008/11/04
[ "https://Stackoverflow.com/questions/263122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11649/" ]
I'm writing an image bank with Django, and I want to add a button to get a hi-res version of an image (the low-res is shown in the details page). If I put just an `<a>` link, the browser will open the image instead of downloading it. Adding an HTTP header like: ``` Content-Disposition: attachment; filename="beach008.j...
If your django app is proxied by nginx you can use [x-accell-redirect](http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/). You need to pass a special header in your response, nginx will intercepet this and start serving the file, you can also pass Content-Disposition in the same response to force a d...
263,129
<p>I have a php script and i'm using ajax with it. I have a textarea form connect with the ajax class</p> <p>The problem when I pass a text like (<code>&amp;some text</code>) the function return an empty text, I guess that I have a problem with (<code>&amp;</code>).</p> <p>The javascript function:</p> <pre><code>fun...
[ { "answer_id": 263161, "author": "David Alpert", "author_id": 8997, "author_profile": "https://Stackoverflow.com/users/8997", "pm_score": 0, "selected": false, "text": "<p>when i see HTML and &amp; and problem, i look to make sure that my character encoding is all properly specified. </...
2008/11/04
[ "https://Stackoverflow.com/questions/263129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22634/" ]
I have a php script and i'm using ajax with it. I have a textarea form connect with the ajax class The problem when I pass a text like (`&some text`) the function return an empty text, I guess that I have a problem with (`&`). The javascript function: ``` function sendFormData(idForm, dataSource, divID, ifLoading) {...
Make sure your & is encoded with &amp; if you're passing it using Javascript. All & need to be encoded, or some browsers can freak out a bit, and any validater will complain at you.
263,151
<p>Generally, when using the conditional operator, here's the syntax:</p> <pre><code>int x = 6; int y = x == 6 ? 5 : 9; </code></pre> <p>Nothing fancy, pretty straight forward.</p> <p>Now, let's try to use this when assigning a Lambda to a Func type. Let me explain:</p> <pre><code>Func&lt;Order, bool&gt; predicate ...
[ { "answer_id": 263177, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>You can convert a lambda expression to a particular target delegate type, but in order to determine the type of the co...
2008/11/04
[ "https://Stackoverflow.com/questions/263151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15861/" ]
Generally, when using the conditional operator, here's the syntax: ``` int x = 6; int y = x == 6 ? 5 : 9; ``` Nothing fancy, pretty straight forward. Now, let's try to use this when assigning a Lambda to a Func type. Let me explain: ``` Func<Order, bool> predicate = id == null ? p => p.EmployeeID == null :...
You can convert a lambda expression to a particular target delegate type, but in order to determine the type of the conditional expression, the compiler needs to know the type of each of the second and third operands. While they're both just "lambda expression" there's no conversion from one to the other, so the compil...
263,191
<p>In C#, I want to initialize a string value with an empty string.</p> <p>How should I do this? What is the right way, and why?</p> <pre><code>string willi = string.Empty; </code></pre> <p>or</p> <pre><code>string willi = String.Empty; </code></pre> <p>or</p> <pre><code>string willi = ""; </code></pre> <p>or w...
[ { "answer_id": 263195, "author": "MidnightGun", "author_id": 13220, "author_profile": "https://Stackoverflow.com/users/13220", "pm_score": 4, "selected": false, "text": "<p>I personally prefer \"\" unless there is a good reason to something more complex.</p>\n" }, { "answer_id": ...
2008/11/04
[ "https://Stackoverflow.com/questions/263191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31406/" ]
In C#, I want to initialize a string value with an empty string. How should I do this? What is the right way, and why? ``` string willi = string.Empty; ``` or ``` string willi = String.Empty; ``` or ``` string willi = ""; ``` or what?
**Use whatever you and your team find the most readable.** Other answers have suggested that a new string is created every time you use `""`. This is not true - due to string interning, it will be created either once per assembly or once per AppDomain (or possibly once for the whole process - not sure on that front). ...
263,225
<p>I've done some Googling, and can't find anything, though maybe I'm just looking in the wrong places. I'm also not very adept at VBA, but I'm sure I can figure it out with the right pointers :)</p> <p>I have a string I'm building that's a concatenation of various cells, based on various conditions. I hit these in or...
[ { "answer_id": 263245, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 0, "selected": false, "text": "<p>It's probably easier to start at the end, make your additions to the beginning of the string, and only add D if Y is...
2008/11/04
[ "https://Stackoverflow.com/questions/263225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4418/" ]
I've done some Googling, and can't find anything, though maybe I'm just looking in the wrong places. I'm also not very adept at VBA, but I'm sure I can figure it out with the right pointers :) I have a string I'm building that's a concatenation of various cells, based on various conditions. I hit these in order. ``` ...
I just got this as a possible solution via email, too: ``` =IF(A15<>A14,G15,IF(OR(AND(G15="CR247, ",ISNUMBER(FIND("CR247, ",H14))),AND(G15="CR149, ",ISNUMBER(FIND("CR215, ",H14))),AND(G15="CR149, ",ISNUMBER(FIND("CR180, ",H14))),AND(G15="CR180, ",ISNUMBER(FIND("CR215, ",H14))),G15="CR113, "),H14,G15&H14)) ``` (this ...
263,227
<p>Several times, while perusing the Boost library's documentation, I've run across return values that are marked "<a href="http://www.boost.org/doc/libs/1_36_0/libs/utility/Collection.html" rel="noreferrer">convertible to <code>bool</code></a>" (search that page for the phrase "convertible to bool", it's about a third...
[ { "answer_id": 263279, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 0, "selected": false, "text": "<p>Maybe for performance? In C/C++ you can do an if statement on numbers (0 is false, anything else is true). Converting to ...
2008/11/04
[ "https://Stackoverflow.com/questions/263227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12193/" ]
Several times, while perusing the Boost library's documentation, I've run across return values that are marked "[convertible to `bool`](http://www.boost.org/doc/libs/1_36_0/libs/utility/Collection.html)" (search that page for the phrase "convertible to bool", it's about a third of the way down). I once stumbled across ...
“convertible to bool” simply means anything which can meaningfully be used in a boolean context (e.g. in an `if` condition). This makes sense in implicit conversions. Imagine an object which you want to use in a boolean context, e.g. `std::fstream`: ``` ifstream ifs("filename"); while (ifs >> token) cout "token " ...
263,228
<p>I've been using Flex Builder 3 to create Flex applications that are part of larger Flex / Java project using LiveCycle Data Services. Flex Builder creates and deploys the .war file, which is convenient for the development cycle, but I don't understand what the .war file has to contain in order to deploy and run.</p...
[ { "answer_id": 269800, "author": "Chris", "author_id": 9276, "author_profile": "https://Stackoverflow.com/users/9276", "pm_score": 0, "selected": false, "text": "<p>I don't know anything about LiveCycle Data Services, so that may be an issue. However, I have a flex app that interacts wit...
2008/11/04
[ "https://Stackoverflow.com/questions/263228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34372/" ]
I've been using Flex Builder 3 to create Flex applications that are part of larger Flex / Java project using LiveCycle Data Services. Flex Builder creates and deploys the .war file, which is convenient for the development cycle, but I don't understand what the .war file has to contain in order to deploy and run. I've ...
Check out the sample applications here: <http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/lcds/help.html?content=build_apps_3.html> Those apps will give you some idea of what needs to go in the WAR. In a nutshell there are four significant locations in a standard WAR and one additional significant locatio...
263,229
<p>In a tightly looped test application that prints out the value of <code>DateTime.UtcNow.Ticks</code>, I notice that the value will jump a remarkable amount once every hour or so. Look closely at the following sample data:</p> <pre><code>1:52:14.312 PM - 633614215343125000 1:52:14.359 PM - 633614215343593750 1:52:1...
[ { "answer_id": 263277, "author": "Matt Lacey", "author_id": 1755, "author_profile": "https://Stackoverflow.com/users/1755", "pm_score": 0, "selected": false, "text": "<p>Can you post code to show how you generated this data? And provide details about the machine you are running this on?...
2008/11/04
[ "https://Stackoverflow.com/questions/263229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18051/" ]
In a tightly looped test application that prints out the value of `DateTime.UtcNow.Ticks`, I notice that the value will jump a remarkable amount once every hour or so. Look closely at the following sample data: ``` 1:52:14.312 PM - 633614215343125000 1:52:14.359 PM - 633614215343593750 1:52:14.421 PM - 633614215344218...
Actually, just running some test with this loop: ``` static DateTime past = DateTime.UtcNow; static void PrintTime() { while (stopLoop == 0) { DateTime now = DateTime.UtcNow; Console.WriteLine("{0} - {1} d: {2}", now, now.Ticks, now - past); Program.past = no...
263,232
<p>I'm working with jQuery and looking to see if there is an easy way to determine if the element has a specific CSS class associated with it.</p> <p>I have the id of the element, and the CSS class that I'm looking for. I just need to be able to, in an if statement, do a comparison based on the existence of that clas...
[ { "answer_id": 263240, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 9, "selected": true, "text": "<p>Use the <code>hasClass</code> method:</p>\n\n<pre><code>jQueryCollection.hasClass(className);\n</code></pre>\n\n<...
2008/11/04
[ "https://Stackoverflow.com/questions/263232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13279/" ]
I'm working with jQuery and looking to see if there is an easy way to determine if the element has a specific CSS class associated with it. I have the id of the element, and the CSS class that I'm looking for. I just need to be able to, in an if statement, do a comparison based on the existence of that class on the el...
Use the `hasClass` method: ``` jQueryCollection.hasClass(className); ``` or ``` $(selector).hasClass(className); ``` The argument is (obviously) a string representing the class you are checking, and it returns a boolean (so it doesn't support chaining like most jQuery methods). **Note:** If you pass a `className...
263,234
<p>I have a WinForms application (I'm using VB) that can be minimized to the system tray. I used the "hackish" methods described in multiple posts utilizing a NotifyIcon and playing with the Form_Resize event. </p> <p>This all works fine aesthetically, but the resources and memory used are unaffected. I want to be abl...
[ { "answer_id": 263262, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 2, "selected": false, "text": "<p>To clean up unused memory, use GC.Collect()... though you should read up on why to do it and why its usually a bad i...
2008/11/04
[ "https://Stackoverflow.com/questions/263234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25962/" ]
I have a WinForms application (I'm using VB) that can be minimized to the system tray. I used the "hackish" methods described in multiple posts utilizing a NotifyIcon and playing with the Form\_Resize event. This all works fine aesthetically, but the resources and memory used are unaffected. I want to be able to mini...
Calling MiniMizeMemory() will do a garbage collection, trim the process working size, then compact the process' heap. ``` public static void MinimizeMemory() { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); SetProcessWorkingSetSize( Process.GetCurrentProcess().Handle, (UIntPtr...
263,249
<p>Are there any good <a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html" rel="noreferrer">value list handler</a> implementations available?</p> <p>I've found <a href="http://valuelist.sourceforge.net/" rel="noreferrer">valuelist</a>, but it seems to be stagnating... besides I real...
[ { "answer_id": 263262, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 2, "selected": false, "text": "<p>To clean up unused memory, use GC.Collect()... though you should read up on why to do it and why its usually a bad i...
2008/11/04
[ "https://Stackoverflow.com/questions/263249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24443/" ]
Are there any good [value list handler](http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html) implementations available? I've found [valuelist](http://valuelist.sourceforge.net/), but it seems to be stagnating... besides I really need good control of links the taglib generates, because I need...
Calling MiniMizeMemory() will do a garbage collection, trim the process working size, then compact the process' heap. ``` public static void MinimizeMemory() { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); SetProcessWorkingSetSize( Process.GetCurrentProcess().Handle, (UIntPtr...
263,263
<p>I'm using Apache Subversion to manage and store a decent volume of code. Trying to get at it on a standard work machine using svn+ssh with TortoiseSVN on Windows Vista, I find that I can't actually bring all of it down to my local machine at once - the transfer stops after about 1 MB. I can grab it all in fits and s...
[ { "answer_id": 263262, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 2, "selected": false, "text": "<p>To clean up unused memory, use GC.Collect()... though you should read up on why to do it and why its usually a bad i...
2008/11/04
[ "https://Stackoverflow.com/questions/263263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34384/" ]
I'm using Apache Subversion to manage and store a decent volume of code. Trying to get at it on a standard work machine using svn+ssh with TortoiseSVN on Windows Vista, I find that I can't actually bring all of it down to my local machine at once - the transfer stops after about 1 MB. I can grab it all in fits and star...
Calling MiniMizeMemory() will do a garbage collection, trim the process working size, then compact the process' heap. ``` public static void MinimizeMemory() { GC.Collect(GC.MaxGeneration); GC.WaitForPendingFinalizers(); SetProcessWorkingSetSize( Process.GetCurrentProcess().Handle, (UIntPtr...
263,267
<p>Is there a way, within the .net framework, to check to see if two different shared folders are actually pointing to the same physical directory? Do directories in Windows have some sort of unique identifier? Google-fu is failing me.</p> <p>(I mean, aside from writing a temp file to one and seeing if it appears in...
[ { "answer_id": 264280, "author": "Brody", "author_id": 17131, "author_profile": "https://Stackoverflow.com/users/17131", "pm_score": 0, "selected": false, "text": "<p>You can examine the share definition itself by using the System.Management namespace but it is not easy to use.</p>\n\n<p...
2008/11/04
[ "https://Stackoverflow.com/questions/263267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7856/" ]
Is there a way, within the .net framework, to check to see if two different shared folders are actually pointing to the same physical directory? Do directories in Windows have some sort of unique identifier? Google-fu is failing me. (I mean, aside from writing a temp file to one and seeing if it appears in the other) ...
I believe using WMI queries will take care of what I need to do: ``` Connection options = new ConnectionOptions(); ManagementScope scpoe = new ManagementScope("\\\\Server\\root\\cimv2", options); ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Share WHERE Name = '" + name +"'") ManagementObjectSearcher searc...
263,271
<p>I have a Ruby script that generates a UTF8 CSV file remotely in a Linux machine and then transfers the file to a Windows machine thru SFTP. </p> <p>I then need to open this file with Excel, but Excel doesn't get UTF8, so I always need to open the file in a text editor that has the capability to convert UTF8 to ANSI...
[ { "answer_id": 263324, "author": "AShelly", "author_id": 10396, "author_profile": "https://Stackoverflow.com/users/10396", "pm_score": 5, "selected": true, "text": "<pre><code>ascii_str = yourUTF8text.unpack(\"U*\").map{|c|c.chr}.join\n</code></pre>\n\n<p>assuming that your text really d...
2008/11/04
[ "https://Stackoverflow.com/questions/263271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/407003/" ]
I have a Ruby script that generates a UTF8 CSV file remotely in a Linux machine and then transfers the file to a Windows machine thru SFTP. I then need to open this file with Excel, but Excel doesn't get UTF8, so I always need to open the file in a text editor that has the capability to convert UTF8 to ANSI. I would...
``` ascii_str = yourUTF8text.unpack("U*").map{|c|c.chr}.join ``` assuming that your text really does fit in the ascii character set.
263,296
<p>I am currently trying to create a win32 service using pywin32. My main point of reference has been this tutorial:</p> <p><a href="http://code.activestate.com/recipes/551780/" rel="noreferrer">http://code.activestate.com/recipes/551780/</a></p> <p>What i don't understand is the initialization process, since the Dae...
[ { "answer_id": 264871, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 4, "selected": true, "text": "<p>I've never used these APIs, but digging through the code, it looks like the class passed in is used to register t...
2008/11/04
[ "https://Stackoverflow.com/questions/263296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34395/" ]
I am currently trying to create a win32 service using pywin32. My main point of reference has been this tutorial: <http://code.activestate.com/recipes/551780/> What i don't understand is the initialization process, since the Daemon is never initialized directly by Daemon(), instead from my understanding its initializ...
I've never used these APIs, but digging through the code, it looks like the class passed in is used to register the name of the class in the registry, so you can't do any initialization of your own. But there's a method called GetServiceCustomOption that may help: <http://mail.python.org/pipermail/python-win32/2006-Ap...
263,322
<p>What is the best way to add "copy to clipboard" functionality to a ListView control in WPF?</p> <p>I tried adding an ApplicationCommands.Copy to either the ListView ContextMenu or the ListViewItem ContextMenu, but the command remains disabled.</p> <p>Thanks, Peter</p> <p>Here is an xaml sample of one of my attemp...
[ { "answer_id": 263540, "author": "Todd White", "author_id": 30833, "author_profile": "https://Stackoverflow.com/users/30833", "pm_score": 3, "selected": true, "text": "<p>It looks like you need a CommandBinding.</p>\n\n<p>Here is how I would probably go about doing what you trying to do....
2008/11/04
[ "https://Stackoverflow.com/questions/263322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34403/" ]
What is the best way to add "copy to clipboard" functionality to a ListView control in WPF? I tried adding an ApplicationCommands.Copy to either the ListView ContextMenu or the ListViewItem ContextMenu, but the command remains disabled. Thanks, Peter Here is an xaml sample of one of my attempts... ``` <Window.Reso...
It looks like you need a CommandBinding. Here is how I would probably go about doing what you trying to do. ``` <Window.CommandBindings> <CommandBinding Command="ApplicationCommands.Copy" Executed="CopyCommandHandler" CanExecute="CanCopyExecuteHandler" /> </Window.CommandBindings> <Window...
263,336
<p>I'm trying out asp.net mvc for a new project, and I ran across something odd. When I use the MVC UI helpers for textboxes, the values get persisted between calls. But, when I use a series of radio buttons, the checked state doesn't get persisted.</p> <p>Here's an example from my view.</p> <pre><code>&lt;li&gt; ...
[ { "answer_id": 263863, "author": "Haacked", "author_id": 598, "author_profile": "https://Stackoverflow.com/users/598", "pm_score": 2, "selected": false, "text": "<p>The form shouldn't be posting to the querystring, unless you forgot to specify the form as method=\"POST\". How are you spe...
2008/11/04
[ "https://Stackoverflow.com/questions/263336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672/" ]
I'm trying out asp.net mvc for a new project, and I ran across something odd. When I use the MVC UI helpers for textboxes, the values get persisted between calls. But, when I use a series of radio buttons, the checked state doesn't get persisted. Here's an example from my view. ``` <li> <%=Html.RadioButton("p...
If you give the radio buttons the same name as the property on your model, then MVC will automatically set the checked attribute on the appropriate button. I think this relies on having a strongly typed Model.
263,339
<p>I'm looking for a clean C++ way to parse a string containing expressions wrapped in ${} and build a result string from the programmatically evaluated expressions.</p> <p>Example: "Hi ${user} from ${host}" will be evaluated to "Hi foo from bar" if I implement the program to let "user" evaluate to "foo", etc.</p> <...
[ { "answer_id": 263389, "author": "Matt Cruikshank", "author_id": 8643, "author_profile": "https://Stackoverflow.com/users/8643", "pm_score": 0, "selected": false, "text": "<p>How many evaluation expressions do intend to have? If it's small enough, you might just want to use brute force....
2008/11/04
[ "https://Stackoverflow.com/questions/263339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20444/" ]
I'm looking for a clean C++ way to parse a string containing expressions wrapped in ${} and build a result string from the programmatically evaluated expressions. Example: "Hi ${user} from ${host}" will be evaluated to "Hi foo from bar" if I implement the program to let "user" evaluate to "foo", etc. The current appr...
``` #include <iostream> #include <conio.h> #include <string> #include <map> using namespace std; struct Token { enum E { Replace, Literal, Eos }; }; class ParseExp { private: enum State { State_Begin, State_Literal, State_StartRep, State_Rep...
263,355
<p>Portfolio A → Fund 1</p> <p>Portfolio A → Fund 2</p> <p>Portfolio A → Fund 3</p> <p>I couldn't frame my sentence without not using is/has. But between 1 &amp; 2,</p> <p>1) has a:</p> <pre><code>class PortfolioA { List&lt;Fund&gt; obj; } </code></pre> <p>2) is a:</p> <pre><code>class PortfolioA : List&lt;F...
[ { "answer_id": 263366, "author": "jonnii", "author_id": 4590, "author_profile": "https://Stackoverflow.com/users/4590", "pm_score": 3, "selected": false, "text": "<p>The first one, because you should try to favour composition over inheritance when you can.</p>\n" }, { "answer_id"...
2008/11/04
[ "https://Stackoverflow.com/questions/263355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31622/" ]
Portfolio A → Fund 1 Portfolio A → Fund 2 Portfolio A → Fund 3 I couldn't frame my sentence without not using is/has. But between 1 & 2, 1) has a: ``` class PortfolioA { List<Fund> obj; } ``` 2) is a: ``` class PortfolioA : List<Fund> { } ``` which one do you think is better from the point of extensibili...
I vote with the other folks who say HAS-A is better in this case. You ask in a comment: > > when I say that a Portfolio is just a > collection of funds, with a few > attributes of its own like > TotalPortfolio etc, does that > fundamentally not become an "is-a"? > > > I don't think so. If you say `Portfolio` ...
263,359
<p>I'm writing some Javascript to resize the large image to fit into the user's browser window. (I don't control the size of the source images unfortunately.)</p> <p>So something like this would be in the HTML:</p> <pre><code>&lt;img id="photo" src="a_really_big_file.jpg" alt="this is some alt text" t...
[ { "answer_id": 263447, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 6, "selected": true, "text": "<p>Either add an event listener, or have the image announce itself with onload. Then figure out the dime...
2008/11/04
[ "https://Stackoverflow.com/questions/263359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18511/" ]
I'm writing some Javascript to resize the large image to fit into the user's browser window. (I don't control the size of the source images unfortunately.) So something like this would be in the HTML: ``` <img id="photo" src="a_really_big_file.jpg" alt="this is some alt text" title="this is some title ...
Either add an event listener, or have the image announce itself with onload. Then figure out the dimensions from there. ``` <img id="photo" onload='loaded(this.id)' src="a_really_big_file.jpg" alt="this is some alt text" title="this is some title text" /> ```
263,367
<p>When supporting a new web app in an enterprise environment, it is often necessary to log in as a specific user in order to diagnose a real or perceived problem they are having. Two opposing issues apply here:</p> <ol> <li><p>Best practice is to use <strong>hashed or encrypted passwords</strong>, not clear text. Som...
[ { "answer_id": 263388, "author": "Matt Brunell", "author_id": 24970, "author_profile": "https://Stackoverflow.com/users/24970", "pm_score": 1, "selected": false, "text": "<p>An administrator should be able to change a user's password. Change the password for the user to something you kn...
2008/11/04
[ "https://Stackoverflow.com/questions/263367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27637/" ]
When supporting a new web app in an enterprise environment, it is often necessary to log in as a specific user in order to diagnose a real or perceived problem they are having. Two opposing issues apply here: 1. Best practice is to use **hashed or encrypted passwords**, not clear text. Sometimes, there is a third-part...
A number of these ideas inconvenience the user, either by forcing them to change their password, or by occupying their desktop for your debugging session. Markc's idea is the best: augment your authentication logic to allow superusers to log in as a particular user by supplying not the user's credentials, but the user...
263,376
<p>Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan 1, 1970 is November 31, 1969. Well, someone please explain what's wrong with my assumption that the first test should produce a time 10,000,000 milliseconds from Jan 1, 1970. Numbers smaller than 10,000,000 produce the s...
[ { "answer_id": 263432, "author": "Davide", "author_id": 25891, "author_profile": "https://Stackoverflow.com/users/25891", "pm_score": 0, "selected": false, "text": "<p>You can figure out yourself if you change your first <code>c.setTimeInMillis(l);</code> in <code>c.clear();</code></p>\n...
2008/11/04
[ "https://Stackoverflow.com/questions/263376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34410/" ]
Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan 1, 1970 is November 31, 1969. Well, someone please explain what's wrong with my assumption that the first test should produce a time 10,000,000 milliseconds from Jan 1, 1970. Numbers smaller than 10,000,000 produce the same re...
The dates you print from `Calendar` are local to your timezone, whereas the epoch is defined to be midnight of 1970-01-01 in UTC. So if you live in a timezone west of UTC, then your date will show up as 1969-12-31, even though (in UTC) it's still 1970-01-01.
263,380
<p>I am building an ASP.NET web site where the users may upload photos of themselves. There could be thousands of photos uploaded every day. One thing my boss has asked a few time is if there is any way we could detect if any of the photos are showing too much 'skin' and automatically move flag these as 'Adults Only' b...
[ { "answer_id": 263403, "author": "JSBձոգչ", "author_id": 8078, "author_profile": "https://Stackoverflow.com/users/8078", "pm_score": 4, "selected": false, "text": "<p>I doubt that there exists any off-the-shelf software that can determine if the user uploads a naughty picture. Your best ...
2008/11/04
[ "https://Stackoverflow.com/questions/263380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
I am building an ASP.NET web site where the users may upload photos of themselves. There could be thousands of photos uploaded every day. One thing my boss has asked a few time is if there is any way we could detect if any of the photos are showing too much 'skin' and automatically move flag these as 'Adults Only' befo...
Your best bet is to deal with the image in the HSV colour space (see [here](http://www.cs.rit.edu/~ncs/color/t_convert.html) for rgb - hsv conversion). The colour of skin is pretty much the same between all races, its just the saturation that changes. By dealing with the image in HSV you can simply search for the colou...
263,392
<p>Trends data from Twitter Search API in JSON.</p> <p>Grabbing the file using:</p> <pre><code>$jsonurl = "http://search.twitter.com/trends.json"; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); </code></pre> <p>How do I work with data from this object. As an array? Only really ne...
[ { "answer_id": 263426, "author": "Peter Bailey", "author_id": 8815, "author_profile": "https://Stackoverflow.com/users/8815", "pm_score": 8, "selected": true, "text": "<p>You mean something like this?</p>\n\n<pre><code>&lt;?php\n\n$jsonurl = \"http://search.twitter.com/trends.json\";\n$j...
2008/11/04
[ "https://Stackoverflow.com/questions/263392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Trends data from Twitter Search API in JSON. Grabbing the file using: ``` $jsonurl = "http://search.twitter.com/trends.json"; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); ``` How do I work with data from this object. As an array? Only really need to extract data from the [name...
You mean something like this? ``` <?php $jsonurl = "http://search.twitter.com/trends.json"; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json); foreach ( $json_output->trends as $trend ) { echo "{$trend->name}\n"; } ```
263,400
<p>In .NET, the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.object.gethashcode" rel="noreferrer"><code>GetHashCode</code> method</a> is used in a lot of places throughout the .NET base class libraries. Implementing it properly is especially important to find items quickly in a collection or when determ...
[ { "answer_id": 263416, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 12, "selected": true, "text": "<p>I usually go with something like the implementation given in Josh Bloch's <em>fabulous</em> <a href=\"https://rads.st...
2008/11/04
[ "https://Stackoverflow.com/questions/263400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227/" ]
In .NET, the [`GetHashCode` method](https://learn.microsoft.com/en-us/dotnet/api/system.object.gethashcode) is used in a lot of places throughout the .NET base class libraries. Implementing it properly is especially important to find items quickly in a collection or when determining equality. Is there a standard algor...
I usually go with something like the implementation given in Josh Bloch's *fabulous* [Effective Java](https://rads.stackoverflow.com/amzn/click/com/0321356683). It's fast and creates a pretty good hash which is unlikely to cause collisions. Pick two different prime numbers, e.g. 17 and 23, and do: ``` public override ...
263,402
<p>Imagine the following REBOL code:</p> <pre>foo: context [bar: 3]</pre> <p>I now have a context <code>foo</code> in which <code>'bar</code> is defined. How can I dynamically inject a new word into this context? Is it possible?</p> <p>I've tried:</p> <pre>set/any in foo 'baz 3</pre> <p>But that doesn't work becau...
[ { "answer_id": 430848, "author": "Peter W A Wood", "author_id": 53663, "author_profile": "https://Stackoverflow.com/users/53663", "pm_score": 4, "selected": true, "text": "<p>You can achieve the same by using the existing object as a prototype to create a new object. </p>\n\n<pre><code>&...
2008/11/04
[ "https://Stackoverflow.com/questions/263402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27779/" ]
Imagine the following REBOL code: ``` foo: context [bar: 3] ``` I now have a context `foo` in which `'bar` is defined. How can I dynamically inject a new word into this context? Is it possible? I've tried: ``` set/any in foo 'baz 3 ``` But that doesn't work because the expression `in foo 'baz` fails because there ...
You can achieve the same by using the existing object as a prototype to create a new object. ``` >> foo: make object! [bar: 3] >> foo: make foo [baz: 3] >> probe foo make object! [ bar: 3 baz: 3 ] ```
263,404
<p>I have a unique development situation and would like some input from others.</p> <p>I have a situation where I need to load loose xaml files within a rich client application. A given loose xaml file may have references to an assembly not currently loaded in memory so the referenced assembly is loaded before the lo...
[ { "answer_id": 520969, "author": "fubaar", "author_id": 59083, "author_profile": "https://Stackoverflow.com/users/59083", "pm_score": 1, "selected": false, "text": "<p>I'm guessing that you are already doing dynamic assembly resolution and loading? If so, then you could try substituting ...
2008/11/04
[ "https://Stackoverflow.com/questions/263404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34413/" ]
I have a unique development situation and would like some input from others. I have a situation where I need to load loose xaml files within a rich client application. A given loose xaml file may have references to an assembly not currently loaded in memory so the referenced assembly is loaded before the loading the ...
I'm guessing that you are already doing dynamic assembly resolution and loading? If so, then you could try substituting a fake assembly name in place of the real assembly name i n the Xaml - you can then use that in your assembly resolution code to load up and return the right assembly. e.g. if your original source Xam...
263,406
<p>I have a Java server that accepts SSL connections using JSSE and uses a simple XML message format inside the stream. I would like the server to read a complete message and then send a reply. This turns out to be quite difficult because org.xml.sax.XMLReader wants to read the entire stream and then call close(). I...
[ { "answer_id": 520969, "author": "fubaar", "author_id": 59083, "author_profile": "https://Stackoverflow.com/users/59083", "pm_score": 1, "selected": false, "text": "<p>I'm guessing that you are already doing dynamic assembly resolution and loading? If so, then you could try substituting ...
2008/11/04
[ "https://Stackoverflow.com/questions/263406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34416/" ]
I have a Java server that accepts SSL connections using JSSE and uses a simple XML message format inside the stream. I would like the server to read a complete message and then send a reply. This turns out to be quite difficult because org.xml.sax.XMLReader wants to read the entire stream and then call close(). I know ...
I'm guessing that you are already doing dynamic assembly resolution and loading? If so, then you could try substituting a fake assembly name in place of the real assembly name i n the Xaml - you can then use that in your assembly resolution code to load up and return the right assembly. e.g. if your original source Xam...
263,419
<p>I'm planning to add XML support to application, but I'm not familiar with XML programming in Delphi. Basically I need to create objects based on XML nodes and generate XML file based on objects.</p> <p>Which XML component library I should use? Are there any good tutorials for XML with Delphi?</p>
[ { "answer_id": 263492, "author": "Steve", "author_id": 22712, "author_profile": "https://Stackoverflow.com/users/22712", "pm_score": 3, "selected": false, "text": "<p>You could try the following book :\n<a href=\"https://rads.stackoverflow.com/amzn/click/com/1591098629\" rel=\"noreferrer...
2008/11/04
[ "https://Stackoverflow.com/questions/263419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7735/" ]
I'm planning to add XML support to application, but I'm not familiar with XML programming in Delphi. Basically I need to create objects based on XML nodes and generate XML file based on objects. Which XML component library I should use? Are there any good tutorials for XML with Delphi?
You can start by looking at Delphi's TXMLDocument component. This will provide you with the basics of working with XML/DOM. It's simple and can be added by dropping it onto your Form. It has LoadFromFile and SaveToFile methods and is easily navigated. However, at some point you will exhaust TXMLDocument's features, es...
263,457
<p>I'm pretty sure there should be a more Pythonic way of doing this - but I can't think of one: How can I merge a two-dimensional list into a one-dimensional list? Sort of like zip/map but with more than two iterators.</p> <p>Example - I have the following list:</p> <pre><code>array = [[1, 2, 3], [4, 5, 6], [7, 8, 9...
[ { "answer_id": 263465, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 7, "selected": true, "text": "<pre><code>[sum(a) for a in zip(*array)]\n</code></pre>\n" }, { "answer_id": 263523, "author": "Charles ...
2008/11/04
[ "https://Stackoverflow.com/questions/263457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20670/" ]
I'm pretty sure there should be a more Pythonic way of doing this - but I can't think of one: How can I merge a two-dimensional list into a one-dimensional list? Sort of like zip/map but with more than two iterators. Example - I have the following list: ``` array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] ``` I want to ha...
``` [sum(a) for a in zip(*array)] ```
263,469
<p>I have a C# .NET web project that I'm currently working on. What I'm trying to do is read some files that I dropped into a dir which is at the same level as fileReader.cs which is attempting to read them. On a normal desktop app the following would work:</p> <pre><code>DirectoryInfo di = new DirectoryInfo(./myDir...
[ { "answer_id": 263474, "author": "Omer van Kloeten", "author_id": 4979, "author_profile": "https://Stackoverflow.com/users/4979", "pm_score": 2, "selected": false, "text": "<p>Use <a href=\"http://msdn.microsoft.com/library/ms178116.aspx\" rel=\"nofollow noreferrer\"><code>Server.MapPath...
2008/11/04
[ "https://Stackoverflow.com/questions/263469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16684/" ]
I have a C# .NET web project that I'm currently working on. What I'm trying to do is read some files that I dropped into a dir which is at the same level as fileReader.cs which is attempting to read them. On a normal desktop app the following would work: ``` DirectoryInfo di = new DirectoryInfo(./myDir); ``` However...
Use [`Server.MapPath`](http://msdn.microsoft.com/library/ms178116.aspx) to get the local path for the currently executing page.
263,477
<p>I have a gridview like below:</p> <pre><code> &lt;asp:GridView DataKeyNames="TransactionID" AllowSorting="True" AllowPaging="True"ID="grvBrokerage" runat="server" AutoGenerateColumns="False" CssClass="datatable" Width="100%" &lt;Columns&gt; ...
[ { "answer_id": 263797, "author": "Eddie Deyo", "author_id": 9323, "author_profile": "https://Stackoverflow.com/users/9323", "pm_score": 4, "selected": true, "text": "<p>When you are using an ObjectDataSource (or any other *DataSource), you set the DataSourceID for your GridView, not the ...
2008/11/04
[ "https://Stackoverflow.com/questions/263477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
I have a gridview like below: ``` <asp:GridView DataKeyNames="TransactionID" AllowSorting="True" AllowPaging="True"ID="grvBrokerage" runat="server" AutoGenerateColumns="False" CssClass="datatable" Width="100%" <Columns> <asp:BoundField Da...
When you are using an ObjectDataSource (or any other \*DataSource), you set the DataSourceID for your GridView, not the DataSource. The DataSourceID should be whatever the ID of your ObjectDataSource is. If you provide the declaration of your ObjectDataSource, I might be able to help more. As to why your DataSource is...
263,478
<p>Given a result set, how can I determin the actual names of the fields specified in the query (NOT their aliases).</p> <pre><code>$query = "SELECT first AS First_Name, last AS Last_Name FROM people"; $dbResult = mysql_query($query); $fieldCount = mysql_num_fields($dbResult); for ($i=0; $i&lt;$fieldCount; $i++) { ...
[ { "answer_id": 263489, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 4, "selected": false, "text": "<p>If you are using MySQLi:</p>\n\n<p><a href=\"http://www.php.net/manual/en/mysqli-result.fetch-field.php\" rel=\"nor...
2008/11/04
[ "https://Stackoverflow.com/questions/263478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34418/" ]
Given a result set, how can I determin the actual names of the fields specified in the query (NOT their aliases). ``` $query = "SELECT first AS First_Name, last AS Last_Name FROM people"; $dbResult = mysql_query($query); $fieldCount = mysql_num_fields($dbResult); for ($i=0; $i<$fieldCount; $i++) { // Se...
If you are using MySQLi: <http://www.php.net/manual/en/mysqli-result.fetch-field.php> The field object has a "orgname" property. The "classic" MySQL equivalent function doesn't report back the original column names.
263,486
<p>In a forms model, I used to get the current logged-in user by:</p> <pre><code>Page.CurrentUser </code></pre> <p>How do I get the current user inside a controller class in ASP.NET MVC?</p>
[ { "answer_id": 263502, "author": "Sean", "author_id": 29941, "author_profile": "https://Stackoverflow.com/users/29941", "pm_score": 4, "selected": false, "text": "<p>I use:</p>\n\n<pre><code>Membership.GetUser().UserName\n</code></pre>\n\n<p>I am not sure this will work in ASP.NET MVC, b...
2008/11/04
[ "https://Stackoverflow.com/questions/263486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
In a forms model, I used to get the current logged-in user by: ``` Page.CurrentUser ``` How do I get the current user inside a controller class in ASP.NET MVC?
If you need to get the user from within the controller, use the `User` property of Controller. If you need it from the view, I would populate what you specifically need in the `ViewData`, or you could just call User as I think it's a property of `ViewPage`.
263,503
<p>I am using the following code to determine free space on a volume. The folder was provided using NSOpenPanel. The item selected was a mounted volume and the path returned is \Volumes\Name</p> <pre><code>NSDictionary* fileAttributes = [[NSFileManager defaultManager] fileSystemAttributesAtPath:folder]; unsigned lon...
[ { "answer_id": 264486, "author": "diciu", "author_id": 2811, "author_profile": "https://Stackoverflow.com/users/2811", "pm_score": 1, "selected": false, "text": "<p>statfs is consistent with results from df. In theory NSFileSystemFreeSize comes from statfs, so your problem should not exi...
2008/11/04
[ "https://Stackoverflow.com/questions/263503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8761/" ]
I am using the following code to determine free space on a volume. The folder was provided using NSOpenPanel. The item selected was a mounted volume and the path returned is \Volumes\Name ``` NSDictionary* fileAttributes = [[NSFileManager defaultManager] fileSystemAttributesAtPath:folder]; unsigned long long size = [...
The code provided IS the best way in Cocoa to determine the free space on a volume. Just make sure that the path provided to [NSFileManagerObj fileSystemAttributesAtPath] includes the full path of the volume. I was deleting the last path component to assure that a folder rather than a file was passed in which resulted ...
263,507
<p>I'm trying to get the zoom controls to show up in a <code>mapview</code>, the following code almost works, but the zoom controls appear in the top left of the <code>mapview</code>, not the bottom center like I'm specifying via <code>setGravity()</code>. Can someone enlighten me as to what I'm missing?</p> <pre><co...
[ { "answer_id": 275145, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Reto - the problem with using FILL_PARENT is that the zoom control then \"steals\" all of the touch events; so that you can...
2008/11/04
[ "https://Stackoverflow.com/questions/263507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24590/" ]
I'm trying to get the zoom controls to show up in a `mapview`, the following code almost works, but the zoom controls appear in the top left of the `mapview`, not the bottom center like I'm specifying via `setGravity()`. Can someone enlighten me as to what I'm missing? ``` zoomView = (LinearLayout) mapView.getZoomCont...
Add the following line to the `OnCreate()` method of your `MapView` Class: `view.setBuiltInZoomControls(true);`
263,518
<p>Currently I have an application that receives an uploaded file from my web application. I now need to transfer that file to a file server which happens to be located on the same network (however this might not always be the case).</p> <p>I was attempting to use the webclient class in C# .NET.</p> <pre><code> st...
[ { "answer_id": 263525, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 5, "selected": true, "text": "<p>Just use </p>\n\n<pre><code>File.Copy(filepath, \"\\\\\\\\192.168.1.28\\\\Files\");\n</code></pre>\n\n<p>A windo...
2008/11/04
[ "https://Stackoverflow.com/questions/263518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21664/" ]
Currently I have an application that receives an uploaded file from my web application. I now need to transfer that file to a file server which happens to be located on the same network (however this might not always be the case). I was attempting to use the webclient class in C# .NET. ``` string filePath = "C:\\...
Just use ``` File.Copy(filepath, "\\\\192.168.1.28\\Files"); ``` A windows fileshare exposed via a UNC path is treated as part of the file system, and has nothing to do with the web. The credentials used will be that of the ASP.NET worker process, or any impersonation you've enabled. If you can tweak those to get ...
263,550
<p>I'm sorry I could not think of a better title.</p> <p>The problem is the following:</p> <p>For our customer we have created (as part of a larger application) a graphical designer which they can use to build "scenario's".</p> <p>These scenario's consist of "Composites" which in turn consist of "Commands". These co...
[ { "answer_id": 263583, "author": "Andrew Bullock", "author_id": 28543, "author_profile": "https://Stackoverflow.com/users/28543", "pm_score": 2, "selected": false, "text": "<p>From what i think i've understood you have two options</p>\n\n<p>you could either use an XML style \"markup\" to...
2008/11/04
[ "https://Stackoverflow.com/questions/263550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
I'm sorry I could not think of a better title. The problem is the following: For our customer we have created (as part of a larger application) a graphical designer which they can use to build "scenario's". These scenario's consist of "Composites" which in turn consist of "Commands". These command objects all derive...
If you really just want a dirt simple language, you want a 'recursive descent parser'. For example, a language like this: ``` SCENARIO MyScenario DELAY 1 COUNT 1 ADD 1 DIRECT_POWER 23, False, 150 WAIT 3 ... END_SCENARIO ``` You might have a grammar like: ``` scenario :: 'SCENARIO' label newline _cmds END_SCENARIO ...
263,551
<p>Does anyone know how to databind the .Source property of the WebBrowser in WPF ( 3.5SP1 )? I have a listview that I want to have a small WebBrowser on the left, and content on the right, and to databind the source of each WebBrowser with the URI in each object bound to the list item.</p> <p>This is what I have as a...
[ { "answer_id": 265648, "author": "Todd White", "author_id": 30833, "author_profile": "https://Stackoverflow.com/users/30833", "pm_score": 8, "selected": true, "text": "<p>The problem is that <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.webbrowser.source?...
2008/11/04
[ "https://Stackoverflow.com/questions/263551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32772/" ]
Does anyone know how to databind the .Source property of the WebBrowser in WPF ( 3.5SP1 )? I have a listview that I want to have a small WebBrowser on the left, and content on the right, and to databind the source of each WebBrowser with the URI in each object bound to the list item. This is what I have as a proof of ...
The problem is that [`WebBrowser.Source`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.webbrowser.source?view=netframework-4.8) is not a `DependencyProperty`. One workaround would be to use some `AttachedProperty` magic to enable this ability. ``` public static class WebBrowserUtility { pub...
263,578
<p>I am using the ReportViewer control from Visual Studio 2008 in Local Mode with objects as the data source. My classes are mapped to data tables in my database. In the objects, it loads related objects as needed. So it leaves the reference null until you try to use the property, then it tries to load it from the data...
[ { "answer_id": 265207, "author": "James Osborn", "author_id": 6686, "author_profile": "https://Stackoverflow.com/users/6686", "pm_score": 0, "selected": false, "text": "<p>One quick thought, although this isn't an error I've seen, make sure that your Assert is in the same method as the c...
2008/11/04
[ "https://Stackoverflow.com/questions/263578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34440/" ]
I am using the ReportViewer control from Visual Studio 2008 in Local Mode with objects as the data source. My classes are mapped to data tables in my database. In the objects, it loads related objects as needed. So it leaves the reference null until you try to use the property, then it tries to load it from the databas...
I've found the solution. You specify System.Security.Policy.Evidence of you executing assembly (or one that has sufficient rights) to the LocalReport for use during execution. ``` reportViewer.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence); ```
263,582
<p>In the following table structure:</p> <pre><code>Fruits ( fruit_id, fruitName ) Vegetables ( vegetable_id, vegetableName ) favoriteFoods ( food_id, foodName, type_id (References either a fruit or a vegetable) ) </code></pre> <p>I realize that I could forgo using a foreign key co...
[ { "answer_id": 263593, "author": "wonderchook", "author_id": 32113, "author_profile": "https://Stackoverflow.com/users/32113", "pm_score": 3, "selected": true, "text": "<p>I would only use 2 tables instead. Instead of having a separate Fruits and Vegetables table, why not have a table o...
2008/11/04
[ "https://Stackoverflow.com/questions/263582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20178/" ]
In the following table structure: ``` Fruits ( fruit_id, fruitName ) Vegetables ( vegetable_id, vegetableName ) favoriteFoods ( food_id, foodName, type_id (References either a fruit or a vegetable) ) ``` I realize that I could forgo using a foreign key constraint on the favoriteFoo...
I would only use 2 tables instead. Instead of having a separate Fruits and Vegetables table, why not have a table of Foods. Then have a foreign key constraint on fkfood\_id to food\_id. Then if for some reason you ever have to add meat, it would be much easier to maintain the application that uses this. ``` Food (...
263,585
<p>I have over the course of a few projects developed a pattern for creating immutable (readonly) objects and immutable object graphs. Immutable objects carry the benefit of being 100% thread safe and can therefore be reused across threads. In my work I very often use this pattern in Web applications for configuration ...
[ { "answer_id": 263604, "author": "Cory Foy", "author_id": 4083, "author_profile": "https://Stackoverflow.com/users/4083", "pm_score": 3, "selected": false, "text": "<p>You are still dealing with state, and thus can still be bitten if your objects are parallelized before being made immuta...
2008/11/04
[ "https://Stackoverflow.com/questions/263585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27393/" ]
I have over the course of a few projects developed a pattern for creating immutable (readonly) objects and immutable object graphs. Immutable objects carry the benefit of being 100% thread safe and can therefore be reused across threads. In my work I very often use this pattern in Web applications for configuration set...
For info, the second approach is called "popsicle immutability". Eric Lippert has a series of blog entries on immutability starting [here](https://learn.microsoft.com/en-us/archive/blogs/ericlippert/immutability-in-c-part-one-kinds-of-immutability). I'm still getting to grips with the CTP (C# 4.0), but it looks intere...
263,586
<p>I'm writing an implementation of a virtual machine in C#, and I need to implement the VM's stack, which can contain two types of entry - return entries or backtrack entries. What is the best way of implementing this?</p> <p>I'm currently using a base type, as follows:</p> <pre><code>class StackEntry { } class Retu...
[ { "answer_id": 263601, "author": "Andrew Bullock", "author_id": 28543, "author_profile": "https://Stackoverflow.com/users/28543", "pm_score": 2, "selected": false, "text": "<p>Why should you need to down cast? If your base class exposes abstract or virtual members, or is instead an inter...
2008/11/04
[ "https://Stackoverflow.com/questions/263586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34438/" ]
I'm writing an implementation of a virtual machine in C#, and I need to implement the VM's stack, which can contain two types of entry - return entries or backtrack entries. What is the best way of implementing this? I'm currently using a base type, as follows: ``` class StackEntry { } class Return : StackEntry { uin...
I'm having a hard time imagining how you're going to use this, but the basic answer is that you use a single type with a default operation for post-pop processing ``` StackEntry { protected virtual void PostPop(); } Return : StackEntry { protected override void PostPop(); } Backtrack : StackEntry { protected override ...
263,599
<p>I'm wondering how slow it's going to be switching between 2 databases on every call of every page of a site. The site has many different databases for different clients, along with a "global" database that is used for some general settings. I'm wondering if there would be much time added for the execution of each sc...
[ { "answer_id": 263634, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 4, "selected": true, "text": "<p>Assuming that both databases are on the same machine, you don't need to do the mysql_select_db. You can just specify ...
2008/11/04
[ "https://Stackoverflow.com/questions/263599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
I'm wondering how slow it's going to be switching between 2 databases on every call of every page of a site. The site has many different databases for different clients, along with a "global" database that is used for some general settings. I'm wondering if there would be much time added for the execution of each scrip...
Assuming that both databases are on the same machine, you don't need to do the mysql\_select\_db. You can just specify the database in the queries. For example; ``` SELECT * FROM db1.table1; ``` You could also open two connections and use the DB object that is returned from the connect call and use those two objects...
263,612
<p>Earlier today I was hunting down a very weird bug... I finally traced it down to what seems to be causing the problem.</p> <p>The original report can be found here: <a href="https://stackoverflow.com/questions/262017/weird-behaviour-when-running-clickonce-deployed-version-of-wpf-application">original question</a></...
[ { "answer_id": 266815, "author": "DamienG", "author_id": 5720, "author_profile": "https://Stackoverflow.com/users/5720", "pm_score": 2, "selected": false, "text": "<p>Having a property open a database connection and run a query is not a good pattern. </p>\n\n<p>A better approach would b...
2008/11/04
[ "https://Stackoverflow.com/questions/263612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
Earlier today I was hunting down a very weird bug... I finally traced it down to what seems to be causing the problem. The original report can be found here: [original question](https://stackoverflow.com/questions/262017/weird-behaviour-when-running-clickonce-deployed-version-of-wpf-application) The details have chan...
Having a property open a database connection and run a query is not a good pattern. A better approach would be to query a set of objects from LINQ to SQL and bind those to the WPF control instead.
263,623
<p>Is there any Ruby equivalent for Python's builtin <code>zip</code> function? If not, what is a concise way of doing the same thing?</p> <p>A bit of context: this came up when I was trying to find a clean way of doing a check involving two arrays. If I had <code>zip</code>, I could have written something like:</p> ...
[ { "answer_id": 263652, "author": "dgtized", "author_id": 34450, "author_profile": "https://Stackoverflow.com/users/34450", "pm_score": 6, "selected": true, "text": "<p>Ruby has a zip function:</p>\n\n<pre><code>[1,2].zip([3,4]) =&gt; [[1,3],[2,4]]\n</code></pre>\n\n<p>so your code exampl...
2008/11/04
[ "https://Stackoverflow.com/questions/263623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34443/" ]
Is there any Ruby equivalent for Python's builtin `zip` function? If not, what is a concise way of doing the same thing? A bit of context: this came up when I was trying to find a clean way of doing a check involving two arrays. If I had `zip`, I could have written something like: ``` zip(a, b).all? {|pair| pair[0] =...
Ruby has a zip function: ``` [1,2].zip([3,4]) => [[1,3],[2,4]] ``` so your code example is actually: ``` a.zip(b).all? {|pair| pair[0] === pair[1]} ``` or perhaps more succinctly: ``` a.zip(b).all? {|a,b| a === b } ```
263,697
<p>I have a multidimensional array. I need to search it for a specific range of values, edit those values and return the edited data.</p> <p>Example array:</p> <pre><code>array(3) { ["first"]=&gt; array(1) { [0]=&gt; string(4) "baz1" } ["second"]=&gt; array(1) { [0]=&gt; string(4) "foo1" }...
[ { "answer_id": 263713, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 3, "selected": false, "text": "<p>How about something like this:</p>\n\n<pre><code>function addDashBar($arr)\n{\n foreach ($arr as $key =&gt; $val...
2008/11/04
[ "https://Stackoverflow.com/questions/263697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11252/" ]
I have a multidimensional array. I need to search it for a specific range of values, edit those values and return the edited data. Example array: ``` array(3) { ["first"]=> array(1) { [0]=> string(4) "baz1" } ["second"]=> array(1) { [0]=> string(4) "foo1" } ["third"]=> array(1) { [...
If your array will not be extremely deep, this can work. ($array being what you want to replace later with yours) ``` $array= array('first' => array('bazi1'), 'second' => array('foo1'), 'third' => array('foo2') ); function modify_foo(&$item, $key) { $item = str_replace('foo', 'foo-bar', $item); } array_walk_recursi...
263,730
<p>In eclipse, I have a javaproject (not a web project), though it does provide reusable tag files.</p> <p>layout</p> <p>+src<br> +++META-INF<br> ----my.tld<br> +++++++++++tags<br> ---------------include.jsp<br></p> <p>I keep on getting Fragment "/META-INF/tags/include.jsp" was not be found at expected path /Project...
[ { "answer_id": 263930, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Josh, if you're working with .jsp and .tld files, then you really shouldn't be doing this as a \"Java Project\", but instea...
2008/11/04
[ "https://Stackoverflow.com/questions/263730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20641/" ]
In eclipse, I have a javaproject (not a web project), though it does provide reusable tag files. layout +src +++META-INF ----my.tld +++++++++++tags ---------------include.jsp I keep on getting Fragment "/META-INF/tags/include.jsp" was not be found at expected path /Project/META-INF/tags/taginclude.jsp ...
Josh, if you're working with .jsp and .tld files, then you really shouldn't be doing this as a "Java Project", but instead a "Dynamic Web Project" in Eclipse. Nonetheless, I'll try to answer your question. Based on the diagram of your file system, your files are laid out incorrectly. If you're trying to create a web a...
263,735
<p>Problem: How can I tell if a selection of text in the CRichEditCtrl has multiple font sizes in it?</p> <hr> <p>Goal: I am sort of making my own RichEdit toolbar (bold, italic, font type, font size, etc). I want to emulate what MS Word does when a selection of text has more than a single font size spanning the sel...
[ { "answer_id": 265414, "author": "DavidK", "author_id": 31394, "author_profile": "https://Stackoverflow.com/users/31394", "pm_score": 2, "selected": true, "text": "<p>As the above answer notes, the easiest way I can think of to do this is to use the Text Object Model (TOM), which is acce...
2008/11/04
[ "https://Stackoverflow.com/questions/263735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34460/" ]
Problem: How can I tell if a selection of text in the CRichEditCtrl has multiple font sizes in it? --- Goal: I am sort of making my own RichEdit toolbar (bold, italic, font type, font size, etc). I want to emulate what MS Word does when a selection of text has more than a single font size spanning the selection. Ex ...
As the above answer notes, the easiest way I can think of to do this is to use the Text Object Model (TOM), which is accessed through the ITextDocument COM interface. To get at this from your rich edit control (note code not tested, but should work): ``` CComPtr<IRichEditOle> richOle; richOle.Attach(edit.GetIRichEditO...
263,741
<p>I built a <strong>[widget][1]</strong> that grabs the URL from the frontmost window in Safari, then allows you to shorten it using the tr.im API. Works sweet as.</p> <p>I want to make this more flexible, so am investigating how to grab an URL from other browsers. Here's the AppleScript that works in Safari:</p> <p...
[ { "answer_id": 268195, "author": "Andrew Hedges", "author_id": 11577, "author_profile": "https://Stackoverflow.com/users/11577", "pm_score": 0, "selected": false, "text": "<p>Opera (tested on versions 9.21 and 9.62):</p>\n\n<pre><code>tell application \"Opera\"\n return URL of front d...
2008/11/04
[ "https://Stackoverflow.com/questions/263741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11577/" ]
I built a **[widget][1]** that grabs the URL from the frontmost window in Safari, then allows you to shorten it using the tr.im API. Works sweet as. I want to make this more flexible, so am investigating how to grab an URL from other browsers. Here's the AppleScript that works in Safari: ``` tell application "Safari"...
Firefox (tested on versions 2.0.0.14 and 3.0.1): ``` tell application "Firefox" set myURL to «class curl» of window 1 return myURL end tell ```
263,743
<p>How do you get the caret position in a <code>&lt;textarea&gt;</code> using JavaScript?</p> <p>For example: <code>This is| a text</code></p> <p>This should return <code>7</code>.</p> <p>How would you get it to return the strings surrounding the cursor / selection?</p> <p>E.g.: <code>'This is', '', ' a text'</code...
[ { "answer_id": 263796, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 8, "selected": true, "text": "<p>With Firefox, Safari (and other Gecko based browsers) you can easily use textarea.selectionStart, but for IE ...
2008/11/04
[ "https://Stackoverflow.com/questions/263743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32941/" ]
How do you get the caret position in a `<textarea>` using JavaScript? For example: `This is| a text` This should return `7`. How would you get it to return the strings surrounding the cursor / selection? E.g.: `'This is', '', ' a text'`. If the word “is” is highlighted, then it would return `'This ', 'is', ' a tex...
With Firefox, Safari (and other Gecko based browsers) you can easily use textarea.selectionStart, but for IE that doesn't work, so you will have to do something like this: ``` function getCaret(node) { if (node.selectionStart) { return node.selectionStart; } else if (!document.selection) { return 0; } ...
263,748
<p>I normally store all my configs in the registry. Even though I have started using LINQ I would not like to have the DSN in the web.config, but rather let it stay in the registry and attach it (maybe in the Application Start Event) to the System Config.</p> <p>How can this be done?</p> <p>Thanx for any ideas!</p> ...
[ { "answer_id": 264255, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "<p>Why not just keep it encrypted in the web.config? It's fairly easy to encrypt just the connection strings in the we...
2008/11/04
[ "https://Stackoverflow.com/questions/263748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34464/" ]
I normally store all my configs in the registry. Even though I have started using LINQ I would not like to have the DSN in the web.config, but rather let it stay in the registry and attach it (maybe in the Application Start Event) to the System Config. How can this be done? Thanx for any ideas! edit: to make it clea...
Here's what I do. I have a a base class for my DataContext. It's called DataContextBase and is generated by sqlmetal.exe. I have a derived class called DataContext which is what is used in my Linq calls. It looks like this: ``` public class DataContext : DataContextBase { public DataContext() : base(Connec...
263,782
<p>Currently I have subversion set up so that when I make changes in Eclipse PDT, I can commit the changes and they will be saved in /home/administrator/<em>Project File</em>. This file has the /branches /tags and /trunk directories recommended by subversion. I have no problem properly uploading files to the reposito...
[ { "answer_id": 263791, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 4, "selected": true, "text": "<p>You can do an <code>svn export</code> into your www directory. That will give you a \"clean\" version of your repo, without ...
2008/11/04
[ "https://Stackoverflow.com/questions/263782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27673/" ]
Currently I have subversion set up so that when I make changes in Eclipse PDT, I can commit the changes and they will be saved in /home/administrator/*Project File*. This file has the /branches /tags and /trunk directories recommended by subversion. I have no problem properly uploading files to the repository, but do I...
You can do an `svn export` into your www directory. That will give you a "clean" version of your repo, without the .svn directories. ``` cd /var/www svn export /home/administrator/MyProject/trunk MyProject ``` --- Edit: adding in some good ideas from the comments... Some options for when you want to update your ex...
263,801
<p>I have 15 stored procedures that return data from a common table and then join that table with a specific table to retrieve inventory.</p> <p>Example:</p> <pre><code>Common: tblCommon Specific: tblSpecific </code></pre> <p>Is there way I can pass the name "tblSpecific" into a single stored procedure as a variable...
[ { "answer_id": 263822, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 2, "selected": false, "text": "<p>Yep, you can generate an SQL statement dynamically and then execute it.</p>\n\n<p>For example,</p>\n\n<pre><code>...
2008/11/04
[ "https://Stackoverflow.com/questions/263801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have 15 stored procedures that return data from a common table and then join that table with a specific table to retrieve inventory. Example: ``` Common: tblCommon Specific: tblSpecific ``` Is there way I can pass the name "tblSpecific" into a single stored procedure as a variable, like the following? ``` SELECT...
The way you do this is with dynamically generated SQL which is run through the sp\_executesql() stored procedure. In general you pass in your required table name to your master procedure, build an ncharvar string of the SQL you want to execute, and pass that to sp\_executesql. [The curse and blessing of Dynamic SQL]...
263,815
<p>I have a model being populated by my data layer and then I have a partial view which is rendering an instance of that model.</p> <pre><code>&lt;li class="&lt;%= td.Active ? "youarehere" : string.Empty %&gt; &lt;%= i == ViewData.Model.Count() - 1 ? "last" : string.Empty %&gt;"&gt; </code></pre> <p>The problem is th...
[ { "answer_id": 263852, "author": "Haacked", "author_id": 598, "author_profile": "https://Stackoverflow.com/users/598", "pm_score": 3, "selected": true, "text": "<p>I'd probably implement the code to render that class attribute in a helper method. Either one specific to this view, or one ...
2008/11/04
[ "https://Stackoverflow.com/questions/263815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
I have a model being populated by my data layer and then I have a partial view which is rendering an instance of that model. ``` <li class="<%= td.Active ? "youarehere" : string.Empty %> <%= i == ViewData.Model.Count() - 1 ? "last" : string.Empty %>"> ``` The problem is that `class=""` is invalid XHTML and I will ne...
I'd probably implement the code to render that class attribute in a helper method. Either one specific to this view, or one slightly more generic. That way you have less code in your view and it could handle whether or not to even render the class attribute in the case there's nothing to render.
263,816
<p>Alright. I have a query that looks like this:</p> <pre><code>SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name` FROM `orders`, `menu_items`, `order_items` WHERE `orders`.`id` = `order_items`.`order_id` AND `menu_items`.`id` = `order_items`.`menu_item_id` AND `o...
[ { "answer_id": 263917, "author": "Jamie Love", "author_id": 27308, "author_profile": "https://Stackoverflow.com/users/27308", "pm_score": 2, "selected": false, "text": "<p>Randy's answer is close, but the where statement removes any mention of those items not part of any orders in that d...
2008/11/04
[ "https://Stackoverflow.com/questions/263816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16417/" ]
Alright. I have a query that looks like this: ``` SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name` FROM `orders`, `menu_items`, `order_items` WHERE `orders`.`id` = `order_items`.`order_id` AND `menu_items`.`id` = `order_items`.`menu_item_id` AND `orders`.`date` ...
This can be done without any subqueries, if one puts the date conditions in the `JOIN` clause. Below is code I tested on MySQL 5.0. ``` SELECT m.name, COALESCE(SUM(oi.quantity), 0) AS count FROM menu_items AS m LEFT OUTER JOIN ( order_items AS oi JOIN orders AS o ON (o.id = oi.order_id) ) ON (m.id = oi...
263,820
<p>The first batch file launches a command prompt, i need the second command to be in the ccontext of the first. how can I do this in python?</p> <p>As is, it launches the batch, and blocks until the batch (with its command prompt context) terminates, and then executes <code>devenv</code> without the necessary contex...
[ { "answer_id": 263856, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>You could append the devenv command onto the end of the original batch file like so:</p>\n\n<pre><code>'%comspec% /k \"...v...
2008/11/04
[ "https://Stackoverflow.com/questions/263820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20003/" ]
The first batch file launches a command prompt, i need the second command to be in the ccontext of the first. how can I do this in python? As is, it launches the batch, and blocks until the batch (with its command prompt context) terminates, and then executes `devenv` without the necessary context. ``` os.system(r'%c...
I these situations I use script that does it all. That way you can chain as much as you want. Sometimes I will generate the script on the fly. ``` compileit.cmd call C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat devenv $1.sln /rebuild Debug /Out last-build.txt ```
263,834
<p>I just lost 50% of my answer on a test because I wrote the code out instead of an algorithm on my midterm, bumping me from an A to a C. Is writing code out still considered an algorithmic representation?</p> <p><a href="http://en.wikipedia.org/wiki/Algorithm#Expressing_algorithms" rel="nofollow noreferrer">Wikipedi...
[ { "answer_id": 263842, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>All I know is you shouldn't write any code until after you have an algorithim.</p>\n" }, { "answer_id": 263854, ...
2008/11/04
[ "https://Stackoverflow.com/questions/263834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10636/" ]
I just lost 50% of my answer on a test because I wrote the code out instead of an algorithm on my midterm, bumping me from an A to a C. Is writing code out still considered an algorithmic representation? [Wikipedia: Algorithm Representation](http://en.wikipedia.org/wiki/Algorithm#Expressing_algorithms) (since programm...
You may want to give an example. If your code focuses too much on language specifics that are not part of the algorithm, then Understandably, it could be said you had non-algorithm mixed with your algorithm, resulting in an incorrect result. I Feel for the reasoning, the whole point of learning is to show you underst...
263,836
<p>We are using an Oracle 11 database and a java development environment (using Eclipse) and would like to migrate several xml schemas to SQL schemas.</p> <p>Have looked ax xsd but really need something that we can run from ant/ Eclipse without SQL Server installed.</p> <p>Regards,</p> <p>Andy</p>
[ { "answer_id": 263842, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>All I know is you shouldn't write any code until after you have an algorithim.</p>\n" }, { "answer_id": 263854, ...
2008/11/04
[ "https://Stackoverflow.com/questions/263836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34469/" ]
We are using an Oracle 11 database and a java development environment (using Eclipse) and would like to migrate several xml schemas to SQL schemas. Have looked ax xsd but really need something that we can run from ant/ Eclipse without SQL Server installed. Regards, Andy
You may want to give an example. If your code focuses too much on language specifics that are not part of the algorithm, then Understandably, it could be said you had non-algorithm mixed with your algorithm, resulting in an incorrect result. I Feel for the reasoning, the whole point of learning is to show you underst...
263,838
<p>I usually type my map declarations but was doing some maint and found one without typing. This got me thinking (Oh No!). What is the default typing of a Map declaration. Consider the following:</p> <pre><code>Map map = new HashMap(); map.put("one", "1st"); map.put("two", new Integer(2)); map.put("three", "3rd");...
[ { "answer_id": 263861, "author": "davetron5000", "author_id": 3029, "author_profile": "https://Stackoverflow.com/users/3029", "pm_score": 3, "selected": false, "text": "<p>There is no default type.</p>\n\n<p>The types in Java generics are only for compile-time checking. They are erased ...
2008/11/04
[ "https://Stackoverflow.com/questions/263838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34475/" ]
I usually type my map declarations but was doing some maint and found one without typing. This got me thinking (Oh No!). What is the default typing of a Map declaration. Consider the following: ``` Map map = new HashMap(); map.put("one", "1st"); map.put("two", new Integer(2)); map.put("three", "3rd"); for (Map.Entry e...
The type is *java.lang.Object*. The *for* construct takes a type of *Iterable* and calls its *iterator* method. Since the *Set* isn't typed with generics, the iterator returns objects of type *Object*. These need to be explicitly cast to type *Map.Entry*. ``` Map map = new HashMap(); map.put("one", "1st"); map.put("t...
263,850
<p>Is there a way to create a Distinct query in HQL. Either by using the "distinct" keyword or some other method. I am not sure if distinct is a valid keywork for HQL, but I am looking for the HQL equivalent of the SQL keyword "distinct".</p>
[ { "answer_id": 263870, "author": "Feet", "author_id": 18340, "author_profile": "https://Stackoverflow.com/users/18340", "pm_score": 8, "selected": true, "text": "<p>Here's a snippet of hql that we use. (Names have been changed to protect identities)</p>\n\n<pre><code>String queryString =...
2008/11/04
[ "https://Stackoverflow.com/questions/263850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16404/" ]
Is there a way to create a Distinct query in HQL. Either by using the "distinct" keyword or some other method. I am not sure if distinct is a valid keywork for HQL, but I am looking for the HQL equivalent of the SQL keyword "distinct".
Here's a snippet of hql that we use. (Names have been changed to protect identities) ``` String queryString = "select distinct f from Foo f inner join foo.bars as b" + " where f.creationDate >= ? and f.creationDate < ? and b.bar = ?"; return getHibernateTemplate().find(queryString, new Object[]...
263,890
<p>As a simple example, I want to write a CLI script which can print <code>=</code> across the entire width of the terminal window.</p> <pre><code>#!/usr/bin/env php &lt;?php echo str_repeat('=', ???); </code></pre> <p>or</p> <pre><code>#!/usr/bin/env python print '=' * ??? </code></pre> <p>or</p> <pre><code>#!/us...
[ { "answer_id": 263900, "author": "TonyUser", "author_id": 22873, "author_profile": "https://Stackoverflow.com/users/22873", "pm_score": 10, "selected": true, "text": "<ul>\n<li><code>tput cols</code> tells you the number of columns.</li>\n<li><code>tput lines</code> tells you the number ...
2008/11/04
[ "https://Stackoverflow.com/questions/263890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28835/" ]
As a simple example, I want to write a CLI script which can print `=` across the entire width of the terminal window. ``` #!/usr/bin/env php <?php echo str_repeat('=', ???); ``` or ``` #!/usr/bin/env python print '=' * ??? ``` or ``` #!/usr/bin/env bash x=0 while [ $x -lt ??? ]; do echo -n '='; let x=$x+1 done; ...
* `tput cols` tells you the number of columns. * `tput lines` tells you the number of rows.
263,892
<p>I'm using Gnome terminal and I want to change the background color or the profile through a command so I can group some commands in an alias to visually differentiate my windows when I run certain processes. I'm running Ubuntu, and bash is my shell. Are there commands in to do this?</p>
[ { "answer_id": 263928, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 0, "selected": false, "text": "<p>I used to do this with command line arguments to xterm. I set up my .olvwm (am I dating myself) to execute 4 xterms...
2008/11/04
[ "https://Stackoverflow.com/questions/263892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using Gnome terminal and I want to change the background color or the profile through a command so I can group some commands in an alias to visually differentiate my windows when I run certain processes. I'm running Ubuntu, and bash is my shell. Are there commands in to do this?
you can use setterm like this ``` setterm -term linux -back blue -fore white -clear ```
263,899
<p>I have been searching for a way to allow one element of my FileHelpers mapping class to be an array of specific length.</p> <p>For instance, I have a class like this:</p> <pre><code>[DelimitedRecord(",")] public class Example { public string code; public int month; public int day; public double h1;...
[ { "answer_id": 264500, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>I don't know anything about the tool in question, but (assuming it isn't a limitation of the tool) I <em>really</e...
2008/11/04
[ "https://Stackoverflow.com/questions/263899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23597/" ]
I have been searching for a way to allow one element of my FileHelpers mapping class to be an array of specific length. For instance, I have a class like this: ``` [DelimitedRecord(",")] public class Example { public string code; public int month; public int day; public double h1; public double h2...
FileHelpers record classes require public fields. The record class should not be considered as a normal C# class that should follow best coding practices; rather it is just a syntax for describing an import file's structure. The recommended procedure with FileHelpers would be to loop through the resulting `Example[]`...
263,901
<p>I have a local MINICPAN repository, but I want to remove a specific version of a module, and inject an older version.</p> <p>This is the steps I've taken.</p> <pre><code>- create the MINICPAN, not filtering any modules - use mcpani --add for the module in question - use mcpani --inject </code></pre> <p>At this po...
[ { "answer_id": 264173, "author": "ysth", "author_id": 17389, "author_profile": "https://Stackoverflow.com/users/17389", "pm_score": 2, "selected": false, "text": "<p>Doesn't filtering out the module initially work?</p>\n" }, { "answer_id": 264393, "author": "brian d foy", ...
2008/11/04
[ "https://Stackoverflow.com/questions/263901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3839/" ]
I have a local MINICPAN repository, but I want to remove a specific version of a module, and inject an older version. This is the steps I've taken. ``` - create the MINICPAN, not filtering any modules - use mcpani --add for the module in question - use mcpani --inject ``` At this point, I can see in the MINICPAN th...
Filter the modules that you are going to inject. The [CPAN::Mini](http://search.cpan.org/dist/CPAN-Mini) has the documentation for filtering, and I think I had some examples in the resources I pointed you toward earlier. :) If you already have the minicpan, as you said in the comment to ysth, you can create *another* ...
263,906
<pre><code>AlertEvent::AlertEvent(const std::string&amp; text) : IMEvent(kIMEventAlert, alertText.c_str()), alertText(text) { //inspection at time of crash shows alertText is a valid string } IMEvent::IMEvent(long eventID, const char* details) { //during construction, details==0xcccccccc } </code></pr...
[ { "answer_id": 263911, "author": "Steve Jessop", "author_id": 13005, "author_profile": "https://Stackoverflow.com/users/13005", "pm_score": 2, "selected": false, "text": "<p>The IMEvent constructor is called before alertText's constructor is called. In particular therefore its argument <...
2008/11/04
[ "https://Stackoverflow.com/questions/263906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20003/" ]
``` AlertEvent::AlertEvent(const std::string& text) : IMEvent(kIMEventAlert, alertText.c_str()), alertText(text) { //inspection at time of crash shows alertText is a valid string } IMEvent::IMEvent(long eventID, const char* details) { //during construction, details==0xcccccccc } ``` on a related note...
alertText may be shown as a string in a debugger, but it has not been constructed yet (and therefore alertText.c\_str() will return an indeterminate pointer). To avoid this, one could initialize use text.c\_str() as an argument to the IMEvent ctor. ``` AlertEvent::AlertEvent(const std::string& text) : IMEvent(kIM...
263,913
<p>I am trying to get the DataGridView to render the "insert new row" row as the first row in the grid instead of the last row. How do I go about doing that, is it even possible in the control?</p>
[ { "answer_id": 264014, "author": "jons911", "author_id": 34375, "author_profile": "https://Stackoverflow.com/users/34375", "pm_score": 4, "selected": true, "text": "<p>I don't think there is any way to move the \"new row\" row to the top of the data grid.</p>\n\n<p>But, what if you left ...
2008/11/04
[ "https://Stackoverflow.com/questions/263913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32809/" ]
I am trying to get the DataGridView to render the "insert new row" row as the first row in the grid instead of the last row. How do I go about doing that, is it even possible in the control?
I don't think there is any way to move the "new row" row to the top of the data grid. But, what if you left the top row empty and as the data filled in move the row down as appropriate? In other words, make your own "new row" row, which is just first row in the grid and add new blank rows above when editing is over. ...
263,938
<p>For my small wiki application, I mostly need to have the textarea used to edit the contents to use soft (or virtual) wrapping. However, in some cases, not wrapping the content would be preferable. I thought I would do this by simply having a button to turn off wrapping. Here is the simplified code:</p> <pre><code> ...
[ { "answer_id": 264006, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "<p>According to <a href=\"http://www.w3.org/TR/html4/interact/forms.html#edef-TEXTAREA\" rel=\"nofollow noreferrer\">the HTML ...
2008/11/05
[ "https://Stackoverflow.com/questions/263938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For my small wiki application, I mostly need to have the textarea used to edit the contents to use soft (or virtual) wrapping. However, in some cases, not wrapping the content would be preferable. I thought I would do this by simply having a button to turn off wrapping. Here is the simplified code: ``` <form name="w...
See bug 41464: <https://bugzilla.mozilla.org/show_bug.cgi?id=41464> Nasty workaround for now is to replace the textarea with a clone of itself: ``` function setWrap(area, wrap) { if (area.wrap) { area.wrap= wrap; } else { // wrap attribute not supported - try Mozilla workaround area.setAttribu...
263,945
<p>In the following code I loop through a map and test if an element needs to be erased. Is it safe to erase the element and keep iterating or do I need to collect the keys in another container and do a second loop to call the erase()?</p> <pre><code>map&lt;string, SerialdMsg::SerialFunction_t&gt;::iterator pm_it; fo...
[ { "answer_id": 263958, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 9, "selected": true, "text": "<h2>C++11</h2>\n\n<p>This has been fixed in C++11 (or erase has been improved/made consistent across all container type...
2008/11/05
[ "https://Stackoverflow.com/questions/263945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20889/" ]
In the following code I loop through a map and test if an element needs to be erased. Is it safe to erase the element and keep iterating or do I need to collect the keys in another container and do a second loop to call the erase()? ``` map<string, SerialdMsg::SerialFunction_t>::iterator pm_it; for (pm_it = port_map.b...
C++11 ----- This has been fixed in C++11 (or erase has been improved/made consistent across all container types). The erase method now returns the next iterator. ``` auto pm_it = port_map.begin(); while(pm_it != port_map.end()) { if (pm_it->second == delete_this_id) { pm_it = port_map.erase(pm_it);...
263,962
<p>Is there a difference in passing parameters to <code>.load</code></p> <pre><code>$("#myDiv").load("myScript.php?var=x&amp;var2=y&amp;var3=z") </code></pre> <p>vs</p> <pre><code>$("#myDiv").load("myScript.php", {var1:x, var2:y, var3:z}) </code></pre> <p>Also, is there a size limit to how much <code>.load</code> c...
[ { "answer_id": 263974, "author": "Davide Gualano", "author_id": 28582, "author_profile": "https://Stackoverflow.com/users/28582", "pm_score": 5, "selected": false, "text": "<p>In the first case, the data are passed to the script via GET, in the second via POST.</p>\n\n<p><a href=\"http:/...
2008/11/05
[ "https://Stackoverflow.com/questions/263962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a difference in passing parameters to `.load` ``` $("#myDiv").load("myScript.php?var=x&var2=y&var3=z") ``` vs ``` $("#myDiv").load("myScript.php", {var1:x, var2:y, var3:z}) ``` Also, is there a size limit to how much `.load` can handle? Can `myScript.php` return a couple hundred rows of data without issu...
In the first case, the data are passed to the script via GET, in the second via POST. <http://docs.jquery.com/Ajax/load#urldatacallback> I don't think there are limits to the data size, but the completition of the remote call will of course take longer with great amount of data.
263,965
<p>Can I convert a string representing a boolean value (e.g., 'true', 'false') into a intrinsic type in JavaScript?</p> <p>I have a hidden form in HTML that is updated based upon a user's selection within a list. This form contains some fields which represent boolean values and are dynamically populated with an intrin...
[ { "answer_id": 264037, "author": "guinaps", "author_id": 27225, "author_profile": "https://Stackoverflow.com/users/27225", "pm_score": 13, "selected": true, "text": "<h1>Do:</h1>\n<pre><code>var isTrueSet = (myValue === 'true');\n</code></pre>\n<p>using the identity operator (<code>===</...
2008/11/05
[ "https://Stackoverflow.com/questions/263965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4599/" ]
Can I convert a string representing a boolean value (e.g., 'true', 'false') into a intrinsic type in JavaScript? I have a hidden form in HTML that is updated based upon a user's selection within a list. This form contains some fields which represent boolean values and are dynamically populated with an intrinsic boolea...
Do: === ``` var isTrueSet = (myValue === 'true'); ``` using the identity operator (`===`), which doesn't make any implicit type conversions when the compared variables have different types. This will set `isTrueSet` to a boolean `true` if the string is "true" and boolean `false` if it is string "false" or not set a...
263,985
<p>I want to be replace any occurrence of more than one space with a single space, but take no action in text between quotes.</p> <p>Is there any way of doing this with a Java regex? If so, can you please attempt it or give me a hint?</p>
[ { "answer_id": 264025, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 0, "selected": false, "text": "<p>text between quotes : Are the quotes within the same line or multiple lines ?</p>\n" }, { "answer_id": 264044, ...
2008/11/05
[ "https://Stackoverflow.com/questions/263985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27677/" ]
I want to be replace any occurrence of more than one space with a single space, but take no action in text between quotes. Is there any way of doing this with a Java regex? If so, can you please attempt it or give me a hint?
Here's another approach, that uses a lookahead to determine that all quotation marks after the current position come in matched pairs. ``` text = text.replaceAll(" ++(?=(?:[^\"]*+\"[^\"]*+\")*+[^\"]*+$)", " "); ``` If needed, the lookahead can be adapted to handle escaped quotation marks inside the quoted sections.
264,022
<p>I have a DTS job that is using the MSXML2.XMLHTTP3.0 object to generate a post request to an ASP.NET application. Under the covers, the ASP.NET application is using System.Reflection to acquire some assembly information and I receive the following exception:</p> <blockquote> <p>System.Web.HttpException Error Cod...
[ { "answer_id": 289647, "author": "csgero", "author_id": 21764, "author_profile": "https://Stackoverflow.com/users/21764", "pm_score": 0, "selected": false, "text": "<p>Judging by the exception message this does not look like an authentication problem to me.\nCould it be that the invoked ...
2008/11/05
[ "https://Stackoverflow.com/questions/264022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
I have a DTS job that is using the MSXML2.XMLHTTP3.0 object to generate a post request to an ASP.NET application. Under the covers, the ASP.NET application is using System.Reflection to acquire some assembly information and I receive the following exception: > > System.Web.HttpException Error Code: > -2147467259 Mes...
Try this: <http://support.instantasp.co.uk/Topic4710-31-1.aspx>
264,057
<p>I have some old C code that I would like to combine with some C++ code.</p> <p>The C code used to have has the following includes:</p> <pre><code>#include &lt;windows.h&gt; #include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &quot;mysql.h&quot; </code></pre> <p>Now I'm trying to make it use C++ with iostream...
[ { "answer_id": 264081, "author": "Mike G.", "author_id": 18901, "author_profile": "https://Stackoverflow.com/users/18901", "pm_score": 2, "selected": false, "text": "<p>You need to link against your C++ runtime. It depends on your platform and compiler, but adding -lC to your linkline m...
2008/11/05
[ "https://Stackoverflow.com/questions/264057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28462/" ]
I have some old C code that I would like to combine with some C++ code. The C code used to have has the following includes: ``` #include <windows.h> #include <stdio.h> #include <string.h> #include "mysql.h" ``` Now I'm trying to make it use C++ with iostream like this: ``` #include <windows.h> #include <stdio.h> #...
The C `string.h` header and the C++ `string` header are not interchangeable. Overall, though, your problem is that the file is getting properly compiled, but the wrong runtime library is getting linked in. Dev-C++ uses GCC. GCC can correctly determine the language in a file based on file extension, but won't link the...
264,058
<p>I've got a VS 2008 C# Web project and whenever I make some changes to the files in it (not even to the project file itself) VS will remove some lines like this from the csproj file:</p> <pre><code>&lt;SubType&gt;ASPXCodeBehind&lt;/SubType&gt; </code></pre> <p>So something like this:</p> <pre><code>&lt;Compile Inc...
[ { "answer_id": 270356, "author": "Eren Aygunes", "author_id": 27980, "author_profile": "https://Stackoverflow.com/users/27980", "pm_score": 2, "selected": false, "text": "<p>Splitting the content of your file into multiple files - one file per class may help.</p>\n\n<p><a href=\"https://...
2008/11/05
[ "https://Stackoverflow.com/questions/264058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20336/" ]
I've got a VS 2008 C# Web project and whenever I make some changes to the files in it (not even to the project file itself) VS will remove some lines like this from the csproj file: ``` <SubType>ASPXCodeBehind</SubType> ``` So something like this: ``` <Compile Include="Default.aspx.cs"> <DependentUpon>Default.asp...
For me, the difference depends on whether or not the web project is open in Visual Studio. I find if I commit the project file to version control with the project open in Visual Studio the SubType elements are present. Closing the solution/project then removes the SubType elements from the project file. Now I always e...
264,080
<p>What is the most efficient way to cacluate the closest power of a 2 or 10 to another number? e.g.</p> <p>3.5 would return 4 for power of 2 and 1 for power of 10</p> <p>123 would return 128 for power of 2 and 100 for power of 10</p> <p>0.24 would return 0.25 for power of 2 and 0.1 for power of 10</p> <p>I'm just ...
[ { "answer_id": 264093, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 6, "selected": true, "text": "<pre><code>n^round(log_n(x))\n</code></pre>\n\n<p>where log_n is the logarithm to base n. You may have to modify the round...
2008/11/05
[ "https://Stackoverflow.com/questions/264080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5932/" ]
What is the most efficient way to cacluate the closest power of a 2 or 10 to another number? e.g. 3.5 would return 4 for power of 2 and 1 for power of 10 123 would return 128 for power of 2 and 100 for power of 10 0.24 would return 0.25 for power of 2 and 0.1 for power of 10 I'm just looking for the algorithm and d...
``` n^round(log_n(x)) ``` where log\_n is the logarithm to base n. You may have to modify the round() depending on how you define "closest". Note that `log_n(x)` can be implemented as: ``` log_n(x) = log(x) / log(n) ``` where `log` is a logarithm to any convenient base.
264,090
<p>How can I make:</p> <p>DELETE FROM foo WHERE id=1 AND <strong>bar not contains id==1</strong></p> <p>To elaborate, how can I remove a row with <code>id = 1</code>, from table <code>foo</code>, only if there is not a row in table <code>bar</code> with <code>id = 1</code>.</p>
[ { "answer_id": 264103, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 5, "selected": true, "text": "<pre><code>DELETE FROM foo WHERE id=1 AND NOT EXISTS (SELECT * FROM bar WHERE id=1)\n</code></pre>\n\n<p>I'm assumin...
2008/11/05
[ "https://Stackoverflow.com/questions/264090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
How can I make: DELETE FROM foo WHERE id=1 AND **bar not contains id==1** To elaborate, how can I remove a row with `id = 1`, from table `foo`, only if there is not a row in table `bar` with `id = 1`.
``` DELETE FROM foo WHERE id=1 AND NOT EXISTS (SELECT * FROM bar WHERE id=1) ``` I'm assuming you mean that foo and bar are tables, and you want to remove a record from foo if it doesn't exist in bar.
264,123
<p>Is there a way to have % in vim find the next ([{ or whatever, even if it is not on the same line?</p> <p>Example:</p> <pre><code>int main(int argc, char ** argv) { #Your cursor is somewhere in this comment, I want #it to get to the ( after printf printf("Hello there.\n"); } </code></pre>
[ { "answer_id": 264136, "author": "Mike G.", "author_id": 18901, "author_profile": "https://Stackoverflow.com/users/18901", "pm_score": 1, "selected": false, "text": "<p>That's puzzling... For me, % finds the matching close for any {[( no matter how many lines away the match is. I don't...
2008/11/05
[ "https://Stackoverflow.com/questions/264123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way to have % in vim find the next ([{ or whatever, even if it is not on the same line? Example: ``` int main(int argc, char ** argv) { #Your cursor is somewhere in this comment, I want #it to get to the ( after printf printf("Hello there.\n"); } ```
If you want to find opening braces on subsequent lines, without plugins, just enter normal mode and type: ``` /{ [enter] ``` Where { is the type of brace your looking for. You can then browse them all with `n` and `N`. To map the `F12` key to turn search highlighting on and off [use this trick.](http://ronny.harya...
264,127
<p>I have a program that when it starts, opens a winform (it is the one specified in Application.Run(new ...). From this form I open another form:</p> <pre><code>OtherForm newForm=new OtherForm(); newForm.Show(); </code></pre> <p>How can i communicate from the new winform with the form that opened it? So that I can a...
[ { "answer_id": 264132, "author": "Factor Mystic", "author_id": 1569, "author_profile": "https://Stackoverflow.com/users/1569", "pm_score": 2, "selected": false, "text": "<p>The simplest way is to override the constructor, eg, <code>OtherForm newForm=new OtherForm(string title, int data);...
2008/11/05
[ "https://Stackoverflow.com/questions/264127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31791/" ]
I have a program that when it starts, opens a winform (it is the one specified in Application.Run(new ...). From this form I open another form: ``` OtherForm newForm=new OtherForm(); newForm.Show(); ``` How can i communicate from the new winform with the form that opened it? So that I can add some items in it.
I think I have found the answer here: <http://www.c-sharpcorner.com/UploadFile/mosessaur/winformsdelegates09042006094826AM/winformsdelegates.aspx> I have to use delegates. In the second form I define: ``` public delegate void AddItemDelegate(string item); public AddItemDelegate AddItemCallback; ``` And from the for...
264,128
<p>I am trying to export a Ruby framework via XML-RPC. However I am having some problems when trying to call a method from a class not directly added as a handler to the XML-RPC server. Please see my example below:</p> <p>I have a test Ruby XML-RPC server as follows:</p> <pre><code>require "xmlrpc/server" class Exam...
[ { "answer_id": 264165, "author": "jakber", "author_id": 29812, "author_profile": "https://Stackoverflow.com/users/29812", "pm_score": 4, "selected": true, "text": "<p>Your client (s in you Python code) is a ServerProxy object. It only accepts return values of type boolean, integers, floa...
2008/11/05
[ "https://Stackoverflow.com/questions/264128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14260/" ]
I am trying to export a Ruby framework via XML-RPC. However I am having some problems when trying to call a method from a class not directly added as a handler to the XML-RPC server. Please see my example below: I have a test Ruby XML-RPC server as follows: ``` require "xmlrpc/server" class ExampleBar def bar() ...
Your client (s in you Python code) is a ServerProxy object. It only accepts return values of type boolean, integers, floats, arrays, structures, dates or binary data. However, without you doing the wiring, there is no way for it to return another ServerProxy, which you would need for accessing another class. You could...
264,140
<p>I've a web service running on server which return data either in XML format or JSON format. I wanted to request a JSON format but using HTTP Post method.</p>
[ { "answer_id": 264340, "author": "schwa", "author_id": 23113, "author_profile": "https://Stackoverflow.com/users/23113", "pm_score": 2, "selected": false, "text": "<p>Not really sure what your question is exactly. But google \"TouchJSON\" that should help you get started.</p>\n" }, {...
2008/11/05
[ "https://Stackoverflow.com/questions/264140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/451867/" ]
I've a web service running on server which return data either in XML format or JSON format. I wanted to request a JSON format but using HTTP Post method.
This is the code which work for JSON post request, TouchJSON Framework is used for parsing the JSON, thanks 'schwa'. ``` NSArray *keys = [NSArray arrayWithObjects:@"username", @"password", @"preference", @"uid", nil]; NSArray *objects = [NSArray arrayWithObjects:@"accuser", @"accpass", @"abc_region", @"100", nil]; NSD...
264,163
<p>I have a somewhat complex WPF application which seems to be 'hanging' or getting stuck in a Wait call when trying to use the dispatcher to invoke a call on the UI thread.</p> <p>The general process is:</p> <ol> <li>Handle the click event on a button</li> <li>Create a new thread (STA) which: creates a new instance ...
[ { "answer_id": 264444, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 4, "selected": false, "text": "<p>Invoke is synchronous - you want Dispatcher.BeginInvoke. Also, I believe your code sample should move the \"SetValue\" ...
2008/11/05
[ "https://Stackoverflow.com/questions/264163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18434/" ]
I have a somewhat complex WPF application which seems to be 'hanging' or getting stuck in a Wait call when trying to use the dispatcher to invoke a call on the UI thread. The general process is: 1. Handle the click event on a button 2. Create a new thread (STA) which: creates a new instance of the presenter and UI, t...
You say you are creating a new STA thread, is the dispatcher on this new thread running? I'm getting from "this.Dispatcher.Thread != Thread.CurrentThread" that you expect it to be a different dispatcher. Make sure that its running otherwise it wont process its queue.
264,216
<p>I'm playing around with ASP.net MVC and JQuery at the moment. I've come across behavour which doesn't seem to make sense. </p> <p>I'm calling JQuery's <code>$.getJSON</code> function to populate some div's. The event is triggered on the <code>$(document).ready</code> event. This works perfectly.</p> <p>There is a...
[ { "answer_id": 264227, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 2, "selected": false, "text": "<p>You may need to send a cache-breaker. </p>\n\n<p>I would recommend using $.ajax( { cache: no }) just in case ( ad...
2008/11/05
[ "https://Stackoverflow.com/questions/264216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30576/" ]
I'm playing around with ASP.net MVC and JQuery at the moment. I've come across behavour which doesn't seem to make sense. I'm calling JQuery's `$.getJSON` function to populate some div's. The event is triggered on the `$(document).ready` event. This works perfectly. There is a small `AJAX.BeginForm` which adds anoth...
Just to let you know, Firefox and Chrome consider all Ajax request as non-cachable. IE (all versions) treat Ajax call just as other web request. That's why you see this behavior. How to force IE to download data at each request: * As you said, use 'cache' or 'nocache' option in JQuery * Add a random parameter to th...
264,224
<p>I'm interested in compressing data using Python's <code>gzip</code> module. It happens that I want the compressed output to be deterministic, because that's often a really convenient property for things to have in general -- if some non-gzip-aware process is going to be looking for changes in the output, say, or if...
[ { "answer_id": 264297, "author": "Sean", "author_id": 4919, "author_profile": "https://Stackoverflow.com/users/4919", "pm_score": 0, "selected": false, "text": "<p>In lib/gzip.py, we find the method that builds the header, including the part that does indeed contain a timestamp. In Pytho...
2008/11/05
[ "https://Stackoverflow.com/questions/264224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13871/" ]
I'm interested in compressing data using Python's `gzip` module. It happens that I want the compressed output to be deterministic, because that's often a really convenient property for things to have in general -- if some non-gzip-aware process is going to be looking for changes in the output, say, or if the output is ...
From Python 2.7 onwards you can specify the time to be used in the gzip header. N.B. filename is also included in the header and can also be specified manually. ``` import gzip content = b"Some content" f = open("/tmp/f.gz", "wb") gz = gzip.GzipFile(fileobj=f,mode="wb",filename="",mtime=0) gz.write(content) gz.close(...
264,236
<p>How do you determine what to put in .rhosts file in an VAX openvms system when trying to remotely access the server using a remote shell from Cygwin on windows XP ? .rlogin and rsh are the only methods that can be used to access the VAX server and it must be using Cygwin to remote in to the VAX server. SSH is not an...
[ { "answer_id": 264297, "author": "Sean", "author_id": 4919, "author_profile": "https://Stackoverflow.com/users/4919", "pm_score": 0, "selected": false, "text": "<p>In lib/gzip.py, we find the method that builds the header, including the part that does indeed contain a timestamp. In Pytho...
2008/11/05
[ "https://Stackoverflow.com/questions/264236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34531/" ]
How do you determine what to put in .rhosts file in an VAX openvms system when trying to remotely access the server using a remote shell from Cygwin on windows XP ? .rlogin and rsh are the only methods that can be used to access the VAX server and it must be using Cygwin to remote in to the VAX server. SSH is not an op...
From Python 2.7 onwards you can specify the time to be used in the gzip header. N.B. filename is also included in the header and can also be specified manually. ``` import gzip content = b"Some content" f = open("/tmp/f.gz", "wb") gz = gzip.GzipFile(fileobj=f,mode="wb",filename="",mtime=0) gz.write(content) gz.close(...
264,243
<p>I'm working on a quick project to monitor/process data. Essentially that's just monitors, schedules and processors. The monitor checks for data (ftp, local, imap, pop, etc) using a schedule and sends new data to a processor. They all have interfaces.</p> <p>I'm trying to find a sane way to use config to configure w...
[ { "answer_id": 264297, "author": "Sean", "author_id": 4919, "author_profile": "https://Stackoverflow.com/users/4919", "pm_score": 0, "selected": false, "text": "<p>In lib/gzip.py, we find the method that builds the header, including the part that does indeed contain a timestamp. In Pytho...
2008/11/05
[ "https://Stackoverflow.com/questions/264243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91911/" ]
I'm working on a quick project to monitor/process data. Essentially that's just monitors, schedules and processors. The monitor checks for data (ftp, local, imap, pop, etc) using a schedule and sends new data to a processor. They all have interfaces. I'm trying to find a sane way to use config to configure what schedu...
From Python 2.7 onwards you can specify the time to be used in the gzip header. N.B. filename is also included in the header and can also be specified manually. ``` import gzip content = b"Some content" f = open("/tmp/f.gz", "wb") gz = gzip.GzipFile(fileobj=f,mode="wb",filename="",mtime=0) gz.write(content) gz.close(...
264,248
<p>I'm looking into integrating jBPM with my current project, so far so good just including the jpdl jar in my ear and using the spring modules 0.8 jbpm module, however I've got to have a reasonable way of going from my changes to to the process definition in the designer to deployment in production.</p> <p>The path ...
[ { "answer_id": 266157, "author": "shyam", "author_id": 7616, "author_profile": "https://Stackoverflow.com/users/7616", "pm_score": 0, "selected": false, "text": "<p>Why not use the ant task extensions provided by JBPM specifically <a href=\"http://docs.jboss.org/jbpm/v3/javadoc/org/jbpm/...
2008/11/05
[ "https://Stackoverflow.com/questions/264248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm looking into integrating jBPM with my current project, so far so good just including the jpdl jar in my ear and using the spring modules 0.8 jbpm module, however I've got to have a reasonable way of going from my changes to to the process definition in the designer to deployment in production. The path has to be r...
If you want to avoid going down the `.par` route, it's easy to write some simple Java code to deploy a new process definition version to your database. Something like ``` JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml")); ProcessDefinition processDefinition = ProcessDefinition.parseX...
264,249
<p>I've been beating my head against this wall for quite some time now, so I thought I'd ask some experts.</p> <p>I need to send an xml string from one computer to the next. I would like to format the xml something like this:</p> <pre><code>&lt;xml&gt; &lt;author&gt;Joe the Magnificent&lt;/author&gt; &lt;title&g...
[ { "answer_id": 264279, "author": "Jim Burger", "author_id": 20164, "author_profile": "https://Stackoverflow.com/users/20164", "pm_score": 2, "selected": false, "text": "<p>Using the <a href=\"http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.load.aspx\" rel=\"nofollow norefe...
2008/11/05
[ "https://Stackoverflow.com/questions/264249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34539/" ]
I've been beating my head against this wall for quite some time now, so I thought I'd ask some experts. I need to send an xml string from one computer to the next. I would like to format the xml something like this: ``` <xml> <author>Joe the Magnificent</author> <title>Joe Goes Home</title> </xml> ``` Can anyon...
Here's what I ended up doing: ``` Public Function FormatMessage(ByVal author As String, ByVal title As String, ByVal genre As String) As String Dim xDoc As New XmlDocument ' Create outer XML Dim xNode As XmlNode = xDoc.AppendChild(xDoc.CreateElement("xml")) ' Create Author Node Dim xAuthor As XmlNode = xNode.AppendC...
264,269
<p>A basic definition and example and a few references for "<a href="http://en.wikipedia.org/wiki/C_preprocessor#X-Macros" rel="nofollow noreferrer">X-Macros</a>" is given in this <a href="http://en.wikipedia.org/wiki/C_preprocessor" rel="nofollow noreferrer">wikipedia entry on the C pre-processor</a>:</p> <blockquot...
[ { "answer_id": 265291, "author": "qrdl", "author_id": 28494, "author_profile": "https://Stackoverflow.com/users/28494", "pm_score": 3, "selected": false, "text": "<p>Dr. Dobb's has an <a href=\"http://www.ddj.com/cpp/184401387\" rel=\"noreferrer\">article</a> on this.</p>\n" }, { ...
2008/11/05
[ "https://Stackoverflow.com/questions/264269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30636/" ]
A basic definition and example and a few references for "[X-Macros](http://en.wikipedia.org/wiki/C_preprocessor#X-Macros)" is given in this [wikipedia entry on the C pre-processor](http://en.wikipedia.org/wiki/C_preprocessor): > > An X-Macro is a header file (commonly > using a ".def" extension instead of > the tra...
I use X Macros() in code a lot. The value comes from only adding new data only to the "X list" and not modifying any other code. The most common use of X Macros() is for associating error text with error codes. When new error codes are added, programmers must remember to add the code and the text, typically in separat...