question_id
int64
4
6.31M
answer_id
int64
7
6.31M
title
stringlengths
9
150
question_body
stringlengths
0
28.8k
answer_body
stringlengths
60
27.2k
question_text
stringlengths
40
28.9k
combined_text
stringlengths
124
39.6k
tags
listlengths
1
6
question_score
int64
0
26.3k
answer_score
int64
0
28.8k
view_count
int64
15
14M
answer_count
int64
0
182
favorite_count
int64
0
32
question_creation_date
stringdate
2008-07-31 21:42:52
2011-06-10 18:12:18
answer_creation_date
stringdate
2008-07-31 22:17:57
2011-06-10 18:14:17
141,154
141,211
How can I determine installed SQL Server instances and their versions?
I'm trying to determine what instances of sql server/sql express I have installed (either manually or programmatically) but all of the examples are telling me to run a SQL query to determine this which assumes I'm already connected to a particular instance.
At a command line: SQLCMD -L or OSQL -L (Note: must be a capital L) This will list all the sql servers installed on your network. There are configuration options you can set to prevent a SQL Server from showing in the list. To do this... At command line: svrnetcn In the enabled protocols list, select 'TCP/IP', then cli...
How can I determine installed SQL Server instances and their versions? I'm trying to determine what instances of sql server/sql express I have installed (either manually or programmatically) but all of the examples are telling me to run a SQL query to determine this which assumes I'm already connected to a particular i...
TITLE: How can I determine installed SQL Server instances and their versions? QUESTION: I'm trying to determine what instances of sql server/sql express I have installed (either manually or programmatically) but all of the examples are telling me to run a SQL query to determine this which assumes I'm already connected...
[ "sql-server", "sql-server-express" ]
259
228
716,757
21
0
2008-09-26T18:32:23.457000
2008-09-26T18:45:50.493000
141,198
141,225
How do I detect a keyboard modifier in a bookmarklet?
Is there a way to detect if the user is holding down the shift key (or other modifier keys) when executing a javascript bookmarklet? In my tests of Safari 3.1 and Firefox 3, window.event is always undefined.
If you're looking for a way to detect the mouse position while the bookmarklet is being physically clicked, no, there is no way. Since the bookmarklet is positioned outside of any page (this area is generally called the browser "chrome" - which is confusing since there's now a browser with that name) it's not possible ...
How do I detect a keyboard modifier in a bookmarklet? Is there a way to detect if the user is holding down the shift key (or other modifier keys) when executing a javascript bookmarklet? In my tests of Safari 3.1 and Firefox 3, window.event is always undefined.
TITLE: How do I detect a keyboard modifier in a bookmarklet? QUESTION: Is there a way to detect if the user is holding down the shift key (or other modifier keys) when executing a javascript bookmarklet? In my tests of Safari 3.1 and Firefox 3, window.event is always undefined. ANSWER: If you're looking for a way to ...
[ "javascript", "firefox", "safari", "keyboard", "bookmarklet" ]
7
17
1,177
2
0
2008-09-26T18:42:44.273000
2008-09-26T18:48:47.723000
141,201
143,357
How to best handle per-Model database connections with ActiveRecord?
I'd like the canonical way to do this. My Google searches have come up short. I have one ActiveRecord model that should map to a different database than the rest of the application. I would like to store the new configurations in the database.yml file as well. I understand that establish_connection should be called, bu...
Also, it is a good idea to subclass your model that uses different database, such as: class AnotherBase < ActiveRecord::Base self.abstract_class = true establish_connection "anotherbase_#{RAILS_ENV}" end And in your model class Foo < AnotherBase end It is useful when you need to add subsequent models that access the sa...
How to best handle per-Model database connections with ActiveRecord? I'd like the canonical way to do this. My Google searches have come up short. I have one ActiveRecord model that should map to a different database than the rest of the application. I would like to store the new configurations in the database.yml file...
TITLE: How to best handle per-Model database connections with ActiveRecord? QUESTION: I'd like the canonical way to do this. My Google searches have come up short. I have one ActiveRecord model that should map to a different database than the rest of the application. I would like to store the new configurations in the...
[ "ruby-on-rails", "ruby", "activerecord" ]
13
21
3,407
2
0
2008-09-26T18:43:17.457000
2008-09-27T10:06:55.643000
141,202
141,627
AppDomain And the Current Directory
I have a class that utilizes a directory swap method for the Environment.CurrentDirectory. The code looks something like this: var str = Environment.CurrentDirectory; Environment.CurrentDirectory = Path.GetDirectoryName(pathToAssembly); var assembly = Assembly.Load(Path.GetFileNameWithoutExtension(pathToAssembly)); Env...
This post suggests that you can't change the search path of the primary AppDomain once it is loaded -- you have to set it in the config file -- and has a number of suggestions, though they all boil down to "you can't do it in the primary AppDomain".
AppDomain And the Current Directory I have a class that utilizes a directory swap method for the Environment.CurrentDirectory. The code looks something like this: var str = Environment.CurrentDirectory; Environment.CurrentDirectory = Path.GetDirectoryName(pathToAssembly); var assembly = Assembly.Load(Path.GetFileNameWi...
TITLE: AppDomain And the Current Directory QUESTION: I have a class that utilizes a directory swap method for the Environment.CurrentDirectory. The code looks something like this: var str = Environment.CurrentDirectory; Environment.CurrentDirectory = Path.GetDirectoryName(pathToAssembly); var assembly = Assembly.Load(...
[ "c#", "appdomain" ]
1
1
4,783
1
0
2008-09-26T18:43:26.427000
2008-09-26T20:04:00.350000
141,204
141,215
What is the proper way to ensure a SQL connection is closed when an exception is thrown?
I use a pattern that looks something like this often. I'm wondering if this is alright or if there is a best practice that I am not applying here. Specifically I'm wondering; in the case that an exception is thrown is the code that I have in the finally block enough to ensure that the connection is closed appropriately...
Wrap your database handling code inside a "using" using (SqlConnection conn = new SqlConnection (...)) { // Whatever happens in here, the connection is // disposed of (closed) at the end. }
What is the proper way to ensure a SQL connection is closed when an exception is thrown? I use a pattern that looks something like this often. I'm wondering if this is alright or if there is a best practice that I am not applying here. Specifically I'm wondering; in the case that an exception is thrown is the code that...
TITLE: What is the proper way to ensure a SQL connection is closed when an exception is thrown? QUESTION: I use a pattern that looks something like this often. I'm wondering if this is alright or if there is a best practice that I am not applying here. Specifically I'm wondering; in the case that an exception is throw...
[ "c#", ".net", "sql", "sqlconnection" ]
18
46
18,072
9
0
2008-09-26T18:43:55.613000
2008-09-26T18:46:37.603000
141,207
141,216
How do you pass parameters to called function using ASP.Net Ajax $addHandler
I am trying to use the $addHandler function to add a handler to a text box's click event var o=$get('myTextBox'); var f = Type.parse('funcWithArgs'); $addHandler(o, 'click', f); However I need to pass parameters to the called function. How do you do that? TIA
Wrap your function with an anonymous function (aka lambda): $addHandler(o, 'click', function() { f(my, arguments, go, here); }); Alternative solution: If you had a function that created partials, you could do that as well - I use a toolkit that provides for that, and this is how it would be done: $addHandler(o, 'click'...
How do you pass parameters to called function using ASP.Net Ajax $addHandler I am trying to use the $addHandler function to add a handler to a text box's click event var o=$get('myTextBox'); var f = Type.parse('funcWithArgs'); $addHandler(o, 'click', f); However I need to pass parameters to the called function. How do ...
TITLE: How do you pass parameters to called function using ASP.Net Ajax $addHandler QUESTION: I am trying to use the $addHandler function to add a handler to a text box's click event var o=$get('myTextBox'); var f = Type.parse('funcWithArgs'); $addHandler(o, 'click', f); However I need to pass parameters to the called...
[ "asp.net", "javascript", "ajax" ]
1
3
2,348
1
0
2008-09-26T18:44:43.910000
2008-09-26T18:46:37.790000
141,212
141,326
How to have a LinkClicked event using an ArrayList of LinkLabels in .NET
I'm working on a form that will display links to open different types of reports. This system has different types of users, so the users should only be able to see the links to the types of reports they can access. Currently, the way I have this set up is that I have an ArrayList of LinkLabels, but the problem I'm havi...
You can apply the same event handler to every LinkLabel in your list and get the specific LinkLabel from the sender argument.
How to have a LinkClicked event using an ArrayList of LinkLabels in .NET I'm working on a form that will display links to open different types of reports. This system has different types of users, so the users should only be able to see the links to the types of reports they can access. Currently, the way I have this s...
TITLE: How to have a LinkClicked event using an ArrayList of LinkLabels in .NET QUESTION: I'm working on a form that will display links to open different types of reports. This system has different types of users, so the users should only be able to see the links to the types of reports they can access. Currently, the...
[ ".net", "visual-studio-2005", "arraylist", "linklabel" ]
1
2
327
3
0
2008-09-26T18:46:01.863000
2008-09-26T19:06:31.597000
141,232
141,243
How many database indexes is too many?
I'm working on a project with a rather large Oracle database (although my question applies equally well to other databases). We have a web interface which allows users to search on almost any possible combination of fields. To make these searches go fast, we're adding indexes to the fields and combinations of fields on...
It depends on the operations that occur on the table. If there's lots of SELECTs and very few changes, index all you like.... these will (potentially) speed the SELECT statements up. If the table is heavily hit by UPDATEs, INSERTs + DELETEs... these will be very slow with lots of indexes since they all need to be modif...
How many database indexes is too many? I'm working on a project with a rather large Oracle database (although my question applies equally well to other databases). We have a web interface which allows users to search on almost any possible combination of fields. To make these searches go fast, we're adding indexes to t...
TITLE: How many database indexes is too many? QUESTION: I'm working on a project with a rather large Oracle database (although my question applies equally well to other databases). We have a web interface which allows users to search on almost any possible combination of fields. To make these searches go fast, we're a...
[ "database", "oracle", "database-design" ]
127
101
54,892
17
0
2008-09-26T18:50:13.680000
2008-09-26T18:52:53.643000
141,241
141,267
Does java have an equivalent to the C# "using" clause
I've seen reference in some C# posted questions to a "using" clause. Does java have the equivalent?
Yes. Java 1.7 introduced the try-with-resources construct allowing you to write: try(InputStream is1 = new FileInputStream("/tmp/foo"); InputStream is2 = new FileInputStream("/tmp/bar")) { /* do stuff with is1 and is2 */ }... just like a using statement. Unfortunately, before Java 1.7, Java programmers were forced to u...
Does java have an equivalent to the C# "using" clause I've seen reference in some C# posted questions to a "using" clause. Does java have the equivalent?
TITLE: Does java have an equivalent to the C# "using" clause QUESTION: I've seen reference in some C# posted questions to a "using" clause. Does java have the equivalent? ANSWER: Yes. Java 1.7 introduced the try-with-resources construct allowing you to write: try(InputStream is1 = new FileInputStream("/tmp/foo"); Inp...
[ "java", "syntax" ]
27
30
14,879
12
0
2008-09-26T18:52:28.853000
2008-09-26T18:56:34.397000
141,242
141,320
Exceptions vs Result Codes for a socket client class
I have a class that encapsulates tcp socket communications with a server. For each command message sent to the server, the server will send back a response message that invariably contains a response code (OK, Fail). Using my class, each command can be executed either sync or async. There are basically two types of exc...
I think your strategy is basically sound. Keep in mind that the purpose of Exceptions is to deal with exceptional conditions. The closer to the source of the problem, the better. In your case, it appears that your strategy is something like "It didn't work right now. Let's retry". I don't see a reason to really raise e...
Exceptions vs Result Codes for a socket client class I have a class that encapsulates tcp socket communications with a server. For each command message sent to the server, the server will send back a response message that invariably contains a response code (OK, Fail). Using my class, each command can be executed eithe...
TITLE: Exceptions vs Result Codes for a socket client class QUESTION: I have a class that encapsulates tcp socket communications with a server. For each command message sent to the server, the server will send back a response message that invariably contains a response code (OK, Fail). Using my class, each command can...
[ "c#", ".net", "networking", "sockets", "tcp" ]
2
1
352
4
0
2008-09-26T18:52:35.017000
2008-09-26T19:05:38.807000
141,251
144,215
Windows .url links that point to same address when copied over or deleted
This is really annoying, we've switched our client downloads page to a different site and want to send a link out with our installer. When the link is created and overwrites the existing file, the metadata in windows XP still points to the same place even though the contents of the.url shows the correct address. I can ...
Take a look at here: http://www.cyanwerks.com/file-format-url.html It explains there's a Modified field you can add to the.url file. It also explains how to interpret it.
Windows .url links that point to same address when copied over or deleted This is really annoying, we've switched our client downloads page to a different site and want to send a link out with our installer. When the link is created and overwrites the existing file, the metadata in windows XP still points to the same p...
TITLE: Windows .url links that point to same address when copied over or deleted QUESTION: This is really annoying, we've switched our client downloads page to a different site and want to send a link out with our installer. When the link is created and overwrites the existing file, the metadata in windows XP still po...
[ "url", "installation", "hyperlink", "software-distribution" ]
2
3
906
2
0
2008-09-26T18:54:37.927000
2008-09-27T18:44:11.033000
141,262
141,271
Can someone explain hex offsets to me?
I downloaded Hex Workshop, and I was told to read a.dbc file. It should contain 28,315 if you read offset 0x04 and 0x05 I am unsure how to do this? What does 0x04 mean?
0x04 is hex for 4 (the 0x is just a common prefix convention for base 16 representation of numbers - since many people think in decimal), and that would be the fourth byte (since they are saying offset, they probably count the first byte as byte 0, so offset 0x04 would be the 5th byte). I guess they are saying that the...
Can someone explain hex offsets to me? I downloaded Hex Workshop, and I was told to read a.dbc file. It should contain 28,315 if you read offset 0x04 and 0x05 I am unsure how to do this? What does 0x04 mean?
TITLE: Can someone explain hex offsets to me? QUESTION: I downloaded Hex Workshop, and I was told to read a.dbc file. It should contain 28,315 if you read offset 0x04 and 0x05 I am unsure how to do this? What does 0x04 mean? ANSWER: 0x04 is hex for 4 (the 0x is just a common prefix convention for base 16 representati...
[ "hex", "hex-editors" ]
24
14
91,586
6
0
2008-09-26T18:56:00.797000
2008-09-26T18:57:49.557000
141,278
141,310
Subqueries vs joins
I refactored a slow section of an application we inherited from another company to use an inner join instead of a subquery like: WHERE id IN (SELECT id FROM...) The refactored query runs about 100x faster. (~50 seconds to ~0.3) I expected an improvement, but can anyone explain why it was so drastic? The columns used in...
A "correlated subquery" (i.e., one in which the where condition depends on values obtained from the rows of the containing query) will execute once for each row. A non-correlated subquery (one in which the where condition is independent of the containing query) will execute once at the beginning. The SQL engine makes t...
Subqueries vs joins I refactored a slow section of an application we inherited from another company to use an inner join instead of a subquery like: WHERE id IN (SELECT id FROM...) The refactored query runs about 100x faster. (~50 seconds to ~0.3) I expected an improvement, but can anyone explain why it was so drastic?...
TITLE: Subqueries vs joins QUESTION: I refactored a slow section of an application we inherited from another company to use an inner join instead of a subquery like: WHERE id IN (SELECT id FROM...) The refactored query runs about 100x faster. (~50 seconds to ~0.3) I expected an improvement, but can anyone explain why ...
[ "sql", "mysql", "performance", "database-design", "join" ]
164
167
61,825
13
0
2008-09-26T18:58:53.517000
2008-09-26T19:03:42.213000
141,280
141,369
What's the best way to count keywords in JavaScript?
What's the best and most efficient way to count keywords in JavaScript? Basically, I'd like to take a string and get the top N words or phrases that occur in the string, mainly for the use of suggesting tags. I'm looking more for conceptual hints or links to real-life examples than actual code, but I certainly wouldn't...
Cut, paste + execute demo: var text = "Text to be examined to determine which n words are used the most"; // Find 'em! var wordRegExp = /\w+(?:'\w{1,2})?/g; var words = {}; var matches; while ((matches = wordRegExp.exec(text))!= null) { var word = matches[0].toLowerCase(); if (typeof words[word] == "undefined") { word...
What's the best way to count keywords in JavaScript? What's the best and most efficient way to count keywords in JavaScript? Basically, I'd like to take a string and get the top N words or phrases that occur in the string, mainly for the use of suggesting tags. I'm looking more for conceptual hints or links to real-lif...
TITLE: What's the best way to count keywords in JavaScript? QUESTION: What's the best and most efficient way to count keywords in JavaScript? Basically, I'd like to take a string and get the top N words or phrases that occur in the string, mainly for the use of suggesting tags. I'm looking more for conceptual hints or...
[ "javascript", "regex", "arrays", "string" ]
2
4
3,156
5
0
2008-09-26T18:59:15.017000
2008-09-26T19:15:35.227000
141,284
141,303
The difference between the Runnable and Callable interfaces in Java
What is the difference between using the Runnable and Callable interfaces when designing a concurrent thread in Java, why would you choose one over the other?
See explanation here. The Callable interface is similar to Runnable, in that both are designed for classes whose instances are potentially executed by another thread. A Runnable, however, does not return a result and cannot throw a checked exception.
The difference between the Runnable and Callable interfaces in Java What is the difference between using the Runnable and Callable interfaces when designing a concurrent thread in Java, why would you choose one over the other?
TITLE: The difference between the Runnable and Callable interfaces in Java QUESTION: What is the difference between using the Runnable and Callable interfaces when designing a concurrent thread in Java, why would you choose one over the other? ANSWER: See explanation here. The Callable interface is similar to Runnabl...
[ "java", "multithreading", "interface", "runnable", "callable" ]
568
496
365,274
14
0
2008-09-26T19:00:37.883000
2008-09-26T19:02:17.363000
141,288
219,571
Possible to use Flex Framework/Components without using MXML?
Is it possible to use the Flex Framework and Components, without using MXML? I know ActionScript pretty decently, and don't feel like messing around with some new XML language just to get some simple UI in there. Can anyone provide an example consisting of an.as file which can be compiled (ideally via FlashDevelop, tho...
I did a simple bootstrap similar to Borek (see below). I would love to get rid of the mxml file, but if I don't have it, I don't get any of the standard themes that come with Flex (haloclassic.swc, etc). Does anybody know how to do what Theo suggests and still have the standard themes applied? Here's my simplified boot...
Possible to use Flex Framework/Components without using MXML? Is it possible to use the Flex Framework and Components, without using MXML? I know ActionScript pretty decently, and don't feel like messing around with some new XML language just to get some simple UI in there. Can anyone provide an example consisting of a...
TITLE: Possible to use Flex Framework/Components without using MXML? QUESTION: Is it possible to use the Flex Framework and Components, without using MXML? I know ActionScript pretty decently, and don't feel like messing around with some new XML language just to get some simple UI in there. Can anyone provide an examp...
[ "apache-flex", "actionscript-3", "mxml", "flashdevelop" ]
19
13
9,978
4
0
2008-09-26T19:00:47.163000
2008-10-20T19:29:28.633000
141,291
141,327
How to list only top level directories in Python?
I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-doc', 'DLLs', 'Doc', 'include', 'Lib', 'libs', 'LICENSE.txt', 'mod_p...
Filter the result using os.path.isdir() (and use os.path.join() to get the real path): >>> [ name for name in os.listdir(thedir) if os.path.isdir(os.path.join(thedir, name)) ] ['ctypes', 'distutils', 'encodings', 'lib-tk', 'config', 'idlelib', 'xml', 'bsddb', 'hotshot', 'logging', 'doc', 'test', 'compiler', 'curses', '...
How to list only top level directories in Python? I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-doc', 'DLLs', 'Doc...
TITLE: How to list only top level directories in Python? QUESTION: I want to be able to list only the directories inside some folder. This means I don't want filenames listed, nor do I want additional sub-folders. Let's see if an example helps. In the current directory we have: >>> os.listdir(os.getcwd()) ['cx_Oracle-...
[ "python", "filesystems" ]
204
173
264,676
21
0
2008-09-26T19:01:06.650000
2008-09-26T19:06:57.477000
141,302
141,339
Checking File is Open in Delphi
Is there a way to check if a file has been opened by ReWrite in Delphi? Code would go something like this: AssignFile(textfile, 'somefile.txt'); if not textFile.IsOpen then Rewrite(textFile);
You can get the filemode. (One moment, I'll create an example). TTextRec(txt).Mode gives you the mode: 55216 = closed 55217 = open read 55218 = open write fmClosed = $D7B0; fmInput = $D7B1; fmOutput = $D7B2; fmInOut = $D7B3; Search TTextRec in the system unit for more information.
Checking File is Open in Delphi Is there a way to check if a file has been opened by ReWrite in Delphi? Code would go something like this: AssignFile(textfile, 'somefile.txt'); if not textFile.IsOpen then Rewrite(textFile);
TITLE: Checking File is Open in Delphi QUESTION: Is there a way to check if a file has been opened by ReWrite in Delphi? Code would go something like this: AssignFile(textfile, 'somefile.txt'); if not textFile.IsOpen then Rewrite(textFile); ANSWER: You can get the filemode. (One moment, I'll create an example). TText...
[ "delphi", "file-io" ]
15
17
28,744
5
0
2008-09-26T19:02:15.210000
2008-09-26T19:11:16.857000
141,312
141,343
Pronouncing dictionaries
Are there any alternatives to The CMU Pronouncing Dictionary, commercial or open source?
I don't believe the answer is definitively "no," but I do know that CMU is the most popular pronouncing dictionary in my anecdotal experience. I believe it is open source so if it's missing something, perhaps you could find a way to add it (or request it be added). Barring that, I would check with the folks at Language...
Pronouncing dictionaries Are there any alternatives to The CMU Pronouncing Dictionary, commercial or open source?
TITLE: Pronouncing dictionaries QUESTION: Are there any alternatives to The CMU Pronouncing Dictionary, commercial or open source? ANSWER: I don't believe the answer is definitively "no," but I do know that CMU is the most popular pronouncing dictionary in my anecdotal experience. I believe it is open source so if it...
[ "dictionary", "phonetics" ]
8
6
1,084
6
0
2008-09-26T19:04:12.820000
2008-09-26T19:12:03.847000
141,319
141,361
What's the difference between Phing and PHPUnderControl?
We currently use a hand-rolled setup and configuration script and a hand-rolled continuous integration script to build and deploy our application. I am looking at formalizing this somewhat with a third party system designed for these purposes. I have looked into Phing before, and I get that it's basically like Ant. But...
phing is pretty much ant written in PHP where phpUnderControl adds support for PHP projects to CruiseControl and uses phing or ant on the backend to parse the build.xml file and run commands. I just set up CruiseControl and phpUnderControl and it's been working great. It checks out my SVN, runs it through phpDocumentor...
What's the difference between Phing and PHPUnderControl? We currently use a hand-rolled setup and configuration script and a hand-rolled continuous integration script to build and deploy our application. I am looking at formalizing this somewhat with a third party system designed for these purposes. I have looked into ...
TITLE: What's the difference between Phing and PHPUnderControl? QUESTION: We currently use a hand-rolled setup and configuration script and a hand-rolled continuous integration script to build and deploy our application. I am looking at formalizing this somewhat with a third party system designed for these purposes. I...
[ "php", "continuous-integration", "phpunit", "cruisecontrol", "phing" ]
9
8
2,438
3
0
2008-09-26T19:05:37.607000
2008-09-26T19:14:41.717000
141,332
141,770
Perl - Win32 - How to do a non-blocking read of a filehandle from another process?
I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might look like this: sub _read_from_client { my ($file_handle) = @_; while (my $line = <$file_handle>) { pr...
This thread on Perlmonks suggests you can make a socket nonblocking on Windows in Perl this way: ioctl($socket, 0x8004667e, 1); More details and resources in that thread
Perl - Win32 - How to do a non-blocking read of a filehandle from another process? I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might look like this: sub...
TITLE: Perl - Win32 - How to do a non-blocking read of a filehandle from another process? QUESTION: I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might l...
[ "perl", "winapi", "file", "asynchronous" ]
2
5
2,660
2
0
2008-09-26T19:08:30.797000
2008-09-26T20:29:29.853000
141,337
141,380
Should I store entire objects, or pointers to objects in containers?
Designing a new system from scratch. I'll be using the STL to store lists and maps of certain long-live objects. Question: Should I ensure my objects have copy constructors and store copies of objects within my STL containers, or is it generally better to manage the life & scope myself and just store the pointers to th...
Since people are chiming in on the efficency of using pointers. If you're considering using a std::vector and if updates are few and you often iterate over your collection and it's a non polymorphic type storing object "copies" will be more efficent since you'll get better locality of reference. Otoh, if updates are co...
Should I store entire objects, or pointers to objects in containers? Designing a new system from scratch. I'll be using the STL to store lists and maps of certain long-live objects. Question: Should I ensure my objects have copy constructors and store copies of objects within my STL containers, or is it generally bette...
TITLE: Should I store entire objects, or pointers to objects in containers? QUESTION: Designing a new system from scratch. I'll be using the STL to store lists and maps of certain long-live objects. Question: Should I ensure my objects have copy constructors and store copies of objects within my STL containers, or is ...
[ "c++", "stl", "pointers" ]
169
68
66,344
10
0
2008-09-26T19:10:38.280000
2008-09-26T19:18:20.930000
141,348
141,504
How to parse a time into a Date object from user input in JavaScript?
I am working on a form widget for users to enter a time of day into a text input (for a calendar application). Using JavaScript (we are using jQuery FWIW), I want to find the best way to parse the text that the user enters into a JavaScript Date() object so I can easily perform comparisons and other things on it. I tri...
A quick solution which works on the input that you've specified: function parseTime( t ) { var d = new Date(); var time = t.match( /(\d+)(?::(\d\d))?\s*(p?)/ ); d.setHours( parseInt( time[1]) + (time[3]? 12: 0) ); d.setMinutes( parseInt( time[2]) || 0 ); return d; } var tests = [ '1:00 pm','1:00 p.m.','1:00 p...
How to parse a time into a Date object from user input in JavaScript? I am working on a form widget for users to enter a time of day into a text input (for a calendar application). Using JavaScript (we are using jQuery FWIW), I want to find the best way to parse the text that the user enters into a JavaScript Date() ob...
TITLE: How to parse a time into a Date object from user input in JavaScript? QUESTION: I am working on a form widget for users to enter a time of day into a text input (for a calendar application). Using JavaScript (we are using jQuery FWIW), I want to find the best way to parse the text that the user enters into a Ja...
[ "javascript", "datetime", "parsing", "date", "time" ]
79
78
81,691
24
0
2008-09-26T19:13:02.237000
2008-09-26T19:44:31.240000
141,353
141,925
Team Foundation Server - Use API to Sync to SVN
Has anyone out there used TFS's API to synchronize different types of repositories? I have a SVN repo that I want to sync with a TFS repo. More accurately, I just want to take everything latest from SVN occasionally (nightly) and dump it out to TFS as the latest version. Any advice?
The people who run CodePlex created a bridge between TFS and SVN. It's called SvnBridge. They have 2 versions of the app. One version runs in IIS, and the other version is a client. You might be able to talk to the project and see if you can do what you want. I believe that the actual flow right now is SVN to TFS, but ...
Team Foundation Server - Use API to Sync to SVN Has anyone out there used TFS's API to synchronize different types of repositories? I have a SVN repo that I want to sync with a TFS repo. More accurately, I just want to take everything latest from SVN occasionally (nightly) and dump it out to TFS as the latest version. ...
TITLE: Team Foundation Server - Use API to Sync to SVN QUESTION: Has anyone out there used TFS's API to synchronize different types of repositories? I have a SVN repo that I want to sync with a TFS repo. More accurately, I just want to take everything latest from SVN occasionally (nightly) and dump it out to TFS as th...
[ "svn", "tfs", "version-control", "synchronization" ]
3
2
2,169
1
0
2008-09-26T19:13:33.843000
2008-09-26T20:55:19.883000
141,370
143,611
INotifyPropertyChanged property name - hardcode vs reflection?
What is the best way to specify a property name when using INotifyPropertyChanged? Most examples hardcode the property name as an argument on the PropertyChanged Event. I was thinking about using MethodBase.GetCurrentMethod.Name.Substring(4) but am a little uneasy about the reflection overhead.
Don't forget one thing: PropertyChanged event is mainly consumed by components that will use reflection to get the value of the named property. The most obvious example is databinding. When you fire PropertyChanged event, passing the name of the property as a parameter, you should know that the subscriber of this event...
INotifyPropertyChanged property name - hardcode vs reflection? What is the best way to specify a property name when using INotifyPropertyChanged? Most examples hardcode the property name as an argument on the PropertyChanged Event. I was thinking about using MethodBase.GetCurrentMethod.Name.Substring(4) but am a little...
TITLE: INotifyPropertyChanged property name - hardcode vs reflection? QUESTION: What is the best way to specify a property name when using INotifyPropertyChanged? Most examples hardcode the property name as an argument on the PropertyChanged Event. I was thinking about using MethodBase.GetCurrentMethod.Name.Substring(...
[ ".net", "wpf", "reflection" ]
42
45
22,405
16
0
2008-09-26T19:15:43.307000
2008-09-27T13:02:23.943000
141,372
141,824
How to emulate Emacs’ transpose-words in Vim?
Emacs has a useful transpose-words command which lets one exchange the word before the cursor with the word after the cursor, preserving punctuation. For example, ‘ stack |overflow ’ + M-t = ‘ overflow stack| ’ (‘ | ’ is the cursor position). | becomes. Is it possible to emulate it in Vim? I know I can use dwwP, but it...
These are from my.vimrc and work well for me. " swap two words:vnoremap `.``gvP``P " Swap word with next word nmap gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/ *N*
How to emulate Emacs’ transpose-words in Vim? Emacs has a useful transpose-words command which lets one exchange the word before the cursor with the word after the cursor, preserving punctuation. For example, ‘ stack |overflow ’ + M-t = ‘ overflow stack| ’ (‘ | ’ is the cursor position). | becomes. Is it possible to em...
TITLE: How to emulate Emacs’ transpose-words in Vim? QUESTION: Emacs has a useful transpose-words command which lets one exchange the word before the cursor with the word after the cursor, preserving punctuation. For example, ‘ stack |overflow ’ + M-t = ‘ overflow stack| ’ (‘ | ’ is the cursor position). | becomes. Is...
[ "vim", "emacs", "editor", "usability" ]
16
7
3,582
6
0
2008-09-26T19:16:17.283000
2008-09-26T20:38:07.773000
141,405
141,421
Yahoo GeoPlanet & XPathNavigator C#
I am returning XML data from the Yahoo GeoPlanet web service using HttpWebRequest. I am loading the XML using XPathDocument doc = new XPathDocument(HttpWebResponse.GetResponseStream()) Next comes: XPathNavigator nav = doc.CreateNavigator(); If I do nav.Select("places"); or nav.Select("/places"); or nav.Select("//places...
I know nothing about the format of the Yahoo data but I do know that the most common misstake with C# and XPath is forgetting to add the relevant namespaces to your "NamespaceManager" have a look here http://mydotnet.wordpress.com/2008/05/29/worlds-smallest-xml-xpath-tutorial/
Yahoo GeoPlanet & XPathNavigator C# I am returning XML data from the Yahoo GeoPlanet web service using HttpWebRequest. I am loading the XML using XPathDocument doc = new XPathDocument(HttpWebResponse.GetResponseStream()) Next comes: XPathNavigator nav = doc.CreateNavigator(); If I do nav.Select("places"); or nav.Select...
TITLE: Yahoo GeoPlanet & XPathNavigator C# QUESTION: I am returning XML data from the Yahoo GeoPlanet web service using HttpWebRequest. I am loading the XML using XPathDocument doc = new XPathDocument(HttpWebResponse.GetResponseStream()) Next comes: XPathNavigator nav = doc.CreateNavigator(); If I do nav.Select("place...
[ "c#", "web-services", "xpath", "yahoo" ]
0
2
520
1
0
2008-09-26T19:24:30.523000
2008-09-26T19:27:49.050000
141,411
142,190
Tomcat 6.0.18 service will not start on a windows server
I installed Tomcat 6.0.18 on a windows server 2003 box and it will not start as a service. I'm running it with jdk 1.6.0_07. It runs when I start it with tomcat6.exe. I got a vague error in the System Event Log on Windows. The Apache Tomcat 6 service terminated with service-specific error 0 (0x0).
I'll bite it:-) Tomcat Service on windows is dependent on the MS C Runtime library msvcr71.dll. As long as it is in the path, the service will start just fine. Just to prevent your other windows to be forced to use this version of the runtime library, you might want to copy the DLL to just the tomcat bin path instead o...
Tomcat 6.0.18 service will not start on a windows server I installed Tomcat 6.0.18 on a windows server 2003 box and it will not start as a service. I'm running it with jdk 1.6.0_07. It runs when I start it with tomcat6.exe. I got a vague error in the System Event Log on Windows. The Apache Tomcat 6 service terminated w...
TITLE: Tomcat 6.0.18 service will not start on a windows server QUESTION: I installed Tomcat 6.0.18 on a windows server 2003 box and it will not start as a service. I'm running it with jdk 1.6.0_07. It runs when I start it with tomcat6.exe. I got a vague error in the System Event Log on Windows. The Apache Tomcat 6 se...
[ "java", "tomcat", "windows-server-2003" ]
5
9
40,749
6
0
2008-09-26T19:25:25.840000
2008-09-26T21:48:55.480000
141,422
142,436
How can a transform a polynomial to another coordinate system?
Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n' Ax^(n-1) + Bx^(n-2) +... + Z I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here's the catch. I've done this work in one coordinate system we'l...
The problem statement is slightly unclear, so first I will clarify my own interpretation of it: You have a polynomial function f(x) = C n x n + C n-1 x n-1 +... + C 0 [I changed A, B,... Z into C n, C n-1,..., C 0 to more easily work with linear algebra below.] Then you also have a transformation such as: z = ax + b th...
How can a transform a polynomial to another coordinate system? Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n' Ax^(n-1) + Bx^(n-2) +... + Z I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here...
TITLE: How can a transform a polynomial to another coordinate system? QUESTION: Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n' Ax^(n-1) + Bx^(n-2) +... + Z I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomi...
[ "algorithm", "language-agnostic", "math", "geometry", "transform" ]
8
7
5,719
5
0
2008-09-26T19:27:52.623000
2008-09-26T23:03:45.880000
141,423
141,468
If I register for an event in c# while it's dispatching, am I guaranteed to not get called again during that dispatch?
In C#, I find myself occasionally wanting to register a method for an event in the middle of a dispatch of that same event. For example, if I have a class that transitions states based on successive dispatches of the same event, I might want the first state's handler to unregister itself and register the second handler...
Yes, it's guaranteed. From the unified C# 3.0 spec, section 15.1: However, when two non-null delegate instances are combined, their invocation lists are concatenated—in the order left operand then right operand—to form a new invocation list, which contains two or more entries. Note the "new invocation list". And again ...
If I register for an event in c# while it's dispatching, am I guaranteed to not get called again during that dispatch? In C#, I find myself occasionally wanting to register a method for an event in the middle of a dispatch of that same event. For example, if I have a class that transitions states based on successive di...
TITLE: If I register for an event in c# while it's dispatching, am I guaranteed to not get called again during that dispatch? QUESTION: In C#, I find myself occasionally wanting to register a method for an event in the middle of a dispatch of that same event. For example, if I have a class that transitions states base...
[ "c#", "events", "mono" ]
5
9
1,314
1
0
2008-09-26T19:28:06.193000
2008-09-26T19:36:29.620000
141,428
141,671
Is there a standard implementation for Electronic Signatures on fill-in-form web applications?
I have a client who is interested in adding in electronic signature support to a long (40 question) seller application form. I'm a little stumped on whether there is an existing standard or process that's out there that folks in the financial world would expect to see? I could certainly add in a system where we generat...
What purpose is the signature trying to fill? Are you trying to verify that the form actually came from a specific seller? (If so, you would have to know their public key ahead of time.) Are you trying to hold the seller accountable for their answers at a later date? (In that case, you might need some kind of third-par...
Is there a standard implementation for Electronic Signatures on fill-in-form web applications? I have a client who is interested in adding in electronic signature support to a long (40 question) seller application form. I'm a little stumped on whether there is an existing standard or process that's out there that folks...
TITLE: Is there a standard implementation for Electronic Signatures on fill-in-form web applications? QUESTION: I have a client who is interested in adding in electronic signature support to a long (40 question) seller application form. I'm a little stumped on whether there is an existing standard or process that's ou...
[ "cryptography", "standards", "pgp", "electronic-signature" ]
3
0
626
3
0
2008-09-26T19:29:01.480000
2008-09-26T20:12:01.860000
141,432
142,162
How can I create a status bar item with Cocoa and Python (PyObjC)?
I have created a brand new project in XCode and have the following in my AppDelegate.py file: from Foundation import * from AppKit import * class MyApplicationAppDelegate(NSObject): def applicationDidFinishLaunching_(self, sender): NSLog("Application did finish launching.") statusItem = NSStatusBar.systemStatusBar()....
I had to do this to make it work: Open MainMenu.xib. Make sure the class of the app delegate is MyApplicationAppDelegate. I'm not sure if you will have to do this, but I did. It was wrong and so the app delegate never got called in the first place. Add statusItem.retain() because it gets autoreleased right away.
How can I create a status bar item with Cocoa and Python (PyObjC)? I have created a brand new project in XCode and have the following in my AppDelegate.py file: from Foundation import * from AppKit import * class MyApplicationAppDelegate(NSObject): def applicationDidFinishLaunching_(self, sender): NSLog("Application d...
TITLE: How can I create a status bar item with Cocoa and Python (PyObjC)? QUESTION: I have created a brand new project in XCode and have the following in my AppDelegate.py file: from Foundation import * from AppKit import * class MyApplicationAppDelegate(NSObject): def applicationDidFinishLaunching_(self, sender): NS...
[ "python", "cocoa", "pyobjc" ]
9
5
2,758
2
0
2008-09-26T19:29:48.343000
2008-09-26T21:41:54.733000
141,435
141,607
Advantages of using MSBuild or NAnt versus running DevEnv.exe from command-line
Can anyone explain what advantages there are to using a tool like MSBuild (or NAnt) to build a collection of projects versus running DevEnv.exe from the command-line? A colleague I had worked with in the past had explained that (at least with older versions of Visual Studio) using DevEnv.exe was much slower than the ot...
One reason is because there's much more to building a product than just compiling it. Tasks such as creating installs, updating version numbers, creating escrows, distributing the final packages, etc. can be much easier because of what these tools (and their extensions) provide. While you could do all this with regular...
Advantages of using MSBuild or NAnt versus running DevEnv.exe from command-line Can anyone explain what advantages there are to using a tool like MSBuild (or NAnt) to build a collection of projects versus running DevEnv.exe from the command-line? A colleague I had worked with in the past had explained that (at least wi...
TITLE: Advantages of using MSBuild or NAnt versus running DevEnv.exe from command-line QUESTION: Can anyone explain what advantages there are to using a tool like MSBuild (or NAnt) to build a collection of projects versus running DevEnv.exe from the command-line? A colleague I had worked with in the past had explained...
[ "msbuild", "build-process", "nant" ]
20
16
9,396
6
0
2008-09-26T19:30:46.640000
2008-09-26T19:59:36.913000
141,449
141,451
How do I wrap a string in a file in Python?
How do I create a file-like object (same duck type as File) with the contents of a string?
For Python 2.x, use the StringIO module. For example: >>> from cStringIO import StringIO >>> f = StringIO('foo') >>> f.read() 'foo' I use cStringIO (which is faster), but note that it doesn't accept Unicode strings that cannot be encoded as plain ASCII strings. (You can switch to StringIO by changing "from cStringIO" t...
How do I wrap a string in a file in Python? How do I create a file-like object (same duck type as File) with the contents of a string?
TITLE: How do I wrap a string in a file in Python? QUESTION: How do I create a file-like object (same duck type as File) with the contents of a string? ANSWER: For Python 2.x, use the StringIO module. For example: >>> from cStringIO import StringIO >>> f = StringIO('foo') >>> f.read() 'foo' I use cStringIO (which is ...
[ "python", "string", "file", "stringio" ]
136
163
86,814
4
0
2008-09-26T19:33:55.570000
2008-09-26T19:34:04.977000
141,452
141,492
How to purge expired items from cache?
I've got a nice little class built that acts as a cache. Each item has an expiration TimeSpan or DateTime. Each time an attempt to access an item in the cache is made, the item's expiration is checked, and if it's expired, the item is removed from the cache and nothing is returned. That's great for objects that are acc...
In my experience, maintaining a custom caching mechanism became more trouble than it was worth. There are several libraries out there that have already solved these problems. I would suggest using one of them. A popular one in.Net is the Enterprise Library, although I have limited experience with its caching abilities....
How to purge expired items from cache? I've got a nice little class built that acts as a cache. Each item has an expiration TimeSpan or DateTime. Each time an attempt to access an item in the cache is made, the item's expiration is checked, and if it's expired, the item is removed from the cache and nothing is returned...
TITLE: How to purge expired items from cache? QUESTION: I've got a nice little class built that acts as a cache. Each item has an expiration TimeSpan or DateTime. Each time an attempt to access an item in the cache is made, the item's expiration is checked, and if it's expired, the item is removed from the cache and n...
[ "c#", ".net", "caching" ]
3
1
2,104
5
0
2008-09-26T19:34:09.050000
2008-09-26T19:41:41.137000
141,454
1,724,409
jdbc driver for Microsoft SQL Server CE(Compact Edition) 3.5
I want to be able to explore the contents of a DB for this version of the DB. I was thinking of using the Squirrel DB client (which needs a JDBC driver). Therefore, I'm looking for a JDBC type 4 driver for SQL SERVER 3.5. Can somone point me to a FREE OR open source or trial ware? If no JDBC driver, how do MS developer...
There is a free program called SQLCeEditor that does it. I'd still like a JDBC driver though since that would make it easy to use with Eclipse and Java.
jdbc driver for Microsoft SQL Server CE(Compact Edition) 3.5 I want to be able to explore the contents of a DB for this version of the DB. I was thinking of using the Squirrel DB client (which needs a JDBC driver). Therefore, I'm looking for a JDBC type 4 driver for SQL SERVER 3.5. Can somone point me to a FREE OR open...
TITLE: jdbc driver for Microsoft SQL Server CE(Compact Edition) 3.5 QUESTION: I want to be able to explore the contents of a DB for this version of the DB. I was thinking of using the Squirrel DB client (which needs a JDBC driver). Therefore, I'm looking for a JDBC type 4 driver for SQL SERVER 3.5. Can somone point me...
[ "java", "sql-server", "database", "jdbc", "sql-server-ce" ]
5
1
11,619
7
0
2008-09-26T19:34:15.663000
2009-11-12T18:36:46.167000
141,467
141,528
Recursive List Flattening
I could probably write this myself, but the specific way I'm trying to accomplish it is throwing me off. I'm trying to write a generic extension method similar to the others introduced in.NET 3.5 that will take a nested IEnumerable of IEnumerables (and so on) and flatten it into one IEnumerable. Anyone have any ideas? ...
Hmm... I'm not sure exactly what you want here, but here's a "one level" option: public static IEnumerable Flatten (this IEnumerable sequences) where TSequence: IEnumerable { foreach (TSequence sequence in sequences) { foreach(TElement element in sequence) { yield return element; } } } If that's not what you want, coul...
Recursive List Flattening I could probably write this myself, but the specific way I'm trying to accomplish it is throwing me off. I'm trying to write a generic extension method similar to the others introduced in.NET 3.5 that will take a nested IEnumerable of IEnumerables (and so on) and flatten it into one IEnumerabl...
TITLE: Recursive List Flattening QUESTION: I could probably write this myself, but the specific way I'm trying to accomplish it is throwing me off. I'm trying to write a generic extension method similar to the others introduced in.NET 3.5 that will take a nested IEnumerable of IEnumerables (and so on) and flatten it i...
[ "c#", ".net", "recursion" ]
42
20
28,488
13
0
2008-09-26T19:36:20.200000
2008-09-26T19:47:25.600000
141,487
141,554
Is there an easy way to populate SlugField from CharField?
class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin.
for Admin in Django 1.0 and up, you'd need to use prepopulated_fields = {'slug': ('title',), } in your admin.py Your key in the prepopulated_fields dictionary is the field you want filled, and the value is a tuple of fields you want concatenated. Outside of admin, you can use the slugify function in your views. In temp...
Is there an easy way to populate SlugField from CharField? class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin.
TITLE: Is there an easy way to populate SlugField from CharField? QUESTION: class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin. ANSWER: for Admin in D...
[ "python", "django", "slug" ]
44
74
28,348
8
0
2008-09-26T19:40:57.660000
2008-09-26T19:51:46.527000
141,498
285,538
What open source C++ static analysis tools are available?
Java has some very good open source static analysis tools such as FindBugs, Checkstyle and PMD. Those tools are easy to use, very helpful, runs on multiple operating systems and free. Commercial C++ static analysis products are available. Although having such products are great, the cost is just way too much for studen...
Oink is a tool built on top of the Elsa C++ front-end. Mozilla's Pork is a fork of Elsa/Oink. See: http://danielwilkerson.com/oink/index.html
What open source C++ static analysis tools are available? Java has some very good open source static analysis tools such as FindBugs, Checkstyle and PMD. Those tools are easy to use, very helpful, runs on multiple operating systems and free. Commercial C++ static analysis products are available. Although having such pr...
TITLE: What open source C++ static analysis tools are available? QUESTION: Java has some very good open source static analysis tools such as FindBugs, Checkstyle and PMD. Those tools are easy to use, very helpful, runs on multiple operating systems and free. Commercial C++ static analysis products are available. Altho...
[ "c++", "static-analysis" ]
312
20
110,508
14
0
2008-09-26T19:43:19.887000
2008-11-12T22:04:12.717000
141,499
141,594
Any Java libraries out there that validate SQL syntax?
I'm not sure if this even exists or not, so I figured I would tap the wisdom of others.. I was wondering if there are any Java libraries out there that can be used to validate a SQL query's syntax. I know that there are many deviations from common SQL spec, so it would probably only work against something like SQL:2006...
I don't think there are such libraries. The SQL syntax has too many derivatives. A possible solution would be to use parts of an open source pure Java DBMS like SmallSQL. In this project you can create an instance of the SQLParser. The needed references to the connection can be removed very easily.
Any Java libraries out there that validate SQL syntax? I'm not sure if this even exists or not, so I figured I would tap the wisdom of others.. I was wondering if there are any Java libraries out there that can be used to validate a SQL query's syntax. I know that there are many deviations from common SQL spec, so it w...
TITLE: Any Java libraries out there that validate SQL syntax? QUESTION: I'm not sure if this even exists or not, so I figured I would tap the wisdom of others.. I was wondering if there are any Java libraries out there that can be used to validate a SQL query's syntax. I know that there are many deviations from common...
[ "java", "sql", "syntax" ]
26
4
34,891
7
0
2008-09-26T19:43:29.697000
2008-09-26T19:57:54.517000
141,500
141,527
Visual Studio 2008 source control for small teams
I work on a small web team where I am the only.NET developer currently using Visual Studio 2008 Professional to build and maintain a few web applications. I am about to start training another member of our team so we purchased him a copy of Visual Studio 2008 Professional. I've looked into Visual Source Safe, but I'm d...
Subversion has good integration with Visual Studio 2008 through VisualSVN and Ankh. SourceSafe is dangerous. You're right that a filesharing-based SCM is a bad idea, and Microsoft themselves have downplayed it and replaced it with a new SCM that comes with the Team edition of Visual Studio.
Visual Studio 2008 source control for small teams I work on a small web team where I am the only.NET developer currently using Visual Studio 2008 Professional to build and maintain a few web applications. I am about to start training another member of our team so we purchased him a copy of Visual Studio 2008 Profession...
TITLE: Visual Studio 2008 source control for small teams QUESTION: I work on a small web team where I am the only.NET developer currently using Visual Studio 2008 Professional to build and maintain a few web applications. I am about to start training another member of our team so we purchased him a copy of Visual Stud...
[ ".net", "windows", "visual-studio", "visual-studio-2008", "version-control" ]
15
27
16,617
12
0
2008-09-26T19:43:48.933000
2008-09-26T19:47:23.900000
141,508
141,514
Does anyone know when the ASP.NET MVC will be fully released?
When do you think we can expect the full release version of ASP.NET MVC?
EDIT (16/Jul/2009) Updating to ensure this page contains the most recent details. ASP.NET MVC is now fully released http://www.asp.net/mvc/. EDIT (28/Jan/2009) ASP.NET MVC 1.0 RC Now Available.... final next month ( From ScottGu's Blog ) Today’s RC is the last public release of ASP.NET MVC that we’ll ship prior to the ...
Does anyone know when the ASP.NET MVC will be fully released? When do you think we can expect the full release version of ASP.NET MVC?
TITLE: Does anyone know when the ASP.NET MVC will be fully released? QUESTION: When do you think we can expect the full release version of ASP.NET MVC? ANSWER: EDIT (16/Jul/2009) Updating to ensure this page contains the most recent details. ASP.NET MVC is now fully released http://www.asp.net/mvc/. EDIT (28/Jan/2009...
[ ".net", "asp.net", "asp.net-mvc" ]
2
7
267
2
0
2008-09-26T19:45:29.960000
2008-09-26T19:46:06.137000
141,513
143,207
Which php variable debugging function do you use? var_dump, print_r, var_export, other?
I personally use var_dump, but lots of people like print_r. What does everyone use? Pros and Cons? Does someone have a special home brew function of their own?
I always use the Xdebug extended var_dump. It gives out a lot of verbose output. See: http://xdebug.org/docs/display for more details.
Which php variable debugging function do you use? var_dump, print_r, var_export, other? I personally use var_dump, but lots of people like print_r. What does everyone use? Pros and Cons? Does someone have a special home brew function of their own?
TITLE: Which php variable debugging function do you use? var_dump, print_r, var_export, other? QUESTION: I personally use var_dump, but lots of people like print_r. What does everyone use? Pros and Cons? Does someone have a special home brew function of their own? ANSWER: I always use the Xdebug extended var_dump. It...
[ "php", "debugging" ]
4
4
11,406
9
0
2008-09-26T19:46:00.800000
2008-09-27T08:04:01.243000
141,525
141,873
What are bitwise shift (bit-shift) operators and how do they work?
I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)... At a core level, what does bit-shifting ( <<, >>, >>> ) do, what problems can it help solve, and what gotchas lurk around the bend? In other words, an absolute beginner's guide ...
The bit shifting operators do exactly what their name implies. They shift bits. Here's a brief (or not-so-brief) introduction to the different shift operators. The Operators >> is the arithmetic (or signed) right shift operator. >>> is the logical (or unsigned) right shift operator. << is the left shift operator, and m...
What are bitwise shift (bit-shift) operators and how do they work? I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)... At a core level, what does bit-shifting ( <<, >>, >>> ) do, what problems can it help solve, and what gotchas ...
TITLE: What are bitwise shift (bit-shift) operators and how do they work? QUESTION: I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)... At a core level, what does bit-shifting ( <<, >>, >>> ) do, what problems can it help solve,...
[ "language-agnostic", "bit-manipulation", "operators", "bit-shift", "binary-operators" ]
1,550
1,887
877,480
11
0
2008-09-26T19:47:15.367000
2008-09-26T20:46:39.813000
141,534
142,640
MVC n-level route building
I want to create a productcatalog with N-Level Categories e.g. /Catalog/Category1/Category2/../SubCategoryN/Product/{ProductActions}/{ID} And at the same time be able to /Catalog/Category1/Category2/../SubCategoryN/{CategoryActions} Is that possible and if Yes how?
Not with the default Route class, but you can make your own route class by deriving from RouteBase. You basically end up having to do all the work yourself of parsing the URL, but you can use the source from Route to help you get started.
MVC n-level route building I want to create a productcatalog with N-Level Categories e.g. /Catalog/Category1/Category2/../SubCategoryN/Product/{ProductActions}/{ID} And at the same time be able to /Catalog/Category1/Category2/../SubCategoryN/{CategoryActions} Is that possible and if Yes how?
TITLE: MVC n-level route building QUESTION: I want to create a productcatalog with N-Level Categories e.g. /Catalog/Category1/Category2/../SubCategoryN/Product/{ProductActions}/{ID} And at the same time be able to /Catalog/Category1/Category2/../SubCategoryN/{CategoryActions} Is that possible and if Yes how? ANSWER...
[ "asp.net-mvc", "model-view-controller", "mvcroutehandler" ]
0
1
283
1
0
2008-09-26T19:48:09.517000
2008-09-27T00:43:57.433000
141,545
141,777
How to overload __init__ method based on argument type?
Let's say I have a class that has a member called data which is a list. I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list. What's your technique for doing this? Do you just check the type by looking at __class__? Is there some tri...
A much neater way to get 'alternate constructors' is to use classmethods. For instance: >>> class MyData:... def __init__(self, data):... "Initialize MyData from a sequence"... self.data = data...... @classmethod... def fromfilename(cls, filename):... "Initialize MyData from a file"... data = open(filename).readlines()...
How to overload __init__ method based on argument type? Let's say I have a class that has a member called data which is a list. I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list. What's your technique for doing this? Do you just c...
TITLE: How to overload __init__ method based on argument type? QUESTION: Let's say I have a class that has a member called data which is a list. I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list. What's your technique for doing t...
[ "python", "constructor", "operator-overloading" ]
436
565
263,194
10
0
2008-09-26T19:49:46.640000
2008-09-26T20:30:15.857000
141,556
141,582
What are the pitfalls of inserting millions of records into SQL Server from flat file?
I am about to start on a journey writing a windows forms application that will open a txt file that is pipe delimited and about 230 mb in size. This app will then insert this data into a sql server 2005 database (obviously this needs to happen swiftly). I am using c# 3.0 and.net 3.5 for this project. I am not asking fo...
Do you have to write a winforms app? It might be much easier and faster to use SSIS. There are some built-in tasks available especially Bulk Insert task. Also, worth checking Flat File Bulk Import methods speed comparison in SQL Server 2005. Update: If you are new to SSIS, check out some of these sites to get you on fa...
What are the pitfalls of inserting millions of records into SQL Server from flat file? I am about to start on a journey writing a windows forms application that will open a txt file that is pipe delimited and about 230 mb in size. This app will then insert this data into a sql server 2005 database (obviously this needs...
TITLE: What are the pitfalls of inserting millions of records into SQL Server from flat file? QUESTION: I am about to start on a journey writing a windows forms application that will open a txt file that is pipe delimited and about 230 mb in size. This app will then insert this data into a sql server 2005 database (ob...
[ "c#", "sql-server", "sql-server-2005", "ssis", "bulkinsert" ]
4
16
2,868
9
0
2008-09-26T19:52:04.203000
2008-09-26T19:56:14.940000
141,560
149,610
Should try...catch go inside or outside a loop?
I have a loop that looks something like this: for (int i = 0; i < max; i++) { String myString =...; float myNum = Float.parseFloat(myString); myFloats[i] = myNum; } This is the main content of a method whose sole purpose is to return the array of floats. I want this method to return null if there is an error, so I put ...
All right, after Jeffrey L Whitledge said that there was no performance difference (as of 1997), I went and tested it. I ran this small benchmark: public class Main { private static final int NUM_TESTS = 100; private static int ITERATIONS = 1000000; // time counters private static long inTime = 0L; private static long...
Should try...catch go inside or outside a loop? I have a loop that looks something like this: for (int i = 0; i < max; i++) { String myString =...; float myNum = Float.parseFloat(myString); myFloats[i] = myNum; } This is the main content of a method whose sole purpose is to return the array of floats. I want this metho...
TITLE: Should try...catch go inside or outside a loop? QUESTION: I have a loop that looks something like this: for (int i = 0; i < max; i++) { String myString =...; float myNum = Float.parseFloat(myString); myFloats[i] = myNum; } This is the main content of a method whose sole purpose is to return the array of floats....
[ "java", "performance", "loops", "try-catch" ]
211
49
156,983
21
0
2008-09-26T19:52:30.143000
2008-09-29T16:55:35.973000
141,562
141,574
SQL to find the number of distinct values in a column
I can select all the distinct values in a column in the following ways: SELECT DISTINCT column_name FROM table_name; SELECT column_name FROM table_name GROUP BY column_name; But how do I get the row count from that query? Is a subquery required?
You can use the DISTINCT keyword within the COUNT aggregate function: SELECT COUNT(DISTINCT column_name) AS some_alias FROM table_name This will count only the distinct values for that column.
SQL to find the number of distinct values in a column I can select all the distinct values in a column in the following ways: SELECT DISTINCT column_name FROM table_name; SELECT column_name FROM table_name GROUP BY column_name; But how do I get the row count from that query? Is a subquery required?
TITLE: SQL to find the number of distinct values in a column QUESTION: I can select all the distinct values in a column in the following ways: SELECT DISTINCT column_name FROM table_name; SELECT column_name FROM table_name GROUP BY column_name; But how do I get the row count from that query? Is a subquery required? A...
[ "sql", "distinct" ]
440
742
773,506
14
0
2008-09-26T19:52:48.677000
2008-09-26T19:54:59.217000
141,598
141,687
Storing Relational Data in XML
I'm wondering what the best practices are for storing a relational data structure in XML. Particulary, I am wondering about best practices for enforcing node order. For example, say I have three objects: School, Course, and Student, which are defined as follows: class School { List Courses; List Students; } class Cour...
Don't think in SQL or relational when working with XML, because there are no order constraints. You can however query using XPath to any portion of the XML document at any time. You want the courses first, then "//Courses/Course". You want the students enrollments next, then "//Students/Student/EnrolledIn/Course". The ...
Storing Relational Data in XML I'm wondering what the best practices are for storing a relational data structure in XML. Particulary, I am wondering about best practices for enforcing node order. For example, say I have three objects: School, Course, and Student, which are defined as follows: class School { List Course...
TITLE: Storing Relational Data in XML QUESTION: I'm wondering what the best practices are for storing a relational data structure in XML. Particulary, I am wondering about best practices for enforcing node order. For example, say I have three objects: School, Course, and Student, which are defined as follows: class Sc...
[ "c#", "xml" ]
1
2
1,656
8
0
2008-09-26T19:58:52.157000
2008-09-26T20:14:55.567000
141,599
141,619
How do you get a list of changes from a Subversion repository by date range?
What I would like is be able to generate a simple report that is the output of svn log for a certain date range. Specifically, all the changes since 'yesterday'. Is there an easy way to accomplish this in Subversion besides grep-ing the svn log output for the timestamp? Example: svn -v log -d 2008-9-23:2008-9:24 > repo...
Very first hit by google for "svn log date range": http://svn.haxx.se/users/archive-2006-08/0737.shtml So svn log -r {2008-09-19}:{2008-09-26} will get all changes for the past week, including today. And if you want to generate reports for a repo, there's a solution: Statsvn. HTH
How do you get a list of changes from a Subversion repository by date range? What I would like is be able to generate a simple report that is the output of svn log for a certain date range. Specifically, all the changes since 'yesterday'. Is there an easy way to accomplish this in Subversion besides grep-ing the svn lo...
TITLE: How do you get a list of changes from a Subversion repository by date range? QUESTION: What I would like is be able to generate a simple report that is the output of svn log for a certain date range. Specifically, all the changes since 'yesterday'. Is there an easy way to accomplish this in Subversion besides g...
[ "svn" ]
57
66
69,147
5
0
2008-09-26T19:58:52.907000
2008-09-26T20:02:19.933000
141,602
141,635
LINQ Syntext Sequence
The following SQL SELECT * FROM customers converted to this in LINQ var customers = from c in customers select c; Is their any good reasones why the from and select is swaped? The only logical reason I can think of is for intellisens? For the intellesens to get resolved, it needs to know what it is querying (scope)? An...
Select is swapped because it represents the order of the method calls that the LINQ query syntax is representing. This is equivalent to customers.Select(c=>c); or customers.Select(); SQL gets away with it, by processing the entire statement before proceeding, but in order to get things like intellisense and to figure o...
LINQ Syntext Sequence The following SQL SELECT * FROM customers converted to this in LINQ var customers = from c in customers select c; Is their any good reasones why the from and select is swaped? The only logical reason I can think of is for intellisens? For the intellesens to get resolved, it needs to know what it i...
TITLE: LINQ Syntext Sequence QUESTION: The following SQL SELECT * FROM customers converted to this in LINQ var customers = from c in customers select c; Is their any good reasones why the from and select is swaped? The only logical reason I can think of is for intellisens? For the intellesens to get resolved, it needs...
[ "linq", "linq-to-sql" ]
2
9
153
1
0
2008-09-26T19:59:16.900000
2008-09-26T20:05:26.027000
141,606
141,616
How can I hide content in a HTML file from search engines?
Say that I write an article or document about a certain topic, but the content is meant for readers with certain prior knowledge about the topic. To help people who don't have the "required" background information, I would like to add a note to the top of the page with an explanation and possibly a link to some referen...
You can build that portion of the content dynamically using Javascript. For example: Rest of the content here. If you're really stuck, you can just go old school and reference an image that has your text as part of it. It's not particularly "accessibility-friendly" though.
How can I hide content in a HTML file from search engines? Say that I write an article or document about a certain topic, but the content is meant for readers with certain prior knowledge about the topic. To help people who don't have the "required" background information, I would like to add a note to the top of the p...
TITLE: How can I hide content in a HTML file from search engines? QUESTION: Say that I write an article or document about a certain topic, but the content is meant for readers with certain prior knowledge about the topic. To help people who don't have the "required" background information, I would like to add a note t...
[ "javascript", "search-engine" ]
3
4
3,301
8
0
2008-09-26T19:59:35.183000
2008-09-26T20:01:19.017000
141,612
141,651
Database structure to track change history
I'm working on database designs for a project management system as personal project and I've hit a snag. I want to implement a ticket system and I want the tickets to look like the tickets in Trac. What structure would I use to replicate this system? (I have not had any success installing trac on any of my systems so I...
I have implemented pure record change data using a "thin" design: RecordID Table Column OldValue NewValue -------- ----- ------ -------- -------- You may not want to use "Table" and "Column", but rather "Object" and "Property", and so forth, depending on your design. This has the advantage of flexibility and simplicity...
Database structure to track change history I'm working on database designs for a project management system as personal project and I've hit a snag. I want to implement a ticket system and I want the tickets to look like the tickets in Trac. What structure would I use to replicate this system? (I have not had any succes...
TITLE: Database structure to track change history QUESTION: I'm working on database designs for a project management system as personal project and I've hit a snag. I want to implement a ticket system and I want the tickets to look like the tickets in Trac. What structure would I use to replicate this system? (I have ...
[ "ruby-on-rails", "database-design" ]
10
19
9,401
6
0
2008-09-26T20:00:24.057000
2008-09-26T20:09:16.877000
141,620
141,721
RoR: Accessing models from with application.rb
i am working on a simple web app which has a user model and role model (among others), and an admin section that contains many controllers. i would like to use a before_filter to check that the user of the user in the session has a 'can_access_admin' flag. i have this code in the application.rb: def check_role @user = ...
just a guess but it seems that your session[:user] is just storing the id, you need to do: @user = User.find(session[:user]) or something along those lines to fetch the user from the database (along with its associations). It's good to do the above in a before filter too.
RoR: Accessing models from with application.rb i am working on a simple web app which has a user model and role model (among others), and an admin section that contains many controllers. i would like to use a before_filter to check that the user of the user in the session has a 'can_access_admin' flag. i have this code...
TITLE: RoR: Accessing models from with application.rb QUESTION: i am working on a simple web app which has a user model and role model (among others), and an admin section that contains many controllers. i would like to use a before_filter to check that the user of the user in the session has a 'can_access_admin' flag...
[ "ruby-on-rails", "ruby" ]
1
6
558
3
0
2008-09-26T20:03:15.783000
2008-09-26T20:21:25.690000
141,626
144,354
How can I access PostData from WebBrowser.Navigating event handler?
I've got a windows form in Visual Studio 2008 using.NET 3.5 which has a WebBrowser control on it. I need to analyse the form's PostData in the Navigating event handler before the request is sent. Is there a way to get to it? The old win32 browser control had a Before_Navigate event which had PostData as one of its argu...
That functionality isn't exposed by the.NET WebBrowser control. Fortunately, that control is mostly a wrapper around the 'old' control. This means you can subscribe to the BeforeNavigate2 event you know and love(?) using something like the following (after adding a reference to SHDocVw to your project): Dim ie = Direct...
How can I access PostData from WebBrowser.Navigating event handler? I've got a windows form in Visual Studio 2008 using.NET 3.5 which has a WebBrowser control on it. I need to analyse the form's PostData in the Navigating event handler before the request is sent. Is there a way to get to it? The old win32 browser contr...
TITLE: How can I access PostData from WebBrowser.Navigating event handler? QUESTION: I've got a windows form in Visual Studio 2008 using.NET 3.5 which has a WebBrowser control on it. I need to analyse the form's PostData in the Navigating event handler before the request is sent. Is there a way to get to it? The old w...
[ ".net", "browser", "postdata" ]
5
6
12,502
2
0
2008-09-26T20:03:46.967000
2008-09-27T20:03:47.737000
141,641
142,060
What constitutes effective Perl training for non-Perl developers?
I've been working with Perl long enough that many of its idiosyncracies have become second nature to me. When new programmers join our group, they frequently have little to no experience with Perl, and it's usually my task to train them (to the extent necessary). I'd like to know what to focus on when training a progra...
Check out the tables of contents for my books. Both Learning Perl and Intermediate Perl are designed to teach programmers the Perl language. We cover the 80% of Perl that most people use all of the time and developed that from years and years of teaching people Perl. Each book is designed as a tutorial, and there are e...
What constitutes effective Perl training for non-Perl developers? I've been working with Perl long enough that many of its idiosyncracies have become second nature to me. When new programmers join our group, they frequently have little to no experience with Perl, and it's usually my task to train them (to the extent ne...
TITLE: What constitutes effective Perl training for non-Perl developers? QUESTION: I've been working with Perl long enough that many of its idiosyncracies have become second nature to me. When new programmers join our group, they frequently have little to no experience with Perl, and it's usually my task to train them...
[ "perl", "cpan", "timtowtdi" ]
20
20
1,061
19
0
2008-09-26T20:06:33.590000
2008-09-26T21:20:44.737000
141,642
141,710
What limitations have closures in Python compared to language X closures?
Where X is any programming language (C#, Javascript, Lisp, Perl, Ruby, Scheme, etc) which supports some flavour of closures. Some limitations are mentioned in the Closures in Python (compared to Ruby's closures), but the article is old and many limitations do not exist in modern Python any more. Seeing a code example f...
The most important limitation, currently, is that you cannot assign to an outer-scope variable. In other words, closures are read-only: >>> def outer(x):... def inner_reads():... # Will return outer's 'x'.... return x... def inner_writes(y):... # Will assign to a local 'x', not the outer 'x'... x = y... def inner_error...
What limitations have closures in Python compared to language X closures? Where X is any programming language (C#, Javascript, Lisp, Perl, Ruby, Scheme, etc) which supports some flavour of closures. Some limitations are mentioned in the Closures in Python (compared to Ruby's closures), but the article is old and many l...
TITLE: What limitations have closures in Python compared to language X closures? QUESTION: Where X is any programming language (C#, Javascript, Lisp, Perl, Ruby, Scheme, etc) which supports some flavour of closures. Some limitations are mentioned in the Closures in Python (compared to Ruby's closures), but the article...
[ "python", "closures" ]
48
45
8,714
7
0
2008-09-26T20:06:41.937000
2008-09-26T20:19:27.833000
141,650
169,031
How do you make a generic memoize function in Haskell?
I've seen the other post about this, but is there a clean way of doing this in Haskell? As a 2nd part, can it also be done without making the function monadic?
This largely follows http://www.haskell.org/haskellwiki/Memoization. You want a function of type (a -> b). If it doesn't call itself, then you can just write a simple wrapper that caches the return values. The best way to store this mapping depends on what properties of a you can exploit. Ordering is pretty much a mini...
How do you make a generic memoize function in Haskell? I've seen the other post about this, but is there a clean way of doing this in Haskell? As a 2nd part, can it also be done without making the function monadic?
TITLE: How do you make a generic memoize function in Haskell? QUESTION: I've seen the other post about this, but is there a clean way of doing this in Haskell? As a 2nd part, can it also be done without making the function monadic? ANSWER: This largely follows http://www.haskell.org/haskellwiki/Memoization. You want ...
[ "haskell", "monads", "memoization" ]
21
9
4,810
5
0
2008-09-26T20:08:49.777000
2008-10-03T21:48:27.673000
141,659
141,685
Viewing the Visual SourceSafe log inside Visual Studio
Is there any way to view the activity log for the integrate SourceSafe inside Visual Studio 2005 Pro? I'd like to be able to quickly see the results of any Get Latest Version, Check In and Checkout actions, and I can't find a way to get that information without having to open the VSS client.
The output window (View - Output) echoes a lot. If it isn't verbose enough though I don't know how one would configure that.
Viewing the Visual SourceSafe log inside Visual Studio Is there any way to view the activity log for the integrate SourceSafe inside Visual Studio 2005 Pro? I'd like to be able to quickly see the results of any Get Latest Version, Check In and Checkout actions, and I can't find a way to get that information without hav...
TITLE: Viewing the Visual SourceSafe log inside Visual Studio QUESTION: Is there any way to view the activity log for the integrate SourceSafe inside Visual Studio 2005 Pro? I'd like to be able to quickly see the results of any Get Latest Version, Check In and Checkout actions, and I can't find a way to get that infor...
[ "visual-studio", "visual-sourcesafe" ]
1
3
1,065
2
0
2008-09-26T20:10:05.767000
2008-09-26T20:14:20.887000
141,669
141,705
Polyglot Programming: Is building applications with multiple languages a good practice?
I am considering building an application that is a blend of a dynamic language (python or ruby) and compiled language and need some help getting convincing myself that this is a good idea. My thought are that I can use a dynamic language to get a lot of code written quickly, and then dropping down to a compiled languag...
I think your approach is very sensible. The way to address the downsides is to find out ahead of time how easy it is to interface the dynamic language with C or C++ before deciding whether or not to use it for your project. Also, you need to think about whether or not you want your application to be cross-platform. A d...
Polyglot Programming: Is building applications with multiple languages a good practice? I am considering building an application that is a blend of a dynamic language (python or ruby) and compiled language and need some help getting convincing myself that this is a good idea. My thought are that I can use a dynamic lan...
TITLE: Polyglot Programming: Is building applications with multiple languages a good practice? QUESTION: I am considering building an application that is a blend of a dynamic language (python or ruby) and compiled language and need some help getting convincing myself that this is a good idea. My thought are that I can...
[ "architecture", "polyglot" ]
10
12
908
11
0
2008-09-26T20:11:45.467000
2008-09-26T20:18:31.173000
141,683
142,766
Adding a flash after authentication with merb-auth
What's the best way to add a flash message, for successful or unsuccessful login when using the merb-auth slice (Other than overriding sessions create)?
Hey deimos. If you want to add an message without overwriting the create action you can always use an after filter. Something like........... after:set_login_flash,:only => [:create] private def set_login_flash flash[:error] = "You're not logged in" unless logged_in? end.......... You'll need to tune it to use the app...
Adding a flash after authentication with merb-auth What's the best way to add a flash message, for successful or unsuccessful login when using the merb-auth slice (Other than overriding sessions create)?
TITLE: Adding a flash after authentication with merb-auth QUESTION: What's the best way to add a flash message, for successful or unsuccessful login when using the merb-auth slice (Other than overriding sessions create)? ANSWER: Hey deimos. If you want to add an message without overwriting the create action you can a...
[ "ruby", "merb", "merb-auth" ]
0
2
412
1
0
2008-09-26T20:13:57.923000
2008-09-27T02:16:09.083000
141,693
141,996
Java Web Deployment: build code, or deploy .war?
Two main ways to deploy a J2EE/Java Web app (in a very simplistic sense): Deploy assembled artifacts to production box Here, we create the.war (or whatever) elsewhere, configure it for production (possibly creating numerous artifacts for numerous boxes) and place the resulting artifacts on the production servers. Pros:...
I'm firmly against building on the production box, because it means you're using a different build than you tested with. It also means every deployment machine has a different JAR/WAR file. If nothing else, do a unified build just so that when bug tracking you won't have to worry about inconsistencies between servers. ...
Java Web Deployment: build code, or deploy .war? Two main ways to deploy a J2EE/Java Web app (in a very simplistic sense): Deploy assembled artifacts to production box Here, we create the.war (or whatever) elsewhere, configure it for production (possibly creating numerous artifacts for numerous boxes) and place the res...
TITLE: Java Web Deployment: build code, or deploy .war? QUESTION: Two main ways to deploy a J2EE/Java Web app (in a very simplistic sense): Deploy assembled artifacts to production box Here, we create the.war (or whatever) elsewhere, configure it for production (possibly creating numerous artifacts for numerous boxes)...
[ "java", "deployment", "jakarta-ee" ]
9
7
6,251
7
0
2008-09-26T20:16:56.560000
2008-09-26T21:10:59.347000
141,707
143,964
How to set CPU load on a Red Hat Linux box?
I have a RHEL box that I need to put under a moderate and variable amount of CPU load (50%-75%). What is the best way to go about this? Is there a program that can do this that I am not aware of? I am happy to write some C code to make this happen, I just don't know what system calls will help.
This is exactly what you need (internet archive link): https://web.archive.org/web/20120512025754/http://weather.ou.edu/~apw/projects/stress/stress-1.0.4.tar.gz From the homepage: "stress is a simple workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the syste...
How to set CPU load on a Red Hat Linux box? I have a RHEL box that I need to put under a moderate and variable amount of CPU load (50%-75%). What is the best way to go about this? Is there a program that can do this that I am not aware of? I am happy to write some C code to make this happen, I just don't know what syst...
TITLE: How to set CPU load on a Red Hat Linux box? QUESTION: I have a RHEL box that I need to put under a moderate and variable amount of CPU load (50%-75%). What is the best way to go about this? Is there a program that can do this that I am not aware of? I am happy to write some C code to make this happen, I just do...
[ "linux", "load", "redhat", "cpu-cycles" ]
6
15
19,429
10
0
2008-09-26T20:18:39.193000
2008-09-27T16:38:42.597000
141,716
141,782
.NET Compact Framework 3.5 on Windows Mobile 2003 SE
Does.NET Compact Framework 3.5 work on Windows Mobile 2003 SE without limitations?
Yes, it works fine. The documentation for the download shows this as well.
.NET Compact Framework 3.5 on Windows Mobile 2003 SE Does.NET Compact Framework 3.5 work on Windows Mobile 2003 SE without limitations?
TITLE: .NET Compact Framework 3.5 on Windows Mobile 2003 SE QUESTION: Does.NET Compact Framework 3.5 work on Windows Mobile 2003 SE without limitations? ANSWER: Yes, it works fine. The documentation for the download shows this as well.
[ "compact-framework" ]
1
2
2,923
1
0
2008-09-26T20:20:32.073000
2008-09-26T20:31:30.627000
141,718
141,821
SQL Server Temp Tables and Connection Pooling
I have a multi-user ASP.NET app running against SQL Server and want to have StoredProcA create a #temptable temp table - not a table variable - to insert some data, then branch to StoredProcB, StoredProcC, and StoredProcD to manipulate the data in #temptable per business rules. The web app uses connection pooling when ...
Connection pooling (with any modern version of SQL Server) will call sp_reset_connection when reusing a connection. This stored proc, among other things, drops any temporary tables that the connection owns.
SQL Server Temp Tables and Connection Pooling I have a multi-user ASP.NET app running against SQL Server and want to have StoredProcA create a #temptable temp table - not a table variable - to insert some data, then branch to StoredProcB, StoredProcC, and StoredProcD to manipulate the data in #temptable per business ru...
TITLE: SQL Server Temp Tables and Connection Pooling QUESTION: I have a multi-user ASP.NET app running against SQL Server and want to have StoredProcA create a #temptable temp table - not a table variable - to insert some data, then branch to StoredProcB, StoredProcC, and StoredProcD to manipulate the data in #temptab...
[ "sql-server", "sql-server-2005" ]
35
54
16,560
6
0
2008-09-26T20:20:58.017000
2008-09-26T20:38:01.487000
141,720
141,724
How do you compare structs for equality in C?
How do you compare two instances of structs for equality in standard C?
C provides no language facilities to do this - you have to do it yourself and compare each structure member by member.
How do you compare structs for equality in C? How do you compare two instances of structs for equality in standard C?
TITLE: How do you compare structs for equality in C? QUESTION: How do you compare two instances of structs for equality in standard C? ANSWER: C provides no language facilities to do this - you have to do it yourself and compare each structure member by member.
[ "c", "struct", "equality" ]
259
238
269,079
11
0
2008-09-26T20:21:23.850000
2008-09-26T20:22:14.520000
141,733
350,034
OC4J 10.1.3.4 problem with deploying multiple 2.1 EJBs
I am having troubles migrating from OC4J 10.1.2.3 to 10.1.3.1.4. The problem is for applications that have multiple EJBs (all are 2.1, no EJB 3.0). Jdeveloper will take the default ejb-jar.xml (the one required for Jdeveloper to run it on its stand-alone OC4J instance) and package it into each EJB JAR module NO MATTER ...
The problem was multiple reference in our deployment profiles. We were create a deployment profile for EACH EJB. This meant that each EJB had it's own ejb-jar.xml (this file contained a description of all EJBS in the project). Therefore, every time JDeveloper created an EJB, it placed a descriptor of all EJBS in each E...
OC4J 10.1.3.4 problem with deploying multiple 2.1 EJBs I am having troubles migrating from OC4J 10.1.2.3 to 10.1.3.1.4. The problem is for applications that have multiple EJBs (all are 2.1, no EJB 3.0). Jdeveloper will take the default ejb-jar.xml (the one required for Jdeveloper to run it on its stand-alone OC4J insta...
TITLE: OC4J 10.1.3.4 problem with deploying multiple 2.1 EJBs QUESTION: I am having troubles migrating from OC4J 10.1.2.3 to 10.1.3.1.4. The problem is for applications that have multiple EJBs (all are 2.1, no EJB 3.0). Jdeveloper will take the default ejb-jar.xml (the one required for Jdeveloper to run it on its stan...
[ "java", "jakarta-ee", "ejb", "oc4j", "ejb-jar.xml" ]
0
0
1,522
2
0
2008-09-26T20:23:47.747000
2008-12-08T16:16:14.540000
141,734
141,755
What is the default session timeout for a Java EE website?
If I do not specify the following in my web.xml file: 10 What will be my default session timeout? (I am running Tomcat 6.0)
If you're using Tomcat, it's 30 minutes. You can read more about it here.
What is the default session timeout for a Java EE website? If I do not specify the following in my web.xml file: 10 What will be my default session timeout? (I am running Tomcat 6.0)
TITLE: What is the default session timeout for a Java EE website? QUESTION: If I do not specify the following in my web.xml file: 10 What will be my default session timeout? (I am running Tomcat 6.0) ANSWER: If you're using Tomcat, it's 30 minutes. You can read more about it here.
[ "java", "jsp", "tomcat", "jakarta-ee" ]
29
34
62,063
4
0
2008-09-26T20:23:48.680000
2008-09-26T20:26:46.427000
141,752
141,772
Float values behaving differently across the release and debug builds
My application is generating different floating point values when I compile it in release mode and in debug mode. The only reason that I found out is I save a binary trace log and the one from the release build is ever so slightly off from the debug build, it looks like the bottom two bits of the 32 bit float values ar...
Release mode may have a different FP strategy set. There are different floating point arithmetic modes depending on the level of optimization you'd like. MSVC, for example, has strict, fast, and precise modes.
Float values behaving differently across the release and debug builds My application is generating different floating point values when I compile it in release mode and in debug mode. The only reason that I found out is I save a binary trace log and the one from the release build is ever so slightly off from the debug ...
TITLE: Float values behaving differently across the release and debug builds QUESTION: My application is generating different floating point values when I compile it in release mode and in debug mode. The only reason that I found out is I save a binary trace log and the one from the release build is ever so slightly o...
[ "c++", "c", "debugging", "compiler-construction", "floating-point" ]
7
11
3,201
9
0
2008-09-26T20:26:22.700000
2008-09-26T20:29:35.110000
141,775
141,798
Is there an alternative to conditional display:none
I inherited an application where display:none was used to control conditional display of input elements based the values of other input elements. The way this was handled is by running some pretty ugly code to evaluate field values and reset the display property in the during page load. Every time. Isn't there a better...
Using display: none in conjunction with JavaScript and CSS is the easiest way of simply showing or hiding DOM elements on the fly. That said, you could manipulate the DOM itself by adding or removing elements rather than simply showing / hiding them (with jQuery, for example).
Is there an alternative to conditional display:none I inherited an application where display:none was used to control conditional display of input elements based the values of other input elements. The way this was handled is by running some pretty ugly code to evaluate field values and reset the display property in th...
TITLE: Is there an alternative to conditional display:none QUESTION: I inherited an application where display:none was used to control conditional display of input elements based the values of other input elements. The way this was handled is by running some pretty ugly code to evaluate field values and reset the disp...
[ "html", "css" ]
1
6
4,396
5
0
2008-09-26T20:30:06.637000
2008-09-26T20:33:52.637000
141,779
143,288
Solving the NP-complete problem in XKCD
The problem/comic in question: http://xkcd.com/287/ I'm not sure this is the best way to do it, but here's what I've come up with so far. I'm using CFML, but it should be readable by anyone. #arguments.currentCombo# = 15.05 #arguments.currentCombo# > 15.05 (aborting) #arguments.currentCombo# < 15.05 (traversing) #testC...
The point about an NP-complete problem is not that it's tricky on a small data set, but that the amount of work to solve it grows at a rate greater than polynomial, i.e. there is no O(n^x) algorithm. If the time complexity is O(n!), as in (I believe) the two problems mentioned above, that is in NP.
Solving the NP-complete problem in XKCD The problem/comic in question: http://xkcd.com/287/ I'm not sure this is the best way to do it, but here's what I've come up with so far. I'm using CFML, but it should be readable by anyone. #arguments.currentCombo# = 15.05 #arguments.currentCombo# > 15.05 (aborting) #arguments.c...
TITLE: Solving the NP-complete problem in XKCD QUESTION: The problem/comic in question: http://xkcd.com/287/ I'm not sure this is the best way to do it, but here's what I've come up with so far. I'm using CFML, but it should be readable by anyone. #arguments.currentCombo# = 15.05 #arguments.currentCombo# > 15.05 (abor...
[ "language-agnostic", "np-complete" ]
45
24
11,840
15
0
2008-09-26T20:30:38.680000
2008-09-27T09:17:03.923000
141,802
141,826
How do I dump an entire Python process for later debugging inspection?
I have a Python application in a strange state. I don't want to do live debugging of the process. Can I dump it to a file and examine its state later? I know I've restored corefiles of C programs in gdb later, but I don't know how to examine a Python application in a useful way from gdb. (This is a variation on my ques...
There is no builtin way other than aborting (with os.abort(), causing the coredump if resource limits allow it) -- although you can certainly build your own 'dump' function that dumps relevant information about the data you care about. There are no ready-made tools for it. As for handling the corefile of a Python proce...
How do I dump an entire Python process for later debugging inspection? I have a Python application in a strange state. I don't want to do live debugging of the process. Can I dump it to a file and examine its state later? I know I've restored corefiles of C programs in gdb later, but I don't know how to examine a Pytho...
TITLE: How do I dump an entire Python process for later debugging inspection? QUESTION: I have a Python application in a strange state. I don't want to do live debugging of the process. Can I dump it to a file and examine its state later? I know I've restored corefiles of C programs in gdb later, but I don't know how ...
[ "python", "debugging", "coredump" ]
27
6
18,952
5
0
2008-09-26T20:34:19.827000
2008-09-26T20:38:17.633000
141,808
1,922,265
How to ignore accents in highlight function
I have a micro-mini-search engine that highlights the search terms in my rails app. The search ignores accents and the highlight is case insensitive. Almost perfect. But, for instance if I have a record with the text "pão de queijo" and searches for "pao de queijo" the record is returned but the iext is not highlighted...
I've just submitted a patch to Rails thats solves this. http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3593-patch-support-for-highlighting-with-ignoring-special-chars # Highlights one or more +phrases+ everywhere in +text+ by inserting it into # a:highlighter string. The highlighter can be specializ...
How to ignore accents in highlight function I have a micro-mini-search engine that highlights the search terms in my rails app. The search ignores accents and the highlight is case insensitive. Almost perfect. But, for instance if I have a record with the text "pão de queijo" and searches for "pao de queijo" the record...
TITLE: How to ignore accents in highlight function QUESTION: I have a micro-mini-search engine that highlights the search terms in my rails app. The search ignores accents and the highlight is case insensitive. Almost perfect. But, for instance if I have a record with the text "pão de queijo" and searches for "pao de ...
[ "ruby-on-rails" ]
3
3
1,618
4
0
2008-09-26T20:35:38.030000
2009-12-17T14:49:42.360000
141,820
141,851
Which Haskell package contains given module
I know a Haskell module name, but I can't figure out in what package it is defined. This is bad because I can't compile without a package exposing this module. Specificaly it is Text.Regex that I can't locate, but I would like to know how to solve that problem in general.
http://www.haskell.org/ghc/docs/latest/html/users_guide/packages.html ghc-pkg find-module Text.Regex But that only works for (a) recent GHCs, and (b) packages installed on your system. You can also grep through the package file (e.g. /usr/lib/ghc-6.8.2/package.conf) to see what's installed. You can also use either the ...
Which Haskell package contains given module I know a Haskell module name, but I can't figure out in what package it is defined. This is bad because I can't compile without a package exposing this module. Specificaly it is Text.Regex that I can't locate, but I would like to know how to solve that problem in general.
TITLE: Which Haskell package contains given module QUESTION: I know a Haskell module name, but I can't figure out in what package it is defined. This is bad because I can't compile without a package exposing this module. Specificaly it is Text.Regex that I can't locate, but I would like to know how to solve that probl...
[ "haskell", "cabal", "hackage" ]
15
15
2,042
4
0
2008-09-26T20:37:57.010000
2008-09-26T20:42:07.013000
141,828
141,840
sql 2005 rollback transaction
I just did a delete from table How do I roll back or undelete the rows??
if you called begin transaction before you did it, and have not yet called commit, then you can call rollback, otherwise... you're gonna have to restore
sql 2005 rollback transaction I just did a delete from table How do I roll back or undelete the rows??
TITLE: sql 2005 rollback transaction QUESTION: I just did a delete from table How do I roll back or undelete the rows?? ANSWER: if you called begin transaction before you did it, and have not yet called commit, then you can call rollback, otherwise... you're gonna have to restore
[ "sql-server" ]
1
7
2,587
7
0
2008-09-26T20:38:39.083000
2008-09-26T20:40:27.860000
141,855
141,861
Programmatically Lighten a Color
Motivation I'd like to find a way to take an arbitrary color and lighten it a few shades, so that I can programatically create a nice gradient from the one color to a lighter version. The gradient will be used as a background in a UI. Possibility 1 Obviously I can just split out the RGB values and increase them individ...
I would go for the second option. Generally speaking the RGB space is not really good for doing color manipulation (creating transition from one color to an other, lightening / darkening a color, etc). Below are two sites I've found with a quick search to convert from/to RGB to/from HSL: from the "Fundamentals of Compu...
Programmatically Lighten a Color Motivation I'd like to find a way to take an arbitrary color and lighten it a few shades, so that I can programatically create a nice gradient from the one color to a lighter version. The gradient will be used as a background in a UI. Possibility 1 Obviously I can just split out the RGB...
TITLE: Programmatically Lighten a Color QUESTION: Motivation I'd like to find a way to take an arbitrary color and lighten it a few shades, so that I can programatically create a nice gradient from the one color to a lighter version. The gradient will be used as a background in a UI. Possibility 1 Obviously I can just...
[ "user-interface", "language-agnostic", "colors" ]
78
39
65,711
19
0
2008-09-26T20:43:35.590000
2008-09-26T20:44:51.250000
141,863
142,463
Is there an issue sending XML via WCF?
Suppose you have an XElement or an XmlElment or even a string containing xml that you want to send via WCF. Are there any special precautions you have to take? The question just came up, what happens when, within the xml message, you transmit an xml document declaration ( ), which may happen if serializing an XmlDocume...
I hade no problem sending XML as a string with WCF. If your XML exceed a few Kb, you must make changes in client&server to allow larger data amounts.
Is there an issue sending XML via WCF? Suppose you have an XElement or an XmlElment or even a string containing xml that you want to send via WCF. Are there any special precautions you have to take? The question just came up, what happens when, within the xml message, you transmit an xml document declaration ( ), which...
TITLE: Is there an issue sending XML via WCF? QUESTION: Suppose you have an XElement or an XmlElment or even a string containing xml that you want to send via WCF. Are there any special precautions you have to take? The question just came up, what happens when, within the xml message, you transmit an xml document decl...
[ ".net", "xml", "wcf" ]
2
2
6,271
2
0
2008-09-26T20:45:15.183000
2008-09-26T23:18:15.830000
141,864
141,926
Operator overloading for C++ maps
I need help understanding some C++ operator overload statements. The class is declared like this: template class ipdc_map_template_t: public ipdc_lockable_t {... typedef map > map_t;... The creator of the class has created an iterator for the internal map structure: struct iterator: public map_t::iterator { iterator() ...
These are typecast operators, so you can do this: { key_t key = iter; ipdc_t *val = iter; } Or, since ipdc_map_template::iterator is a subclass of std::map::iterator, you can still use the original accessors (which I find more readable): { key_t key = (*iter).first; ipdc_t *val = (*iter).second; // or, equivalently ke...
Operator overloading for C++ maps I need help understanding some C++ operator overload statements. The class is declared like this: template class ipdc_map_template_t: public ipdc_lockable_t {... typedef map > map_t;... The creator of the class has created an iterator for the internal map structure: struct iterator: pu...
TITLE: Operator overloading for C++ maps QUESTION: I need help understanding some C++ operator overload statements. The class is declared like this: template class ipdc_map_template_t: public ipdc_lockable_t {... typedef map > map_t;... The creator of the class has created an iterator for the internal map structure: s...
[ "c++", "templates" ]
2
6
3,776
3
0
2008-09-26T20:45:19.673000
2008-09-26T20:55:23.893000
141,869
141,978
Best place for log files in an in-house IT environment
All of my users are a short walk down the hall, and all of my programs run on workstations on the same LAN. Some years ago, I had the staff write the log files for all of their programs to a shared folder hierarchy, naming each log file after the machine name in a sub-directory named after the app. But this arrangement...
You can use MSMQ. Write your logs to a MSMQ queue, and then have a service that picks these logs up and puts them in a database or out to a file in a central location if you want. It wouldn't be instantaneous, but you could tell it to run whenever you want to get new log entries. Plus it would be reliable since it uses...
Best place for log files in an in-house IT environment All of my users are a short walk down the hall, and all of my programs run on workstations on the same LAN. Some years ago, I had the staff write the log files for all of their programs to a shared folder hierarchy, naming each log file after the machine name in a ...
TITLE: Best place for log files in an in-house IT environment QUESTION: All of my users are a short walk down the hall, and all of my programs run on workstations on the same LAN. Some years ago, I had the staff write the log files for all of their programs to a shared folder hierarchy, naming each log file after the ...
[ ".net", "logging" ]
1
1
461
10
0
2008-09-26T20:46:09.080000
2008-09-26T21:06:42.727000
141,875
142,009
Antlr: Simplest way to recognize dates and numbers?
What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match a number, I need a parse rule like: number: (MONTH|INT); It only gets ...
The problem is that you seem to want to perform both syntactical and semantical checking in your lexer and/or your parser. It's a common mistake, and something that is only possible in very simple languages. What you really need to do is accept more broadly in the lexer and parser, and then perform semantic checks. How...
Antlr: Simplest way to recognize dates and numbers? What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match a number, I need a...
TITLE: Antlr: Simplest way to recognize dates and numbers? QUESTION: What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match ...
[ "antlr", "grammar" ]
5
6
7,232
2
0
2008-09-26T20:46:55.023000
2008-09-26T21:14:13.957000
141,876
142,943
Application Title Cut Off In VB6
Platform: Windows XP Development Platform: VB6 When trying to set an application title via the Project Properties dialog on the Make tab, it seems to silently cut off the title at a set number of characters. Also tried this via the App.Title property and it seems to suffer from the same problem. I wouldn't care about t...
One solution using the Windows API Disclaimer: IMHO this seems like overkill just to meet the requirement stated in the question, but in the spirit of giving a (hopefully) complete answer to the problem, here goes nothing... Here is a working version I came up with after looking around in MSDN for awhile, until I final...
Application Title Cut Off In VB6 Platform: Windows XP Development Platform: VB6 When trying to set an application title via the Project Properties dialog on the Make tab, it seems to silently cut off the title at a set number of characters. Also tried this via the App.Title property and it seems to suffer from the same...
TITLE: Application Title Cut Off In VB6 QUESTION: Platform: Windows XP Development Platform: VB6 When trying to set an application title via the Project Properties dialog on the Make tab, it seems to silently cut off the title at a set number of characters. Also tried this via the App.Title property and it seems to su...
[ "vb6" ]
4
2
3,304
4
0
2008-09-26T20:46:55.833000
2008-09-27T03:59:32.300000
141,878
141,930
How to escape an underscore in a C preprocessor token?
The following snippet is supposed to take the value of PROJECT (defined in the Makefile) and create an include file name. For example, if PROJECT=classifier, then it should at the end generate classifier_ir.h for PROJECTINCSTR I find that this code works as long as I am not trying to use an underscore in the suffix. Ho...
#define QMAKESTR(x) #x #define MAKESTR(x) QMAKESTR(x) #define SMASH(x,y) x##y #define MAKEINC(x) SMASH(x,_ir.h) #define PROJECTINC MAKEINC(PROJECT) #define PROJECTINCSTR MAKESTR(PROJECTINC)
How to escape an underscore in a C preprocessor token? The following snippet is supposed to take the value of PROJECT (defined in the Makefile) and create an include file name. For example, if PROJECT=classifier, then it should at the end generate classifier_ir.h for PROJECTINCSTR I find that this code works as long as...
TITLE: How to escape an underscore in a C preprocessor token? QUESTION: The following snippet is supposed to take the value of PROJECT (defined in the Makefile) and create an include file name. For example, if PROJECT=classifier, then it should at the end generate classifier_ir.h for PROJECTINCSTR I find that this cod...
[ "c", "c-preprocessor" ]
1
7
1,828
3
0
2008-09-26T20:47:08.453000
2008-09-26T20:55:52.770000
141,888
141,918
What are the methods for tokenizing strings in .Net?
This must be a classic.NET question for anyone migrating from Java..NET does not seem to have a direct equivalent to java.io.StreamTokenizer, however the JLCA provides a SupportClass that attempts to implement it. I believe the JLCA also provides a Tokenizer SupportClass that takes a String as the source, which I thoug...
There isn't anything in.NET that is completely equivalent to StreamTokenizer. For simple cases, you can use String.Split(), but for more advanced token parsing, you'll probably end up using System.Text.RegularExpressions.Regex.
What are the methods for tokenizing strings in .Net? This must be a classic.NET question for anyone migrating from Java..NET does not seem to have a direct equivalent to java.io.StreamTokenizer, however the JLCA provides a SupportClass that attempts to implement it. I believe the JLCA also provides a Tokenizer SupportC...
TITLE: What are the methods for tokenizing strings in .Net? QUESTION: This must be a classic.NET question for anyone migrating from Java..NET does not seem to have a direct equivalent to java.io.StreamTokenizer, however the JLCA provides a SupportClass that attempts to implement it. I believe the JLCA also provides a ...
[ "c#", "java", ".net", "migration" ]
9
8
6,717
6
0
2008-09-26T20:49:04.207000
2008-09-26T20:54:11.760000
141,912
141,952
Alternatives to the MVC
What are the alternative "design methods" to the Model View Controller? MVC seems to be popular (SO was built with it, I know that much) but is it the only method used?
There are many others: Model View Presenter (MVP) Supervising Controller Passive View Model View ViewModel (MVVM) This is common in WPF applications (though Prism uses the MVP pattern (usually))
Alternatives to the MVC What are the alternative "design methods" to the Model View Controller? MVC seems to be popular (SO was built with it, I know that much) but is it the only method used?
TITLE: Alternatives to the MVC QUESTION: What are the alternative "design methods" to the Model View Controller? MVC seems to be popular (SO was built with it, I know that much) but is it the only method used? ANSWER: There are many others: Model View Presenter (MVP) Supervising Controller Passive View Model View Vie...
[ "model-view-controller", "design-patterns" ]
75
39
68,816
8
0
2008-09-26T20:53:22.730000
2008-09-26T21:00:49.997000
141,913
143,029
Pulling both the text and attribute of a given node using Xpath
I'm parsing XML results from an API call using PHP and xpath. $dom = new DOMDocument(); $dom->loadXML($response->getBody()); $xpath = new DOMXPath($dom); $xpath->registerNamespace("a", "http://www.example.com"); $hrefs = $xpath->query('//a:Books/text()', $dom); for ($i = 0; $i < $hrefs->length; $i++) { $arrBookTitle...
After doing some looking around I came across this solution. This way I can get the element text and access any attributes of the node. $hrefs = $xpath->query('//a:Books', $dom); for ($i = 0; $i < $hrefs->length; $i++) { $arrBookTitle[$i] = $hrefs->item($i)->nodeValue; $arrBookDewey[$i] = $hrefs->item($i)->getAttribut...
Pulling both the text and attribute of a given node using Xpath I'm parsing XML results from an API call using PHP and xpath. $dom = new DOMDocument(); $dom->loadXML($response->getBody()); $xpath = new DOMXPath($dom); $xpath->registerNamespace("a", "http://www.example.com"); $hrefs = $xpath->query('//a:Books/text()',...
TITLE: Pulling both the text and attribute of a given node using Xpath QUESTION: I'm parsing XML results from an API call using PHP and xpath. $dom = new DOMDocument(); $dom->loadXML($response->getBody()); $xpath = new DOMXPath($dom); $xpath->registerNamespace("a", "http://www.example.com"); $hrefs = $xpath->query('...
[ "php", "dom", "xpath" ]
5
4
3,431
4
0
2008-09-26T20:53:51.887000
2008-09-27T05:01:38.313000
141,951
141,990
Rules for multi-user WinForms apps on Vista
We have an MSI installer for a.Net WinForms app for Windows XP that installs and runs only as an admin. Users have to log in to the app when it runs. Customers want it to install and run under a user account under Vista, and to use their Windows account. A preliminary look through the code shows lots of problems; the i...
"the app must be installable and uninstallable by any user" "all users share the same data files" You're going to have trouble with having to meet both of these requirements. Vista's new security features are designed to keep users from trampling on each other (and on the system). About the only way I can think of to m...
Rules for multi-user WinForms apps on Vista We have an MSI installer for a.Net WinForms app for Windows XP that installs and runs only as an admin. Users have to log in to the app when it runs. Customers want it to install and run under a user account under Vista, and to use their Windows account. A preliminary look th...
TITLE: Rules for multi-user WinForms apps on Vista QUESTION: We have an MSI installer for a.Net WinForms app for Windows XP that installs and runs only as an admin. Users have to log in to the app when it runs. Customers want it to install and run under a user account under Vista, and to use their Windows account. A p...
[ ".net", "windows", "winforms", "windows-vista" ]
1
1
741
3
0
2008-09-26T21:00:47.640000
2008-09-26T21:09:40.850000
141,970
142,180
class with valueTypes fields and boxing
I'm experimenting with generics and I'm trying to create structure similar to Dataset class. I have following code public struct Column { T value; T originalValue; public bool HasChanges { get { return!value.Equals(originalValue); } } public void AcceptChanges() { originalValue = value; } } public class Record { Col...
As you asked for examples from functional languages; in lisp you could prevent the writing of all that code upon each addition of a column by using a macro to crank the code out for you. Sadly, I do not think that is possible in C#. In terms of performance: the macro would be evaluated at compile time (thus slowing com...
class with valueTypes fields and boxing I'm experimenting with generics and I'm trying to create structure similar to Dataset class. I have following code public struct Column { T value; T originalValue; public bool HasChanges { get { return!value.Equals(originalValue); } } public void AcceptChanges() { originalValue...
TITLE: class with valueTypes fields and boxing QUESTION: I'm experimenting with generics and I'm trying to create structure similar to Dataset class. I have following code public struct Column { T value; T originalValue; public bool HasChanges { get { return!value.Equals(originalValue); } } public void AcceptChanges...
[ "c#", "data-structures", "t4" ]
1
1
378
5
0
2008-09-26T21:05:09.893000
2008-09-26T21:46:47.717000
141,973
164,870
How do I get the key value of a db.ReferenceProperty without a database hit?
Is there a way to get the key (or id) value of a db.ReferenceProperty, without dereferencing the actual entity it points to? I have been digging around - it looks like the key is stored as the property name preceeded with an _, but I have been unable to get any code working. Examples would be much appreciated. Thanks. ...
Actually, the way that you are advocating accessing the key for a ReferenceProperty might well not exist in the future. Attributes that begin with '_' in python are generally accepted to be "protected" in that things that are closely bound and intimate with its implementation can use them, but things that are updated w...
How do I get the key value of a db.ReferenceProperty without a database hit? Is there a way to get the key (or id) value of a db.ReferenceProperty, without dereferencing the actual entity it points to? I have been digging around - it looks like the key is stored as the property name preceeded with an _, but I have been...
TITLE: How do I get the key value of a db.ReferenceProperty without a database hit? QUESTION: Is there a way to get the key (or id) value of a db.ReferenceProperty, without dereferencing the actual entity it points to? I have been digging around - it looks like the key is stored as the property name preceeded with an ...
[ "python", "google-app-engine" ]
1
13
1,258
2
0
2008-09-26T21:05:25.943000
2008-10-02T22:17:40.930000
141,989
142,054
Why would an UpdatePanel stop working after a few minutes?
What aspects of the UpdatePanel are sensitive to time? I have an UpdatePanel that works fine. If I leave the page for a few minutes and come back, the UpdatePanel doesn't work. Looking at firebug, I see that it sends the Request and gets a Response back. However, the page itself doesn't update. I'm not seeing any scrip...
Maybe your application domain recycled or your Session was lost. Have you tried seeing what is being called on the server? That'd be my suggestion on where to look next.
Why would an UpdatePanel stop working after a few minutes? What aspects of the UpdatePanel are sensitive to time? I have an UpdatePanel that works fine. If I leave the page for a few minutes and come back, the UpdatePanel doesn't work. Looking at firebug, I see that it sends the Request and gets a Response back. Howeve...
TITLE: Why would an UpdatePanel stop working after a few minutes? QUESTION: What aspects of the UpdatePanel are sensitive to time? I have an UpdatePanel that works fine. If I leave the page for a few minutes and come back, the UpdatePanel doesn't work. Looking at firebug, I see that it sends the Request and gets a Res...
[ "javascript", "ajax", "asp.net-ajax", "updatepanel" ]
1
1
1,236
5
0
2008-09-26T21:09:36.077000
2008-09-26T21:19:51.807000
141,993
142,167
Best way to compare 2 XML documents in Java
I'm trying to write an automated test of an application that basically translates a custom message format into an XML message and sends it out the other end. I've got a good set of input/output message pairs so all I need to do is send the input messages in and listen for the XML message to come out the other end. When...
Sounds like a job for XMLUnit http://www.xmlunit.org/ https://github.com/xmlunit Example: public class SomeTest extends XMLTestCase { @Test public void test() { String xml1 =... String xml2 =... XMLUnit.setIgnoreWhitespace(true); // ignore whitespace differences // can also compare xml Documents, InputSources, Reader...
Best way to compare 2 XML documents in Java I'm trying to write an automated test of an application that basically translates a custom message format into an XML message and sends it out the other end. I've got a good set of input/output message pairs so all I need to do is send the input messages in and listen for the...
TITLE: Best way to compare 2 XML documents in Java QUESTION: I'm trying to write an automated test of an application that basically translates a custom message format into an XML message and sends it out the other end. I've got a good set of input/output message pairs so all I need to do is send the input messages in ...
[ "java", "xml", "testing", "parsing", "comparison" ]
226
214
240,447
15
0
2008-09-26T21:10:32.827000
2008-09-26T21:43:03.857000
142,000
142,109
jQuery override form submit not working when submit called by javascript on a element
I've got a page with a normal form with a submit button and some jQuery which binds to the form submit event and overrides it with e.preventDefault() and runs an AJAX command. This works fine when the submit button is clicked but when a link with onclick='document.formName.submit();' is clicked, the event is not caught...
A couple of suggestions: Overwrite the submit function to do your evil bidding var oldSubmit = form.submit; form.submit = function() { $(form).trigger("submit"); oldSubmit.call(form, arguments); } Why not bind to all the tags? Then you don't have to do any monkey patching, and it could be as simple as (assuming all the...
jQuery override form submit not working when submit called by javascript on a element I've got a page with a normal form with a submit button and some jQuery which binds to the form submit event and overrides it with e.preventDefault() and runs an AJAX command. This works fine when the submit button is clicked but when...
TITLE: jQuery override form submit not working when submit called by javascript on a element QUESTION: I've got a page with a normal form with a submit button and some jQuery which binds to the form submit event and overrides it with e.preventDefault() and runs an AJAX command. This works fine when the submit button i...
[ "javascript", "jquery" ]
35
35
45,333
4
0
2008-09-26T21:11:51.687000
2008-09-26T21:31:39.580000
142,003
142,069
Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on
I have a scenario. (Windows Forms, C#,.NET) There is a main form which hosts some user control. The user control does some heavy data operation, such that if I directly call the UserControl_Load method the UI become nonresponsive for the duration for load method execution. To overcome this I load data on different thre...
As per Prerak K's update comment (since deleted): I guess I have not presented the question properly. Situation is this: I want to load data into a global variable based on the value of a control. I don't want to change the value of a control from the child thread. I'm not going to do it ever from a child thread. So on...
Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on I have a scenario. (Windows Forms, C#,.NET) There is a main form which hosts some user control. The user control does some heavy data operation, such that if I directly call the UserControl_Load method the UI become...
TITLE: Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on QUESTION: I have a scenario. (Windows Forms, C#,.NET) There is a main form which hosts some user control. The user control does some heavy data operation, such that if I directly call the UserControl_Load me...
[ "c#", "multithreading", "winforms", "invoke" ]
679
485
507,501
22
0
2008-09-26T21:12:41.917000
2008-09-26T21:22:30.303000
142,005
142,070
Server based syntax highlighting in Management Studio
Why are some keywords highlighted blue and some gray in SQL Server Management Studio? And why does the UNION keyword highlight as gray when connected to a SQL Server 2000 database, but blue when connected to a SQL Server 2005 database?
They are reserved words. We have a table called Order in our production DB (Before I started!), which is annoying. Edit: Sorry, misread you. Blue = Keyword, Gray = Operator. Full list of colpurs: http://www.informit.com/guides/content.aspx?g=sqlserver&seqNum=177 about halfway down.
Server based syntax highlighting in Management Studio Why are some keywords highlighted blue and some gray in SQL Server Management Studio? And why does the UNION keyword highlight as gray when connected to a SQL Server 2000 database, but blue when connected to a SQL Server 2005 database?
TITLE: Server based syntax highlighting in Management Studio QUESTION: Why are some keywords highlighted blue and some gray in SQL Server Management Studio? And why does the UNION keyword highlight as gray when connected to a SQL Server 2000 database, but blue when connected to a SQL Server 2005 database? ANSWER: The...
[ "sql-server" ]
1
2
690
1
0
2008-09-26T21:13:04.943000
2008-09-26T21:22:53.547000
142,007
588,984
Force a Samba process to close a file
Is there a way to force a Samba process to close a given file without killing it? Samba opens a process for each client connection, and sometimes I see it holds open files far longer than needed. Usually i just kill the process, and the (windows) client will reopen it the next time it access the share; but sometimes it...
This happens all the time on our systems, particularly when connecting to Samba from a Win98 machine. We follow these steps to solve it (which are probably similar to yours): See which computer is using the file (i.e. lsof|grep -i ) Try to open that file from the offending computer, or see if a process is hiding in tas...
Force a Samba process to close a file Is there a way to force a Samba process to close a given file without killing it? Samba opens a process for each client connection, and sometimes I see it holds open files far longer than needed. Usually i just kill the process, and the (windows) client will reopen it the next time...
TITLE: Force a Samba process to close a file QUESTION: Is there a way to force a Samba process to close a given file without killing it? Samba opens a process for each client connection, and sometimes I see it holds open files far longer than needed. Usually i just kill the process, and the (windows) client will reope...
[ "system-administration", "samba" ]
5
6
29,695
8
0
2008-09-26T21:13:53.867000
2009-02-26T03:34:28.620000
142,010
144,505
Can XPath do a foreign key lookup across two subtrees of an XML?
Say I have the following XML......what would the XPath be that returns that the "bucket" contains "red" and "blue"?
If you're using XSLT, I'd recommend setting up a key: You can then get the within with a particular key using key('tents', $id) Then you can do key('tents', /root/bucket/tent/@key)/@color or, if $bucket is a particular element, key('tents', $bucket/tent/@key)/@color
Can XPath do a foreign key lookup across two subtrees of an XML? Say I have the following XML......what would the XPath be that returns that the "bucket" contains "red" and "blue"?
TITLE: Can XPath do a foreign key lookup across two subtrees of an XML? QUESTION: Say I have the following XML......what would the XPath be that returns that the "bucket" contains "red" and "blue"? ANSWER: If you're using XSLT, I'd recommend setting up a key: You can then get the within with a particular key using ke...
[ "xml", "xslt", "xpath", "subtree", "xslkey" ]
4
5
2,356
4
0
2008-09-26T21:14:21.993000
2008-09-27T21:19:35.683000
142,016
142,023
C/C++ Structure offset
I'm looking for a piece of code that can tell me the offset of a field within a structure without allocating an instance of the structure. IE: given struct mstct { int myfield; int myfield2; }; I could write: mstct thing; printf("offset %lu\n", (unsigned long)(&thing.myfield2 - &thing)); And get offset 4 for the output...
How about the standard offsetof() macro (in stddef.h)? Edit: for people who might not have the offsetof() macro available for some reason, you can get the effect using something like: #define OFFSETOF(type, field) ((unsigned long) &(((type *) 0)->field))
C/C++ Structure offset I'm looking for a piece of code that can tell me the offset of a field within a structure without allocating an instance of the structure. IE: given struct mstct { int myfield; int myfield2; }; I could write: mstct thing; printf("offset %lu\n", (unsigned long)(&thing.myfield2 - &thing)); And get ...
TITLE: C/C++ Structure offset QUESTION: I'm looking for a piece of code that can tell me the offset of a field within a structure without allocating an instance of the structure. IE: given struct mstct { int myfield; int myfield2; }; I could write: mstct thing; printf("offset %lu\n", (unsigned long)(&thing.myfield2 - ...
[ "c++", "c", "oop" ]
39
73
38,197
3
0
2008-09-26T21:15:16.373000
2008-09-26T21:16:04.687000
142,041
142,113
Is classic ASP still a alternative adverse other languages for new projects?
There are a lot of webs still using classic ASP instead of ASP.NET but that is not the question - "never change a running project". The question is if it is still a first choice as a base for a new web-project or would it be worth to switch to ASP.NET? Would you recommend a classic ASP programmer another language to sw...
While I would personally never willingly choose to create another ASP project over an ASP.NET project, the single biggest reason to do so is "skillset". I'd definitely recommend an ASP developer pickup ASP.NET, but if there is a project needed "now", go with what you know. Then learn ASP.NET before you have another pro...
Is classic ASP still a alternative adverse other languages for new projects? There are a lot of webs still using classic ASP instead of ASP.NET but that is not the question - "never change a running project". The question is if it is still a first choice as a base for a new web-project or would it be worth to switch to...
TITLE: Is classic ASP still a alternative adverse other languages for new projects? QUESTION: There are a lot of webs still using classic ASP instead of ASP.NET but that is not the question - "never change a running project". The question is if it is still a first choice as a base for a new web-project or would it be ...
[ "asp.net", "asp-classic" ]
2
9
1,955
12
0
2008-09-26T21:18:14.963000
2008-09-26T21:32:21.370000
142,042
142,077
Create xml-stylesheet PI with Rails XMLBuilder
I want to attach an xslt stylesheet to an XML document that I build with XMLBuilder. This is done with a Processing Instruction that looks like Normally, I'd use the instruct! method, but:xml-stylesheet is not a valid Ruby symbol. XMLBuilder has a solution for this case for elements using tag! method, but I don't see t...
I'm not sure this will solve your problem since I don't know the instruct! method of that object, but:'xml-stylesheet' is a valid ruby symbol.
Create xml-stylesheet PI with Rails XMLBuilder I want to attach an xslt stylesheet to an XML document that I build with XMLBuilder. This is done with a Processing Instruction that looks like Normally, I'd use the instruct! method, but:xml-stylesheet is not a valid Ruby symbol. XMLBuilder has a solution for this case fo...
TITLE: Create xml-stylesheet PI with Rails XMLBuilder QUESTION: I want to attach an xslt stylesheet to an XML document that I build with XMLBuilder. This is done with a Processing Instruction that looks like Normally, I'd use the instruct! method, but:xml-stylesheet is not a valid Ruby symbol. XMLBuilder has a solutio...
[ "ruby-on-rails", "xml", "ruby" ]
0
2
1,700
3
0
2008-09-26T21:18:17.443000
2008-09-26T21:25:57.690000
142,058
1,948,373
Relative path for xsl:import or xsl:include
I am trying to use VBScript to do an XSLT transform on an XML object. The XSL file I'm translating includes the directive. If I use the absolute URL ( http://localhost/mysite/script.xsl ), it imports the style sheet fine; however, if I use the relative path ( script.xsl ) it reports "resource not found." I need to be a...
First Attempt: I tried including script.xsl as another xml chunk and changing the import statement in every way I could imagine but without success. Final solution: Since the absolute url for includeing script.xsl worked from the beginning, my final solution was to convert style.xsl to style.asp with the correct doctyp...
Relative path for xsl:import or xsl:include I am trying to use VBScript to do an XSLT transform on an XML object. The XSL file I'm translating includes the directive. If I use the absolute URL ( http://localhost/mysite/script.xsl ), it imports the style sheet fine; however, if I use the relative path ( script.xsl ) it ...
TITLE: Relative path for xsl:import or xsl:include QUESTION: I am trying to use VBScript to do an XSLT transform on an XML object. The XSL file I'm translating includes the directive. If I use the absolute URL ( http://localhost/mysite/script.xsl ), it imports the style sheet fine; however, if I use the relative path ...
[ "xml", "xslt", "vbscript", "client-side" ]
6
0
24,332
7
0
2008-09-26T21:20:35.020000
2009-12-22T18:46:58.777000