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
135,664
136,083
How many bytes per element are there in a Python list (tuple)?
For example, how much memory is required to store a list of one million (32-bit) integers? alist = range(1000000) # or list(range(1000000)) in Python 3.0
Useful links: How to get memory size/usage of python object Memory sizes of python objects? if you put data into dictionary, how do we calculate the data size? However they don't give a definitive answer. The way to go: Measure memory consumed by Python interpreter with/without the list (use OS tools). Use a third-part...
How many bytes per element are there in a Python list (tuple)? For example, how much memory is required to store a list of one million (32-bit) integers? alist = range(1000000) # or list(range(1000000)) in Python 3.0
TITLE: How many bytes per element are there in a Python list (tuple)? QUESTION: For example, how much memory is required to store a list of one million (32-bit) integers? alist = range(1000000) # or list(range(1000000)) in Python 3.0 ANSWER: Useful links: How to get memory size/usage of python object Memory sizes of ...
[ "python", "memory-management" ]
18
15
16,754
5
0
2008-09-25T20:04:09.230000
2008-09-25T21:00:40.327000
135,701
135,729
Can you have too many stored procedures?
Is there such a thing as too many stored procedures? I know there is not a limit to the number you can have but is this any performance or architectural reason not to create hundreds, thousands??
To me the biggest limitation to that hundreds or thousands store procedure is maintainability. Even though that is not a direct performance hit, it should be a consideration. That is an architectural stand point, you have to plan not just for the initial development of the application, but future changes and maintenanc...
Can you have too many stored procedures? Is there such a thing as too many stored procedures? I know there is not a limit to the number you can have but is this any performance or architectural reason not to create hundreds, thousands??
TITLE: Can you have too many stored procedures? QUESTION: Is there such a thing as too many stored procedures? I know there is not a limit to the number you can have but is this any performance or architectural reason not to create hundreds, thousands?? ANSWER: To me the biggest limitation to that hundreds or thousan...
[ "sql", "database-design" ]
14
7
6,581
19
0
2008-09-25T20:08:48.580000
2008-09-25T20:12:22.627000
135,730
135,792
What are the different types of indexes, what are the benefits of each?
What are the different types of indexes, what are the benefits of each? I heard of covering and clustered indexes, are there more? Where would you use them?
Unique - Guarantees unique values for the column(or set of columns) included in the index Covering - Includes all of the columns that are used in a particular query (or set of queries), allowing the database to use only the index and not actually have to look at the table data to retrieve the results Clustered - This i...
What are the different types of indexes, what are the benefits of each? What are the different types of indexes, what are the benefits of each? I heard of covering and clustered indexes, are there more? Where would you use them?
TITLE: What are the different types of indexes, what are the benefits of each? QUESTION: What are the different types of indexes, what are the benefits of each? I heard of covering and clustered indexes, are there more? Where would you use them? ANSWER: Unique - Guarantees unique values for the column(or set of colum...
[ "sql", "database", "database-design", "indexing" ]
32
31
120,349
11
0
2008-09-25T20:12:25.530000
2008-09-25T20:23:52.957000
135,734
136,427
Page down and page up in Emacs on Windows using the Windows key
I am trying to learn Emacs and trying to find best keyboard layout for me. One thing is really annoying me. I have added following lines to.emacs (global-set-key "\C-y" 'scroll-up) (global-set-key "\M-y" 'scroll-down) When I hold Control and press y a few times, it will page down on every press of y. However, when I ho...
Could this be a side affect of using the Windows key as Meta? I'm thinking this because in a non-Emacs situation if you press and hold the Windows key and another key for a short cut (Win+E for Explorer, Win+R for Run dialog, etc.) the desired action only triggers once, not multiple times if you keep holding it down. I...
Page down and page up in Emacs on Windows using the Windows key I am trying to learn Emacs and trying to find best keyboard layout for me. One thing is really annoying me. I have added following lines to.emacs (global-set-key "\C-y" 'scroll-up) (global-set-key "\M-y" 'scroll-down) When I hold Control and press y a few ...
TITLE: Page down and page up in Emacs on Windows using the Windows key QUESTION: I am trying to learn Emacs and trying to find best keyboard layout for me. One thing is really annoying me. I have added following lines to.emacs (global-set-key "\C-y" 'scroll-up) (global-set-key "\M-y" 'scroll-down) When I hold Control ...
[ "windows", "emacs", "editor" ]
2
4
3,067
3
0
2008-09-25T20:12:59.317000
2008-09-25T21:55:23.533000
135,754
135,831
How to keep from duplicating path variable in csh
It is typical to have something like this in your cshrc file for setting the path: set path = (. $otherpath $path ) but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication? EDIT: This is one unclean way of doing it: set localpaths = (. $otherpaths ) echo ${path} ...
you can use the following Perl script to prune paths of duplicates. #!/usr/bin/perl # # ^^ ensure this is pointing to the correct location. # # Title: SLimPath # Author: David "Shoe Lace" Pyke #: Tim Nelson # Purpose: To create a slim version of my envirnoment path so as to eliminate # duplicate entries and ensure that...
How to keep from duplicating path variable in csh It is typical to have something like this in your cshrc file for setting the path: set path = (. $otherpath $path ) but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication? EDIT: This is one unclean way of doing i...
TITLE: How to keep from duplicating path variable in csh QUESTION: It is typical to have something like this in your cshrc file for setting the path: set path = (. $otherpath $path ) but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication? EDIT: This is one uncl...
[ "path", "environment-variables", "csh", "path-variables" ]
9
3
9,993
12
0
2008-09-25T20:16:18.063000
2008-09-25T20:28:48.687000
135,755
136,218
How can I find the version of an installed Perl module?
How do you find the version of an installed Perl module? This is in an answer down at the bottom, but I figure it important enough to live up here. With these suggestions, I create a function in my.bashrc function perlmodver { perl -M$1 -e 'print "Version ". $ARGV[0]->VERSION. " of ". $ARGV[0]. \ " is installed.\n"' $1...
Why are you trying to get the version of the module? Do you need this from within a program, do you just need the number to pass to another operation, or are you just trying to find out what you have? I have this built into the cpan (which comes with perl) with the -D switch so you can see the version that you have ins...
How can I find the version of an installed Perl module? How do you find the version of an installed Perl module? This is in an answer down at the bottom, but I figure it important enough to live up here. With these suggestions, I create a function in my.bashrc function perlmodver { perl -M$1 -e 'print "Version ". $ARGV...
TITLE: How can I find the version of an installed Perl module? QUESTION: How do you find the version of an installed Perl module? This is in an answer down at the bottom, but I figure it important enough to live up here. With these suggestions, I create a function in my.bashrc function perlmodver { perl -M$1 -e 'print...
[ "perl", "module", "version", "cpan" ]
66
64
69,761
12
0
2008-09-25T20:16:24.507000
2008-09-25T21:19:10.283000
135,759
135,772
Why Can't I Inherit IO.Directory?
Why can't I create a class in VB.NET that inherits System.IO.Directory? According to Lutz Roeder, it is not declared as NotInheritable! I want to create a utility class that adds functionality to the Directory class. For instance, I want to add a Directory.Move function. Please advise and I will send you a six pack. OK...
From the Meta Data of.NET namespace System.IO { // Summary: // Exposes static methods for creating, moving, and enumerating through directories // and subdirectories. This class cannot be inherited. [ComVisible(true)] public static class Directory You cannot inherit from a Static Class.
Why Can't I Inherit IO.Directory? Why can't I create a class in VB.NET that inherits System.IO.Directory? According to Lutz Roeder, it is not declared as NotInheritable! I want to create a utility class that adds functionality to the Directory class. For instance, I want to add a Directory.Move function. Please advise ...
TITLE: Why Can't I Inherit IO.Directory? QUESTION: Why can't I create a class in VB.NET that inherits System.IO.Directory? According to Lutz Roeder, it is not declared as NotInheritable! I want to create a utility class that adds functionality to the Directory class. For instance, I want to add a Directory.Move functi...
[ "vb.net", "inheritance", "system.io.directory" ]
2
11
1,165
4
0
2008-09-25T20:17:21.883000
2008-09-25T20:19:20.100000
135,777
707,502
A StringToken Parser which gives Google Search style "Did you mean:" Suggestions
Seeking a method to: Take whitespace separated tokens in a String; return a suggested Word ie: Google Search can take "fonetic wrd nterpreterr", and atop of the result page it shows "Did you mean: phonetic word interpreter" A solution in any of the C* languages or Java would be preferred. Are there any existing Open Li...
In his article How to Write a Spelling Corrector, Peter Norvig discusses how a Google-like spellchecker could be implemented. The article contains a 20-line implementation in Python, as well as links to several reimplementations in C, C++, C# and Java. Here is an excerpt: The full details of an industrial-strength spel...
A StringToken Parser which gives Google Search style "Did you mean:" Suggestions Seeking a method to: Take whitespace separated tokens in a String; return a suggested Word ie: Google Search can take "fonetic wrd nterpreterr", and atop of the result page it shows "Did you mean: phonetic word interpreter" A solution in a...
TITLE: A StringToken Parser which gives Google Search style "Did you mean:" Suggestions QUESTION: Seeking a method to: Take whitespace separated tokens in a String; return a suggested Word ie: Google Search can take "fonetic wrd nterpreterr", and atop of the result page it shows "Did you mean: phonetic word interprete...
[ "language-agnostic", "parsing", "nlp" ]
5
11
1,900
8
0
2008-09-25T20:19:43.437000
2009-04-01T21:57:12.977000
135,782
136,041
Generic logging of function parameters in exception handling
A lot of my C# code follows this pattern: void foo(string param1, string param2, string param3) { try { // do something... } catch(Exception ex) { LogError(String.Format("Error in foo(param1={0}, param2={1}, param3={2}), exception={3}", param1, param2, param3, ex.Message)); } } Is there a way in.NET to get a Key/Value ...
You could use Reflection and the convention that you must pass the parameters to the LogError with the right order: private static void MyMethod(string s, int x, int y) { try { throw new NotImplementedException(); } catch (Exception ex) { LogError(MethodBase.GetCurrentMethod(), ex, s, x, y); } } private static void Lo...
Generic logging of function parameters in exception handling A lot of my C# code follows this pattern: void foo(string param1, string param2, string param3) { try { // do something... } catch(Exception ex) { LogError(String.Format("Error in foo(param1={0}, param2={1}, param3={2}), exception={3}", param1, param2, param3...
TITLE: Generic logging of function parameters in exception handling QUESTION: A lot of my C# code follows this pattern: void foo(string param1, string param2, string param3) { try { // do something... } catch(Exception ex) { LogError(String.Format("Error in foo(param1={0}, param2={1}, param3={2}), exception={3}", para...
[ "c#", ".net" ]
32
37
31,541
8
0
2008-09-25T20:20:45.540000
2008-09-25T20:56:47.187000
135,789
135,829
TDD. When you can move on?
When doing TDD, how to tell "that's enough tests for this class / feature"? I.e. when could you tell that you completed testing all edge cases?
With Test Driven Development, you’ll write a test before you write the code it tests. Once you’re written the code and the test passes, then it’s time to write another test. If you follow TDD correctly, you’ve written enough tests once you’re code does all that is required. As for edge cases, let's take an example such...
TDD. When you can move on? When doing TDD, how to tell "that's enough tests for this class / feature"? I.e. when could you tell that you completed testing all edge cases?
TITLE: TDD. When you can move on? QUESTION: When doing TDD, how to tell "that's enough tests for this class / feature"? I.e. when could you tell that you completed testing all edge cases? ANSWER: With Test Driven Development, you’ll write a test before you write the code it tests. Once you’re written the code and the...
[ "tdd" ]
13
13
1,428
13
0
2008-09-25T20:23:12.913000
2008-09-25T20:28:24.007000
135,799
226,624
Determining the port a Visual Studio Web App runs on
I've been using the macro from this blog entry for attaching the Visual Studio debugger to an already running instance of the Web Application I'm currently working on. However, if I have more than one instance of the Visual Studio web server running it's pot luck which one it'll attach to. Is there a way to determine w...
If that can help you, I have found a link that might actually to the trick. However, it require DllImport call and a lot of fun. You can take a look at that article there: http://bytes.com/forum/thread574901.html Quotes from the actual site: By calling into iphlpapi.dll using PInvoke interop. Google around for GetExten...
Determining the port a Visual Studio Web App runs on I've been using the macro from this blog entry for attaching the Visual Studio debugger to an already running instance of the Web Application I'm currently working on. However, if I have more than one instance of the Visual Studio web server running it's pot luck whi...
TITLE: Determining the port a Visual Studio Web App runs on QUESTION: I've been using the macro from this blog entry for attaching the Visual Studio debugger to an already running instance of the Web Application I'm currently working on. However, if I have more than one instance of the Visual Studio web server running...
[ "asp.net", "visual-studio" ]
2
0
3,171
3
0
2008-09-25T20:24:48.103000
2008-10-22T16:41:48.550000
135,826
135,905
For tabular data, what renders faster, CSS or <TABLE>?
I am looking for some stats on current browsers for how long it takes to render a table using plain HTML versus a hacked-up CSS puritan method that avoids using actual TABLE, TR, TD etc. tags. I am not looking for what's proper, only for what's faster, particularly on Firefox 3, although I am also interested in the sta...
In general, I would say use for tabular data. However, if the table is very long (say, over 100 rows) and the number of columns is low (~3), using divs to emulate rows would result in a much smaller markup footprint. This is especially relevant if you are using DOM searching javascript (as provided by the many JS libra...
For tabular data, what renders faster, CSS or <TABLE>? I am looking for some stats on current browsers for how long it takes to render a table using plain HTML versus a hacked-up CSS puritan method that avoids using actual TABLE, TR, TD etc. tags. I am not looking for what's proper, only for what's faster, particularly...
TITLE: For tabular data, what renders faster, CSS or <TABLE>? QUESTION: I am looking for some stats on current browsers for how long it takes to render a table using plain HTML versus a hacked-up CSS puritan method that avoids using actual TABLE, TR, TD etc. tags. I am not looking for what's proper, only for what's fa...
[ "html", "css", "html-table", "benchmarking" ]
7
8
7,428
10
0
2008-09-25T20:27:51.827000
2008-09-25T20:40:13.683000
135,834
135,966
Python: SWIG vs ctypes
In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
SWIG generates (rather ugly) C or C++ code. It is straightforward to use for simple functions (things that can be translated directly) and reasonably easy to use for more complex functions (such as functions with output parameters that need an extra translation step to represent in Python.) For more powerful interfacin...
Python: SWIG vs ctypes In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two?
TITLE: Python: SWIG vs ctypes QUESTION: In python, under what circumstances is SWIG a better choice than ctypes for calling entry points in shared libraries? Let's assume you don't already have the SWIG interface file(s). What are the performance metrics of the two? ANSWER: SWIG generates (rather ugly) C or C++ code....
[ "python", "c++", "swig", "ctypes", "ffi" ]
64
71
27,452
10
0
2008-09-25T20:29:27.767000
2008-09-25T20:47:28.410000
135,841
135,852
Marking A Class Static in VB.NET
As just stated in a recent question and answer, you can't inherit from a static class. How does one enforce the rules that go along with static classes inside VB.NET? Since the framework is compatible between C# and VB it would make sense that there would be a way to mark a class static, but there doesn't seem to be a ...
Module == static class If you just want a class that you can't inherit, use a NotInheritable class; but it won't be static/Shared. You could mark all the methods, properties, and members as Shared, but that's not strictly the same thing as a static class in C# since it's not enforced by the compiler. If you really want...
Marking A Class Static in VB.NET As just stated in a recent question and answer, you can't inherit from a static class. How does one enforce the rules that go along with static classes inside VB.NET? Since the framework is compatible between C# and VB it would make sense that there would be a way to mark a class static...
TITLE: Marking A Class Static in VB.NET QUESTION: As just stated in a recent question and answer, you can't inherit from a static class. How does one enforce the rules that go along with static classes inside VB.NET? Since the framework is compatible between C# and VB it would make sense that there would be a way to m...
[ "c#", "vb.net" ]
102
138
113,546
5
0
2008-09-25T20:30:32.007000
2008-09-25T20:32:22.313000
135,845
135,871
Are booleans as method arguments unacceptable?
A colleague of mine states that booleans as method arguments are not acceptable. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example. What's easier to understand? file.writeData( data, true ); Or enum WriteMode { Append, Overwrite }; file.writeData( data, Append ); Now...
Boolean's represent "yes/no" choices. If you want to represent a "yes/no", then use a boolean, it should be self-explanatory. But if it's a choice between two options, neither of which is clearly yes or no, then an enum can sometimes be more readable.
Are booleans as method arguments unacceptable? A colleague of mine states that booleans as method arguments are not acceptable. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example. What's easier to understand? file.writeData( data, true ); Or enum WriteMode { Append, Ov...
TITLE: Are booleans as method arguments unacceptable? QUESTION: A colleague of mine states that booleans as method arguments are not acceptable. They shall be replaced by enumerations. At first I did not see any benefit, but he gave me an example. What's easier to understand? file.writeData( data, true ); Or enum Writ...
[ "coding-style", "boolean", "enumeration" ]
125
132
9,101
26
0
2008-09-25T20:31:26.810000
2008-09-25T20:35:02.977000
135,894
136,079
Zooming an element and its contents-- an alternative to CSS3's zoom property?
Is there a cross-browser method to emulate CSS3's zoom property? I know how to zoom images and text separately, but cannot seem to keep everything aligned. One solution might be to read the computed styles of the element and its children, convert all measures to px, multiply them by some factor, and then generate HTML/...
You could try using the Scriptaculous library that provides Effect.Scale functionality.
Zooming an element and its contents-- an alternative to CSS3's zoom property? Is there a cross-browser method to emulate CSS3's zoom property? I know how to zoom images and text separately, but cannot seem to keep everything aligned. One solution might be to read the computed styles of the element and its children, con...
TITLE: Zooming an element and its contents-- an alternative to CSS3's zoom property? QUESTION: Is there a cross-browser method to emulate CSS3's zoom property? I know how to zoom images and text separately, but cannot seem to keep everything aligned. One solution might be to read the computed styles of the element and...
[ "javascript", "html", "css", "zooming" ]
2
3
4,403
1
0
2008-09-25T20:38:18.447000
2008-09-25T21:00:29.063000
135,896
136,126
where can I find a description of *all* MIPS instructions
Does anyone know of a web site where I can find a list of 32-bit MIPS instructions/opcodes, with the following features: Clearly distinguishes between real opcodes and assembly-language macros (pseudo-instructions) Describes the instruction behavior including differences depending on privilege level. Indicates in which...
I can only partially answer the question: I'd recommend See MIPS Run by Dominic Sweetman, if you're not already referring to it. I have the first edition of the book, the second edition is now current. table 8.2 lists each opcode and expected behavior, differentiating assembler macros and listing the instructions they ...
where can I find a description of *all* MIPS instructions Does anyone know of a web site where I can find a list of 32-bit MIPS instructions/opcodes, with the following features: Clearly distinguishes between real opcodes and assembly-language macros (pseudo-instructions) Describes the instruction behavior including di...
TITLE: where can I find a description of *all* MIPS instructions QUESTION: Does anyone know of a web site where I can find a list of 32-bit MIPS instructions/opcodes, with the following features: Clearly distinguishes between real opcodes and assembly-language macros (pseudo-instructions) Describes the instruction beh...
[ "assembly", "mips", "instruction-set", "mips32" ]
15
4
5,888
5
0
2008-09-25T20:38:31.753000
2008-09-25T21:04:52.440000
135,909
135,930
What is the method for converting radians to degrees?
I run into this occasionally and always forget how to do it. One of those things that pop up ever so often. Also, what's the formula to convert angles expressed in radians to degrees and back again?
radians = degrees * (pi/180) degrees = radians * (180/pi) As for implementation, the main question is how precise you want to be about the value of pi. There is some related discussion here
What is the method for converting radians to degrees? I run into this occasionally and always forget how to do it. One of those things that pop up ever so often. Also, what's the formula to convert angles expressed in radians to degrees and back again?
TITLE: What is the method for converting radians to degrees? QUESTION: I run into this occasionally and always forget how to do it. One of those things that pop up ever so often. Also, what's the formula to convert angles expressed in radians to degrees and back again? ANSWER: radians = degrees * (pi/180) degrees = ...
[ "algorithm", "math", "trigonometry" ]
177
307
141,974
12
0
2008-09-25T20:40:52.637000
2008-09-25T20:43:58.683000
135,919
135,991
java.net.SocketException: Software caused connection abort: recv failed
I haven't been able to find an adequate answer to what exactly the following error means: java.net.SocketException: Software caused connection abort: recv failed Notes: This error is infrequent and unpredictable; although getting this error means that all future requests for URIs will also fail. The only solution that ...
This usually means that there was a network error, such as a TCP timeout. I would start by placing a sniffer (wireshark) on the connection to see if you can see any problems. If there is a TCP error, you should be able to see it. Also, you can check your router logs, if this is applicable. If wireless is involved anywh...
java.net.SocketException: Software caused connection abort: recv failed I haven't been able to find an adequate answer to what exactly the following error means: java.net.SocketException: Software caused connection abort: recv failed Notes: This error is infrequent and unpredictable; although getting this error means t...
TITLE: java.net.SocketException: Software caused connection abort: recv failed QUESTION: I haven't been able to find an adequate answer to what exactly the following error means: java.net.SocketException: Software caused connection abort: recv failed Notes: This error is infrequent and unpredictable; although getting ...
[ "java", "sockets" ]
96
33
364,830
10
0
2008-09-25T20:43:00.277000
2008-09-25T20:50:21.617000
135,929
136,002
Can you have just a comment in a block of your SQL if-statement?
I'd like to just put in a comment in the block of my if-statement, but I get an error when I try. I want to be more like Steve McConnell. declare @ConstraintName varchar(255) set @ConstraintName = 'PK_Whatever' IF LEFT(@ConstraintName, 2) = 'PK' BEGIN --can't drop primary keys END The error I get is: Incorrect syntax ...
No, you cannot have an empty if block (or one that contains only comments). You don't say why you would want this. If you are just trying to comment out the contents of the if for debugging, you should comment the entire if.
Can you have just a comment in a block of your SQL if-statement? I'd like to just put in a comment in the block of my if-statement, but I get an error when I try. I want to be more like Steve McConnell. declare @ConstraintName varchar(255) set @ConstraintName = 'PK_Whatever' IF LEFT(@ConstraintName, 2) = 'PK' BEGIN --...
TITLE: Can you have just a comment in a block of your SQL if-statement? QUESTION: I'd like to just put in a comment in the block of my if-statement, but I get an error when I try. I want to be more like Steve McConnell. declare @ConstraintName varchar(255) set @ConstraintName = 'PK_Whatever' IF LEFT(@ConstraintName, ...
[ "sql-server", "t-sql" ]
3
5
1,625
9
0
2008-09-25T20:43:55.360000
2008-09-25T20:52:23.437000
135,933
135,947
Strategy for storing an string of unspecified length in Sql Server?
So a column will hold some text that beforehand I won't know how long the length of this string can be. Realistically 95% of the time, it will probably be between 100-500 chars, but there can be that one case where it will 10000 chars long. I have no control over the size of this string and never does the user. Besides...
Varchar(max) in sqlserver 2005 is what I use. SqlServer handles large string fields weirdly, in that if you specify "text" or a large varchar, but not max, it stores part of the bits in the record and the rest outside. To my knowledge with varchar(max) it goes ahead and stores the entire contents out of the record, whi...
Strategy for storing an string of unspecified length in Sql Server? So a column will hold some text that beforehand I won't know how long the length of this string can be. Realistically 95% of the time, it will probably be between 100-500 chars, but there can be that one case where it will 10000 chars long. I have no c...
TITLE: Strategy for storing an string of unspecified length in Sql Server? QUESTION: So a column will hold some text that beforehand I won't know how long the length of this string can be. Realistically 95% of the time, it will probably be between 100-500 chars, but there can be that one case where it will 10000 chars...
[ "sql-server" ]
1
6
1,222
4
0
2008-09-25T20:44:03.847000
2008-09-25T20:45:14.280000
135,938
137,417
Flash: Listen to all events of a type with one eventlistener
It's not a matter of life or death but I wonder if this could be possible: I got a couple of events from one type of custom event (FormEvent) now I got a FormListener that listens to all those events and handles them according to the event type. Instead of adding one eventListener at the time I wish to add all events a...
You only really need one event listener in this case anyhow. That listener will be listening for any change with the form and a parameter equal to what the change was becomes available to the event listener function. I will show you, but please remember that this is a pseudo situation and normally I wouldn't dispatch a...
Flash: Listen to all events of a type with one eventlistener It's not a matter of life or death but I wonder if this could be possible: I got a couple of events from one type of custom event (FormEvent) now I got a FormListener that listens to all those events and handles them according to the event type. Instead of ad...
TITLE: Flash: Listen to all events of a type with one eventlistener QUESTION: It's not a matter of life or death but I wonder if this could be possible: I got a couple of events from one type of custom event (FormEvent) now I got a FormListener that listens to all those events and handles them according to the event t...
[ "actionscript-3", "events" ]
3
7
4,993
2
0
2008-09-25T20:44:18.993000
2008-09-26T02:32:35.630000
135,943
135,965
Encrypting Source Code
I work on relatively sensitive code that we wouldn't want falling into the wrong hands. Up until now, all the code has been keep in house so it hasn't been an issue. I am moving to working from home a day or two a week and we want to secure the code on my laptop. We have looked at a few alternatives, but Windows EFS an...
Truecrypt: WARNING: Using TrueCrypt is not secure as it may contain unfixed security issues This page exists only to help migrate existing data encrypted by TrueCrypt. The development of TrueCrypt was ended in 5/2014 after Microsoft terminated support of Windows XP. Windows 8/7/Vista and later offer integrated support ...
Encrypting Source Code I work on relatively sensitive code that we wouldn't want falling into the wrong hands. Up until now, all the code has been keep in house so it hasn't been an issue. I am moving to working from home a day or two a week and we want to secure the code on my laptop. We have looked at a few alternati...
TITLE: Encrypting Source Code QUESTION: I work on relatively sensitive code that we wouldn't want falling into the wrong hands. Up until now, all the code has been keep in house so it hasn't been an issue. I am moving to working from home a day or two a week and we want to secure the code on my laptop. We have looked ...
[ "obfuscation", "encrypting-file-system" ]
5
13
803
8
0
2008-09-25T20:44:33.063000
2008-09-25T20:47:07.723000
135,944
135,963
Can PHP's SQL Server driver return SQL return codes?
Stored procs in SQL Server sometimes finish with a return code, as opposed to a recordset of data. I've seen ASP code that's able to get this return code, but I can't figure out how to get this code with PHP's mssql driver. mssql_get_last_message() always returns nothing, and I'm thinking it's because it only returns t...
Are you talking about SQL Server error codes, e.g. RAISERRROR or other failures? If so, last time I checked in PHP you need to ask for @@ERROR (e.g. select @@error) instead. If it is a return code, you must explicitly catch it, e.g. DECLARE @return_code INT EXEC @return_code = your_stored_procedure 1123 SELECT @return_...
Can PHP's SQL Server driver return SQL return codes? Stored procs in SQL Server sometimes finish with a return code, as opposed to a recordset of data. I've seen ASP code that's able to get this return code, but I can't figure out how to get this code with PHP's mssql driver. mssql_get_last_message() always returns not...
TITLE: Can PHP's SQL Server driver return SQL return codes? QUESTION: Stored procs in SQL Server sometimes finish with a return code, as opposed to a recordset of data. I've seen ASP code that's able to get this return code, but I can't figure out how to get this code with PHP's mssql driver. mssql_get_last_message() ...
[ "php", "sql-server" ]
1
2
869
2
0
2008-09-25T20:44:53.907000
2008-09-25T20:46:51.607000
135,971
4,523,559
Is there a tool to discover if the same class exists in multiple jars in the classpath?
If you have two jars in your classpath that contain different versions of the same class, the classpath order becomes critical. I am looking for a tool that can detect and flag such potential conflicts in a given classpath or set of folders. Certainly a script that starts: classes=`mktemp` for i in `find. -name "*.jar"...
The Tattletale tool from JBoss is another candidate: "Spot if a class/package is located in multiple JAR files"
Is there a tool to discover if the same class exists in multiple jars in the classpath? If you have two jars in your classpath that contain different versions of the same class, the classpath order becomes critical. I am looking for a tool that can detect and flag such potential conflicts in a given classpath or set of...
TITLE: Is there a tool to discover if the same class exists in multiple jars in the classpath? QUESTION: If you have two jars in your classpath that contain different versions of the same class, the classpath order becomes critical. I am looking for a tool that can detect and flag such potential conflicts in a given c...
[ "java", "jar", "classpath" ]
23
8
13,813
6
0
2008-09-25T20:47:56.643000
2010-12-24T00:48:01.513000
135,995
136,194
Is it possible to define a Ruby singleton method using a block?
So, I want to define a singleton method for an object, but I want to do it using a closure. For example, def define_say(obj, msg) def obj.say puts msg end end o = Object.new define_say o, "hello world!" o.say This doesn't work because defining a singleton method via "def" is not a closure, so I get an exception that "...
Here's an answer which does what you're looking for def define_say(obj, msg) # Get a handle to the singleton class of obj metaclass = class << obj; self; end # add the method using define_method instead of def x.say so we can use a closure metaclass.send:define_method,:say do puts msg end end Usage (paste from IRB) >>...
Is it possible to define a Ruby singleton method using a block? So, I want to define a singleton method for an object, but I want to do it using a closure. For example, def define_say(obj, msg) def obj.say puts msg end end o = Object.new define_say o, "hello world!" o.say This doesn't work because defining a singleton...
TITLE: Is it possible to define a Ruby singleton method using a block? QUESTION: So, I want to define a singleton method for an object, but I want to do it using a closure. For example, def define_say(obj, msg) def obj.say puts msg end end o = Object.new define_say o, "hello world!" o.say This doesn't work because de...
[ "ruby", "closures", "singleton-methods" ]
12
8
5,964
2
0
2008-09-25T20:51:01.113000
2008-09-25T21:15:43.160000
136,012
137,064
Comet and jQuery
I've done some research into server push with javascript and have found the general consensus to be that what I'm looking for lies in the "Comet" design pattern. Are there any good implementations of this pattern built on top of jQuery? If not, are there any good implementations of this pattern at all? And regardless o...
I wrote the plugin mentioned by Till. The plugin is an implementation of the Bayeux protocol and currently supports long-polling (local server via AJAX) and callback-polling (remote server via XSS). There is a Bayeux implementation for Python called cometd-twisted that I have heard my plugin works with, but I have not ...
Comet and jQuery I've done some research into server push with javascript and have found the general consensus to be that what I'm looking for lies in the "Comet" design pattern. Are there any good implementations of this pattern built on top of jQuery? If not, are there any good implementations of this pattern at all?...
TITLE: Comet and jQuery QUESTION: I've done some research into server push with javascript and have found the general consensus to be that what I'm looking for lies in the "Comet" design pattern. Are there any good implementations of this pattern built on top of jQuery? If not, are there any good implementations of th...
[ "javascript", "jquery", "design-patterns", "comet", "server-push" ]
114
78
61,385
8
0
2008-09-25T20:53:48.707000
2008-09-26T00:17:07.860000
136,026
136,203
Quickbooks 2005 Web Integration
A customer of ours has Quickbooks 2005 and is looking to have their web data (orders, customers, tax) sent as it is collected from the web in a format that can be imported into Quickbooks 2005 Pro. Does anyone have any experience with this? If so, what was your experience, and what component/method would you recommend ...
Have a look at the QuickBooks Web Connector. There is a similar question: https://stackoverflow.com/questions/9331/integrating-quickbooks-with-your-e-commerce-site
Quickbooks 2005 Web Integration A customer of ours has Quickbooks 2005 and is looking to have their web data (orders, customers, tax) sent as it is collected from the web in a format that can be imported into Quickbooks 2005 Pro. Does anyone have any experience with this? If so, what was your experience, and what compo...
TITLE: Quickbooks 2005 Web Integration QUESTION: A customer of ours has Quickbooks 2005 and is looking to have their web data (orders, customers, tax) sent as it is collected from the web in a format that can be imported into Quickbooks 2005 Pro. Does anyone have any experience with this? If so, what was your experien...
[ "asp.net", "quickbooks" ]
1
3
620
2
0
2008-09-25T20:55:00.043000
2008-09-25T21:17:31.473000
136,028
136,072
Assembly.Load and Environment.CurrentDirectory
I realize there is a somewhat related thread on this here: Loading assemblies and its dependencies But I am modifying something and this doesn't exactly apply. string path = Path.GetDirectoryName( pathOfAssembly ); Environment.CurrentDirectory = path; Assembly.Load(Path.GetFileNameWithoutExtension(pastOfAssembly)); Is ...
Looks like the "Department of Redundancy Department." A lot more code than is necessary. Less is more! Edit: On second thought, it could be that the assembly you are loading has dependencies that live in its own folder that may be required to use the first assembly.
Assembly.Load and Environment.CurrentDirectory I realize there is a somewhat related thread on this here: Loading assemblies and its dependencies But I am modifying something and this doesn't exactly apply. string path = Path.GetDirectoryName( pathOfAssembly ); Environment.CurrentDirectory = path; Assembly.Load(Path.Ge...
TITLE: Assembly.Load and Environment.CurrentDirectory QUESTION: I realize there is a somewhat related thread on this here: Loading assemblies and its dependencies But I am modifying something and this doesn't exactly apply. string path = Path.GetDirectoryName( pathOfAssembly ); Environment.CurrentDirectory = path; Ass...
[ "c#", ".net", "assemblies" ]
2
5
2,036
2
0
2008-09-25T20:55:04.600000
2008-09-25T21:00:10.220000
136,033
136,110
How can I get PHP's (deployment) simplicity but Perl's power?
I despise the PHP language, and I'm quite certain that I'm not alone. But the great thing about PHP is the way that mod_php takes and hides the gory details of integrating with the apache runtime, and achieves CGI-like request isolation and decent performance. What's the shortest-distance approach to getting the same s...
Look at Catalyst this MVC (model, view, controller) framework works stand-a-lone or with apache_perl and hides a lot of the messy bits. There is a slightly odd learning curve (quick start, slower middle, then it really clicks for advanced stuff). Catalyst allows you to use Template Toolkit to separate the design logic ...
How can I get PHP's (deployment) simplicity but Perl's power? I despise the PHP language, and I'm quite certain that I'm not alone. But the great thing about PHP is the way that mod_php takes and hides the gory details of integrating with the apache runtime, and achieves CGI-like request isolation and decent performanc...
TITLE: How can I get PHP's (deployment) simplicity but Perl's power? QUESTION: I despise the PHP language, and I'm quite certain that I'm not alone. But the great thing about PHP is the way that mod_php takes and hides the gory details of integrating with the apache runtime, and achieves CGI-like request isolation and...
[ "php", "perl" ]
19
18
1,371
12
0
2008-09-25T20:55:46.843000
2008-09-25T21:03:29.697000
136,035
136,092
Catch multiple exceptions at once?
It is discouraged to simply catch System.Exception. Instead, only the "known" exceptions should be caught. Now, this sometimes leads to unnecessary repetitive code, for example: try { WebId = new Guid(queryString["web"]); } catch (FormatException) { WebId = Guid.Empty; } catch (OverflowException) { WebId = Guid.Empty; ...
Catch System.Exception and switch on the types catch (Exception ex) { if (ex is FormatException || ex is OverflowException) { WebId = Guid.Empty; } else throw; }
Catch multiple exceptions at once? It is discouraged to simply catch System.Exception. Instead, only the "known" exceptions should be caught. Now, this sometimes leads to unnecessary repetitive code, for example: try { WebId = new Guid(queryString["web"]); } catch (FormatException) { WebId = Guid.Empty; } catch (Overfl...
TITLE: Catch multiple exceptions at once? QUESTION: It is discouraged to simply catch System.Exception. Instead, only the "known" exceptions should be caught. Now, this sometimes leads to unnecessary repetitive code, for example: try { WebId = new Guid(queryString["web"]); } catch (FormatException) { WebId = Guid.Empt...
[ "c#", ".net", "exception" ]
2,567
2,449
844,145
29
0
2008-09-25T20:56:08.513000
2008-09-25T21:01:49.530000
136,050
1,910,905
Prevent visual studio creating browse info (.ncb) files
Is there a way to prevent VS2008 creating browse info file files for C++ projects. I rarely use the class browser and it isn't worth the time it takes to recreate it after every build, especially since it runs even if the build failed. EDIT - it's also needed for go to declaration/definition
There is a registry key for this as well: [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Languages\Language Services\C/C++] Intellisense ON "IntellisenseOptions"=dword:00000000 Intellisense OFF "IntellisenseOptions"=dword:00000007 Intellisense ON - NO Background UPDATE "IntellisenseOptions"=dword:00000005 More ...
Prevent visual studio creating browse info (.ncb) files Is there a way to prevent VS2008 creating browse info file files for C++ projects. I rarely use the class browser and it isn't worth the time it takes to recreate it after every build, especially since it runs even if the build failed. EDIT - it's also needed for ...
TITLE: Prevent visual studio creating browse info (.ncb) files QUESTION: Is there a way to prevent VS2008 creating browse info file files for C++ projects. I rarely use the class browser and it isn't worth the time it takes to recreate it after every build, especially since it runs even if the build failed. EDIT - it'...
[ "c++", "visual-studio", "visual-studio-2008" ]
5
4
7,290
3
0
2008-09-25T20:58:07.167000
2009-12-15T22:31:59.717000
136,065
136,078
How to check if a file has the win2003 "blocked" option on it
How do I check from within my NSIS installer if my installer has the blocked option in preferences on it. Even if you know of a way to check this without NSIS, please let me know so I can script it myself. See this question to find out more info about this blocked option.
Using Hitscan's related answer here... You can check if an EXE has this property simply by checking for the existance of the alternate data stream (ADS): file.exe:Zone.Identifier
How to check if a file has the win2003 "blocked" option on it How do I check from within my NSIS installer if my installer has the blocked option in preferences on it. Even if you know of a way to check this without NSIS, please let me know so I can script it myself. See this question to find out more info about this b...
TITLE: How to check if a file has the win2003 "blocked" option on it QUESTION: How do I check from within my NSIS installer if my installer has the blocked option in preferences on it. Even if you know of a way to check this without NSIS, please let me know so I can script it myself. See this question to find out more...
[ "security", "windows-server-2003", "nsis" ]
0
1
178
1
0
2008-09-25T20:59:18.507000
2008-09-25T21:00:25.693000
136,067
136,154
How do I profile a Perl web app?
I am working on a web app that uses Perl and I need to look into speeding up portions of the app. I thought I'd start profiling the particular calls for the portion I wish to investigate. I've done some searching on profiling Perl code, but unfortunately most of what I find says that I should run my perl code with -d:D...
Have you tried Devel::NYTProf (much better than Devel::DProf), which can work under Apache? Which webserver are you using? Is this a vanilla CGI script, a mod_perl thing, or something else? If you're doing database stuff, the DBI::Profile can benchmark your queries, which is work happening in another program. The real ...
How do I profile a Perl web app? I am working on a web app that uses Perl and I need to look into speeding up portions of the app. I thought I'd start profiling the particular calls for the portion I wish to investigate. I've done some searching on profiling Perl code, but unfortunately most of what I find says that I ...
TITLE: How do I profile a Perl web app? QUESTION: I am working on a web app that uses Perl and I need to look into speeding up portions of the app. I thought I'd start profiling the particular calls for the portion I wish to investigate. I've done some searching on profiling Perl code, but unfortunately most of what I...
[ "perl", "profiling" ]
16
19
2,824
4
0
2008-09-25T20:59:29.020000
2008-09-25T21:07:57.937000
136,069
136,188
Python web development - with or without a framework
I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light weight reporting interface. I did not use a framewor...
The command-line Python, IMO, definitely comes first. Get that to work, since that's the core of what you're doing. The issue is that using a web framework's ORM from a command line application isn't obvious. Django provides specific instructions for using their ORM from a command-line app. Those are annoying at first,...
Python web development - with or without a framework I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light...
TITLE: Python web development - with or without a framework QUESTION: I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basi...
[ "python", "frameworks" ]
19
15
7,549
8
0
2008-09-25T20:59:49.440000
2008-09-25T21:14:33.413000
136,097
1,669,524
What is the difference between @staticmethod and @classmethod in Python?
What is the difference between a method decorated with @staticmethod and one decorated with @classmethod?
Maybe a bit of example code will help: Notice the difference in the call signatures of foo, class_foo and static_foo: class A(object): def foo(self, x): print(f"executing foo({self}, {x})") @classmethod def class_foo(cls, x): print(f"executing class_foo({cls}, {x})") @staticmethod def static_foo(x): print(f"executing...
What is the difference between @staticmethod and @classmethod in Python? What is the difference between a method decorated with @staticmethod and one decorated with @classmethod?
TITLE: What is the difference between @staticmethod and @classmethod in Python? QUESTION: What is the difference between a method decorated with @staticmethod and one decorated with @classmethod? ANSWER: Maybe a bit of example code will help: Notice the difference in the call signatures of foo, class_foo and static_f...
[ "python", "oop", "static-methods", "python-decorators", "class-method" ]
4,645
3,902
1,074,557
36
0
2008-09-25T21:01:57.843000
2009-11-03T19:13:48.353000
136,098
158,386
Grails 1.0.3 console reports 'premature end of file'
Browsing to a dynamic web page built using Grails version 1.0.3 the console log shows the following errors for each page request: [Fatal Error]:-1:-1: Premature end of file. How do I stop this error from appearing for each request?
The log entry occurs when http requests are made from Firefox 3 browsers. The workaround on Grails 1.0.3 is to open Config.groovy in your project and find the following: grails.mime.types = [ html: ['text/html','application/xhtml+xml'], xml: ['text/xml', 'application/xml'],... The second line above, pertaining to xml s...
Grails 1.0.3 console reports 'premature end of file' Browsing to a dynamic web page built using Grails version 1.0.3 the console log shows the following errors for each page request: [Fatal Error]:-1:-1: Premature end of file. How do I stop this error from appearing for each request?
TITLE: Grails 1.0.3 console reports 'premature end of file' QUESTION: Browsing to a dynamic web page built using Grails version 1.0.3 the console log shows the following errors for each page request: [Fatal Error]:-1:-1: Premature end of file. How do I stop this error from appearing for each request? ANSWER: The log ...
[ "grails", "groovy" ]
5
3
1,139
3
0
2008-09-25T21:02:02.477000
2008-10-01T16:09:40.467000
136,104
136,109
Why won't Visual Studio 2005 generate an Xml Serialization assembly?
Why isn't Visual Studio 2005 generating a serialization setting when I set the project setting "Generate Serialization Assembly" to "On"?
It turns out that Dev Studio only honors this setting for Web Services. For non-web services you can get this to work by adding an AfterBuild target to your project file: See also: SGen MSBuild Task AfterBuild Event
Why won't Visual Studio 2005 generate an Xml Serialization assembly? Why isn't Visual Studio 2005 generating a serialization setting when I set the project setting "Generate Serialization Assembly" to "On"?
TITLE: Why won't Visual Studio 2005 generate an Xml Serialization assembly? QUESTION: Why isn't Visual Studio 2005 generating a serialization setting when I set the project setting "Generate Serialization Assembly" to "On"? ANSWER: It turns out that Dev Studio only honors this setting for Web Services. For non-web se...
[ "visual-studio-2005", "xml-serialization", "sgen" ]
3
9
1,296
2
0
2008-09-25T21:02:48.607000
2008-09-25T21:03:14.050000
136,129
136,265
Windows Forms: How do you change the font color for a disabled label
I am trying to set the disabled font characteristics for a Label Control. I can set all of the Font characteristics (size, bold, etc), but the color is overridden by the default windows behavior which seems to be one of these two colors: If background color is transparent then ForeColor is same as TextBox disabled Colo...
Take a look at the ControlPaint.DrawStringDisabled method; it might be something helpful. I've used it when overriding the OnPaint event for custom controls. ControlPaint.DrawStringDisabled(g, this.Text, this.Font, Color.Transparent, new Rectangle(CustomStringWidth, 5, StringSize2.Width, StringSize2.Height), StringForm...
Windows Forms: How do you change the font color for a disabled label I am trying to set the disabled font characteristics for a Label Control. I can set all of the Font characteristics (size, bold, etc), but the color is overridden by the default windows behavior which seems to be one of these two colors: If background...
TITLE: Windows Forms: How do you change the font color for a disabled label QUESTION: I am trying to set the disabled font characteristics for a Label Control. I can set all of the Font characteristics (size, bold, etc), but the color is overridden by the default windows behavior which seems to be one of these two col...
[ "winforms" ]
11
1
23,603
6
0
2008-09-25T21:05:01.597000
2008-09-25T21:28:22.710000
136,165
198,499
Visual Studio 2008 Properties Window SLOW
Even after all the hotfixes and updates that are supposed to fix this, my properties window in Visual Studio 2008 is still SLOW! What happens is a click on a table cell or something similar in the web editor, and regardless of the size of the page I'm working on, it takes a second or two for the properties window to sh...
I think I figured out the problem I was having - I turned off the startup page, and disabled the startup page refresh option (where it checks for latest content every 60 minutes or whatever), so that now when I load the environment, it just shows a blank page. I have no idea why this would relate to the amount of time ...
Visual Studio 2008 Properties Window SLOW Even after all the hotfixes and updates that are supposed to fix this, my properties window in Visual Studio 2008 is still SLOW! What happens is a click on a table cell or something similar in the web editor, and regardless of the size of the page I'm working on, it takes a sec...
TITLE: Visual Studio 2008 Properties Window SLOW QUESTION: Even after all the hotfixes and updates that are supposed to fix this, my properties window in Visual Studio 2008 is still SLOW! What happens is a click on a table cell or something similar in the web editor, and regardless of the size of the page I'm working ...
[ "visual-studio-2008" ]
0
1
1,334
3
0
2008-09-25T21:10:39.197000
2008-10-13T18:20:12.147000
136,168
692,616
Get last n lines of a file, similar to tail
I'm writing a log file viewer for a web application and I want to paginate through the lines of the log file. The items in the file are line based with the newest item at the bottom. So I need a tail() method that can read n lines from the bottom and support an offset. This is what I came up with: def tail(f, n, offset...
The code I ended up using. I think this is the best so far: def tail(f, n, offset=None): """Reads a n lines from f with an offset of offset lines. The return value is a tuple in the form ``(lines, has_more)`` where `has_more` is an indicator that is `True` if there are more lines in the file. """ avg_line_length = 74 t...
Get last n lines of a file, similar to tail I'm writing a log file viewer for a web application and I want to paginate through the lines of the log file. The items in the file are line based with the newest item at the bottom. So I need a tail() method that can read n lines from the bottom and support an offset. This i...
TITLE: Get last n lines of a file, similar to tail QUESTION: I'm writing a log file viewer for a web application and I want to paginate through the lines of the log file. The items in the file are line based with the newest item at the bottom. So I need a tail() method that can read n lines from the bottom and support...
[ "python", "file", "file-io", "tail", "logfile" ]
212
24
196,916
36
0
2008-09-25T21:11:11.363000
2009-03-28T11:13:44.380000
136,175
136,714
Fastest small datastore on Windows
My app keeps track of the state of about 1000 objects. Those objects are read from and written to a persistent store (serialized) in no particular order. Right now the app uses the registry to store each object's state. This is nice because: It is simple It is very fast Individual object's state can be read/written wit...
If you do begin to experiment with SQLite, you should know that "out of the box" it might not seem as fast as you would like, but it can quickly be made to be much faster by applying some established optimization tips: SQLite optimization Depending on the size of the data and the amount of RAM available, one of the bes...
Fastest small datastore on Windows My app keeps track of the state of about 1000 objects. Those objects are read from and written to a persistent store (serialized) in no particular order. Right now the app uses the registry to store each object's state. This is nice because: It is simple It is very fast Individual obj...
TITLE: Fastest small datastore on Windows QUESTION: My app keeps track of the state of about 1000 objects. Those objects are read from and written to a persistent store (serialized) in no particular order. Right now the app uses the registry to store each object's state. This is nice because: It is simple It is very f...
[ "c++", "windows", "data-structures", "caching", "registry" ]
3
3
965
5
0
2008-09-25T21:12:14.777000
2008-09-25T22:54:50.833000
136,178
152,546
How should I use git diff for long lines?
I'm running git-diff on a file, but the change is at the end of a long line. If I use cursor keys to move right, it loses colour-coding—and worse the lines don't line up—making it harder to track the change. Is there a way to prevent that problem or to simply make the lines wrap instead? I'm running Git 1.5.5 via mingw...
The display of the output of git diff is handled by whatever pager you are using. Commonly, under Linux, less would be used. You can tell git to use a different pager by setting the GIT_PAGER environment variable. If you don't mind about paging (for example, your terminal allows you to scroll back) you might try explic...
How should I use git diff for long lines? I'm running git-diff on a file, but the change is at the end of a long line. If I use cursor keys to move right, it loses colour-coding—and worse the lines don't line up—making it harder to track the change. Is there a way to prevent that problem or to simply make the lines wra...
TITLE: How should I use git diff for long lines? QUESTION: I'm running git-diff on a file, but the change is at the end of a long line. If I use cursor keys to move right, it loses colour-coding—and worse the lines don't line up—making it harder to track the change. Is there a way to prevent that problem or to simply ...
[ "git", "diff", "word-wrap" ]
259
131
55,248
15
0
2008-09-25T21:12:34.730000
2008-09-30T10:43:23.783000
136,190
136,223
What is the best approach to centralzing error messages in an application?
All throughout an application wherever error messages (or other user messages) are used I typically hard-code a string. Obviosly this can be really bad (especially when you may have to come back and localize an app). What is the best approach to centralize these strings? A static class? Constants? An XML File? Or a com...
Create the strings in a resource file. You can then localise by adding additional resource files. Check out http://geekswithblogs.net/dotNETPlayground/archive/2007/11/09/116726.aspx
What is the best approach to centralzing error messages in an application? All throughout an application wherever error messages (or other user messages) are used I typically hard-code a string. Obviosly this can be really bad (especially when you may have to come back and localize an app). What is the best approach to...
TITLE: What is the best approach to centralzing error messages in an application? QUESTION: All throughout an application wherever error messages (or other user messages) are used I typically hard-code a string. Obviosly this can be really bad (especially when you may have to come back and localize an app). What is th...
[ ".net", "error-handling", "coding-style" ]
0
5
316
5
0
2008-09-25T21:15:08.997000
2008-09-25T21:20:22.590000
136,191
136,317
How do I make this "Use of uninitialized value" warning go away?
Let's say I want to write a regular expression to change all,, and tags into tags.. and I also want to change their closing tags to. This seems like a reasonable regex (ignore the backticks; StackOverflow has trouble with the less-than signs if I don't include them): `s!<(/)?(abc|def|ghi)>!<${1}xyz>!g;` And it works, t...
Move the question mark inside the capturing bracket. That way $1 will always be defined, but may be a zero-length string.
How do I make this "Use of uninitialized value" warning go away? Let's say I want to write a regular expression to change all,, and tags into tags.. and I also want to change their closing tags to. This seems like a reasonable regex (ignore the backticks; StackOverflow has trouble with the less-than signs if I don't in...
TITLE: How do I make this "Use of uninitialized value" warning go away? QUESTION: Let's say I want to write a regular expression to change all,, and tags into tags.. and I also want to change their closing tags to. This seems like a reasonable regex (ignore the backticks; StackOverflow has trouble with the less-than s...
[ "regex", "perl" ]
1
10
1,374
9
0
2008-09-25T21:15:20.103000
2008-09-25T21:35:27.310000
136,195
141,381
Trying to set/get a JavaScript variable in an ActiveX WebBrowser from C#
We have a windows application that contains an ActiveX WebBrowser control. As part of the regular operation of this application modifications are made to the pages that are displayed by the ActiveX WebBrowser control. Part of these modifications involve setting a JavaScript variable in a web page being loaded into the ...
These two articles helped us find a solution to our problem. They outline the basics of what one needs to know: Microsoft Web Browser Automation using C# Using MSHTML Advanced Hosting Interfaces So we implemented a DocHostUIHandler interface and that allowed us to set a UIHandler, allowing us to reference the method fr...
Trying to set/get a JavaScript variable in an ActiveX WebBrowser from C# We have a windows application that contains an ActiveX WebBrowser control. As part of the regular operation of this application modifications are made to the pages that are displayed by the ActiveX WebBrowser control. Part of these modifications i...
TITLE: Trying to set/get a JavaScript variable in an ActiveX WebBrowser from C# QUESTION: We have a windows application that contains an ActiveX WebBrowser control. As part of the regular operation of this application modifications are made to the pages that are displayed by the ActiveX WebBrowser control. Part of the...
[ "c#", "javascript", "activex", "browser" ]
2
2
9,203
4
0
2008-09-25T21:15:44.317000
2008-09-26T19:18:31.850000
136,204
136,228
What's the point of Perl's map?
Not really getting the point of the map function. Can anyone explain with examples its use? Are there any performance benefits to using this instead of a loop or is it just sugar?
Any time you want to generate a list based another list: # Double all elements of a list my @double = map { $_ * 2 } (1,2,3,4,5); # @double = (2,4,6,8,10); Since lists are easily converted pairwise into hashes, if you want a hash table for objects based on a particular attribute: # @user_objects is a list of objects ha...
What's the point of Perl's map? Not really getting the point of the map function. Can anyone explain with examples its use? Are there any performance benefits to using this instead of a loop or is it just sugar?
TITLE: What's the point of Perl's map? QUESTION: Not really getting the point of the map function. Can anyone explain with examples its use? Are there any performance benefits to using this instead of a loop or is it just sugar? ANSWER: Any time you want to generate a list based another list: # Double all elements of...
[ "list", "perl", "dictionary", "higher-order-functions" ]
34
46
21,622
16
0
2008-09-25T21:17:31.580000
2008-09-25T21:21:15.817000
136,219
136,312
Silverlight Security- Sensitive Data
Silverlight works on client side so putting any sensitive data like connection strings, passwords etc. in the code seems not to be a good thing. I want to build whole web app in Silverlight doing lots of authorization and database quering things. How to make it safe? Any tips&tricks and what things should I avoid?
I have never developed / used a silverlight app, but I would assume you would use a webservice to broker communication between your app and the database. This is at least how Flex works. Edit: This is how Silverlight works as well
Silverlight Security- Sensitive Data Silverlight works on client side so putting any sensitive data like connection strings, passwords etc. in the code seems not to be a good thing. I want to build whole web app in Silverlight doing lots of authorization and database quering things. How to make it safe? Any tips&tricks...
TITLE: Silverlight Security- Sensitive Data QUESTION: Silverlight works on client side so putting any sensitive data like connection strings, passwords etc. in the code seems not to be a good thing. I want to build whole web app in Silverlight doing lots of authorization and database quering things. How to make it saf...
[ "c#", ".net", "silverlight", "security" ]
1
2
302
1
0
2008-09-25T21:19:23.980000
2008-09-25T21:34:44.833000
136,233
136,313
redirect STDERR in tcsh from .aliases
in tcsh I'm trying to redirect STDERR from a command from my.aliases file. I found that I can redirect STDERR from the command line like this... $ (xemacs > /dev/tty) >& /dev/null... but when I put this in my.aliases file I get an alias loop... $ cat.aliases alias xemacs '(xemacs > /dev/tty ) >& /dev/null' $ xemacs & A...
I suspect this is a case where NOT using an alias is the best option - try using a shell script instead: #!/bin/tcsh (xemacs $* > /dev/tty ) >& /dev/null
redirect STDERR in tcsh from .aliases in tcsh I'm trying to redirect STDERR from a command from my.aliases file. I found that I can redirect STDERR from the command line like this... $ (xemacs > /dev/tty) >& /dev/null... but when I put this in my.aliases file I get an alias loop... $ cat.aliases alias xemacs '(xemacs >...
TITLE: redirect STDERR in tcsh from .aliases QUESTION: in tcsh I'm trying to redirect STDERR from a command from my.aliases file. I found that I can redirect STDERR from the command line like this... $ (xemacs > /dev/tty) >& /dev/null... but when I put this in my.aliases file I get an alias loop... $ cat.aliases alias...
[ "tcsh" ]
4
5
7,633
2
0
2008-09-25T21:22:19.387000
2008-09-25T21:34:59.370000
136,237
136,365
Visual Studios Link.exe error: "extra operand"
Our build process uses Visual Studios 2003 link.exe for linking. On one machine we're seeing the following error: _X86_Win32/Debug/Intermediate/OurApp.exe LINK: extra operand `/subsystem:windows' Try `LINK --help' for more information It appears to be using the same version of visual studios as the other machines. Has ...
It looks like there's a copy of the GNU link utility somewhere in the search path. This message isn't from the Microsoft linker.
Visual Studios Link.exe error: "extra operand" Our build process uses Visual Studios 2003 link.exe for linking. On one machine we're seeing the following error: _X86_Win32/Debug/Intermediate/OurApp.exe LINK: extra operand `/subsystem:windows' Try `LINK --help' for more information It appears to be using the same versio...
TITLE: Visual Studios Link.exe error: "extra operand" QUESTION: Our build process uses Visual Studios 2003 link.exe for linking. On one machine we're seeing the following error: _X86_Win32/Debug/Intermediate/OurApp.exe LINK: extra operand `/subsystem:windows' Try `LINK --help' for more information It appears to be usi...
[ "visual-studio", "build-process", "linker" ]
17
33
6,282
1
0
2008-09-25T21:23:05.500000
2008-09-25T21:42:37.403000
136,238
136,261
Trouble when adding a lot of Controls to a .NET Windows Form (C#)
I have a Windows Form app written in C#. Its job is to send messages to a list of users. While those messages are being sent, I'd like to display status of the operation for each user. What I am doing (for each user) is creating a Label control and adding it to Panel. This works without a problem for a small set of use...
Given the size, I would consider displaying your status in a RichTextBox. What is happening is that you are generating too many handles and the Framework can't handle them all.
Trouble when adding a lot of Controls to a .NET Windows Form (C#) I have a Windows Form app written in C#. Its job is to send messages to a list of users. While those messages are being sent, I'd like to display status of the operation for each user. What I am doing (for each user) is creating a Label control and addin...
TITLE: Trouble when adding a lot of Controls to a .NET Windows Form (C#) QUESTION: I have a Windows Form app written in C#. Its job is to send messages to a list of users. While those messages are being sent, I'd like to display status of the operation for each user. What I am doing (for each user) is creating a Label...
[ "c#", "winforms" ]
1
3
1,946
8
0
2008-09-25T21:23:08.977000
2008-09-25T21:27:55.037000
136,278
136,285
Why should you remove unnecessary C# using directives?
For example, I rarely need: using System.Text; but it's always there by default. I assume the application will use more memory if your code contains unnecessary using directives. But is there anything else I should be aware of? Also, does it make any difference whatsoever if the same using directive is used in only one...
It won't change anything when your program runs. Everything that's needed is loaded on demand. So even if you have that using statement, unless you actually use a type in that namespace / assembly, the assembly that using statement is correlated to won't be loaded. Mainly, it's just to clean up for personal preference.
Why should you remove unnecessary C# using directives? For example, I rarely need: using System.Text; but it's always there by default. I assume the application will use more memory if your code contains unnecessary using directives. But is there anything else I should be aware of? Also, does it make any difference wha...
TITLE: Why should you remove unnecessary C# using directives? QUESTION: For example, I rarely need: using System.Text; but it's always there by default. I assume the application will use more memory if your code contains unnecessary using directives. But is there anything else I should be aware of? Also, does it make ...
[ "c#", "assemblies", "using" ]
232
185
60,123
14
0
2008-09-25T21:30:07.120000
2008-09-25T21:31:32.687000
136,284
137,423
Ajax autocomplete extender populated from SQL
OK, first let me state that I have never used this control and this is also my first attempt at using a web service. My dilemma is as follows. I need to query a database to get back a certain column and use that for my autocomplete. Obviously I don't want the query to run every time a user types another word in the tex...
Why not keep track of the query executed by the user in a session variable, then use that to filter any further results? The trick to preventing the database from overloading I think is really to just limit how frequently the auto updater is allowed to update, something like once per 2 seconds seems reasonable to me. W...
Ajax autocomplete extender populated from SQL OK, first let me state that I have never used this control and this is also my first attempt at using a web service. My dilemma is as follows. I need to query a database to get back a certain column and use that for my autocomplete. Obviously I don't want the query to run e...
TITLE: Ajax autocomplete extender populated from SQL QUESTION: OK, first let me state that I have never used this control and this is also my first attempt at using a web service. My dilemma is as follows. I need to query a database to get back a certain column and use that for my autocomplete. Obviously I don't want ...
[ "sql", "ajax" ]
1
2
2,780
4
0
2008-09-25T21:31:28.880000
2008-09-26T02:33:56.437000
136,298
136,329
What's required for a clean uninstall of Visual Studio 2005
Due to continuing crash problems, I'm about to uninstall and reinstall my copy of Visual Studio 2005. I know that just running the uninstaller leaves a lot of resources and settings on my machine and would like to be able to reinstall from a pristine state. Is there any way to completely uninstall VS2k5 from my machine...
Visual Studio 2005 is known for not uninstalling so well (especially the Express editions). Use the technique found here to manually uninstall all of Visual Studio.
What's required for a clean uninstall of Visual Studio 2005 Due to continuing crash problems, I'm about to uninstall and reinstall my copy of Visual Studio 2005. I know that just running the uninstaller leaves a lot of resources and settings on my machine and would like to be able to reinstall from a pristine state. Is...
TITLE: What's required for a clean uninstall of Visual Studio 2005 QUESTION: Due to continuing crash problems, I'm about to uninstall and reinstall my copy of Visual Studio 2005. I know that just running the uninstaller leaves a lot of resources and settings on my machine and would like to be able to reinstall from a ...
[ "visual-studio", "visual-studio-2005" ]
2
2
9,022
6
0
2008-09-25T21:33:03.243000
2008-09-25T21:36:36.980000
136,308
136,344
How do you refresh maven dependencies from eclipse?
We recently started using maven for dependency management. Our team uses eclipse as it's IDE. Is there an easy way to get eclipse to refresh the maven dependencies without running mvn eclipse:eclipse? The dependencies are up to date in the local maven repository, but eclipse doesn't pick up the changes until we use the...
Have you tried using the m2eclipse plugin? I use it with eclipse and it maintains the eclipse.classpath when I add dependencies. It'll also check for updated dependencies.
How do you refresh maven dependencies from eclipse? We recently started using maven for dependency management. Our team uses eclipse as it's IDE. Is there an easy way to get eclipse to refresh the maven dependencies without running mvn eclipse:eclipse? The dependencies are up to date in the local maven repository, but ...
TITLE: How do you refresh maven dependencies from eclipse? QUESTION: We recently started using maven for dependency management. Our team uses eclipse as it's IDE. Is there an easy way to get eclipse to refresh the maven dependencies without running mvn eclipse:eclipse? The dependencies are up to date in the local mave...
[ "java", "eclipse", "maven-2" ]
10
15
24,172
2
0
2008-09-25T21:33:54.663000
2008-09-25T21:38:29.863000
136,337
136,385
Does a definitive list of design patterns exist?
Where did the idea of design patterns come from, who decided what is and isn't a pattern and gave them their names? Is there an official organisation that defines them, or do they exist through some community consensus?
I think there's a basic "life cycle of a design pattern" Author writes about design pattern in a book. Book becomes well read, possibly best seller Design pattern enters public conscious, gains mindshare. Design pattern gets used. It works well. design pattern gets more mindshare Design pattern becomes panacea, gets ov...
Does a definitive list of design patterns exist? Where did the idea of design patterns come from, who decided what is and isn't a pattern and gave them their names? Is there an official organisation that defines them, or do they exist through some community consensus?
TITLE: Does a definitive list of design patterns exist? QUESTION: Where did the idea of design patterns come from, who decided what is and isn't a pattern and gave them their names? Is there an official organisation that defines them, or do they exist through some community consensus? ANSWER: I think there's a basic ...
[ "design-patterns" ]
46
70
16,405
12
0
2008-09-25T21:38:03.933000
2008-09-25T21:45:26.040000
136,362
136,397
Adding referenced Eclipse projects to Maven dependencies
Right now, I have two Eclipse projects - they both use Maven 2 for all their jar-dependency goodness. Inside Eclipse, I have project Foo included in project Bar's build path, so that I can use Foo's classes from project Bar. This works really well in Eclipse land, but when I try: mvn compile inside Bar's directory, it ...
Maybe you are referencing the other project via Eclipse configure-> build path only. This works as long as you use Eclipse to build your project. Try running first mvn install in project Bar (in order to put Bar in your Maven repository), and then add the dependency to Foo's pom.xml. That should work!.
Adding referenced Eclipse projects to Maven dependencies Right now, I have two Eclipse projects - they both use Maven 2 for all their jar-dependency goodness. Inside Eclipse, I have project Foo included in project Bar's build path, so that I can use Foo's classes from project Bar. This works really well in Eclipse land...
TITLE: Adding referenced Eclipse projects to Maven dependencies QUESTION: Right now, I have two Eclipse projects - they both use Maven 2 for all their jar-dependency goodness. Inside Eclipse, I have project Foo included in project Bar's build path, so that I can use Foo's classes from project Bar. This works really we...
[ "java", "eclipse", "maven-2" ]
25
21
26,438
7
0
2008-09-25T21:42:06.343000
2008-09-25T21:48:54.533000
136,366
360,925
How can I leverage an ORM for a database whose schema is unknown until runtime?
I am trying to leverage ORM given the following requirements: 1) Using.NET Framework (latest Framework is okay) 2) Must be able to use Sybase, Oracle, MSSQL interchangeably 3) The schema is mostly static, BUT there are dynamic parts. I am somewhat familiar with SubSonic and NHibernate, but not deeply. I get the nagging...
Acording to this blog you can in fact use NHibernate with dynamic mapping. It takes a bit of tweaking though...
How can I leverage an ORM for a database whose schema is unknown until runtime? I am trying to leverage ORM given the following requirements: 1) Using.NET Framework (latest Framework is okay) 2) Must be able to use Sybase, Oracle, MSSQL interchangeably 3) The schema is mostly static, BUT there are dynamic parts. I am s...
TITLE: How can I leverage an ORM for a database whose schema is unknown until runtime? QUESTION: I am trying to leverage ORM given the following requirements: 1) Using.NET Framework (latest Framework is okay) 2) Must be able to use Sybase, Oracle, MSSQL interchangeably 3) The schema is mostly static, BUT there are dyn...
[ "c#", ".net", "database", "orm", "dynamic" ]
3
1
2,163
5
0
2008-09-25T21:42:37.403000
2008-12-11T21:07:28.957000
136,401
160,792
Reversing an RSS feed
This could be weird, Have you ever come across a blog which you wanted to read in the chronological order? And that blog could be old, with several hundred posts. When i add this feed to my feed reader, say googlereader, the latest feed comes on top and as i scroll down further, the older posts appear. This could be fr...
If you do decide to roll your own C# application to do this, it is very straightforward in the current version of the.NET Framework. Look for the System.ServiceModel.Syndication namespace. That has classes related to RSS and Atom feeds. I wrote some code recently that generates a feed from a database using these classe...
Reversing an RSS feed This could be weird, Have you ever come across a blog which you wanted to read in the chronological order? And that blog could be old, with several hundred posts. When i add this feed to my feed reader, say googlereader, the latest feed comes on top and as i scroll down further, the older posts ap...
TITLE: Reversing an RSS feed QUESTION: This could be weird, Have you ever come across a blog which you wanted to read in the chronological order? And that blog could be old, with several hundred posts. When i add this feed to my feed reader, say googlereader, the latest feed comes on top and as i scroll down further, ...
[ ".net", "rss", "feed" ]
1
2
737
5
0
2008-09-25T21:50:21.080000
2008-10-02T03:35:30.240000
136,413
136,569
Flex - Avoid click event on container when enclosed component is clicked
I have a Flex application where I'm using a Canvas to contain several other components. On that Canvas there is a Button which is used to invoke a particular flow through the system. Clicking anywhere else on the Canvas should cause cause a details pane to appear showing more information about the record represented by...
The event continues on because event.bubbles is set to true. This means everything in the display heirarchy gets the event. To stop the event from continuing, you call event.stopImmediatePropagation()
Flex - Avoid click event on container when enclosed component is clicked I have a Flex application where I'm using a Canvas to contain several other components. On that Canvas there is a Button which is used to invoke a particular flow through the system. Clicking anywhere else on the Canvas should cause cause a detail...
TITLE: Flex - Avoid click event on container when enclosed component is clicked QUESTION: I have a Flex application where I'm using a Canvas to contain several other components. On that Canvas there is a Button which is used to invoke a particular flow through the system. Clicking anywhere else on the Canvas should ca...
[ "apache-flex", "events", "containers" ]
4
7
4,620
3
0
2008-09-25T21:52:39.140000
2008-09-25T22:22:26.947000
136,419
136,434
Get integer value of the current year in Java
I need to determine the current year in Java as an integer. I could just use java.util.Date(), but it is deprecated.
For Java 8 onwards: int year = Year.now().getValue(); For older version of Java: int year = Calendar.getInstance().get(Calendar.YEAR);
Get integer value of the current year in Java I need to determine the current year in Java as an integer. I could just use java.util.Date(), but it is deprecated.
TITLE: Get integer value of the current year in Java QUESTION: I need to determine the current year in Java as an integer. I could just use java.util.Date(), but it is deprecated. ANSWER: For Java 8 onwards: int year = Year.now().getValue(); For older version of Java: int year = Calendar.getInstance().get(Calendar.YE...
[ "java", "datetime", "date" ]
382
798
636,315
16
0
2008-09-25T21:53:52.837000
2008-09-25T21:56:41.207000
136,429
139,397
Don't wait for the process to exit
I have a PHP script that is called from a cron job every minute. This script takes some info from the database and then calls another PHP script using the System function (passing it some parameters). That means that I can start up to 10 scripts from this "main" one. And what I would like to do is that I would call the...
You may be able to use proc_open(), stream_select() and stream_set_blocking() in concert to achieve this kind of thing. If that sounds vague, I was going to paste a big chunk of code in here that I used in a recent project that did something similar, but then felt it may hinder rather than help! In summary though, the ...
Don't wait for the process to exit I have a PHP script that is called from a cron job every minute. This script takes some info from the database and then calls another PHP script using the System function (passing it some parameters). That means that I can start up to 10 scripts from this "main" one. And what I would ...
TITLE: Don't wait for the process to exit QUESTION: I have a PHP script that is called from a cron job every minute. This script takes some info from the database and then calls another PHP script using the System function (passing it some parameters). That means that I can start up to 10 scripts from this "main" one....
[ "php" ]
1
3
8,332
7
0
2008-09-25T21:55:30.727000
2008-09-26T13:08:57.150000
136,435
2,506,504
Any way to make a WPF textblock selectable?
How to allow TextBlock 's text to be selectable? I tried to get it to work by displaying the text using a read-only TextBox styled to look like a textblock but this will not work in my case because a TextBox does not have inlines. In other words, how to make it selectable?
Use a TextBox with these settings instead to make it read only and to look like a TextBlock control.
Any way to make a WPF textblock selectable? How to allow TextBlock 's text to be selectable? I tried to get it to work by displaying the text using a read-only TextBox styled to look like a textblock but this will not work in my case because a TextBox does not have inlines. In other words, how to make it selectable?
TITLE: Any way to make a WPF textblock selectable? QUESTION: How to allow TextBlock 's text to be selectable? I tried to get it to work by displaying the text using a read-only TextBox styled to look like a textblock but this will not work in my case because a TextBox does not have inlines. In other words, how to make...
[ "wpf", "xaml", "textbox", "textblock" ]
264
274
146,803
20
0
2008-09-25T21:56:51.003000
2010-03-24T09:27:23.480000
136,436
136,491
How do I run a series of processes in C# and keep their environment settings?
I am developing an auto-builder that will run a series of steps in our build process and build our target application. We used to use a batch file which set up a bunch of environment variables or called tools that setup environment variables and ultimately runs a 'make'. I've been using the 'Process' class which works ...
i would suggest some code that would save your environment variables to an external file, and then you can retrieve these variables via the external file at the start of following processes.
How do I run a series of processes in C# and keep their environment settings? I am developing an auto-builder that will run a series of steps in our build process and build our target application. We used to use a batch file which set up a bunch of environment variables or called tools that setup environment variables ...
TITLE: How do I run a series of processes in C# and keep their environment settings? QUESTION: I am developing an auto-builder that will run a series of steps in our build process and build our target application. We used to use a batch file which set up a bunch of environment variables or called tools that setup envi...
[ "c#", "build-process", "makefile", "environment", "auto-build" ]
3
0
1,138
5
0
2008-09-25T21:57:25.870000
2008-09-25T22:06:24.490000
136,443
159,582
Why doesn't IE7 copy <pre><code> blocks to the clipboard correctly?
We've noticed that IE7 has an odd behavor with code blocks posted on Stack Overflow. For example, this little code block: public PageSizer(string href, int index) { HRef = href; PageIndex = index; } Copy and pasted from IE7, ends up like this: public PageSizer(string href, int index){ HRef = href; PageIndex = index; } ...
It seems that this is a known bug for IE6 and prettify.js has a workaround for it. Specifically it replaces the BR tags with '\r\n'. By modifying the check to allow for IE6 or 7 then the cut-and-paste will work correctly from IE7, but it will render with a newline followed by a space. By checking for IE7 and providing ...
Why doesn't IE7 copy <pre><code> blocks to the clipboard correctly? We've noticed that IE7 has an odd behavor with code blocks posted on Stack Overflow. For example, this little code block: public PageSizer(string href, int index) { HRef = href; PageIndex = index; } Copy and pasted from IE7, ends up like this: public P...
TITLE: Why doesn't IE7 copy <pre><code> blocks to the clipboard correctly? QUESTION: We've noticed that IE7 has an odd behavor with code blocks posted on Stack Overflow. For example, this little code block: public PageSizer(string href, int index) { HRef = href; PageIndex = index; } Copy and pasted from IE7, ends up l...
[ "html", "internet-explorer" ]
37
35
6,945
7
0
2008-09-25T21:58:05.383000
2008-10-01T20:36:04.193000
136,444
137,384
How do I send an ARP packet from a C program?
I'm working on an embedded linux system in C, I'm looking for the source code to the equivalet of SendARP in Windows. Any pointers?
Take a look at arping. The quick and dirty way of sending an arp would be to do: foo = system("/somepath/arping somehost"); But a look through the arping source should be able to give you a better solution. For the all-out solution though, you can construct your own by hand and use either a raw socket or libpcap to sen...
How do I send an ARP packet from a C program? I'm working on an embedded linux system in C, I'm looking for the source code to the equivalet of SendARP in Windows. Any pointers?
TITLE: How do I send an ARP packet from a C program? QUESTION: I'm working on an embedded linux system in C, I'm looking for the source code to the equivalet of SendARP in Windows. Any pointers? ANSWER: Take a look at arping. The quick and dirty way of sending an arp would be to do: foo = system("/somepath/arping som...
[ "network-programming" ]
1
3
3,392
3
0
2008-09-25T21:58:21.750000
2008-09-26T02:18:47.443000
136,456
136,553
Probability problem - Duplicates when choosing from large basket
I need to explain to the client why dupes are showing up between 2 supposedly different exams. It's been 20 years since Prob and Stats. I have a generated Multiple choice exam. There are 192 questions in the database, 100 are chosen at random (no dupes). Obviously, there is a 100% chance of there being at least 8 dupes...
Erm, this is really really hazy for me. But there are (192 choose 100) possible exams, right? And there are (100 choose N) ways of picking N dupes, each with (92 choose 100-N) ways of picking the rest of the questions, no? So isn't the probability of picking N dupes just: (100 choose N) * (92 choose 100-N) / (192 choos...
Probability problem - Duplicates when choosing from large basket I need to explain to the client why dupes are showing up between 2 supposedly different exams. It's been 20 years since Prob and Stats. I have a generated Multiple choice exam. There are 192 questions in the database, 100 are chosen at random (no dupes). ...
TITLE: Probability problem - Duplicates when choosing from large basket QUESTION: I need to explain to the client why dupes are showing up between 2 supposedly different exams. It's been 20 years since Prob and Stats. I have a generated Multiple choice exam. There are 192 questions in the database, 100 are chosen at r...
[ "math", "probability" ]
2
2
2,999
2
0
2008-09-25T22:00:26.783000
2008-09-25T22:18:33.587000
136,458
4,222,584
Change the URL in the browser without loading the new page using JavaScript
How would I have a JavaScript action that may have some effects on the current page but would also change the URL in the browser so if the user hits reload or bookmark, then the new URL is used? It would also be nice if the back button would reload the original URL. I am trying to record JavaScript state in the URL.
With HTML 5, use the history.pushState function. As an example: and a href: Click to change url to bar.html If you want to change the URL without adding an entry to the back button list, use history.replaceState instead.
Change the URL in the browser without loading the new page using JavaScript How would I have a JavaScript action that may have some effects on the current page but would also change the URL in the browser so if the user hits reload or bookmark, then the new URL is used? It would also be nice if the back button would re...
TITLE: Change the URL in the browser without loading the new page using JavaScript QUESTION: How would I have a JavaScript action that may have some effects on the current page but would also change the URL in the browser so if the user hits reload or bookmark, then the new URL is used? It would also be nice if the ba...
[ "javascript", "url", "html5-history", "fragment-identifier", "hashchange" ]
304
124
310,828
14
0
2008-09-25T22:00:38.887000
2010-11-19T06:20:18.737000
136,474
136,631
best way to pick a random subset from a collection?
I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution: Vector itemsVector = getItems(); Collections.shuffle(itemsVector); itemsVector.setSize(5); While t...
Jon Bentley discusses this in either 'Programming Pearls' or 'More Programming Pearls'. You need to be careful with your N of M selection process, but I think the code shown works correctly. Rather than randomly shuffle all the items, you can do the random shuffle only shuffling the first N positions - which is a usefu...
best way to pick a random subset from a collection? I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution: Vector itemsVector = getItems(); Collections.s...
TITLE: best way to pick a random subset from a collection? QUESTION: I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution: Vector itemsVector = getItems...
[ "java", "algorithm", "collections", "random", "subset" ]
70
12
38,835
10
0
2008-09-25T22:02:59.600000
2008-09-25T22:35:59.303000
136,483
136,990
Something Good & Something Bad about SharePoint
I'm trying to wrap my head around SharePoint. Why is it good? Why is it bad? At a glance it appears to offer some incredible collaboration tools. However, the cost looks astronomical and it seems to be rigid & difficult to customize. To those who've worked with SharePoint; please describe something good and something b...
Pros: Document management is its most well-known function and integrates extremely well with Office 2007. Create group calendars that can be overlayed onto your personal Outlook and managed on the web. Notifications in response to certain actions on the group website Wiki-type functionality with full integration into t...
Something Good & Something Bad about SharePoint I'm trying to wrap my head around SharePoint. Why is it good? Why is it bad? At a glance it appears to offer some incredible collaboration tools. However, the cost looks astronomical and it seems to be rigid & difficult to customize. To those who've worked with SharePoint...
TITLE: Something Good & Something Bad about SharePoint QUESTION: I'm trying to wrap my head around SharePoint. Why is it good? Why is it bad? At a glance it appears to offer some incredible collaboration tools. However, the cost looks astronomical and it seems to be rigid & difficult to customize. To those who've work...
[ "sharepoint" ]
6
8
1,675
9
0
2008-09-25T22:03:48.477000
2008-09-25T23:57:32.400000
136,505
136,591
Searching for UUIDs in text with regex
I'm searching for UUIDs in blocks of text using a regex. Currently I'm relying on the assumption that all UUIDs will follow a patttern of 8-4-4-4-12 hexadecimal digits. Can anyone think of a use case where this assumption would be invalid and would cause me to miss some UUIDs?
I agree that by definition your regex does not miss any UUID. However it may be useful to note that if you are searching especially for Microsoft's Globally Unique Identifiers (GUIDs), there are five equivalent string representations for a GUID: "ca761232ed4211cebacd00aa0057b223" "CA761232-ED42-11CE-BACD-00AA0057B223"...
Searching for UUIDs in text with regex I'm searching for UUIDs in blocks of text using a regex. Currently I'm relying on the assumption that all UUIDs will follow a patttern of 8-4-4-4-12 hexadecimal digits. Can anyone think of a use case where this assumption would be invalid and would cause me to miss some UUIDs?
TITLE: Searching for UUIDs in text with regex QUESTION: I'm searching for UUIDs in blocks of text using a regex. Currently I'm relying on the assumption that all UUIDs will follow a patttern of 8-4-4-4-12 hexadecimal digits. Can anyone think of a use case where this assumption would be invalid and would cause me to mi...
[ "regex" ]
380
43
413,673
20
0
2008-09-25T22:08:27.433000
2008-09-25T22:27:13.940000
136,528
136,600
Using .NET's Reflection.Emit to generate an interface
I need to generate a new interface at run-time with all the same members as an existing interface, except that I will be putting different attributes on some of the methods (some of the attribute parameters are not known until run-time). How can it be achieved?
Your question isn't very specific. If you update it with more information, I'll flesh out this answer with additional detail. Here's an overview of the manual steps involved. Create an assembly with DefineDynamicAssembly Create a module with DefineDynamicModule Create the type with DefineType. Be sure to pass TypeAttri...
Using .NET's Reflection.Emit to generate an interface I need to generate a new interface at run-time with all the same members as an existing interface, except that I will be putting different attributes on some of the methods (some of the attribute parameters are not known until run-time). How can it be achieved?
TITLE: Using .NET's Reflection.Emit to generate an interface QUESTION: I need to generate a new interface at run-time with all the same members as an existing interface, except that I will be putting different attributes on some of the methods (some of the attribute parameters are not known until run-time). How can it...
[ ".net", "reflection.emit" ]
7
8
2,427
2
0
2008-09-25T22:14:17.483000
2008-09-25T22:29:20.957000
136,539
136,576
Determining if a folder is shared in .NET
Is there a way through the.net framework to determine if a folder is shared or not? Neither Diretory, DirectoryInfo or FileAttributes seem to have any corresponding field. One thing I forgot to mention was that I want to be checking for network shares. But I'll investigate the WMI stuff.
You can use WMI Win32_Share. Take a look at: http://www.gamedev.net/community/forums/topic.asp?topic_id=408923 Shows a sample for querying, creating and deleting shared folders.
Determining if a folder is shared in .NET Is there a way through the.net framework to determine if a folder is shared or not? Neither Diretory, DirectoryInfo or FileAttributes seem to have any corresponding field. One thing I forgot to mention was that I want to be checking for network shares. But I'll investigate the ...
TITLE: Determining if a folder is shared in .NET QUESTION: Is there a way through the.net framework to determine if a folder is shared or not? Neither Diretory, DirectoryInfo or FileAttributes seem to have any corresponding field. One thing I forgot to mention was that I want to be checking for network shares. But I'l...
[ "c#", ".net", "windows" ]
11
4
13,710
4
0
2008-09-25T22:15:24.610000
2008-09-25T22:23:19.443000
136,548
136,695
Pro/con: Initializing a variable in a conditional statement
In C++ you can initialize a variable in an if statement, like so: if (CThing* pThing = GetThing()) { } Why would one consider this bad or good style? What are the benefits and disadvantages? Personally i like this style because it limits the scope of the pThing variable, so it can never be used accidentally when it is ...
The important thing is that a declaration in C++ is not an expression. bool a = (CThing* pThing = GetThing()); // not legit!! You can't do both a declaration and boolean logic in an if statement, C++ language spec specifically allows either an expression or a declaration. if(A *a = new A) { // this is legit and a is sc...
Pro/con: Initializing a variable in a conditional statement In C++ you can initialize a variable in an if statement, like so: if (CThing* pThing = GetThing()) { } Why would one consider this bad or good style? What are the benefits and disadvantages? Personally i like this style because it limits the scope of the pThin...
TITLE: Pro/con: Initializing a variable in a conditional statement QUESTION: In C++ you can initialize a variable in an if statement, like so: if (CThing* pThing = GetThing()) { } Why would one consider this bad or good style? What are the benefits and disadvantages? Personally i like this style because it limits the ...
[ "c++", "coding-style", "if-statement" ]
20
22
24,016
12
0
2008-09-25T22:18:08.223000
2008-09-25T22:52:00.887000
136,554
136,788
Timeout doesn't work with '-re' flag in expect script
I'm trying to get an expect script to work, and when I use the -re flag (to invoke regular expression parsing), the 'timeout' keyword seems to no longer work. When the following script is run, I get the message 'timed out at step 1', then 'starting step 2' and then it times out but does NOT print the 'timed out at step...
Figured it out: expect { timeout { puts "timed out at step 2"; exit } -re "foo " { puts "it said foo at step 2"} }
Timeout doesn't work with '-re' flag in expect script I'm trying to get an expect script to work, and when I use the -re flag (to invoke regular expression parsing), the 'timeout' keyword seems to no longer work. When the following script is run, I get the message 'timed out at step 1', then 'starting step 2' and then ...
TITLE: Timeout doesn't work with '-re' flag in expect script QUESTION: I'm trying to get an expect script to work, and when I use the -re flag (to invoke regular expression parsing), the 'timeout' keyword seems to no longer work. When the following script is run, I get the message 'timed out at step 1', then 'starting...
[ "tcl", "expect" ]
0
2
5,557
2
0
2008-09-25T22:19:24.303000
2008-09-25T23:12:45.157000
136,580
138,693
How to have a Label inherite a Composite's GC in SWT
I'm writing an app and our designers want to use gradients for some of the backgrounds on a few of our composites. I wrote the following code: composite.addListener (SWT.Paint, new Listener () { public void handleEvent (Event e) { GC gc = e.gc; Rectangle rect = composite.getClientArea (); Color color1 = new Color (disp...
Use composite.setBackgroundMode(SWT.INHERIT_DEFAULT), but do not paint the composite directly - paint an image and set it as the background image using composite.setBackgroundImage(Image). Unless I'm missing a trick, this means you only have to regenerate the image when the composite is resized too. You should be able ...
How to have a Label inherite a Composite's GC in SWT I'm writing an app and our designers want to use gradients for some of the backgrounds on a few of our composites. I wrote the following code: composite.addListener (SWT.Paint, new Listener () { public void handleEvent (Event e) { GC gc = e.gc; Rectangle rect = compo...
TITLE: How to have a Label inherite a Composite's GC in SWT QUESTION: I'm writing an app and our designers want to use gradients for some of the backgrounds on a few of our composites. I wrote the following code: composite.addListener (SWT.Paint, new Listener () { public void handleEvent (Event e) { GC gc = e.gc; Rect...
[ "java", "user-interface", "swt" ]
8
10
7,412
2
0
2008-09-25T22:24:43.323000
2008-09-26T10:51:27.320000
136,581
140,576
Disabling interstitial graphic when using cfdiv binding
Is there a way to keep the "Loading..." graphic from appearing when cfdiv refreshes? I'd like to prevent the flicker of loading the graphic then loading the new html.
By adding these lines at the bottom of the header, it overwrites the "Loading..." html and seems to prevent the flickering effect in both IE and FireFox: While this seems to do the trick, it would be nice if there was an officially supported way to customize the loading animation on a per page or per control basis. Hop...
Disabling interstitial graphic when using cfdiv binding Is there a way to keep the "Loading..." graphic from appearing when cfdiv refreshes? I'd like to prevent the flicker of loading the graphic then loading the new html.
TITLE: Disabling interstitial graphic when using cfdiv binding QUESTION: Is there a way to keep the "Loading..." graphic from appearing when cfdiv refreshes? I'd like to prevent the flicker of loading the graphic then loading the new html. ANSWER: By adding these lines at the bottom of the header, it overwrites the "...
[ "ajax", "coldfusion" ]
4
4
1,326
4
0
2008-09-25T22:24:45.693000
2008-09-26T16:34:01.650000
136,598
362,282
What is the difference between Application and Cache in ASP.NET?
What the difference between Application("some-object") and Cache("some-object") in ASP.NET?
According to MS, Application storage is only preserved for backward compatibility with classic ASP applications so use the Cache because it's smarter and thread-safe.
What is the difference between Application and Cache in ASP.NET? What the difference between Application("some-object") and Cache("some-object") in ASP.NET?
TITLE: What is the difference between Application and Cache in ASP.NET? QUESTION: What the difference between Application("some-object") and Cache("some-object") in ASP.NET? ANSWER: According to MS, Application storage is only preserved for backward compatibility with classic ASP applications so use the Cache because...
[ "asp.net", "caching" ]
5
4
9,678
4
0
2008-09-25T22:29:01.253000
2008-12-12T09:14:12.283000
136,604
137,162
Duplicate Data over One-to-Many self relation (Tsql)
Sorry if the title is poorly descriptive, but I can't do better right now =( So, I have this master-detail scheme, with the detail being a tree structure (one to many self relation) with n levels (on SQLServer 2005) I need to copy a detail structure from one master to the another using a stored procedure, by passing th...
If I understand the problem, this might be what you want: INSERT dbo.Master VALUES (@NewMaster_ID, @NewDescription) INSERT dbo.Detail (parent_id, master_id, [name]) SELECT detail_ID, @NewMaster_ID, [name] FROM dbo.Detail WHERE master_id = @OldMaster_ID UPDATE NewChild SET parent_id = NewParent.detail_id FROM dbo.Deta...
Duplicate Data over One-to-Many self relation (Tsql) Sorry if the title is poorly descriptive, but I can't do better right now =( So, I have this master-detail scheme, with the detail being a tree structure (one to many self relation) with n levels (on SQLServer 2005) I need to copy a detail structure from one master t...
TITLE: Duplicate Data over One-to-Many self relation (Tsql) QUESTION: Sorry if the title is poorly descriptive, but I can't do better right now =( So, I have this master-detail scheme, with the detail being a tree structure (one to many self relation) with n levels (on SQLServer 2005) I need to copy a detail structure...
[ "sql-server", "t-sql" ]
1
1
1,224
2
0
2008-09-25T22:30:36.507000
2008-09-26T00:46:22.967000
136,615
136,625
How can I test a TCP connection to a server with C# given the server's IP address and port?
How can I programmatically determine if I have access to a server (TCP) with a given IP address and port using C#?
Assuming you mean through a TCP socket: IPAddress IP; if(IPAddress.TryParse("127.0.0.1",out IP)){ Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try{ s.Connect(IPs[0], port); } catch(Exception ex){ // something went wrong } } For more information: http://msdn.microsoft.com/en-u...
How can I test a TCP connection to a server with C# given the server's IP address and port? How can I programmatically determine if I have access to a server (TCP) with a given IP address and port using C#?
TITLE: How can I test a TCP connection to a server with C# given the server's IP address and port? QUESTION: How can I programmatically determine if I have access to a server (TCP) with a given IP address and port using C#? ANSWER: Assuming you mean through a TCP socket: IPAddress IP; if(IPAddress.TryParse("127.0.0.1...
[ "c#", "networking" ]
17
17
54,850
3
0
2008-09-25T22:32:46.267000
2008-09-25T22:34:37.263000
136,635
136,931
What does AllowLocation="true" do in System.Web section of Web.Config?
We have a.NET 2.0 application which we normally run on IIS6, and used to run fine on IIS7, but recently after installing SP1 for Vista IIS7 seems to be choking on a line in the Web.Config file: Is it safe to remove the AllowLocation attribute? What does this attribute do?
From MSDN: When set to false, the AllowLocation property indicates that the section is accessed by native-code readers. Therefore, the use of the location attribute is not allowed, because the native-code readers do not support the concept of location. The default value is true, so you should be able to remove it with ...
What does AllowLocation="true" do in System.Web section of Web.Config? We have a.NET 2.0 application which we normally run on IIS6, and used to run fine on IIS7, but recently after installing SP1 for Vista IIS7 seems to be choking on a line in the Web.Config file: Is it safe to remove the AllowLocation attribute? What ...
TITLE: What does AllowLocation="true" do in System.Web section of Web.Config? QUESTION: We have a.NET 2.0 application which we normally run on IIS6, and used to run fine on IIS7, but recently after installing SP1 for Vista IIS7 seems to be choking on a line in the Web.Config file: Is it safe to remove the AllowLocatio...
[ "asp.net", "windows", "iis", "configuration", ".net-2.0" ]
2
1
1,636
2
0
2008-09-25T22:36:53.043000
2008-09-25T23:42:56.210000
136,638
812,150
How can I compare multiple .resx files?
How can I compare the content of two (or more) large.resx files? With hundreds of Name/Value pairs in each file, it'd be very helpful to view a combined version. I'm especially interested in Name/Value pairs which are present in the neutral culture but are not also specified in a culture-specific version.
There is a great freeware tool to edit resx files where you can see multiple languages at once and clearly see what is missing or extra - Zeta Resource Editor
How can I compare multiple .resx files? How can I compare the content of two (or more) large.resx files? With hundreds of Name/Value pairs in each file, it'd be very helpful to view a combined version. I'm especially interested in Name/Value pairs which are present in the neutral culture but are not also specified in a...
TITLE: How can I compare multiple .resx files? QUESTION: How can I compare the content of two (or more) large.resx files? With hundreds of Name/Value pairs in each file, it'd be very helpful to view a combined version. I'm especially interested in Name/Value pairs which are present in the neutral culture but are not a...
[ ".net", "resources", "resx" ]
23
34
12,342
7
0
2008-09-25T22:37:48.690000
2009-05-01T16:39:35.543000
136,642
136,654
PHP regex to remove multiple ?-marks
I'm having trouble coming up with the correct regex string to remove a sequence of multiple? characters. I want to replace more than one sequential? with a single?, but which characters to escape...is escaping me. Example input: Is this thing on??? or what??? Desired output: Is this thing on? or what? I'm using preg_re...
preg_replace('{\?+}', '?', 'Is this thing on??? or what???'); That is, you only have to escape the question mark, the plus in "\?+" means that we're replacing every instance with one or more characters, though I suspect "\?{2,}" might be even better and more efficient (replacing every instance with two or more question...
PHP regex to remove multiple ?-marks I'm having trouble coming up with the correct regex string to remove a sequence of multiple? characters. I want to replace more than one sequential? with a single?, but which characters to escape...is escaping me. Example input: Is this thing on??? or what??? Desired output: Is this...
TITLE: PHP regex to remove multiple ?-marks QUESTION: I'm having trouble coming up with the correct regex string to remove a sequence of multiple? characters. I want to replace more than one sequential? with a single?, but which characters to escape...is escaping me. Example input: Is this thing on??? or what??? Desir...
[ "php", "regex", "escaping" ]
5
10
4,608
7
0
2008-09-25T22:38:42.947000
2008-09-25T22:41:36.247000
136,672
137,836
Programmatically logging to the Sharepoint ULS
I'd like to log stuff in my Sharepoint Web Parts, but I want it to go into the ULS. Most examples that I've found log into the Event Log or some other file, but I did not really find one yet for logging into the ULS. Annoyingly, Microsoft.SharePoint.Diagnostics Classes are all marked Internal. I did find one example of...
Yes this is possible, see this MSDN article: http://msdn2.microsoft.com/hi-in/library/aa979595(en-us).aspx And here is some sample code in C#: using System; using System.Runtime.InteropServices; using Microsoft.SharePoint.Administration; namespace ManagedTraceProvider { class Program { static void Main(string[] args) ...
Programmatically logging to the Sharepoint ULS I'd like to log stuff in my Sharepoint Web Parts, but I want it to go into the ULS. Most examples that I've found log into the Event Log or some other file, but I did not really find one yet for logging into the ULS. Annoyingly, Microsoft.SharePoint.Diagnostics Classes are...
TITLE: Programmatically logging to the Sharepoint ULS QUESTION: I'd like to log stuff in my Sharepoint Web Parts, but I want it to go into the ULS. Most examples that I've found log into the Event Log or some other file, but I did not really find one yet for logging into the ULS. Annoyingly, Microsoft.SharePoint.Diagn...
[ ".net", "sharepoint", "sharepoint-2007" ]
6
8
13,380
5
0
2008-09-25T22:45:00.793000
2008-09-26T04:52:10.910000
136,674
136,688
Reasons to NOT run a business-critical C# console application via the debugger?
I'm looking for a few talking points I could use to convince coworkers that it's NOT OK to run a 24/7 production application by simply opening Visual Studio and running the app in debug mode. What's different about running a compiled console application vs. running that same app in debug mode? Are there ever times when...
You will suffer from reduced performance when running under the debugger (not to mention the complexity concerns mentioned by Bruce ), and there is nothing to keep you from getting the same functionality as running under the debugger when compiled in release mode -- you can always set your program up to log unhandled e...
Reasons to NOT run a business-critical C# console application via the debugger? I'm looking for a few talking points I could use to convince coworkers that it's NOT OK to run a 24/7 production application by simply opening Visual Studio and running the app in debug mode. What's different about running a compiled consol...
TITLE: Reasons to NOT run a business-critical C# console application via the debugger? QUESTION: I'm looking for a few talking points I could use to convince coworkers that it's NOT OK to run a 24/7 production application by simply opening Visual Studio and running the app in debug mode. What's different about running...
[ "c#", "debugging" ]
5
10
1,296
10
0
2008-09-25T22:45:16.753000
2008-09-25T22:48:40.380000
136,696
140,587
Can I use a Hashtable in a unified EL expression on a c:forEach tag using JSF 1.2 with JSP 2.1?
I have a Hashtable called sportMap and a list of sportIds (List sportIds) from my backing bean. The Sport object has a List equipmentList. Can I do the following using the unified EL to get the list of equipment for each sport? I get the following exception when trying to run this JSP code. 15:57:59,438 ERROR [Exceptio...
@ keith30xi.myopenid.com Not TRUE in JSF 1.2. According to the java.net wiki faq they should work together as expected. Here's an extract from each faq: JSF 1.1 FAQ Q. Do JavaServer Faces tags interoperate with JSTL core tags, forEach, if, choose and when? A. The forEach tag does not work with JavaServer Faces technolo...
Can I use a Hashtable in a unified EL expression on a c:forEach tag using JSF 1.2 with JSP 2.1? I have a Hashtable called sportMap and a list of sportIds (List sportIds) from my backing bean. The Sport object has a List equipmentList. Can I do the following using the unified EL to get the list of equipment for each spo...
TITLE: Can I use a Hashtable in a unified EL expression on a c:forEach tag using JSF 1.2 with JSP 2.1? QUESTION: I have a Hashtable called sportMap and a list of sportIds (List sportIds) from my backing bean. The Sport object has a List equipmentList. Can I do the following using the unified EL to get the list of equi...
[ "java", "jsp", "jsf", "jstl" ]
2
2
5,004
3
0
2008-09-25T22:52:03.883000
2008-09-26T16:37:01.923000
136,703
137,117
Is there a one-liner to read in a file to a string in C++?
I need a quick easy way to get a string from a file in standard C++. I can write my own, but just want to know if there is already a standard way, in C++. Equivalent of this if you know Cocoa: NSString *string = [NSString stringWithContentsOfFile:file];
We can do it but it's a long line: #include #include #include #include using namespace std; int main() { // The one-liner string fileContents(istreambuf_iterator (ifstream("filename.txt")), istreambuf_iterator ()); // Check result cout << fileContents; } Edited: use "istreambuf_iterator" instead of "istream_iterator"
Is there a one-liner to read in a file to a string in C++? I need a quick easy way to get a string from a file in standard C++. I can write my own, but just want to know if there is already a standard way, in C++. Equivalent of this if you know Cocoa: NSString *string = [NSString stringWithContentsOfFile:file];
TITLE: Is there a one-liner to read in a file to a string in C++? QUESTION: I need a quick easy way to get a string from a file in standard C++. I can write my own, but just want to know if there is already a standard way, in C++. Equivalent of this if you know Cocoa: NSString *string = [NSString stringWithContentsOfF...
[ "c++", "file", "filesystems" ]
8
17
2,396
7
0
2008-09-25T22:52:42.930000
2008-09-26T00:31:17.543000
136,726
220,253
Means of SAP R/3 standard code modification?
I'm trying to determine how to modify SAP R/3 package code of an installed system. Can anyone suggest the module/tool for that?
SAP has provided various customer plug-ins in order to enable customers to modify and adapt standard code: User exits (Transactions SMOD, CMOD and SE81). This article covers user exists in greater detail. BADI's (Business Add-inns, Transaction SE18). This is an Object Oriented(ish) way of extending standard functionali...
Means of SAP R/3 standard code modification? I'm trying to determine how to modify SAP R/3 package code of an installed system. Can anyone suggest the module/tool for that?
TITLE: Means of SAP R/3 standard code modification? QUESTION: I'm trying to determine how to modify SAP R/3 package code of an installed system. Can anyone suggest the module/tool for that? ANSWER: SAP has provided various customer plug-ins in order to enable customers to modify and adapt standard code: User exits (T...
[ "customization", "abap", "sap-r3" ]
4
6
2,313
2
0
2008-09-25T22:56:42.530000
2008-10-20T23:05:53.610000
136,727
136,816
Why doesn't a <table>'s margin collapse with an adjacent <p>?
From my understanding of the CSS spec, a table above or below a paragraph should collapse vertical margins with it. However, that's not happening here: table { margin: 100px; border: solid red 2px; } p { margin: 100px } This is a one-celled table with 100px margin all around. This is a paragraph with 100px margin...
Margin collapsing is only defined for block elements. Try it - add display: block to the table styles, and suddenly it works (and alters the display of the table...) Tables are special. In the CSS specs, they're not quite block elements - special rules apply to size and position, both of their children (obviously), and...
Why doesn't a <table>'s margin collapse with an adjacent <p>? From my understanding of the CSS spec, a table above or below a paragraph should collapse vertical margins with it. However, that's not happening here: table { margin: 100px; border: solid red 2px; } p { margin: 100px } This is a one-celled table with ...
TITLE: Why doesn't a <table>'s margin collapse with an adjacent <p>? QUESTION: From my understanding of the CSS spec, a table above or below a paragraph should collapse vertical margins with it. However, that's not happening here: table { margin: 100px; border: solid red 2px; } p { margin: 100px } This is a one-...
[ "html", "css" ]
12
9
3,740
4
0
2008-09-25T22:56:50.813000
2008-09-25T23:19:08.170000
136,734
136,780
Key Presses in Python
Is it possible to make it appear to a system that a key was pressed, for example I need to make A key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python. A better way to put it, I need to emu...
Install the pywin32 extensions. Then you can do the following: import win32com.client as comclt wsh= comclt.Dispatch("WScript.Shell") wsh.AppActivate("Notepad") # select another application wsh.SendKeys("a") # send the keys you want Search for documentation of the WScript.Shell object (I believe installed by default in...
Key Presses in Python Is it possible to make it appear to a system that a key was pressed, for example I need to make A key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python. A better way to...
TITLE: Key Presses in Python QUESTION: Is it possible to make it appear to a system that a key was pressed, for example I need to make A key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Pytho...
[ "python", "keypress" ]
41
49
265,386
11
0
2008-09-25T22:58:01.090000
2008-09-25T23:09:39.550000
136,739
136,749
Python language API
I'm starting with Python coming from java. I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it. I've found very helpul to use help( thing ) from the Python ( command line ) I have found this also: http://docs.python.org/2/ https://doc...
pydoc? I'm not sure if you're looking for something more sophisticated, but it does the trick.
Python language API I'm starting with Python coming from java. I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it. I've found very helpul to use help( thing ) from the Python ( command line ) I have found this also: http://docs.pytho...
TITLE: Python language API QUESTION: I'm starting with Python coming from java. I was wondering if there exists something similar to JavaDoc API where I can find the class, its methods and and example of how to use it. I've found very helpul to use help( thing ) from the Python ( command line ) I have found this also:...
[ "python", "reference", "documentation", "python-2.x" ]
6
5
533
9
0
2008-09-25T22:59:10.853000
2008-09-25T23:00:48.243000
136,770
136,854
How to check for null values before doing .AddDays() in SSRS?
I have the following as the value for my textbox in SSRS report: =iif(IsNothing(Fields!MyDate.Value), "", Format(Fields!MyDate.Value.AddDays(30), "MMMM dd, yyyy")) It gives me an "#Error" every time MyDate is null. How do i work around this? UPDATE: i wrote this custom function, it got rid of the error, but returns Jan...
The problem, of course, is that VB's IIF statement evaluates both sides regardless of the outcome. So even if your field is null it's still evaluating the "Value.DateAdd" call. If I recall correctly, SSRS has its own "DateAdd" function that you can use instead. So you can do something like this (check the documentation...
How to check for null values before doing .AddDays() in SSRS? I have the following as the value for my textbox in SSRS report: =iif(IsNothing(Fields!MyDate.Value), "", Format(Fields!MyDate.Value.AddDays(30), "MMMM dd, yyyy")) It gives me an "#Error" every time MyDate is null. How do i work around this? UPDATE: i wrote ...
TITLE: How to check for null values before doing .AddDays() in SSRS? QUESTION: I have the following as the value for my textbox in SSRS report: =iif(IsNothing(Fields!MyDate.Value), "", Format(Fields!MyDate.Value.AddDays(30), "MMMM dd, yyyy")) It gives me an "#Error" every time MyDate is null. How do i work around this...
[ "vb.net", "reporting-services", "ssrs-2008-r2" ]
5
6
15,107
1
0
2008-09-25T23:07:09.587000
2008-09-25T23:25:42.630000
136,771
137,159
SQL Server Agent Job - Exists then Drop?
How can I drop sql server agent jobs, if (and only if) it exists? This is a well functioning script for stored procedures. How can I do the same to sql server agent jobs? if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[storedproc]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo]....
Try something like this: DECLARE @jobId binary(16) SELECT @jobId = job_id FROM msdb.dbo.sysjobs WHERE (name = N'Name of Your Job') IF (@jobId IS NOT NULL) BEGIN EXEC msdb.dbo.sp_delete_job @jobId END DECLARE @ReturnCode int EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'Name of Your Job' Best to read the docs on ...
SQL Server Agent Job - Exists then Drop? How can I drop sql server agent jobs, if (and only if) it exists? This is a well functioning script for stored procedures. How can I do the same to sql server agent jobs? if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[storedproc]') and OBJECTPROPERTY(id, N...
TITLE: SQL Server Agent Job - Exists then Drop? QUESTION: How can I drop sql server agent jobs, if (and only if) it exists? This is a well functioning script for stored procedures. How can I do the same to sql server agent jobs? if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[storedproc]') and OB...
[ "sql", "sql-server", "sql-server-agent", "sql-job" ]
68
110
88,587
3
0
2008-09-25T23:07:31.490000
2008-09-26T00:46:00.287000
136,782
5,367,048
Convert from MySQL datetime to another format with PHP
I have a datetime column in MySQL. How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?
If you're looking for a way to normalize a date into MySQL format, use the following $phpdate = strtotime( $mysqldate ); $mysqldate = date( 'Y-m-d H:i:s', $phpdate ); The line $phpdate = strtotime( $mysqldate ) accepts a string and performs a series of heuristics to turn that string into a unix timestamp. The line $mys...
Convert from MySQL datetime to another format with PHP I have a datetime column in MySQL. How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?
TITLE: Convert from MySQL datetime to another format with PHP QUESTION: I have a datetime column in MySQL. How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP? ANSWER: If you're looking for a way to normalize a date into MySQL format, use the following $phpdate = strtotime( $mysqldate ); $mysqldate ...
[ "php", "mysql", "datetime" ]
481
569
812,402
18
0
2008-09-25T23:10:30.203000
2011-03-20T06:06:08.663000
136,789
137,320
How do you make Python / PostgreSQL faster?
Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: http://gist.github.com/12978. I've used psyco (as seen in the code) and I'm also compiling it and using the compiled version. It's doing about 100 lines every 0.3 second...
Don't waste time profiling. The time is always in the database operations. Do as few as possible. Just the minimum number of inserts. Three Things. One. Don't SELECT over and over again to conform the Date, Hostname and Person dimensions. Fetch all the data ONCE into a Python dictionary and use it in memory. Don't do r...
How do you make Python / PostgreSQL faster? Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: http://gist.github.com/12978. I've used psyco (as seen in the code) and I'm also compiling it and using the compiled version....
TITLE: How do you make Python / PostgreSQL faster? QUESTION: Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: http://gist.github.com/12978. I've used psyco (as seen in the code) and I'm also compiling it and using the...
[ "python", "postgresql" ]
7
10
8,676
5
0
2008-09-25T23:12:50.087000
2008-09-26T01:50:23.767000
136,807
139,112
What can cause mutated Flash display like this?
I'm having a weird cross-browser flash problem. Please see the screenshot below. I have seen this behaviour before, but I cannot recall what the cause was. Can someone please tell me why this happens, and possible actions I can take to fix it?
Definately need more info to give a full answer. It looks like the IE flash player version is not high enough to properly play the flash file. It looks like it is loading the first frame (which has all of the assets laid out on it to aid with pre-loading). Then, the Actionscript that is supposed to play the movie fails...
What can cause mutated Flash display like this? I'm having a weird cross-browser flash problem. Please see the screenshot below. I have seen this behaviour before, but I cannot recall what the cause was. Can someone please tell me why this happens, and possible actions I can take to fix it?
TITLE: What can cause mutated Flash display like this? QUESTION: I'm having a weird cross-browser flash problem. Please see the screenshot below. I have seen this behaviour before, but I cannot recall what the cause was. Can someone please tell me why this happens, and possible actions I can take to fix it? ANSWER: D...
[ "flash", "internet-explorer", "firefox", "video", "cross-browser" ]
0
6
266
3
0
2008-09-25T23:17:32.447000
2008-09-26T12:29:22.190000
136,818
136,861
Reference .NET Assembly from a SQL Server Stored procedure or function
Is it possible to reference a.NET Assembly from a SQL Server Stored procedure or function, or otherwise access the clr code from SQL Server? EDIT Whilst this solution will require to be somewhat generic, I am fairly confident expecting SQL 2005+
It depends on your version of SQL Server. SQL Server 2005 and higher supports CLR Stored Procedures. If you have an older version, you need to register the Assembly as a COM class (using attributes on the objects/methods/assembly), and then registering it using regasm. Then you can call it like any other COM Object. ht...
Reference .NET Assembly from a SQL Server Stored procedure or function Is it possible to reference a.NET Assembly from a SQL Server Stored procedure or function, or otherwise access the clr code from SQL Server? EDIT Whilst this solution will require to be somewhat generic, I am fairly confident expecting SQL 2005+
TITLE: Reference .NET Assembly from a SQL Server Stored procedure or function QUESTION: Is it possible to reference a.NET Assembly from a SQL Server Stored procedure or function, or otherwise access the clr code from SQL Server? EDIT Whilst this solution will require to be somewhat generic, I am fairly confident expec...
[ ".net", "sql-server", "stored-procedures", "clr" ]
4
4
3,775
3
0
2008-09-25T23:19:30.447000
2008-09-25T23:26:44.937000
136,829
141,954
How do you check if a variable is used in a project programmatically?
In VB.NET (or C#) how can I determine programmatically if a public variable in class helper.vb is used anywhere within a project?
From MSDN The Find object allows you to search for and replace text in places of the environment that support such operations, such as the Code editor. It is intended primarily for macro recording purposes. The editor's macro recording mechanism uses Find rather than TextSelection.FindPattern so that you can discover t...
How do you check if a variable is used in a project programmatically? In VB.NET (or C#) how can I determine programmatically if a public variable in class helper.vb is used anywhere within a project?
TITLE: How do you check if a variable is used in a project programmatically? QUESTION: In VB.NET (or C#) how can I determine programmatically if a public variable in class helper.vb is used anywhere within a project? ANSWER: From MSDN The Find object allows you to search for and replace text in places of the environm...
[ "c#", ".net", "vb.net", "add-in", "envdte" ]
7
2
2,412
5
0
2008-09-25T23:21:23.250000
2008-09-26T21:00:59.247000
136,831
136,867
What is a cross platform way to select a random seed in Java?
After reading this answer: best way to pick a random subset from a collection? It got me wondering, how does one pick a random seed in Java? And don't say use System.currentTimeMillis() or System.nanoTime(). Read the article to see why not. That's a hard question, but let me make it harder. Let's say you need to genera...
Take a look at Uncommons Maths (full disclosure: I wrote it). It should solve most of the problems you'll ever have with random numbers in Java. Even, if you don't use it you should be able to get some ideas from the various SeedGenerator implementations it provides. Basically, it defaults to using /dev/random. If that...
What is a cross platform way to select a random seed in Java? After reading this answer: best way to pick a random subset from a collection? It got me wondering, how does one pick a random seed in Java? And don't say use System.currentTimeMillis() or System.nanoTime(). Read the article to see why not. That's a hard que...
TITLE: What is a cross platform way to select a random seed in Java? QUESTION: After reading this answer: best way to pick a random subset from a collection? It got me wondering, how does one pick a random seed in Java? And don't say use System.currentTimeMillis() or System.nanoTime(). Read the article to see why not....
[ "java", "random", "cross-platform", "random-seed" ]
4
6
1,005
3
0
2008-09-25T23:21:48.570000
2008-09-25T23:28:03.313000
136,836
137,183
C# Array initialization - with non-default value
What is the slickest way to initialize an array of dynamic size in C# that you know of? This is the best I could come up with private bool[] GetPageNumbersToLink(IPagedResult result) { if (result.TotalPages <= 9) return new bool[result.TotalPages + 1].Select(b => true).ToArray();...
use Enumerable.Repeat Enumerable.Repeat(true, result.TotalPages + 1).ToArray()
C# Array initialization - with non-default value What is the slickest way to initialize an array of dynamic size in C# that you know of? This is the best I could come up with private bool[] GetPageNumbersToLink(IPagedResult result) { if (result.TotalPages <= 9) return new bool[result.TotalPages + 1].Select(b => true).T...
TITLE: C# Array initialization - with non-default value QUESTION: What is the slickest way to initialize an array of dynamic size in C# that you know of? This is the best I could come up with private bool[] GetPageNumbersToLink(IPagedResult result) { if (result.TotalPages <= 9) return new bool[result.TotalPages + 1].S...
[ "c#", ".net" ]
33
38
38,049
7
0
2008-09-25T23:22:34.090000
2008-09-26T00:56:09.200000