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
131,393
131,428
Is there a Dependency Injection framework for PHP4?
I'm stuck on a PHP 4 server, and I would like to start moving an old legacy project to modern Design Patterns, including Dependency Injection. Are there any dependency injection frameworks that will work with PHP 4?
i found this (drip), but it looks like it hasn't been updated in a few years.
Is there a Dependency Injection framework for PHP4? I'm stuck on a PHP 4 server, and I would like to start moving an old legacy project to modern Design Patterns, including Dependency Injection. Are there any dependency injection frameworks that will work with PHP 4?
TITLE: Is there a Dependency Injection framework for PHP4? QUESTION: I'm stuck on a PHP 4 server, and I would like to start moving an old legacy project to modern Design Patterns, including Dependency Injection. Are there any dependency injection frameworks that will work with PHP 4? ANSWER: i found this (drip), but ...
[ "php", "dependency-injection", "design-patterns", "php4" ]
2
1
549
3
0
2008-09-25T03:48:04.507000
2008-09-25T04:03:22.097000
131,406
131,424
What is the best method to convert floating point to an integer in JavaScript?
There are several different methods for converting floating point numbers to Integers in JavaScript. My question is what method gives the best performance, is most compatible, or is considered the best practice? Here are a few methods that I know of: var a = 2.5; window.parseInt(a); // 2 Math.floor(a); // 2 a | 0; // 2...
According to this website: parseInt is occasionally used as a means of turning a floating point number into an integer. It is very ill suited to that task because if its argument is of numeric type it will first be converted into a string and then parsed as a number... For rounding numbers to integers one of Math.round...
What is the best method to convert floating point to an integer in JavaScript? There are several different methods for converting floating point numbers to Integers in JavaScript. My question is what method gives the best performance, is most compatible, or is considered the best practice? Here are a few methods that I...
TITLE: What is the best method to convert floating point to an integer in JavaScript? QUESTION: There are several different methods for converting floating point numbers to Integers in JavaScript. My question is what method gives the best performance, is most compatible, or is considered the best practice? Here are a ...
[ "javascript", "variables", "types" ]
32
41
37,268
12
0
2008-09-25T03:53:48.673000
2008-09-25T04:01:02.807000
131,433
133,356
Sources for learning about Scheme Macros: define-syntax and syntax-rules
I've read JRM's Syntax-rules Primer for the Merely Eccentric and it has helped me understand syntax-rules and how it's different from common-lisp's define-macro. syntax-rules is only one way of implementing a syntax transformer within define-syntax. I'm looking for two things, the first is more examples and explanation...
To answer your second question: syntax-case is the other form that goes inside define-syntax. Kent Dybvig is the primary proponent of syntax-case, and he has a tutorial on using it [PDF]. I also read the PLT Scheme documentation on syntax-case for a few more examples, and to learn about the variation in implementation.
Sources for learning about Scheme Macros: define-syntax and syntax-rules I've read JRM's Syntax-rules Primer for the Merely Eccentric and it has helped me understand syntax-rules and how it's different from common-lisp's define-macro. syntax-rules is only one way of implementing a syntax transformer within define-synta...
TITLE: Sources for learning about Scheme Macros: define-syntax and syntax-rules QUESTION: I've read JRM's Syntax-rules Primer for the Merely Eccentric and it has helped me understand syntax-rules and how it's different from common-lisp's define-macro. syntax-rules is only one way of implementing a syntax transformer w...
[ "macros", "lisp", "scheme", "syntax-rules", "define-syntax" ]
11
7
6,191
4
0
2008-09-25T04:07:21.043000
2008-09-25T13:34:28.060000
131,435
132,399
Using AppleScript to hide Keynote Text Fields in A Slide
I am no AppleScript Jedi, I've only done a few simple things, but I haven't been able to figure this one out and could use some help: My wife uses slides for her Art History courses and would like to use the same slides for exams (sans identifying names). Rather than create a new presentation, I'd like a tool that iter...
AFAIK, with Applescript you can only access the title and the body boxes of the slides. If the text you wish to remove is consistently in either of these boxes the simplest solution would be to loop through the slides replacing that text and then saving a copy of the document. tell application "Keynote" open "/Path/To/...
Using AppleScript to hide Keynote Text Fields in A Slide I am no AppleScript Jedi, I've only done a few simple things, but I haven't been able to figure this one out and could use some help: My wife uses slides for her Art History courses and would like to use the same slides for exams (sans identifying names). Rather ...
TITLE: Using AppleScript to hide Keynote Text Fields in A Slide QUESTION: I am no AppleScript Jedi, I've only done a few simple things, but I haven't been able to figure this one out and could use some help: My wife uses slides for her Art History courses and would like to use the same slides for exams (sans identifyi...
[ "macos", "applescript", "automator", "keynote" ]
2
2
1,822
1
0
2008-09-25T04:09:22.987000
2008-09-25T09:53:40.773000
131,439
131,539
How can a C program produce a core dump of itself without terminating?
I want a C program to produce a core dump under certain circumstances. This is a program that runs in a production environment and isn't easily stopped and restarted to adjust other kinds of debugging code. Also, since it's in a production environment, I don't want to call abort(). The issues under investigation aren't...
void create_dump(void) { if(!fork()) { // Crash the app in your favorite way here *((void*)0) = 42; } } Fork the process then crash the child - it'll give you a snapshot whenever you want
How can a C program produce a core dump of itself without terminating? I want a C program to produce a core dump under certain circumstances. This is a program that runs in a production environment and isn't easily stopped and restarted to adjust other kinds of debugging code. Also, since it's in a production environme...
TITLE: How can a C program produce a core dump of itself without terminating? QUESTION: I want a C program to produce a core dump under certain circumstances. This is a program that runs in a production environment and isn't easily stopped and restarted to adjust other kinds of debugging code. Also, since it's in a pr...
[ "c", "debugging", "coredump" ]
32
61
14,757
5
0
2008-09-25T04:11:05.403000
2008-09-25T04:56:38.350000
131,445
131,689
C++ tr1 on GCC 3.4.4 (for the Nokia N810 tablet computer)
What does it take to get C++ tr1 members (shared_ptr especially, but we'd like function and bind and ALL the others) working with GCC 3.4.4 (for the Nokia N810 tablet computer). Has anyone done this? Attempted this? It may not be feasible for us to upgrade to GCC 4.x to cross-compile for this device (but if you've done...
For shared_ptr from boost, at least, the number of dependencies is pretty small. You can use bcp to extract subsets from boost as well, so you don't need the whole of boost to compile your application.
C++ tr1 on GCC 3.4.4 (for the Nokia N810 tablet computer) What does it take to get C++ tr1 members (shared_ptr especially, but we'd like function and bind and ALL the others) working with GCC 3.4.4 (for the Nokia N810 tablet computer). Has anyone done this? Attempted this? It may not be feasible for us to upgrade to GC...
TITLE: C++ tr1 on GCC 3.4.4 (for the Nokia N810 tablet computer) QUESTION: What does it take to get C++ tr1 members (shared_ptr especially, but we'd like function and bind and ALL the others) working with GCC 3.4.4 (for the Nokia N810 tablet computer). Has anyone done this? Attempted this? It may not be feasible for u...
[ "c++", "gcc", "tr1" ]
2
3
1,747
3
0
2008-09-25T04:13:08.657000
2008-09-25T06:10:58.063000
131,449
131,522
Do I have to cause an ValueError in Python
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError: #doSomething else: #doSomethingElse I want to be able to do this because I don't like knowfully causing Exceptions: chars = #some list indx = chars.index(chars) if indx == -1: #doSomething else: #doSomethingElse Is there a way I c...
Note that the latter approach is going against the generally accepted "pythonic" philosophy of EAFP, or "It is Easier to Ask for Forgiveness than Permission.", while the former follows it.
Do I have to cause an ValueError in Python I have this code: chars = #some list try: indx = chars.index(chars) except ValueError: #doSomething else: #doSomethingElse I want to be able to do this because I don't like knowfully causing Exceptions: chars = #some list indx = chars.index(chars) if indx == -1: #doSomethin...
TITLE: Do I have to cause an ValueError in Python QUESTION: I have this code: chars = #some list try: indx = chars.index(chars) except ValueError: #doSomething else: #doSomethingElse I want to be able to do this because I don't like knowfully causing Exceptions: chars = #some list indx = chars.index(chars) if indx ...
[ "python", "exception", "list" ]
5
10
3,074
3
0
2008-09-25T04:14:34.147000
2008-09-25T04:47:35.690000
131,456
131,467
How do you apply a .net attribute to a return type
How do I apply the MarshalAsAttribute to the return type of the code below? public ISomething Foo() { return new MyFoo(); }
According to http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx: [return: MarshalAs( )] public ISomething Foo() { return new MyFoo(); }
How do you apply a .net attribute to a return type How do I apply the MarshalAsAttribute to the return type of the code below? public ISomething Foo() { return new MyFoo(); }
TITLE: How do you apply a .net attribute to a return type QUESTION: How do I apply the MarshalAsAttribute to the return type of the code below? public ISomething Foo() { return new MyFoo(); } ANSWER: According to http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx: [return: ...
[ "c#", ".net", "attributes", "return-type" ]
17
42
6,649
2
0
2008-09-25T04:19:40.747000
2008-09-25T04:24:44.713000
131,473
131,798
EWOULDBLOCK equivalent errno under Windows Perl
G'day Stackoverflowers, I'm the author of Perl's autodie pragma, which changes Perl's built-ins to throw exceptions on failure. It's similar to Fatal, but with lexical scope, an extensible exception model, more intelligent return checking, and much, much nicer error messages. It will be replacing the Fatal module in fu...
Under Win32 "native" Perl, note that $^E is more descriptive at 33, "The process cannot access the file because another process locked a portion of the file" which is ERROR_LOCK_VIOLATION (available from Win32::WinError ).
EWOULDBLOCK equivalent errno under Windows Perl G'day Stackoverflowers, I'm the author of Perl's autodie pragma, which changes Perl's built-ins to throw exceptions on failure. It's similar to Fatal, but with lexical scope, an extensible exception model, more intelligent return checking, and much, much nicer error messa...
TITLE: EWOULDBLOCK equivalent errno under Windows Perl QUESTION: G'day Stackoverflowers, I'm the author of Perl's autodie pragma, which changes Perl's built-ins to throw exceptions on failure. It's similar to Fatal, but with lexical scope, an extensible exception model, more intelligent return checking, and much, much...
[ "windows", "perl", "magic-numbers", "errno" ]
10
11
1,856
2
0
2008-09-25T04:26:26.207000
2008-09-25T06:58:17.043000
131,475
131,542
WSE 2.0 Web Services Client using .NET 2.0
What's the best way to access WSE 2.0 web services from.NET 2.0? Using VS2005's web references is not working, because generated classes are using System.Web.Services as their base (instead of Microsoft.Web.Services2).
We use VS2003 to generate and update the web references with a batch file to copy them to the vs2005 and now 2008 project.
WSE 2.0 Web Services Client using .NET 2.0 What's the best way to access WSE 2.0 web services from.NET 2.0? Using VS2005's web references is not working, because generated classes are using System.Web.Services as their base (instead of Microsoft.Web.Services2).
TITLE: WSE 2.0 Web Services Client using .NET 2.0 QUESTION: What's the best way to access WSE 2.0 web services from.NET 2.0? Using VS2005's web references is not working, because generated classes are using System.Web.Services as their base (instead of Microsoft.Web.Services2). ANSWER: We use VS2003 to generate and u...
[ "web-services", ".net-2.0", "wse2.0" ]
1
2
839
1
0
2008-09-25T04:26:47.987000
2008-09-25T05:00:00.293000
131,481
131,686
Preventing Mongrel/Mysql Errno::EPIPE exceptions
I have a rails app that I have serving up XML on an infrequent basis. This is being run with mongrel and mysql. I've found that if I don't exercise the app for longer than a few hours it goes dead and starts throwing Errno::EPIPE errors. It seems that the mysql connection get timed out for inactivity or something like ...
Here's a solution: https://boxpanel.blueboxgrp.com/public/the_vault/index.php/Mongrel_/_MySQL_Timeout The timeouts on the above solution seem a little high to me. You don't want your DB timeouts to be too low, because of the amount of memory a connection can use. If a connection is orphaned, you want it to time out rea...
Preventing Mongrel/Mysql Errno::EPIPE exceptions I have a rails app that I have serving up XML on an infrequent basis. This is being run with mongrel and mysql. I've found that if I don't exercise the app for longer than a few hours it goes dead and starts throwing Errno::EPIPE errors. It seems that the mysql connectio...
TITLE: Preventing Mongrel/Mysql Errno::EPIPE exceptions QUESTION: I have a rails app that I have serving up XML on an infrequent basis. This is being run with mongrel and mysql. I've found that if I don't exercise the app for longer than a few hours it goes dead and starts throwing Errno::EPIPE errors. It seems that t...
[ "mysql", "ruby-on-rails", "timeout", "mongrel" ]
0
1
708
2
0
2008-09-25T04:29:39.977000
2008-09-25T06:10:23.417000
131,498
131,499
What am I missing by not moving my ASP.NET 2.0 site to ASP.NET 3.5?
I have a web application using ASP.NET 2.0 and I want to know if I should be moving it to ASP.NET 3.5, particularly... what am I missing by not moving to ASP.NET 3.5? I understand the disadvantages, but I don't understand the advantages. What are the biggest benefits of migrating/rewriting? Will I get a speed improveme...
You will only miss access to the newer.NET 3.5 libraries, and cool syntax such as LINQ and lambda expressions. Performance wise they will run the same. By the way, ASP.NET MVC is NOT included with.NET 3.5...yet.
What am I missing by not moving my ASP.NET 2.0 site to ASP.NET 3.5? I have a web application using ASP.NET 2.0 and I want to know if I should be moving it to ASP.NET 3.5, particularly... what am I missing by not moving to ASP.NET 3.5? I understand the disadvantages, but I don't understand the advantages. What are the b...
TITLE: What am I missing by not moving my ASP.NET 2.0 site to ASP.NET 3.5? QUESTION: I have a web application using ASP.NET 2.0 and I want to know if I should be moving it to ASP.NET 3.5, particularly... what am I missing by not moving to ASP.NET 3.5? I understand the disadvantages, but I don't understand the advantag...
[ "asp.net", "asp.net-mvc" ]
5
5
315
9
0
2008-09-25T04:36:12.127000
2008-09-25T04:37:43.200000
131,508
131,579
Which browsers and operating systems do you target on new websites?
When you are working on a new website, what combinations of browsers and operating systems do you target, and at what priorities? Do you find targeting a few specific combinations (and ignoring the rest) better than trying to strive to make them all work as intended? Common browsers: Firefox (1.5, 2, 3) Internet Explor...
Mainly I just target browsers as the sites I've built don't really depend on anything OS specific. As mentioned above, YAHOO's graded browser support guide is a good starting point on determining which browsers yous should/could support. And Yahoo's User Interface library (CSS+JavaScript) helps massively in achieving t...
Which browsers and operating systems do you target on new websites? When you are working on a new website, what combinations of browsers and operating systems do you target, and at what priorities? Do you find targeting a few specific combinations (and ignoring the rest) better than trying to strive to make them all wo...
TITLE: Which browsers and operating systems do you target on new websites? QUESTION: When you are working on a new website, what combinations of browsers and operating systems do you target, and at what priorities? Do you find targeting a few specific combinations (and ignoring the rest) better than trying to strive t...
[ "browser", "compatibility" ]
4
6
1,012
10
0
2008-09-25T04:42:53.143000
2008-09-25T05:15:56.637000
131,516
132,304
Delphi 7 make complains about files not found
I've got a BPG file that I've modified to use as a make file for our company's automated build server. In order to get it to work I had to change Uses * Uses unit1 in 'unit1.pas' * unit1 unit2 in 'unit2.pas' * unit2... *... in the DPR file to get it to work without the compiler giving me some guff about unit1.pas not f...
It could come from the fact, that the search path in the IDE and the search path of the command line compiler are not the same. If you change the serach path of the command line compiler you might be able to use the exactely same source code as within the IDE. One possibility to configure the search path for the comman...
Delphi 7 make complains about files not found I've got a BPG file that I've modified to use as a make file for our company's automated build server. In order to get it to work I had to change Uses * Uses unit1 in 'unit1.pas' * unit1 unit2 in 'unit2.pas' * unit2... *... in the DPR file to get it to work without the comp...
TITLE: Delphi 7 make complains about files not found QUESTION: I've got a BPG file that I've modified to use as a make file for our company's automated build server. In order to get it to work I had to change Uses * Uses unit1 in 'unit1.pas' * unit1 unit2 in 'unit2.pas' * unit2... *... in the DPR file to get it to wor...
[ "delphi", "makefile", "package" ]
1
2
1,115
3
0
2008-09-25T04:45:15.663000
2008-09-25T09:25:06.660000
131,517
131,568
Should constructor variables pass direct to private fields or properties?
Now this is.NET but I am sure the principal should apply to all OOP language, to simplify I take.NET as an example: R# usually creator constructor and passing incoming variable to private field, which for me mi tend to pass it to Property. Any opinion on how the different and what is the best practice for that?
Using properties is OK as long as they are not virtual/overridden. Properties are essentially methods, and you should not call virtual methods from within the constructor because the appropriate type may not be constructed yet. Microsoft has listed their own set of guidelines, just scroll down to the bottom to see the ...
Should constructor variables pass direct to private fields or properties? Now this is.NET but I am sure the principal should apply to all OOP language, to simplify I take.NET as an example: R# usually creator constructor and passing incoming variable to private field, which for me mi tend to pass it to Property. Any op...
TITLE: Should constructor variables pass direct to private fields or properties? QUESTION: Now this is.NET but I am sure the principal should apply to all OOP language, to simplify I take.NET as an example: R# usually creator constructor and passing incoming variable to private field, which for me mi tend to pass it t...
[ ".net", "oop", "resharper" ]
3
5
609
5
0
2008-09-25T04:46:15.660000
2008-09-25T05:11:27.877000
131,540
131,701
Is it expected that all the units of a Project Group in Delphi 7 to be in one folder?
Maybe this applied to other Delphi's (I've only used 7). We've got our code broken up so that nearly every DLL in our fairly massive app is in a different folder. 99% of the open source stuff I've downloaded to plug into Delphi have had all their source munged into one folder. It seems like this was an assumption that ...
I don't think so. In fact, In more recent versions they've added features to the project manager to make it easier to deal with the fact that code is spread around different directories (such as the flatten directories option), so I think it is accepted that this is how many people organize their code. I suspect it's m...
Is it expected that all the units of a Project Group in Delphi 7 to be in one folder? Maybe this applied to other Delphi's (I've only used 7). We've got our code broken up so that nearly every DLL in our fairly massive app is in a different folder. 99% of the open source stuff I've downloaded to plug into Delphi have h...
TITLE: Is it expected that all the units of a Project Group in Delphi 7 to be in one folder? QUESTION: Maybe this applied to other Delphi's (I've only used 7). We've got our code broken up so that nearly every DLL in our fairly massive app is in a different folder. 99% of the open source stuff I've downloaded to plug ...
[ "delphi", "standards", "package" ]
1
6
391
5
0
2008-09-25T04:57:47.677000
2008-09-25T06:18:27.267000
131,559
131,574
Advanced searching in Vim
Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique. So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single string, can be in different lines altogether). Ho...
/^joe.*fred.*bill/: find joe AND fred AND Bill (Joe at start of line) /fred\|joe: Search for FRED OR JOE
Advanced searching in Vim Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique. So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single string, can be in diffe...
TITLE: Advanced searching in Vim QUESTION: Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique. So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single strin...
[ "search", "vim", "vi" ]
7
15
5,622
4
0
2008-09-25T05:09:07.120000
2008-09-25T05:12:51.493000
131,605
2,003,792
Best way to do Version Control for MS Excel
What version control systems have you used with MS Excel (2003/2007)? What would you recommend and Why? What limitations have you found with your top rated version control system? To put this in perspective, here are a couple of use cases: version control for VBA modules more than one person is working on a Excel sprea...
I've just setup a spreadsheet that uses Bazaar, with manual checkin/out via TortiseBZR. Given that the topic helped me with the save portion, I wanted to post my solution here. The solution for me was to create a spreadsheet that exports all modules on save, and removes and re-imports the modules on open. Yes, this cou...
Best way to do Version Control for MS Excel What version control systems have you used with MS Excel (2003/2007)? What would you recommend and Why? What limitations have you found with your top rated version control system? To put this in perspective, here are a couple of use cases: version control for VBA modules more...
TITLE: Best way to do Version Control for MS Excel QUESTION: What version control systems have you used with MS Excel (2003/2007)? What would you recommend and Why? What limitations have you found with your top rated version control system? To put this in perspective, here are a couple of use cases: version control fo...
[ "excel", "version-control" ]
180
67
172,394
22
0
2008-09-25T05:31:27.143000
2010-01-05T02:28:20.737000
131,609
134,209
Standardized Error Classification & Handling
I need to standardize on how I classify and handle errors/exceptions 'gracefully'. I currently use a process by which I report the errors to a function passing an error-number, severity-code, location-info and extra-info-string. This function returns boolean true if the error is fatal and the app should die, false othe...
How you handle the errors really depends upon the application.A Web application has a different Error-Catching mechanism than A Desktop Application, and both of those differ drastically to an asynchronous messaging system. That being said the a common practice in error handling is to handle it at the lowest possible le...
Standardized Error Classification & Handling I need to standardize on how I classify and handle errors/exceptions 'gracefully'. I currently use a process by which I report the errors to a function passing an error-number, severity-code, location-info and extra-info-string. This function returns boolean true if the erro...
TITLE: Standardized Error Classification & Handling QUESTION: I need to standardize on how I classify and handle errors/exceptions 'gracefully'. I currently use a process by which I report the errors to a function passing an error-number, severity-code, location-info and extra-info-string. This function returns boolea...
[ "handle", "standardized" ]
4
1
1,071
1
0
2008-09-25T05:32:43.350000
2008-09-25T16:02:00.450000
131,619
132,240
Restrict a string to whitelisted characters using XSLT 1.0
Question Using XSLT 1.0, given a string with arbitrary characters how can I get back a string that meets the following rules. First character must be one of these: a-z, A-Z, colon, or underscore All other characters must be any of those above or 0-9, period, or hyphen If any character does not meet the above rules, rep...
You could write a recursive template to do this, working through the characters in the string one by one, testing them and changing them if necessary. Something like: _ However, there is shorter way of doing this if you're prepared for some hackery. First declare some variables: Now the technique is to take the name an...
Restrict a string to whitelisted characters using XSLT 1.0 Question Using XSLT 1.0, given a string with arbitrary characters how can I get back a string that meets the following rules. First character must be one of these: a-z, A-Z, colon, or underscore All other characters must be any of those above or 0-9, period, or...
TITLE: Restrict a string to whitelisted characters using XSLT 1.0 QUESTION: Question Using XSLT 1.0, given a string with arbitrary characters how can I get back a string that meets the following rules. First character must be one of these: a-z, A-Z, colon, or underscore All other characters must be any of those above ...
[ "string", "xslt", "whitelist" ]
0
6
2,609
3
0
2008-09-25T05:38:16.190000
2008-09-25T09:01:44.360000
131,623
131,740
How do you prefer to organize exception definitions?
I almost feel embarrassed to ask, but I always struggle with how to organize exception definitions. The three ways I've done this before are: Use the file-per-class rule. I'm not crazy about this because it clutters up my directory structure and namespaces. I could organize them into subdirectories and segment namespac...
I use the following approaches: Exception class in a separate file: when it's generic and can be thrown by more than one class Exception class together with the class throwing it: when there is only one such class. This makes sense because the exception is part of that class' interface A variant on the latter is making...
How do you prefer to organize exception definitions? I almost feel embarrassed to ask, but I always struggle with how to organize exception definitions. The three ways I've done this before are: Use the file-per-class rule. I'm not crazy about this because it clutters up my directory structure and namespaces. I could o...
TITLE: How do you prefer to organize exception definitions? QUESTION: I almost feel embarrassed to ask, but I always struggle with how to organize exception definitions. The three ways I've done this before are: Use the file-per-class rule. I'm not crazy about this because it clutters up my directory structure and nam...
[ "exception", "language-agnostic" ]
8
3
906
3
0
2008-09-25T05:39:48.230000
2008-09-25T06:41:23.543000
131,628
131,669
What does "Cannot evaluate expression because the code of the current method is optimized." mean?
I wrote some code with a lot of recursion, that takes quite a bit of time to complete. Whenever I "pause" the run to look at what's going on I get: Cannot evaluate expression because the code of the current method is optimized. I think I understand what that means. However, what puzzles me is that after I hit step, the...
The Debugger uses FuncEval to allow you to "look at" variables. FuncEval requires threads to be stopped in managed code at a GarbageCollector safe point. Manually "pausing" the run in the IDE causes all threads to stop as soon as possible. Your highly recursive code will tend to stop at an unsafe point. Hence, the debu...
What does "Cannot evaluate expression because the code of the current method is optimized." mean? I wrote some code with a lot of recursion, that takes quite a bit of time to complete. Whenever I "pause" the run to look at what's going on I get: Cannot evaluate expression because the code of the current method is optim...
TITLE: What does "Cannot evaluate expression because the code of the current method is optimized." mean? QUESTION: I wrote some code with a lot of recursion, that takes quite a bit of time to complete. Whenever I "pause" the run to look at what's going on I get: Cannot evaluate expression because the code of the curre...
[ "c#", ".net", "debugging", "optimization", "compiler-construction" ]
51
31
62,319
15
0
2008-09-25T05:40:52.317000
2008-09-25T06:00:42.050000
131,653
131,660
Inline style to act as :hover in CSS
I know that embedding CSS styles directly into the HTML tags they affect defeats much of the purpose of CSS, but sometimes it's useful for debugging purposes, as in: asdf What's the syntax for embedding a rule like: a:hover {text-decoration: underline;} into the style attribute of an A tag? It's obviously not this... b...
I'm afraid it can't be done, the pseudo-class selectors can't be set in-line, you'll have to do it on the page or on a stylesheet. I should mention that technically you should be able to do it according to the CSS spec, but most browsers don't support it Edit: I just did a quick test with this: Test And it doesn't work...
Inline style to act as :hover in CSS I know that embedding CSS styles directly into the HTML tags they affect defeats much of the purpose of CSS, but sometimes it's useful for debugging purposes, as in: asdf What's the syntax for embedding a rule like: a:hover {text-decoration: underline;} into the style attribute of a...
TITLE: Inline style to act as :hover in CSS QUESTION: I know that embedding CSS styles directly into the HTML tags they affect defeats much of the purpose of CSS, but sometimes it's useful for debugging purposes, as in: asdf What's the syntax for embedding a rule like: a:hover {text-decoration: underline;} into the st...
[ "html", "css" ]
125
126
422,830
6
0
2008-09-25T05:51:40.480000
2008-09-25T05:55:13.983000
131,662
131,692
How to differentiate a HTTP Request submitted from a HTML form and a HTTP Request submitted from a client?
Is there any way (in Java Servlet) to determine whether a HTTP POST or GET request is a result from a submission from a HTML form or otherwise?
You could possibly do it with a hidden form field + a cookie. What you could do is set up a nonce, and have that as the hidden field of the form. You would then apply that to a cookie that is sent along with the form. The cookie should be linked to the hidden field, and should also contain some kind of nonce. Finally, ...
How to differentiate a HTTP Request submitted from a HTML form and a HTTP Request submitted from a client? Is there any way (in Java Servlet) to determine whether a HTTP POST or GET request is a result from a submission from a HTML form or otherwise?
TITLE: How to differentiate a HTTP Request submitted from a HTML form and a HTTP Request submitted from a client? QUESTION: Is there any way (in Java Servlet) to determine whether a HTTP POST or GET request is a result from a submission from a HTML form or otherwise? ANSWER: You could possibly do it with a hidden for...
[ "java", "http" ]
0
5
1,042
7
0
2008-09-25T05:58:22.697000
2008-09-25T06:12:38.700000
131,666
131,684
Vista and ProgramData
What is the right place to store program data files which are the same for every user but have to be writeable for the program? What would be the equivalent location on MS Windows XP? I have read that C:\ProgramData is not writeable after installation by normal users. Is that true? How can I retrieve that directory pro...
SHGetFolderPath() with CSIDL of CSIDL_COMMON_APPDATA. Read more at http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx If you need the path in a batch file, you can also use the %ALLUSERSPROFILE% environment variable.
Vista and ProgramData What is the right place to store program data files which are the same for every user but have to be writeable for the program? What would be the equivalent location on MS Windows XP? I have read that C:\ProgramData is not writeable after installation by normal users. Is that true? How can I retri...
TITLE: Vista and ProgramData QUESTION: What is the right place to store program data files which are the same for every user but have to be writeable for the program? What would be the equivalent location on MS Windows XP? I have read that C:\ProgramData is not writeable after installation by normal users. Is that tru...
[ "windows-vista", "directory", "shared", "programdata" ]
15
8
10,442
5
0
2008-09-25T06:00:31.410000
2008-09-25T06:09:17.270000
131,681
131,685
How can I implement rate limiting with Apache? (requests per second)
What techniques and/or modules are available to implement robust rate limiting (requests|bytes/ip/unit time) in apache?
The best mod_evasive (Focused more on reducing DoS exposure) mod_cband (Best featured for 'normal' bandwidth control) and the rest mod_limitipconn mod_bw mod_bwshare
How can I implement rate limiting with Apache? (requests per second) What techniques and/or modules are available to implement robust rate limiting (requests|bytes/ip/unit time) in apache?
TITLE: How can I implement rate limiting with Apache? (requests per second) QUESTION: What techniques and/or modules are available to implement robust rate limiting (requests|bytes/ip/unit time) in apache? ANSWER: The best mod_evasive (Focused more on reducing DoS exposure) mod_cband (Best featured for 'normal' bandw...
[ "apache", "apache2", "ddos" ]
98
60
143,255
7
0
2008-09-25T06:07:10.130000
2008-09-25T06:09:42.997000
131,690
131,790
How can I programmatically manipulate Windows desktop icon locations?
Several years back, I innocently tried to write a little app to save my tactically placed desktop icons because I was sick of dragging them back to their locations when some event reset them. I gave up after buring WAY too much time having failed to find a way to query, much less save and reset, my icons' desktop posit...
If I'm not mistaken the desktop is just a ListView, and you'll have to send the LVM_SETITEMPOSITION message to the handle of the desktop. I googled a bit for some c# code and couldn't find a example, but I did found the following article. Torry:...get/set the positions of desktop icons?. It's delphi code, but I find it...
How can I programmatically manipulate Windows desktop icon locations? Several years back, I innocently tried to write a little app to save my tactically placed desktop icons because I was sick of dragging them back to their locations when some event reset them. I gave up after buring WAY too much time having failed to ...
TITLE: How can I programmatically manipulate Windows desktop icon locations? QUESTION: Several years back, I innocently tried to write a little app to save my tactically placed desktop icons because I was sick of dragging them back to their locations when some event reset them. I gave up after buring WAY too much time...
[ "c#", "windows", "winapi", "icons", "utility" ]
33
18
28,970
2
0
2008-09-25T06:11:11.993000
2008-09-25T06:56:01.513000
131,704
711,754
Is it possible to make an eclipse p2 provisioning mechanism running *locally*?
Eclipse 3.4[.x] - also known as Ganymede - comes with this new mechanism of provisioning called p2. "Provisioning" is the process allowing to discover and update on demand some parts of an application, as explained in general in this article on the Sun Web site. Eclipse has an extended wiki section in which p2 details ...
Yes, you can specify the repository locations if you use the p2.director this for example is a snippet of a script that I use to install eclipse (Ganymede) from a local copy of the Ganymede repository./eclipse\ -nosplash -consolelog -debug\ -vm "${VM}"\ -application org.eclipse.equinox.p2.director.app.application\ -met...
Is it possible to make an eclipse p2 provisioning mechanism running *locally*? Eclipse 3.4[.x] - also known as Ganymede - comes with this new mechanism of provisioning called p2. "Provisioning" is the process allowing to discover and update on demand some parts of an application, as explained in general in this article...
TITLE: Is it possible to make an eclipse p2 provisioning mechanism running *locally*? QUESTION: Eclipse 3.4[.x] - also known as Ganymede - comes with this new mechanism of provisioning called p2. "Provisioning" is the process allowing to discover and update on demand some parts of an application, as explained in gener...
[ "java", "eclipse", "provisioning", "p2" ]
27
11
4,399
2
0
2008-09-25T06:21:04.997000
2009-04-02T21:49:08.690000
131,715
137,433
HttpHeaders in ASP.NET 1.1
How do I read the Response Headers that are being sent down in a page? I want to be able to read the header values and modify some of them. This is for an ASP.NET 1.1 application but I would be curious to know if it can done in any version of ASP.NET. The reason for doing this is someone may have added custom headers o...
HttpContext.Current.Response (Its a HTTPResponse), exposed ClearHeaders(), AddHeaders() and AppendHeaders(). Not as direct as it is now in later version of ASP.NET, but should be enough to let you modify the headers you wanted to modify. http://msdn.microsoft.com/en-us/library/system.web.httpresponse_members(VS.71).asp...
HttpHeaders in ASP.NET 1.1 How do I read the Response Headers that are being sent down in a page? I want to be able to read the header values and modify some of them. This is for an ASP.NET 1.1 application but I would be curious to know if it can done in any version of ASP.NET. The reason for doing this is someone may ...
TITLE: HttpHeaders in ASP.NET 1.1 QUESTION: How do I read the Response Headers that are being sent down in a page? I want to be able to read the header values and modify some of them. This is for an ASP.NET 1.1 application but I would be curious to know if it can done in any version of ASP.NET. The reason for doing th...
[ "http-headers", "asp.net-1.1" ]
0
1
920
2
0
2008-09-25T06:27:37.930000
2008-09-26T02:36:38.553000
131,716
131,734
Get CSIDL_LOCAL_APPDATA path for any user on Windows
Is there any Win32/MFC API to get the CSIDL_LOCAL_APPDATA for any user that I want (not only the currently logged on one)? Let's say I have a list of users in the form "domain\user" and I want to get a list of their paths - is that possible?
You can get the SID for the user and then look it up under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and get the ProfileImagePath value. Once you have this path, you can get CLSID_LOCAL_APPDATA for your user, convert the absolute path to a relative path to your profile and then append that relative ...
Get CSIDL_LOCAL_APPDATA path for any user on Windows Is there any Win32/MFC API to get the CSIDL_LOCAL_APPDATA for any user that I want (not only the currently logged on one)? Let's say I have a list of users in the form "domain\user" and I want to get a list of their paths - is that possible?
TITLE: Get CSIDL_LOCAL_APPDATA path for any user on Windows QUESTION: Is there any Win32/MFC API to get the CSIDL_LOCAL_APPDATA for any user that I want (not only the currently logged on one)? Let's say I have a list of users in the form "domain\user" and I want to get a list of their paths - is that possible? ANSWER...
[ "winapi", "visual-c++", "mfc", "shell32" ]
4
6
9,602
1
0
2008-09-25T06:28:11.033000
2008-09-25T06:35:08.927000
131,718
133,479
Common CRUD functions in PHP
Is there a simple way to write a common function for each of the CRUD (create, retreive, update, delete) operations in PHP WITHOUT using any framework. For example I wish to have a single create function that takes the table name and field names as parameters and inserts data into a mySQL database. Another requirement ...
I wrote this very thing, it's kind of a polished scaffold. It's basically a class the constructor of which takes the table to be used, an array containing field names and types, and an action. Based on this action the object calls a method on itself. For example: This is the array I pass: $data = array(array('name' => ...
Common CRUD functions in PHP Is there a simple way to write a common function for each of the CRUD (create, retreive, update, delete) operations in PHP WITHOUT using any framework. For example I wish to have a single create function that takes the table name and field names as parameters and inserts data into a mySQL d...
TITLE: Common CRUD functions in PHP QUESTION: Is there a simple way to write a common function for each of the CRUD (create, retreive, update, delete) operations in PHP WITHOUT using any framework. For example I wish to have a single create function that takes the table name and field names as parameters and inserts d...
[ "php", "crud" ]
6
1
17,814
8
0
2008-09-25T06:28:23.590000
2008-09-25T13:54:00.603000
131,723
1,360,098
How do you unit test web page authorization using ASP.NET MVC?
Let's say you have a profile page that can only be accessed by the owner of that profile. This profile page is located at: User/Profile/{userID} Now, I imagine in order to prevent access to this page by other users, you could structure your UserController class's Profile function to check the current session's identity...
I ended up going with the "UserNameFilter" shown in Kazi Manzur's blog post. Works like a charm and easy to unit test.
How do you unit test web page authorization using ASP.NET MVC? Let's say you have a profile page that can only be accessed by the owner of that profile. This profile page is located at: User/Profile/{userID} Now, I imagine in order to prevent access to this page by other users, you could structure your UserController c...
TITLE: How do you unit test web page authorization using ASP.NET MVC? QUESTION: Let's say you have a profile page that can only be accessed by the owner of that profile. This profile page is located at: User/Profile/{userID} Now, I imagine in order to prevent access to this page by other users, you could structure you...
[ "asp.net-mvc", "tdd" ]
6
1
1,581
4
0
2008-09-25T06:29:49.890000
2009-09-01T00:56:11.743000
131,728
131,737
How do I change the maximum Upload File Size for the Document Manager in a Telerik RAD Controls RADEditor/WYSIWYG control?
I'm using the Telerik RAD Controls RADEditor/WYSIWYG control as part of a Dynamic Data solution. I would like to be able to upload files using the Document Manager of this control. However, these files are larger than whatever the default setting is for maximum upload file size. Can anyone point me in the right directi...
The Telerik website has instructions here. Short version: in Web.config set the maxRequestLength
How do I change the maximum Upload File Size for the Document Manager in a Telerik RAD Controls RADEditor/WYSIWYG control? I'm using the Telerik RAD Controls RADEditor/WYSIWYG control as part of a Dynamic Data solution. I would like to be able to upload files using the Document Manager of this control. However, these f...
TITLE: How do I change the maximum Upload File Size for the Document Manager in a Telerik RAD Controls RADEditor/WYSIWYG control? QUESTION: I'm using the Telerik RAD Controls RADEditor/WYSIWYG control as part of a Dynamic Data solution. I would like to be able to upload files using the Document Manager of this control...
[ "asp.net", "telerik", "dynamic-data", "wysiwyg", "rad-controls" ]
0
2
3,550
2
0
2008-09-25T06:31:36.563000
2008-09-25T06:36:15.087000
131,744
132,443
Is there a way to embed a web control in a Windows application that renders using anything but Trident (IE)?
I have heard mention that some desktop applications are pretty much just wrappers for websites now. I have even had the occasional problem that has been best solved this way in the past and I can see it being really useful for current applications development. However, one problem I always seemed to run into was that t...
I've personal experience with both Trident and Gecko. TomTom HOME 1.x hosts Trident, as an ActiveX control. There have been projects to adapt the COM interfaces to Gecko, but they seemed rather far-fetched. We've tried embedding Gecko, and that wasn't too hard. In the end, we reversed our approach though. TomTom HOME 2...
Is there a way to embed a web control in a Windows application that renders using anything but Trident (IE)? I have heard mention that some desktop applications are pretty much just wrappers for websites now. I have even had the occasional problem that has been best solved this way in the past and I can see it being re...
TITLE: Is there a way to embed a web control in a Windows application that renders using anything but Trident (IE)? QUESTION: I have heard mention that some desktop applications are pretty much just wrappers for websites now. I have even had the occasional problem that has been best solved this way in the past and I c...
[ ".net", "web-applications" ]
0
1
208
1
0
2008-09-25T06:42:34.570000
2008-09-25T10:09:05.120000
131,754
131,883
When creating a collection via WebDAV should the name of the collection end with a slash
A WebDAV library I'm using is issuing this request MKCOL /collection HTTP/1.1 To which apache is issuing a 301 because /collection exists HTTP/1.1 301 Location: /collection/ Rather than a HTTP/1.1 405 Method Not Allowed The spec is a bit vague on this (or it could be my reading of it), but when issuing an MKCOL, should...
HTTP Code 301 means "Moved Permanently" as you know. Apache is graciously redirecting you to the proper URL. It can't give you a 405 because no resource exists with the URL you provided. But it can't create the resource with that exact URL either. What it can do is create the resource with the proper URL then redirect ...
When creating a collection via WebDAV should the name of the collection end with a slash A WebDAV library I'm using is issuing this request MKCOL /collection HTTP/1.1 To which apache is issuing a 301 because /collection exists HTTP/1.1 301 Location: /collection/ Rather than a HTTP/1.1 405 Method Not Allowed The spec is...
TITLE: When creating a collection via WebDAV should the name of the collection end with a slash QUESTION: A WebDAV library I'm using is issuing this request MKCOL /collection HTTP/1.1 To which apache is issuing a 301 because /collection exists HTTP/1.1 301 Location: /collection/ Rather than a HTTP/1.1 405 Method Not A...
[ "collections", "webdav" ]
0
3
2,061
1
0
2008-09-25T06:46:39.240000
2008-09-25T07:18:38.913000
131,759
179,722
what's the best implemention of client creatable and modifiable web forms in a relational database?
In several web application projects I've been a part of, the client asks to be able to create their own forms. The question arises on how to store their form definitions, and then how to store user inputted values into those custom forms. I've seen it done two ways: Assuming that the client only defines how many fields...
What you're describing is often called "Entity-Attribute-Value," and sometimes described as "mixing data and metadata." That is, the names of attributes (fields) are stored as strings (data). This leads to a bunch of complex problems like making sure each form instance includes the same set of fields, or making sure ma...
what's the best implemention of client creatable and modifiable web forms in a relational database? In several web application projects I've been a part of, the client asks to be able to create their own forms. The question arises on how to store their form definitions, and then how to store user inputted values into t...
TITLE: what's the best implemention of client creatable and modifiable web forms in a relational database? QUESTION: In several web application projects I've been a part of, the client asks to be able to create their own forms. The question arises on how to store their form definitions, and then how to store user inpu...
[ "database-design", "forms", "webforms", "entity-attribute-value" ]
7
3
898
4
0
2008-09-25T06:47:37.537000
2008-10-07T18:21:16.917000
131,788
131,959
How can I identify references to Java classes using Perl?
I'm writing a Perl script and I've come to a point where I need to parse a Java source file line by line checking for references to a fully qualified Java class name. I know the class I'm looking for up front; also the fully qualified name of the source file that is being searched (based on its path). For example find ...
You also need to skip quoted strings (you can't even skip comments correctly if you don't also deal with quoted strings). I'd probably write a fairly simple, efficient, and incomplete tokenizer very similar to the one I wrote in node 566467. Based on that code I'd probably just dig through the non-comment/non-string ch...
How can I identify references to Java classes using Perl? I'm writing a Perl script and I've come to a point where I need to parse a Java source file line by line checking for references to a fully qualified Java class name. I know the class I'm looking for up front; also the fully qualified name of the source file tha...
TITLE: How can I identify references to Java classes using Perl? QUESTION: I'm writing a Perl script and I've come to a point where I need to parse a Java source file line by line checking for references to a fully qualified Java class name. I know the class I'm looking for up front; also the fully qualified name of t...
[ "java", "perl", "parsing" ]
3
5
415
5
0
2008-09-25T06:55:40.233000
2008-09-25T07:33:14.510000
131,793
131,826
I can't include a version number in this old Delphi project I inherited. How do I fix it?
I have an old Delphi codebase I have to maintain, lots of DLLs, some older than others. In some of these DLLs there is no version information in the Project Options dialog. The controls for adding a version are greyed out and I can't even add a version number by manually editing the.DOF file. How can I include a versio...
Check if the default.RES file exists in the project source location. Delphi includes the version number of the project in a.res file with the same name as the.dpr file. If the.RES file does not exist, the simplest way to recreate it is to add the {$R *.RES} compiler directive to the.DPR file, immediately after the uses...
I can't include a version number in this old Delphi project I inherited. How do I fix it? I have an old Delphi codebase I have to maintain, lots of DLLs, some older than others. In some of these DLLs there is no version information in the Project Options dialog. The controls for adding a version are greyed out and I ca...
TITLE: I can't include a version number in this old Delphi project I inherited. How do I fix it? QUESTION: I have an old Delphi codebase I have to maintain, lots of DLLs, some older than others. In some of these DLLs there is no version information in the Project Options dialog. The controls for adding a version are g...
[ "delphi", "dof-file" ]
5
11
3,069
5
0
2008-09-25T06:57:10.980000
2008-09-25T07:05:36.653000
131,801
131,971
Simple serial AVR programmer for beginner
What is the cheap and good way to make a serial (RS232) programmer for AVR atMega and atTiny? There are several circuits in the Internet, but which one is better? I'd like to be able to program my controller from Linux and Windows using some standard tools.
Try the Serial port AVR programmer (DASA) Kit from Adafruit Industries. It's only $7.50, is very popular with the Arduino community, and she provides step by step instructions for assembly on her personal site. If you don't want to build it yourself, Sparkfun Electronics has several serial programmers available for a b...
Simple serial AVR programmer for beginner What is the cheap and good way to make a serial (RS232) programmer for AVR atMega and atTiny? There are several circuits in the Internet, but which one is better? I'd like to be able to program my controller from Linux and Windows using some standard tools.
TITLE: Simple serial AVR programmer for beginner QUESTION: What is the cheap and good way to make a serial (RS232) programmer for AVR atMega and atTiny? There are several circuits in the Internet, but which one is better? I'd like to be able to program my controller from Linux and Windows using some standard tools. A...
[ "embedded", "avr", "circuit" ]
4
4
5,831
6
0
2008-09-25T06:59:21.957000
2008-09-25T07:36:23.723000
131,803
131,833
unsigned int vs. size_t
I notice that modern C and C++ code seems to use size_t instead of int / unsigned int pretty much everywhere - from parameters for C string functions to the STL. I am curious as to the reason for this and the benefits it brings.
The size_t type is the unsigned integer type that is the result of the sizeof operator (and the offsetof operator), so it is guaranteed to be big enough to contain the size of the biggest object your system can handle (e.g., a static array of 8Gb). The size_t type may be bigger than, equal to, or smaller than an unsign...
unsigned int vs. size_t I notice that modern C and C++ code seems to use size_t instead of int / unsigned int pretty much everywhere - from parameters for C string functions to the STL. I am curious as to the reason for this and the benefits it brings.
TITLE: unsigned int vs. size_t QUESTION: I notice that modern C and C++ code seems to use size_t instead of int / unsigned int pretty much everywhere - from parameters for C string functions to the STL. I am curious as to the reason for this and the benefits it brings. ANSWER: The size_t type is the unsigned integer ...
[ "c++", "c", "size-t" ]
586
471
278,857
8
0
2008-09-25T07:00:03.843000
2008-09-25T07:08:12.997000
131,805
131,861
SQL Command for copying table
What is the SQL command to copy a table from one database to another database? I am using MySQL and I have two databases x and y. Suppose I have a table in x called a and I need to copy that table to y database. Sorry if the question is too novice. Thanks.
If your two database are separated, the simplest thing to do would be to create a dump of your table and to load it into the second database. Refer to your database manual to see how a dump can be performed. Otherwise you can use the following syntax (for MySQL) INSERT INTO database_b.table (SELECT * FROM database_a.ta...
SQL Command for copying table What is the SQL command to copy a table from one database to another database? I am using MySQL and I have two databases x and y. Suppose I have a table in x called a and I need to copy that table to y database. Sorry if the question is too novice. Thanks.
TITLE: SQL Command for copying table QUESTION: What is the SQL command to copy a table from one database to another database? I am using MySQL and I have two databases x and y. Suppose I have a table in x called a and I need to copy that table to y database. Sorry if the question is too novice. Thanks. ANSWER: If you...
[ "sql", "mysql" ]
9
7
9,069
6
0
2008-09-25T07:00:17.540000
2008-09-25T07:13:02.953000
131,806
131,815
Mocking classes that aren't interfaces
I've been writing some providers in c# that inherit from the providerbase class. I've found that it's hard to write tests that use the providers as most mocking frameworks will only allow you to mock an interface. Is there any way to mock a call to a provider that inherits from providerbase? If not, is there a pattern ...
Mocking frameworks should be able to create for you a mock object based on a class, as long as it's got virtual members. You may also want to take a look at Typemock
Mocking classes that aren't interfaces I've been writing some providers in c# that inherit from the providerbase class. I've found that it's hard to write tests that use the providers as most mocking frameworks will only allow you to mock an interface. Is there any way to mock a call to a provider that inherits from pr...
TITLE: Mocking classes that aren't interfaces QUESTION: I've been writing some providers in c# that inherit from the providerbase class. I've found that it's hard to write tests that use the providers as most mocking frameworks will only allow you to mock an interface. Is there any way to mock a call to a provider tha...
[ "c#", "unit-testing", "mocking" ]
7
6
5,544
3
0
2008-09-25T07:00:23.060000
2008-09-25T07:02:39.890000
131,811
131,862
How does string.unpack work in Ruby?
Can someone explain why how the result for the following unpack is computed? "aaa".unpack('h2H2') #=> ["16", "61"] In binary, 'a' = 0110 0001. I'm not sure how the 'h2' can become 16 (0001 0000) or 'H2' can become 61 (0011 1101).
Not 16 - it is showing 1 and then 6. h is giving the hex value of each nibble, so you get 0110 (6), then 0001 (1), depending on whether its the high or low bit you're looking at. Use the high nibble first and you get 61, which is hex for 97 - the value of 'a'
How does string.unpack work in Ruby? Can someone explain why how the result for the following unpack is computed? "aaa".unpack('h2H2') #=> ["16", "61"] In binary, 'a' = 0110 0001. I'm not sure how the 'h2' can become 16 (0001 0000) or 'H2' can become 61 (0011 1101).
TITLE: How does string.unpack work in Ruby? QUESTION: Can someone explain why how the result for the following unpack is computed? "aaa".unpack('h2H2') #=> ["16", "61"] In binary, 'a' = 0110 0001. I'm not sure how the 'h2' can become 16 (0001 0000) or 'H2' can become 61 (0011 1101). ANSWER: Not 16 - it is showing 1 a...
[ "ruby" ]
13
10
9,419
3
0
2008-09-25T07:01:06.367000
2008-09-25T07:13:03.967000
131,812
131,820
How do you calculate accumulative time in C#?
I want to calculate the time span between 2 times which I saved in a database. So literally I want to know the length of time between the 2 values. 14:10:20 - 10:05:15 = 02:05:05 So the result would be 02:05:05. How would I be able to achieve this using C#? 14:10:20 is the format I saved it in in my database.
Read the two time values into TimeSpan variables, then perform a.Subtract() on the bigger TimeSpan variable to get the TimeSpan result. E.g. TimeSpan difference = t1.Subtract(t2);.
How do you calculate accumulative time in C#? I want to calculate the time span between 2 times which I saved in a database. So literally I want to know the length of time between the 2 values. 14:10:20 - 10:05:15 = 02:05:05 So the result would be 02:05:05. How would I be able to achieve this using C#? 14:10:20 is the ...
TITLE: How do you calculate accumulative time in C#? QUESTION: I want to calculate the time span between 2 times which I saved in a database. So literally I want to know the length of time between the 2 values. 14:10:20 - 10:05:15 = 02:05:05 So the result would be 02:05:05. How would I be able to achieve this using C#...
[ "c#", "datetime", "time" ]
1
7
10,697
3
0
2008-09-25T07:02:21.230000
2008-09-25T07:04:22.600000
131,818
132,063
Is putting thread on hold optimal?
Application has an auxiliary thread. This thread is not meant to run all the time, but main process can call it very often. So, my question is, what is more optimal in terms of CPU performance: suspend thread when it is not being used or keep it alive and use WaitForSingleObject function in order to wait for a signal f...
In terms of CPU resources used, both solutions are the same - the thread which is suspended and thread which is waiting in WaitForSingleObject for an object which is not signalled both get no CPU cycles at all. That said, WaitForSingleObject is almost always a prefered solution because the code using it will be much mo...
Is putting thread on hold optimal? Application has an auxiliary thread. This thread is not meant to run all the time, but main process can call it very often. So, my question is, what is more optimal in terms of CPU performance: suspend thread when it is not being used or keep it alive and use WaitForSingleObject funct...
TITLE: Is putting thread on hold optimal? QUESTION: Application has an auxiliary thread. This thread is not meant to run all the time, but main process can call it very often. So, my question is, what is more optimal in terms of CPU performance: suspend thread when it is not being used or keep it alive and use WaitFor...
[ "windows", "multithreading", "delphi", "winapi" ]
8
15
1,197
6
0
2008-09-25T07:03:24.753000
2008-09-25T08:08:16.470000
131,840
131,924
JSP pagination without retrieving the whole result set?
I need to display the log entries from a database. Of course the log data is huge, so I have to show the results on several pages, and that **without** getting **all** the log data at once, but as the user navigates through the pages. I know about DisplayTag and TableTags, but it seems to me that they both fetch all th...
About DisplayTag: it does support Value List design pattern.
JSP pagination without retrieving the whole result set? I need to display the log entries from a database. Of course the log data is huge, so I have to show the results on several pages, and that **without** getting **all** the log data at once, but as the user navigates through the pages. I know about DisplayTag and T...
TITLE: JSP pagination without retrieving the whole result set? QUESTION: I need to display the log entries from a database. Of course the log data is huge, so I have to show the results on several pages, and that **without** getting **all** the log data at once, but as the user navigates through the pages. I know abou...
[ "jsp", "pagination" ]
3
3
7,226
3
0
2008-09-25T07:09:16.550000
2008-09-25T07:27:04.900000
131,868
132,214
Are there naming conventions for ASP.NET web application directory structures?
Currently I am developing a site with about seven partial classes, a few icons, three pages and an App_Themes folder. I was interested to know, is there an industry standard directory structure for anything larger than a small project? For example, I want to keep the classes in separate folders, the images in separate ...
I like to be inspired by Microsoft standards, since we are using a Microsoft technology. Plus a somewhat good standard is better than no standard, especially if you work in a larger team. App_Code is standard of course, because it has a function in ASP.NET, not just a best practice. I sort of like the MVC standard proj...
Are there naming conventions for ASP.NET web application directory structures? Currently I am developing a site with about seven partial classes, a few icons, three pages and an App_Themes folder. I was interested to know, is there an industry standard directory structure for anything larger than a small project? For e...
TITLE: Are there naming conventions for ASP.NET web application directory structures? QUESTION: Currently I am developing a site with about seven partial classes, a few icons, three pages and an App_Themes folder. I was interested to know, is there an industry standard directory structure for anything larger than a sm...
[ "asp.net", "visual-studio", "directory-structure" ]
0
1
3,329
5
0
2008-09-25T07:14:35.523000
2008-09-25T08:54:46.280000
131,871
132,085
Algorithm for implementing C# yield statement
I'd love to figure it out myself but I was wondering roughly what's the algorithm for converting a function with yield statements into a state machine for an enumerator? For example how does C# turn this: IEnumerator strings(IEnumerable args) { IEnumerator enumerator2 = getAnotherEnumerator(); foreach(var arg in arg) {...
The particular code sample you are looking at involves a series of transformations. Please note that this is an approximate description of the algorithm. The actual names used by the compiler and the exact code it generates may be different. The idea is the same, however. The first transformation is the "foreach" trans...
Algorithm for implementing C# yield statement I'd love to figure it out myself but I was wondering roughly what's the algorithm for converting a function with yield statements into a state machine for an enumerator? For example how does C# turn this: IEnumerator strings(IEnumerable args) { IEnumerator enumerator2 = get...
TITLE: Algorithm for implementing C# yield statement QUESTION: I'd love to figure it out myself but I was wondering roughly what's the algorithm for converting a function with yield statements into a state machine for an enumerator? For example how does C# turn this: IEnumerator strings(IEnumerable args) { IEnumerator...
[ "c#", "algorithm", "compiler-construction", "iterator", "state-machine" ]
32
60
4,057
3
0
2008-09-25T07:15:28.033000
2008-09-25T08:17:04.767000
131,901
133,845
What are possible reasons for java.io.IOException: "The filename, directory name, or volume label syntax is incorrect"
I am trying to copy a file using the following code: File targetFile = new File(targetPath + File.separator + filename);... targetFile.createNewFile(); fileInputStream = new FileInputStream(fileToCopy); fileOutputStream = new FileOutputStream(targetFile); byte[] buffer = new byte[64*1024]; int i = 0; while((i = fileInp...
Try this, as it takes more care of adjusting directory separator characters in the path between targetPath and filename: File targetFile = new File(targetPath, filename);
What are possible reasons for java.io.IOException: "The filename, directory name, or volume label syntax is incorrect" I am trying to copy a file using the following code: File targetFile = new File(targetPath + File.separator + filename);... targetFile.createNewFile(); fileInputStream = new FileInputStream(fileToCopy)...
TITLE: What are possible reasons for java.io.IOException: "The filename, directory name, or volume label syntax is incorrect" QUESTION: I am trying to copy a file using the following code: File targetFile = new File(targetPath + File.separator + filename);... targetFile.createNewFile(); fileInputStream = new FileInput...
[ "java", "exception", "file-io" ]
24
9
132,501
14
0
2008-09-25T07:22:28.593000
2008-09-25T15:01:04.857000
131,902
137,019
What are the security concerns of evaluating user code?
I am wondering what security concerns there are to implementing a PHP evaluator like this: This is in the context of making a PHP sandbox so sanitising against DB input etc. isn't a massive issue. Users destroying the server the file is hosted on is. I've seen Ruby simulators so I was curious what's involved security w...
could potentially be in really big trouble if you eval() 'd something like it's an extreme example but it that case your site would just get deleted. hopefully your permissions wouldn't allow it but, it helps illustrate the need for sanitization & checks.
What are the security concerns of evaluating user code? I am wondering what security concerns there are to implementing a PHP evaluator like this: This is in the context of making a PHP sandbox so sanitising against DB input etc. isn't a massive issue. Users destroying the server the file is hosted on is. I've seen Rub...
TITLE: What are the security concerns of evaluating user code? QUESTION: I am wondering what security concerns there are to implementing a PHP evaluator like this: This is in the context of making a PHP sandbox so sanitising against DB input etc. isn't a massive issue. Users destroying the server the file is hosted on...
[ "php", "security" ]
5
5
1,752
9
0
2008-09-25T07:22:30.823000
2008-09-26T00:04:37.157000
131,944
131,980
How do I read a time value and then insert it into a TimeSpan variable
How do I read a time value and then insert it into a TimeSpan variables?
If I understand you correctly you're trying to get some user input in the form of "08:00" and want to store the time in a timespan variable? So.. something like this? string input = "08:00"; DateTime time; if (!DateTime.TryParse(input, out time)) { // invalid input return; } TimeSpan timeSpan = new TimeSpan(time.Hour,...
How do I read a time value and then insert it into a TimeSpan variable How do I read a time value and then insert it into a TimeSpan variables?
TITLE: How do I read a time value and then insert it into a TimeSpan variable QUESTION: How do I read a time value and then insert it into a TimeSpan variables? ANSWER: If I understand you correctly you're trying to get some user input in the form of "08:00" and want to store the time in a timespan variable? So.. som...
[ "c#", ".net", "time", "timespan" ]
2
6
2,955
5
0
2008-09-25T07:29:32.523000
2008-09-25T07:39:45.790000
131,955
133,332
Keyboard shortcut to paste clipboard content into command prompt window (Win XP)
Is there a keyboard shortcut for pasting the content of the clipboard into a command prompt window on Windows XP (instead of using the right mouse button)? The typical Shift + Insert does not seem to work here.
I personally use a little AutoHotkey script to remap certain keyboard functions, for the console window (CMD) I use:; Redefine only when the active window is a console window #IfWinActive ahk_class ConsoleWindowClass; Close Command Window with Ctrl+w $^w:: WinGetTitle sTitle If (InStr(sTitle, "-")=0) { Send EXIT{Enter}...
Keyboard shortcut to paste clipboard content into command prompt window (Win XP) Is there a keyboard shortcut for pasting the content of the clipboard into a command prompt window on Windows XP (instead of using the right mouse button)? The typical Shift + Insert does not seem to work here.
TITLE: Keyboard shortcut to paste clipboard content into command prompt window (Win XP) QUESTION: Is there a keyboard shortcut for pasting the content of the clipboard into a command prompt window on Windows XP (instead of using the right mouse button)? The typical Shift + Insert does not seem to work here. ANSWER: I...
[ "windows", "keyboard-shortcuts" ]
305
163
347,689
21
0
2008-09-25T07:31:36.917000
2008-09-25T13:30:58.130000
131,975
182,447
What are the benefits of dependency injection containers?
I understand benefits of dependency injection itself. Let's take Spring for instance. I also understand benefits of other Spring featureslike AOP, helpers of different kinds, etc. I'm just wondering, what are the benefits of XML configuration such as: compared to plain old java code such as: Female mary = new Female();...
For myself one of the main reasons to use an IoC (and make use of external configuration) is around the two areas of: Testing Production maintenance Testing If you split your testing into 3 scenarios (which is fairly normal in large scale development): Unit testing Integration testing Black box testing What you will wa...
What are the benefits of dependency injection containers? I understand benefits of dependency injection itself. Let's take Spring for instance. I also understand benefits of other Spring featureslike AOP, helpers of different kinds, etc. I'm just wondering, what are the benefits of XML configuration such as: compared t...
TITLE: What are the benefits of dependency injection containers? QUESTION: I understand benefits of dependency injection itself. Let's take Spring for instance. I also understand benefits of other Spring featureslike AOP, helpers of different kinds, etc. I'm just wondering, what are the benefits of XML configuration s...
[ "xml", "spring", "dependency-injection" ]
105
41
33,871
16
0
2008-09-25T07:37:19.540000
2008-10-08T12:20:02.153000
131,985
131,987
Which program in Visual Studio lets me look into DLLs to see its API?
See the question. I want to see the methods and classes offered by a DLLs library.
This is exactly what the Object Browser is for. Add a reference to the DLL. Right click it in the list. Click View in Object Browser.
Which program in Visual Studio lets me look into DLLs to see its API? See the question. I want to see the methods and classes offered by a DLLs library.
TITLE: Which program in Visual Studio lets me look into DLLs to see its API? QUESTION: See the question. I want to see the methods and classes offered by a DLLs library. ANSWER: This is exactly what the Object Browser is for. Add a reference to the DLL. Right click it in the list. Click View in Object Browser.
[ ".net", "visual-studio-2008" ]
58
54
124,942
9
0
2008-09-25T07:43:02.133000
2008-09-25T07:43:40.680000
131,989
132,014
How do I get a list of all subdomains of a domain?
I want to find out all the subdomains of a given domain. I found a hint which tells me to dig the authoritative nameserver with the following option: dig @ns1.foo.example example.com axfr But this never works. Has anyone a better idea/approach?
The hint (using axfr) only works if the NS you're querying ( ns1.foo.example in your example) is configured to allow AXFR requests from the IP you're using; this is unlikely, unless your IP is configured as a secondary for the domain in question. Basically, there's no easy way to do it if you're not allowed to use axfr...
How do I get a list of all subdomains of a domain? I want to find out all the subdomains of a given domain. I found a hint which tells me to dig the authoritative nameserver with the following option: dig @ns1.foo.example example.com axfr But this never works. Has anyone a better idea/approach?
TITLE: How do I get a list of all subdomains of a domain? QUESTION: I want to find out all the subdomains of a given domain. I found a hint which tells me to dig the authoritative nameserver with the following option: dig @ns1.foo.example example.com axfr But this never works. Has anyone a better idea/approach? ANSWE...
[ "dns", "subdomain", "dig", "nameservers" ]
284
165
633,336
8
0
2008-09-25T07:43:52.317000
2008-09-25T07:51:47.977000
131,993
132,036
How do you treat the deployment of configuration files on different systems in Subversion?
Subversion is a great way to update our web applications on our servers. With a simple svn update all changed files get... well, changed. Except for the omnipresent configuration files such as config.php which hold the database access configuration, server paths etc. And are therefore different on my local development ...
I find the easiest way is to switch on the machine's hostname. I have a.ini file with a general section that also overrides this for production, testing and development systems. [general] info=misc db.password=secret db.host=localhost [production: general] info=only on production system db.password=secret1 [testing: ...
How do you treat the deployment of configuration files on different systems in Subversion? Subversion is a great way to update our web applications on our servers. With a simple svn update all changed files get... well, changed. Except for the omnipresent configuration files such as config.php which hold the database a...
TITLE: How do you treat the deployment of configuration files on different systems in Subversion? QUESTION: Subversion is a great way to update our web applications on our servers. With a simple svn update all changed files get... well, changed. Except for the omnipresent configuration files such as config.php which h...
[ "svn", "version-control", "configuration" ]
7
1
622
6
0
2008-09-25T07:45:33.420000
2008-09-25T07:59:33.497000
132,030
146,879
Deployment of custom content type, forms, cqwp, and xsl
Right now I have a visual studio project which contains a custom content type that I made. It also contains all the necessary files for making a sharepoint solution (wsp) file and a script to generate this. Now, I would like to do 2 things. First, I'd like to create a custom display form for the content type and includ...
Use STSDev to create the solution package. That should help with creating the WSP. The custom form, CQWP webpart and the.xls file should also be deployable within the project. To deploy the xslt, your feature will have an This then points to a files such as for the webpart: Now that file will need to be contained in th...
Deployment of custom content type, forms, cqwp, and xsl Right now I have a visual studio project which contains a custom content type that I made. It also contains all the necessary files for making a sharepoint solution (wsp) file and a script to generate this. Now, I would like to do 2 things. First, I'd like to crea...
TITLE: Deployment of custom content type, forms, cqwp, and xsl QUESTION: Right now I have a visual studio project which contains a custom content type that I made. It also contains all the necessary files for making a sharepoint solution (wsp) file and a script to generate this. Now, I would like to do 2 things. First...
[ "sharepoint", "moss", "content-type", "cqwp" ]
2
1
2,260
4
0
2008-09-25T07:57:51.363000
2008-09-28T22:14:31.720000
132,038
1,433,857
Send To/Mail Recipient from WSH
I am trying to implement in windows scripting host the same function as windows Send To/Mail Recipient does. Did not find anything usefull on google except steps to instantiate Outlook.Application and directly calling its methods. I need to go the same path as windows do, as there is a mix of Outlook and Lotus Notes in...
I found one item on CodeProject from 2003 that might be relevant.
Send To/Mail Recipient from WSH I am trying to implement in windows scripting host the same function as windows Send To/Mail Recipient does. Did not find anything usefull on google except steps to instantiate Outlook.Application and directly calling its methods. I need to go the same path as windows do, as there is a m...
TITLE: Send To/Mail Recipient from WSH QUESTION: I am trying to implement in windows scripting host the same function as windows Send To/Mail Recipient does. Did not find anything usefull on google except steps to instantiate Outlook.Application and directly calling its methods. I need to go the same path as windows d...
[ "email", "wsh" ]
0
1
1,006
2
0
2008-09-25T08:00:12.497000
2009-09-16T15:53:33.583000
132,039
132,119
How to send Email through a C++ program?
How can I send an email from C++? Is there a good cross-platform (MS Windows, Linux etc) library that I can use? I'm using GCC (cygwin on MS Windows).
Check out jwSMTP - a cross-platform SMTP class. http://johnwiggins.net/jwsmtp/
How to send Email through a C++ program? How can I send an email from C++? Is there a good cross-platform (MS Windows, Linux etc) library that I can use? I'm using GCC (cygwin on MS Windows).
TITLE: How to send Email through a C++ program? QUESTION: How can I send an email from C++? Is there a good cross-platform (MS Windows, Linux etc) library that I can use? I'm using GCC (cygwin on MS Windows). ANSWER: Check out jwSMTP - a cross-platform SMTP class. http://johnwiggins.net/jwsmtp/
[ "c++", "email", "gcc" ]
2
1
1,854
3
0
2008-09-25T08:00:26.507000
2008-09-25T08:28:21.947000
132,040
132,112
image archive VS image strip
i've noticed that plenty of games / applications (very common on mobile builds) pack numerous images into an image strip. I figured that the advantages in this are making the program more tidy (file system - wise) and reducing (un)installation time. During the runtime of the application, the entire image strip is alloc...
Caching will not be as much of an issue as you think, if the images in the strip are likely to appear at the same time - i.e. are all part of an animation. As far as packing algorithms are concerned, most generic algorithms produce similar levels of efficiency - to get huge increases in packing efficiency you normally ...
image archive VS image strip i've noticed that plenty of games / applications (very common on mobile builds) pack numerous images into an image strip. I figured that the advantages in this are making the program more tidy (file system - wise) and reducing (un)installation time. During the runtime of the application, th...
TITLE: image archive VS image strip QUESTION: i've noticed that plenty of games / applications (very common on mobile builds) pack numerous images into an image strip. I figured that the advantages in this are making the program more tidy (file system - wise) and reducing (un)installation time. During the runtime of t...
[ "algorithm", "optimization", "image-archive" ]
1
2
170
1
0
2008-09-25T08:00:29.343000
2008-09-25T08:26:45.880000
132,052
132,932
Servlet for serving static content
I deploy a webapp on two different containers (Tomcat and Jetty), but their default servlets for serving the static content have a different way of handling the URL structure I want to use ( details ). I am therefore looking to include a small servlet in the webapp to serve its own static content (images, CSS, etc.). T...
I ended up rolling my own StaticServlet. It supports If-Modified-Since, gzip encoding and it should be able to serve static files from war-files as well. It is not very difficult code, but it is not entirely trivial either. The code is available: StaticServlet.java. Feel free to comment. Update: Khurram asks about the ...
Servlet for serving static content I deploy a webapp on two different containers (Tomcat and Jetty), but their default servlets for serving the static content have a different way of handling the URL structure I want to use ( details ). I am therefore looking to include a small servlet in the webapp to serve its own st...
TITLE: Servlet for serving static content QUESTION: I deploy a webapp on two different containers (Tomcat and Jetty), but their default servlets for serving the static content have a different way of handling the URL structure I want to use ( details ). I am therefore looking to include a small servlet in the webapp t...
[ "java", "jsp", "servlets", "jakarta-ee" ]
152
20
182,328
14
0
2008-09-25T08:04:28.353000
2008-09-25T12:14:08.017000
132,058
133,384
Showing the stack trace from a running Python application
I have this Python application that gets stuck from time to time and I can't find out where. Is there any way to signal Python interpreter to show you the exact code that's running? Some kind of on-the-fly stacktrace? Related questions: Print current call stack from a method in Python code Check what a running process ...
I have module I use for situations like this - where a process will be running for a long time but gets stuck sometimes for unknown and irreproducible reasons. Its a bit hacky, and only works on unix (requires signals): import code, traceback, signal def debug(sig, frame): """Interrupt running process, and provide a p...
Showing the stack trace from a running Python application I have this Python application that gets stuck from time to time and I can't find out where. Is there any way to signal Python interpreter to show you the exact code that's running? Some kind of on-the-fly stacktrace? Related questions: Print current call stack ...
TITLE: Showing the stack trace from a running Python application QUESTION: I have this Python application that gets stuck from time to time and I can't find out where. Is there any way to signal Python interpreter to show you the exact code that's running? Some kind of on-the-fly stacktrace? Related questions: Print c...
[ "python", "debugging", "stack-trace", "traceback" ]
399
353
179,499
29
0
2008-09-25T08:06:06.087000
2008-09-25T13:38:45.257000
132,070
132,106
How do I check that I removed required data only?
I have a really big database (running on PostgreSQL) containing a lot of tables with sophisticated relations between them (foreign keys, on delete cascade and so on). I need remove some data from a number of tables, but I'm not sure what amount of data will be really deleted from database due to cascade removals. How c...
You can query the information_schema to draw yourself a picture on how the constraints are defined in the database. Then you'll know what is going to happen when you delete. This will be useful not only for this case, but always. Something like (for constraints) select table_catalog,table_schema,table_name,column_name,...
How do I check that I removed required data only? I have a really big database (running on PostgreSQL) containing a lot of tables with sophisticated relations between them (foreign keys, on delete cascade and so on). I need remove some data from a number of tables, but I'm not sure what amount of data will be really de...
TITLE: How do I check that I removed required data only? QUESTION: I have a really big database (running on PostgreSQL) containing a lot of tables with sophisticated relations between them (foreign keys, on delete cascade and so on). I need remove some data from a number of tables, but I'm not sure what amount of data...
[ "postgresql", "constraints", "referential-integrity", "pg-dump" ]
1
1
385
4
0
2008-09-25T08:10:16.357000
2008-09-25T08:23:43.453000
132,116
132,148
Heisenbug: WinApi program crashes on some computers
Please help! I'm really at my wits' end. My program is a little personal notes manager (google for "cintanotes"). On some computers (and of course I own none of them) it crashes with an unhandled exception just after start. Nothing special about these computers could be said, except that they tend to have AMD CPUs. Env...
So it doesnnt crash when configuration is DEBUG Configuration? There are many things different than a RELEASE configruation: 1.) Initialization of globals 2.) Actual machine Code generated etc.. So first step is find out what are exact settings for each parameter in the RELEASE mode as compared to the DEBUG mode. -AD
Heisenbug: WinApi program crashes on some computers Please help! I'm really at my wits' end. My program is a little personal notes manager (google for "cintanotes"). On some computers (and of course I own none of them) it crashes with an unhandled exception just after start. Nothing special about these computers could ...
TITLE: Heisenbug: WinApi program crashes on some computers QUESTION: Please help! I'm really at my wits' end. My program is a little personal notes manager (google for "cintanotes"). On some computers (and of course I own none of them) it crashes with an unhandled exception just after start. Nothing special about thes...
[ "c++", "debugging", "winapi", "crash", "gdi" ]
9
5
2,472
11
0
2008-09-25T08:27:40.980000
2008-09-25T08:38:13.093000
132,121
274,657
What makes a pthread defunct?
i'm working with a multi-threaded program (using pthreads) that currently create a background thread (PTHREAD_DETACHED) and then invokes pthread_exit(0). My problem is that the process is then listed as "defunct" and curiously do not seems to "really exists" in /proc (which defeats my debugging strategies) I would like...
You can either suspend the execution of the main process waiting for a signal, or don't detach the thread (using the default PHTREAD_CRATE_JOINABLE ) waiting for its termination with a pthread_join().
What makes a pthread defunct? i'm working with a multi-threaded program (using pthreads) that currently create a background thread (PTHREAD_DETACHED) and then invokes pthread_exit(0). My problem is that the process is then listed as "defunct" and curiously do not seems to "really exists" in /proc (which defeats my debu...
TITLE: What makes a pthread defunct? QUESTION: i'm working with a multi-threaded program (using pthreads) that currently create a background thread (PTHREAD_DETACHED) and then invokes pthread_exit(0). My problem is that the process is then listed as "defunct" and curiously do not seems to "really exists" in /proc (whi...
[ "c", "linux", "multithreading", "pthreads", "procfs" ]
2
2
2,450
3
0
2008-09-25T08:29:15.330000
2008-11-08T12:08:01.720000
132,131
135,433
XML namespace problem in Visual Studio generated service reference
I'm connecting to a web service hosted by a third-party provider. I've added a service reference in my project to the web service, VS has generated all the references and classes needed. I'm connecting with this piece of code (client name and methods anonymized): using (var client = new Client()) { try { client.Open();...
If you were able to create a service reference then the WSDL is valid. The exception message is saying you have namespace/type ambiguity problem with _return. The generated code is probably using it in some context as a boolean and in another context as a Service.Status type. I don’t call the ClientBase.Open method bef...
XML namespace problem in Visual Studio generated service reference I'm connecting to a web service hosted by a third-party provider. I've added a service reference in my project to the web service, VS has generated all the references and classes needed. I'm connecting with this piece of code (client name and methods an...
TITLE: XML namespace problem in Visual Studio generated service reference QUESTION: I'm connecting to a web service hosted by a third-party provider. I've added a service reference in my project to the web service, VS has generated all the references and classes needed. I'm connecting with this piece of code (client n...
[ "c#", ".net", "wcf", "web-services" ]
2
2
4,952
1
0
2008-09-25T08:32:54.947000
2008-09-25T19:25:09.590000
132,132
132,165
User Interface - Dropdown
What is the best way to design an interface so that very long drop down values that get trucated due to size limits do not create a very bad user experience. My question is for web applications. Could you please send your suggestions. Thanks.
Well, what I have done in such a case is: Using autocomplete (so that the user can start typing and get at the intended option faster). Have the dropdown of a fixed length like 30 chars. Now, if the value of the drop down is longer I just truncate it to 25 with a '...' at the end. A hover on this value will make the fu...
User Interface - Dropdown What is the best way to design an interface so that very long drop down values that get trucated due to size limits do not create a very bad user experience. My question is for web applications. Could you please send your suggestions. Thanks.
TITLE: User Interface - Dropdown QUESTION: What is the best way to design an interface so that very long drop down values that get trucated due to size limits do not create a very bad user experience. My question is for web applications. Could you please send your suggestions. Thanks. ANSWER: Well, what I have done i...
[ "user-interface" ]
4
1
510
4
0
2008-09-25T08:33:32.370000
2008-09-25T08:42:14.457000
132,134
133,427
PHP - Security what is best way?
What is the best way to secure an intranet website developed using PHP from outside attacks?
That's a stunningly thought-provoking question, and I'm surprised that you haven't received better answers. Summary Everything you would do for an external-facing application, and then some. Thought Process If I'm understanding you correctly, then you are asking a question which very few developers are asking themselve...
PHP - Security what is best way? What is the best way to secure an intranet website developed using PHP from outside attacks?
TITLE: PHP - Security what is best way? QUESTION: What is the best way to secure an intranet website developed using PHP from outside attacks? ANSWER: That's a stunningly thought-provoking question, and I'm surprised that you haven't received better answers. Summary Everything you would do for an external-facing appl...
[ "php", "security" ]
7
11
632
6
0
2008-09-25T08:34:20.153000
2008-09-25T13:43:47.880000
132,139
140,827
Asp.net hosting provider with build capabilities and source control
Can you suggest an asp.net 3.5 hosting provider with continuous integration (cctray – nant builds) and source control facilities (svn)? My requirement would be something like this: I checkin to a svn branch (say trunk) on the hosting provider space. CruiseControl.NET on the server fires off a build. I see success/failu...
I would also have to suggest a VPS as I have yet to see a Shared Hosting provider with compilers installed. On the code repository side Assembla.com has free svn hosting and they also provide a way to kick off a build process by allowing you to specify a URL to post to when a check-in occurs. This URL can kick off a sc...
Asp.net hosting provider with build capabilities and source control Can you suggest an asp.net 3.5 hosting provider with continuous integration (cctray – nant builds) and source control facilities (svn)? My requirement would be something like this: I checkin to a svn branch (say trunk) on the hosting provider space. Cr...
TITLE: Asp.net hosting provider with build capabilities and source control QUESTION: Can you suggest an asp.net 3.5 hosting provider with continuous integration (cctray – nant builds) and source control facilities (svn)? My requirement would be something like this: I checkin to a svn branch (say trunk) on the hosting ...
[ "asp.net", "version-control", "continuous-integration", "hosting" ]
4
2
766
3
0
2008-09-25T08:35:47.543000
2008-09-26T17:32:07.690000
132,166
132,192
Vista Serial programmatically
How do I obtain the serial number of the installed Vista system? Also is there a tool that does the same thing so I can verify MY results?
A quick list of tools: http://pcsupport.about.com/od/productkeysactivation/tp/topkeyfinder.htm http://magicaljellybean.com/keyfinder/ http://techblissonline.com/find-product-key-cd-ley-windows-vista-xp-office-2007-sql-server-produkey/
Vista Serial programmatically How do I obtain the serial number of the installed Vista system? Also is there a tool that does the same thing so I can verify MY results?
TITLE: Vista Serial programmatically QUESTION: How do I obtain the serial number of the installed Vista system? Also is there a tool that does the same thing so I can verify MY results? ANSWER: A quick list of tools: http://pcsupport.about.com/od/productkeysactivation/tp/topkeyfinder.htm http://magicaljellybean.com/k...
[ "windows-vista" ]
0
2
216
1
0
2008-09-25T08:42:57.807000
2008-09-25T08:47:59.480000
132,195
132,211
What is the best operating system for a server?
What would you suggest would be the best operating system for a web server? If possible, please enumerate the advantages and disadvantages if there are any...
Use an operating system you have an administrator account for. A mainstream flavour of Linux is a great choice for stability, but if no one knows how to look after it it's a bad idea. The same goes for any other platform you can name.
What is the best operating system for a server? What would you suggest would be the best operating system for a web server? If possible, please enumerate the advantages and disadvantages if there are any...
TITLE: What is the best operating system for a server? QUESTION: What would you suggest would be the best operating system for a web server? If possible, please enumerate the advantages and disadvantages if there are any... ANSWER: Use an operating system you have an administrator account for. A mainstream flavour of...
[ "operating-system" ]
1
6
853
6
0
2008-09-25T08:49:17.747000
2008-09-25T08:54:05.673000
132,231
134,974
Dealing with command line arguments and Spring
When I'm writing a Spring command line application which parses command line arguments, how do I pass them to Spring? Would I want to have my main() structured so that it first parses the command line args and then inits Spring? Even so, how would it pass the object holding the parsed args to Spring?
Two possibilities I can think of. 1) Set a static reference. (A static variable, although typically frowned upon, is OK in this case, because there can only be 1 command line invocation). public class MyApp { public static String[] ARGS; public static void main(String[] args) { ARGS = args; // create context } } You ca...
Dealing with command line arguments and Spring When I'm writing a Spring command line application which parses command line arguments, how do I pass them to Spring? Would I want to have my main() structured so that it first parses the command line args and then inits Spring? Even so, how would it pass the object holdin...
TITLE: Dealing with command line arguments and Spring QUESTION: When I'm writing a Spring command line application which parses command line arguments, how do I pass them to Spring? Would I want to have my main() structured so that it first parses the command line args and then inits Spring? Even so, how would it pass...
[ "java", "spring", "command-line" ]
39
40
37,987
8
0
2008-09-25T08:59:36.067000
2008-09-25T18:12:21.153000
132,241
132,509
Hidden features of C
I know there is a standard behind all C compiler implementations, so there should be no hidden features. Despite that, I am sure all C developers have hidden/secret tricks they use all the time.
Function pointers. You can use a table of function pointers to implement, e.g., fast indirect-threaded code interpreters (FORTH) or byte-code dispatchers, or to simulate OO-like virtual methods. Then there are hidden gems in the standard library, such as qsort(),bsearch(), strpbrk(), strcspn() [the latter two being use...
Hidden features of C I know there is a standard behind all C compiler implementations, so there should be no hidden features. Despite that, I am sure all C developers have hidden/secret tricks they use all the time.
TITLE: Hidden features of C QUESTION: I know there is a standard behind all C compiler implementations, so there should be no hidden features. Despite that, I am sure all C developers have hidden/secret tricks they use all the time. ANSWER: Function pointers. You can use a table of function pointers to implement, e.g...
[ "c", "hidden-features" ]
141
62
91,431
56
0
2008-09-25T09:02:06.717000
2008-09-25T10:29:18.160000
132,245
132,324
Is there any way to use an extension method in an object initializer block in C#
The simple demo below captures what I am trying to do. In the real program, I have to use the object initialiser block since it is reading a list in a LINQ to SQL select expression, and there is a value that that I want to read off the database and store on the object, but the object doesn't have a simple property that...
Even better: public static T SetBarValue (this T dataObject, int barValue) where T: BaseDataObject { dataObject.SetData("bar", barValue); return dataObject; } and you can use this extension method for derived types of BaseDataObject to chain methods without casts and preserve the real type when inferred into a var fiel...
Is there any way to use an extension method in an object initializer block in C# The simple demo below captures what I am trying to do. In the real program, I have to use the object initialiser block since it is reading a list in a LINQ to SQL select expression, and there is a value that that I want to read off the dat...
TITLE: Is there any way to use an extension method in an object initializer block in C# QUESTION: The simple demo below captures what I am trying to do. In the real program, I have to use the object initialiser block since it is reading a list in a LINQ to SQL select expression, and there is a value that that I want t...
[ "c#", "linq", "extension-methods", "initializer" ]
7
3
1,807
6
0
2008-09-25T09:02:51.677000
2008-09-25T09:33:52.427000
132,251
132,321
WPF animation of items between layouts?
I have two different ways of displaying items in a WPF application. The first uses a WrapPanel and the second a vertical StackPanel. I can switch between the two ways of displaying my items by switching the host panel between the two types. This does work but you get an instance change in layout. Instead I want the chi...
Have a look at the SwitchPanel from IdentityMine's Blendables Layout and also read Dr WPF's article on CodeProject about Conceptual Children
WPF animation of items between layouts? I have two different ways of displaying items in a WPF application. The first uses a WrapPanel and the second a vertical StackPanel. I can switch between the two ways of displaying my items by switching the host panel between the two types. This does work but you get an instance ...
TITLE: WPF animation of items between layouts? QUESTION: I have two different ways of displaying items in a WPF application. The first uses a WrapPanel and the second a vertical StackPanel. I can switch between the two ways of displaying my items by switching the host panel between the two types. This does work but yo...
[ "wpf", "layout", "animation" ]
4
2
1,935
2
0
2008-09-25T09:04:32.217000
2008-09-25T09:32:38.547000
132,263
133,267
When exactly plugin.xml files from dependencies of my plugin are loaded?
I vahe eclipse rcp app. In my plugin A I use 3rd party plugin B. In plugin B there is plugin.xml with some extensions. In my plugin A I have added some extensions to extensions defined in plugin B, and it works. Now I tried to overwrite some values in some extensions from B in plugin A. Now, when I run app sometimes it...
Eclipse makes no guarantees about the order that extensions are seen. Further, there is no guaranteed lifecycle for when specific plugins are loaded. If you want a guarantee, you need to implement it manually, and that will probably require a change of plugin B.
When exactly plugin.xml files from dependencies of my plugin are loaded? I vahe eclipse rcp app. In my plugin A I use 3rd party plugin B. In plugin B there is plugin.xml with some extensions. In my plugin A I have added some extensions to extensions defined in plugin B, and it works. Now I tried to overwrite some value...
TITLE: When exactly plugin.xml files from dependencies of my plugin are loaded? QUESTION: I vahe eclipse rcp app. In my plugin A I use 3rd party plugin B. In plugin B there is plugin.xml with some extensions. In my plugin A I have added some extensions to extensions defined in plugin B, and it works. Now I tried to ov...
[ "java", "eclipse-plugin", "rcp", "plugin.xml" ]
1
1
414
1
0
2008-09-25T09:07:16.063000
2008-09-25T13:19:38.750000
132,277
132,333
Active Directory: Retrieve User information
I've got a web application that is running against Windows Authentication using our Active Directory. I've got a new requirement to pull some personal information through from the Active Directory entry. What would be the easiest way to get access to this information?
Accessing the user directly through a DirectoryEntry seems like the most straightforward approach. Here are some AD-related tidbits I learned from my first AD-related project: In a URI, write LDAP in lowercase. Otherwise you'll get a mystery error. I spent more than a day on this depressing issue... To clear a single-v...
Active Directory: Retrieve User information I've got a web application that is running against Windows Authentication using our Active Directory. I've got a new requirement to pull some personal information through from the Active Directory entry. What would be the easiest way to get access to this information?
TITLE: Active Directory: Retrieve User information QUESTION: I've got a web application that is running against Windows Authentication using our Active Directory. I've got a new requirement to pull some personal information through from the Active Directory entry. What would be the easiest way to get access to this in...
[ "c#", "active-directory" ]
10
17
13,619
5
0
2008-09-25T09:16:34.107000
2008-09-25T09:35:09.367000
132,280
136,724
Are there any tips/tricks about using Subsonic with Asp.Net MVC Framework?
Is there anyone using Subsonic with asp.net mvc framework? If so, can you tell us something about your experience. Are there tips and tricks that can be shared?
If you're planning on doing database first design, and you don't need any mapping (i.e. you're in control of your db naming) then SubSonic is a decent option. It's straight-forward, doesn't hide a lot from you. On the same token, for advanced scenarios I have to side-step it a lot and execute raw sql (or a sproc). If y...
Are there any tips/tricks about using Subsonic with Asp.Net MVC Framework? Is there anyone using Subsonic with asp.net mvc framework? If so, can you tell us something about your experience. Are there tips and tricks that can be shared?
TITLE: Are there any tips/tricks about using Subsonic with Asp.Net MVC Framework? QUESTION: Is there anyone using Subsonic with asp.net mvc framework? If so, can you tell us something about your experience. Are there tips and tricks that can be shared? ANSWER: If you're planning on doing database first design, and yo...
[ "asp.net-mvc", "subsonic" ]
9
9
1,225
2
0
2008-09-25T09:16:55.213000
2008-09-25T22:56:00.317000
132,282
132,285
Is there a standard way to authenticate applications to your web API?
I'm looking at building a simple web app that will expose an API that lets third-party (well, written by me, but that's not the point) apps query for and modify user-specific data stored on the site. Obviously I don't want to allow apps to be able to get user-specific information without that users consent. I would wan...
Will OAuth work for you? That's the problem it was designed to solve.
Is there a standard way to authenticate applications to your web API? I'm looking at building a simple web app that will expose an API that lets third-party (well, written by me, but that's not the point) apps query for and modify user-specific data stored on the site. Obviously I don't want to allow apps to be able to...
TITLE: Is there a standard way to authenticate applications to your web API? QUESTION: I'm looking at building a simple web app that will expose an API that lets third-party (well, written by me, but that's not the point) apps query for and modify user-specific data stored on the site. Obviously I don't want to allow ...
[ "web-services", "authentication", "standards" ]
5
7
286
2
0
2008-09-25T09:18:09.360000
2008-09-25T09:19:11.497000
132,293
133,627
SVNkit cannot create SVNRepoitory
I am trying to run a diff on two svn urls using SVNkit. The problem is that I get the error when diff.doDiff is called. org.tmatesoft.svn.core.SVNException: svn: Unable to create SVNRepository object for ' http://svn.codehaus.org/jruby/trunk/jruby/src/org/jruby/Finalizable.java ' at org.tmatesoft.svn.core.internal.wc.S...
have you called the following static method? DAVRepositoryFactory.setup(); This needs to be called before accessing any http:// repositories and the similar SVNRepositoryFactoryImpl.setup(); should be used for svn:// repositories.
SVNkit cannot create SVNRepoitory I am trying to run a diff on two svn urls using SVNkit. The problem is that I get the error when diff.doDiff is called. org.tmatesoft.svn.core.SVNException: svn: Unable to create SVNRepository object for ' http://svn.codehaus.org/jruby/trunk/jruby/src/org/jruby/Finalizable.java ' at or...
TITLE: SVNkit cannot create SVNRepoitory QUESTION: I am trying to run a diff on two svn urls using SVNkit. The problem is that I get the error when diff.doDiff is called. org.tmatesoft.svn.core.SVNException: svn: Unable to create SVNRepository object for ' http://svn.codehaus.org/jruby/trunk/jruby/src/org/jruby/Finali...
[ "java", "svn", "svnkit" ]
13
21
4,457
1
0
2008-09-25T09:22:13.173000
2008-09-25T14:20:34.440000
132,295
134,152
Last Resource Optimization
I'm writing a Resource Adaptor which does not support two phase commit. I know there is an optimization technique called: "Last Resource Optimization". On JBoss your XAResource class should implement LastResource in order to have the optimization. My question is: how this can be done in WebLogic, WebSpehre, Glassfish, ...
Weblogic: AFAIK (may be very wrong) only JDBC drivers can be used with LRO, and it's a purely administrative task. When a driver doesn't support XA, it can be configured to be used with LRO: "Select this option if you want to enable non-XA JDBC connections from the data source to emulate participation in global transac...
Last Resource Optimization I'm writing a Resource Adaptor which does not support two phase commit. I know there is an optimization technique called: "Last Resource Optimization". On JBoss your XAResource class should implement LastResource in order to have the optimization. My question is: how this can be done in WebLo...
TITLE: Last Resource Optimization QUESTION: I'm writing a Resource Adaptor which does not support two phase commit. I know there is an optimization technique called: "Last Resource Optimization". On JBoss your XAResource class should implement LastResource in order to have the optimization. My question is: how this ca...
[ "java", "application-server", "jta", "2phase-commit" ]
1
6
1,515
1
0
2008-09-25T09:22:37.680000
2008-09-25T15:53:11.113000
132,299
132,451
Is there an easy way, to Port a Win32 App in Delphi 2009 to .NET?
We want migrate from Delphi 7.0 to Delphi 2009, to stay up with a modern IDE and current technology. Our target platform is.NET. What is best way, to achieve this goal?
I'd take onboard the Unicode situation with string handling that came in from D2007 to D2009 - the changes involved in this step might affect your application a lot (only you can tell this). Also, you will need to consider what third party tools/libraries/components you are using. Not everything has made the jump to D2...
Is there an easy way, to Port a Win32 App in Delphi 2009 to .NET? We want migrate from Delphi 7.0 to Delphi 2009, to stay up with a modern IDE and current technology. Our target platform is.NET. What is best way, to achieve this goal?
TITLE: Is there an easy way, to Port a Win32 App in Delphi 2009 to .NET? QUESTION: We want migrate from Delphi 7.0 to Delphi 2009, to stay up with a modern IDE and current technology. Our target platform is.NET. What is best way, to achieve this goal? ANSWER: I'd take onboard the Unicode situation with string handlin...
[ ".net", "delphi", "delphi-2009" ]
3
3
990
6
0
2008-09-25T09:23:16.103000
2008-09-25T10:10:39.080000
132,305
153,459
Linked Server Performance and options
At work we have two servers, one is running an application a lot of people use which has an SQL Server 2000 back end. I have been free to query this for a long time but can't add anything to it such as stored procedures or extra tables. This has lead to us having a second SQL Server linked to the first one and me build...
I would advise dynamic openqueries in a cursor loop instead of linked joins. This is the only way i've been able to replicate MS Access' linked join performance (at least for single remote tables) Regular linked joins in ms sql are too inefficient by pulling everything specially in humongous tables.. -- I would like to...
Linked Server Performance and options At work we have two servers, one is running an application a lot of people use which has an SQL Server 2000 back end. I have been free to query this for a long time but can't add anything to it such as stored procedures or extra tables. This has lead to us having a second SQL Serve...
TITLE: Linked Server Performance and options QUESTION: At work we have two servers, one is running an application a lot of people use which has an SQL Server 2000 back end. I have been free to query this for a long time but can't add anything to it such as stored procedures or extra tables. This has lead to us having ...
[ "sql-server-2000", "linked-server" ]
9
0
20,697
9
0
2008-09-25T09:25:33.227000
2008-09-30T15:04:14.983000
132,318
135,096
How do I correct the character encoding of a file?
I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8. Can the data be decoded correctly or is it lost in transcoding? What tools could I use? Here is a sample of what I have: ç é I can tell from context ...
EDIT: A simple possibility to eliminate before getting into more complicated solutions: have you tried setting the character set to utf8 in the text editor in which you're reading the file? This could just be a case of somebody sending you a utf8 file that you're reading in an editor set to say cp1252. Just taking the ...
How do I correct the character encoding of a file? I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8. Can the data be decoded correctly or is it lost in transcoding? What tools could I use? Here is a sa...
TITLE: How do I correct the character encoding of a file? QUESTION: I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8. Can the data be decoded correctly or is it lost in transcoding? What tools could I...
[ "encoding", "utf-8", "character-encoding", "text-files", "codepages" ]
64
22
228,756
11
0
2008-09-25T09:31:22.963000
2008-09-25T18:31:45.693000
132,323
132,423
Obtain an index into a vector using Iterators
When iterating over elements of a vector it is preferred to use iterators instead of an index (see Why use iterators instead of array indices? ). std::vector vec; std::vector::iterator it; for ( it = vec.begin(); it!= vec.end(); ++it ) { // do work } However, it can be necessary to use the index in the body of the loop...
If you're planning on using exclusively a vector, you may want to switch back to the indexed loop, since it conveys your intent more clearly than iterator-loop. However, if evolution of your program in the future may lead to a change of container, you should stick to the iterators and use std::distance, which is guaran...
Obtain an index into a vector using Iterators When iterating over elements of a vector it is preferred to use iterators instead of an index (see Why use iterators instead of array indices? ). std::vector vec; std::vector::iterator it; for ( it = vec.begin(); it!= vec.end(); ++it ) { // do work } However, it can be nece...
TITLE: Obtain an index into a vector using Iterators QUESTION: When iterating over elements of a vector it is preferred to use iterators instead of an index (see Why use iterators instead of array indices? ). std::vector vec; std::vector::iterator it; for ( it = vec.begin(); it!= vec.end(); ++it ) { // do work } Howev...
[ "c++", "indexing", "vector", "iterator" ]
5
13
5,200
7
0
2008-09-25T09:33:22.693000
2008-09-25T09:59:47.937000
132,329
132,407
Full text search engine example in F#?
Are there any good examples (websites or books) around of how to build a full text search engine in F#?
Do you want to write this yourself? Or do you simply need the functionality? If you need the functionality, an embedded/in-memory database with Full Text Search support may do the trick. Since it's.Net, I'd recommend SQLite ADO.Net Provider as the open-source contender. It's really good ( Support LINQ before any other ...
Full text search engine example in F#? Are there any good examples (websites or books) around of how to build a full text search engine in F#?
TITLE: Full text search engine example in F#? QUESTION: Are there any good examples (websites or books) around of how to build a full text search engine in F#? ANSWER: Do you want to write this yourself? Or do you simply need the functionality? If you need the functionality, an embedded/in-memory database with Full T...
[ "f#", "functional-programming", "full-text-search" ]
3
1
1,029
2
0
2008-09-25T09:34:36.170000
2008-09-25T09:55:25.950000
132,342
136,732
Testing form inputs in PHPUnit
What's the best way to test $_GET and $_POST inputs in PHPUnit? I have a class that sanitises input and want to check that it works correctly when processing bogus data. Is there an easy way to set up the form variables in PHPUnit or should I just pass off the validation to a secondary class/functions that are fed the ...
Take a look at the idea of Dependency injection. In a nutshell you should feed your code what it needs as opposed to it getting the data it needs... Here's an example: example without Dependency Injection function sanitize1() { foreach($_POST as $k => $v) { // code to sanitize $v } } sanitize1(); example with Dependen...
Testing form inputs in PHPUnit What's the best way to test $_GET and $_POST inputs in PHPUnit? I have a class that sanitises input and want to check that it works correctly when processing bogus data. Is there an easy way to set up the form variables in PHPUnit or should I just pass off the validation to a secondary cl...
TITLE: Testing form inputs in PHPUnit QUESTION: What's the best way to test $_GET and $_POST inputs in PHPUnit? I have a class that sanitises input and want to check that it works correctly when processing bogus data. Is there an easy way to set up the form variables in PHPUnit or should I just pass off the validation...
[ "php", "unit-testing", "phpunit" ]
5
16
5,691
1
0
2008-09-25T09:37:54.493000
2008-09-25T22:57:41.917000
132,353
133,023
Double generic constraint on class in Java: extends ConcreteClass & I
Is there a way to define a generic constraint in Java which would be analogous to the following C# generic constratint? class Class1 where I: Interface1, Class2: I I'm trying to do it like this: class Class1 But the compiler complains about the "Class2" part: Type parameter cannot be followed by other bounds.
The simplest way I can see of resolving the Java code is to make Class2 an interface. You cannot constrain a type parameter to extends more than one class or type parameter. Further, you can't use super here.
Double generic constraint on class in Java: extends ConcreteClass & I Is there a way to define a generic constraint in Java which would be analogous to the following C# generic constratint? class Class1 where I: Interface1, Class2: I I'm trying to do it like this: class Class1 But the compiler complains about the "Clas...
TITLE: Double generic constraint on class in Java: extends ConcreteClass & I QUESTION: Is there a way to define a generic constraint in Java which would be analogous to the following C# generic constratint? class Class1 where I: Interface1, Class2: I I'm trying to do it like this: class Class1 But the compiler complai...
[ "java", "generics", "constraints" ]
12
5
6,670
2
0
2008-09-25T09:41:11.740000
2008-09-25T12:32:18.067000
132,358
132,394
How to read file content into istringstream?
In order to improve performance reading from a file, I'm trying to read the entire content of a big (several MB) file into memory and then use a istringstream to access the information. My question is, which is the best way to read this information and "import it" into the string stream? A problem with this approach (s...
std::ifstream has a method rdbuf(), that returns a pointer to a filebuf. You can then "push" this filebuf into your stringstream: #include #include int main() { std::ifstream file( "myFile" ); if ( file ) { std::stringstream buffer; buffer << file.rdbuf(); file.close(); // operations on the buffer... } } EDIT: As M...
How to read file content into istringstream? In order to improve performance reading from a file, I'm trying to read the entire content of a big (several MB) file into memory and then use a istringstream to access the information. My question is, which is the best way to read this information and "import it" into the s...
TITLE: How to read file content into istringstream? QUESTION: In order to improve performance reading from a file, I'm trying to read the entire content of a big (several MB) file into memory and then use a istringstream to access the information. My question is, which is the best way to read this information and "imp...
[ "c++", "optimization", "memory", "stream", "stringstream" ]
44
58
123,571
3
0
2008-09-25T09:42:11.720000
2008-09-25T09:52:08
132,359
416,076
How can Google be so fast?
What are the technologies and programming decisions that make Google able to serve a query so fast? Every time I search something (one of the several times per day) it always amazes me how they serve the results in near or less than 1 second time. What sort of configuration and algorithms could they have in place that ...
Here are some of the great answers and pointers provided: Google Platform Map Reduce Algorithms carefully crafted Hardware - cluster farms and massive number of cheap computers Caching and Load Balancing Google File System
How can Google be so fast? What are the technologies and programming decisions that make Google able to serve a query so fast? Every time I search something (one of the several times per day) it always amazes me how they serve the results in near or less than 1 second time. What sort of configuration and algorithms cou...
TITLE: How can Google be so fast? QUESTION: What are the technologies and programming decisions that make Google able to serve a query so fast? Every time I search something (one of the several times per day) it always amazes me how they serve the results in near or less than 1 second time. What sort of configuration ...
[ "performance", "algorithm" ]
89
5
82,928
19
0
2008-09-25T09:42:55.387000
2009-01-06T10:44:22.013000
132,367
132,376
Invert Regex Matches
How would I invert.NET regex matches? I want to extract only the matched text, e.g. I want to extract all IMG tags from an HTML file, but only the image tags.
That has nothing to do with inverting the Regexp. Just search for the relevant Text and put it in a group.
Invert Regex Matches How would I invert.NET regex matches? I want to extract only the matched text, e.g. I want to extract all IMG tags from an HTML file, but only the image tags.
TITLE: Invert Regex Matches QUESTION: How would I invert.NET regex matches? I want to extract only the matched text, e.g. I want to extract all IMG tags from an HTML file, but only the image tags. ANSWER: That has nothing to do with inverting the Regexp. Just search for the relevant Text and put it in a group.
[ ".net", "regex" ]
1
2
1,235
3
0
2008-09-25T09:46:28.077000
2008-09-25T09:48:53.687000
132,383
132,408
How to gain SSL load balancing?
I have to deploy my ASP.NET application into two seperated IIS servers. My application works over HTTPS/TLS. My ASP code has to handle client SSL certificate and it means I can't use simple forward load balancers, because I will never get such certificate from nginx or Apache Load Balancer. As I understand there is no ...
We use Cisco Local Directors, and they seem to handle it fine. I haven't played with pure software solutions for load balancing, but balance might work fine. I've only used it for purely 1:1 port forwarding. The advantage of using a balance/LD approach over DNS balancing is that you can easily then use it to take serve...
How to gain SSL load balancing? I have to deploy my ASP.NET application into two seperated IIS servers. My application works over HTTPS/TLS. My ASP code has to handle client SSL certificate and it means I can't use simple forward load balancers, because I will never get such certificate from nginx or Apache Load Balanc...
TITLE: How to gain SSL load balancing? QUESTION: I have to deploy my ASP.NET application into two seperated IIS servers. My application works over HTTPS/TLS. My ASP code has to handle client SSL certificate and it means I can't use simple forward load balancers, because I will never get such certificate from nginx or ...
[ "iis", "ssl", "dns", "load-balancing" ]
5
0
8,548
6
0
2008-09-25T09:49:47.477000
2008-09-25T09:56:00.270000
132,390
132,671
Passing timestamp parameters in SQLAnalyzer to debug stored procedures
Hi I'm trying to debug a stored procedure through SQL Analyzer and one of the parameters is a timestamp datatype. If I wanted to pass 0x00000001410039E2 through as a parameter how would i do this? When I pass 0x00000001410039E2 I get a string truncation error and when I pass just 1410039E2 I get 0x1410039E20000000? Edi...
The debug input screen expects you to enter a hexadecimal value. You don't have to enter the 0x in front of this value. Just enter 00000001410039E2 and it will work.
Passing timestamp parameters in SQLAnalyzer to debug stored procedures Hi I'm trying to debug a stored procedure through SQL Analyzer and one of the parameters is a timestamp datatype. If I wanted to pass 0x00000001410039E2 through as a parameter how would i do this? When I pass 0x00000001410039E2 I get a string trunca...
TITLE: Passing timestamp parameters in SQLAnalyzer to debug stored procedures QUESTION: Hi I'm trying to debug a stored procedure through SQL Analyzer and one of the parameters is a timestamp datatype. If I wanted to pass 0x00000001410039E2 through as a parameter how would i do this? When I pass 0x00000001410039E2 I g...
[ "debugging", "sql-server-2000" ]
0
1
1,077
1
0
2008-09-25T09:50:58.923000
2008-09-25T11:14:52.717000
132,397
143,265
Get back the output of os.execute in Lua
When I do an "os.execute" in Lua, a console quickly pops up, executes the command, then closes down. But is there some way of getting back the console output only using the standard Lua libraries?
I think you want this http://pgl.yoyo.org/luai/i/io.popen io.popen. But it's not always compiled in.
Get back the output of os.execute in Lua When I do an "os.execute" in Lua, a console quickly pops up, executes the command, then closes down. But is there some way of getting back the console output only using the standard Lua libraries?
TITLE: Get back the output of os.execute in Lua QUESTION: When I do an "os.execute" in Lua, a console quickly pops up, executes the command, then closes down. But is there some way of getting back the console output only using the standard Lua libraries? ANSWER: I think you want this http://pgl.yoyo.org/luai/i/io.pop...
[ "lua" ]
54
29
56,275
3
0
2008-09-25T09:53:27.233000
2008-09-27T08:56:01.633000
132,405
132,991
Free alternative to RegexBuddy
Are there any good alternatives that support writing regexps in different flavors and allow you to test them?
Here's a list of the Regex tools mentioned across the threads: Regulator Expresso.NET Regular Expression Designer Regex-Coach larsolavtorvik online tool Regex Pal Regular Expression Workbench Rubular Reggy RegExr
Free alternative to RegexBuddy Are there any good alternatives that support writing regexps in different flavors and allow you to test them?
TITLE: Free alternative to RegexBuddy QUESTION: Are there any good alternatives that support writing regexps in different flavors and allow you to test them? ANSWER: Here's a list of the Regex tools mentioned across the threads: Regulator Expresso.NET Regular Expression Designer Regex-Coach larsolavtorvik online tool...
[ "regex" ]
41
50
42,360
3
0
2008-09-25T09:55:13.500000
2008-09-25T12:27:38.827000
132,432
133,754
Java utility to validate string against NMTOKEN
I have some application code which generates XML documents, which are then validated against an XML Schema. The schema makes use of NMTOKEN types, and occasionally, the generated XML contains string values which are illegal NMTOKENs (e.g. they contain spaces or weird punctuation). The Xerces schema validation catches i...
org.apache.axis.types.NMToken from Apachie Axis (the webservice framework) has a static isValid(String) method and may be what you need (or may be more than you need). NMToken in the Axis API
Java utility to validate string against NMTOKEN I have some application code which generates XML documents, which are then validated against an XML Schema. The schema makes use of NMTOKEN types, and occasionally, the generated XML contains string values which are illegal NMTOKENs (e.g. they contain spaces or weird punc...
TITLE: Java utility to validate string against NMTOKEN QUESTION: I have some application code which generates XML documents, which are then validated against an XML Schema. The schema makes use of NMTOKEN types, and occasionally, the generated XML contains string values which are illegal NMTOKENs (e.g. they contain sp...
[ "java", "xml", "utilities" ]
1
2
1,099
1
0
2008-09-25T10:05:23.553000
2008-09-25T14:37:28.423000
132,437
132,809
How do I get user informations from a session id in ASP.NET?
In an asp.net application, i would like to use a webservice to return the username associated with the session id passed as a parameter. We're currently using InProc session store. Is it possible to do this? Edit: what i'm trying to do is get information about another session than the current one. I'm not trying to get...
You could possibly create a "fake"cookie with the session ID and make a request to your web service using it, so that the web service was fooled into thinking you were part of the session, enabling you to read any info from it. Sounds like quite the hack, though:)
How do I get user informations from a session id in ASP.NET? In an asp.net application, i would like to use a webservice to return the username associated with the session id passed as a parameter. We're currently using InProc session store. Is it possible to do this? Edit: what i'm trying to do is get information abou...
TITLE: How do I get user informations from a session id in ASP.NET? QUESTION: In an asp.net application, i would like to use a webservice to return the username associated with the session id passed as a parameter. We're currently using InProc session store. Is it possible to do this? Edit: what i'm trying to do is ge...
[ "asp.net", "session-state", "single-sign-on" ]
2
0
1,029
2
0
2008-09-25T10:07:34.407000
2008-09-25T11:52:06.120000
132,440
132,450
Is Java the best language for Mobile App Devlopment?
I was wondering what are the benefits of using anything else but Java for Mobile Application Development.
Java is the most ubiquitous and for that alone it is your best choice.
Is Java the best language for Mobile App Devlopment? I was wondering what are the benefits of using anything else but Java for Mobile Application Development.
TITLE: Is Java the best language for Mobile App Devlopment? QUESTION: I was wondering what are the benefits of using anything else but Java for Mobile Application Development. ANSWER: Java is the most ubiquitous and for that alone it is your best choice.
[ "java", "mobile" ]
2
4
3,838
11
0
2008-09-25T10:08:14.840000
2008-09-25T10:10:30.733000
132,445
132,467
Direct casting vs 'as' operator?
Consider the following code: void Handler(object o, EventArgs e) { // I swear o is a string string s = (string)o; // 1 //-OR- string s = o as string; // 2 // -OR- string s = o.ToString(); // 3 } What is the difference between the three types of casting (okay, the 3rd one is not a casting, but you get the intent). Which...
string s = (string)o; // 1 Throws InvalidCastException if o is not a string. Otherwise, assigns o to s, even if o is null. string s = o as string; // 2 Assigns null to s if o is not a string or if o is null. For this reason, you cannot use it with value types (the operator could never return null in that case). Otherwi...
Direct casting vs 'as' operator? Consider the following code: void Handler(object o, EventArgs e) { // I swear o is a string string s = (string)o; // 1 //-OR- string s = o as string; // 2 // -OR- string s = o.ToString(); // 3 } What is the difference between the three types of casting (okay, the 3rd one is not a castin...
TITLE: Direct casting vs 'as' operator? QUESTION: Consider the following code: void Handler(object o, EventArgs e) { // I swear o is a string string s = (string)o; // 1 //-OR- string s = o as string; // 2 // -OR- string s = o.ToString(); // 3 } What is the difference between the three types of casting (okay, the 3rd o...
[ "c#", "casting" ]
864
1,022
221,215
16
0
2008-09-25T10:09:18.537000
2008-09-25T10:16:26.240000
132,449
138,103
Wrong number of arguments error with TestMailer
I'm running a strange problem sending emails. I'm getting this exception: ArgumentError (wrong number of arguments (1 for 0)): /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `initialize' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `new' /usr/lib/ruby/...
The problem is with the model that ar_mailer is using to store the message. You can see in the backtrace that the exception is coming from ActiveRecord::Base.create when it calls initialize. Normally an ActiveRecord constructor takes an argument, but in this case it looks like your model doesn't. ar_mailer should be us...
Wrong number of arguments error with TestMailer I'm running a strange problem sending emails. I'm getting this exception: ArgumentError (wrong number of arguments (1 for 0)): /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `initialize' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/a...
TITLE: Wrong number of arguments error with TestMailer QUESTION: I'm running a strange problem sending emails. I'm getting this exception: ArgumentError (wrong number of arguments (1 for 0)): /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `initialize' /usr/lib/ruby/gems/1.8/gems/active...
[ "ruby-on-rails", "ruby", "ar-mailer" ]
2
1
1,481
2
0
2008-09-25T10:10:05.070000
2008-09-26T07:09:25.807000