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
1,005
37,042
How do you get sudo access for a file inside the vi text editor?
Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type sudo vi filename Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up some stuff about vi a while ago, but now I can't find it.
% is replaced with the current file name, thus you can use::w!sudo tee % ( vim will detect that the file has been changed and ask whether you want to it to be reloaded. Say yes by choosing [L] rather than OK.) As a shortcut, you can define your own command. Put the following in your.vimrc: command W w!sudo tee % >/dev/...
How do you get sudo access for a file inside the vi text editor? Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type sudo vi filename Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up s...
TITLE: How do you get sudo access for a file inside the vi text editor? QUESTION: Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type sudo vi filename Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this ...
[ "linux", "unix", "vi" ]
254
310
82,876
10
0
2008-08-04T03:34:02.860000
2008-08-31T19:23:48.347000
1,010
1,074
How to get the value of built, encoded ViewState?
I need to grab the base64-encoded representation of the ViewState. Obviously, this would not be available until fairly late in the request lifecycle, which is OK. For example, if the output of the page includes: I need a way on the server-side to get the value "/wEPDwUJODU0Njc5MD...==" To clarify, I need this value whe...
Rex, I suspect a good place to start looking is solutions that compress the ViewState -- they're grabbing ViewState on the server before it's sent down to the client and gzipping it. That's exactly where you want to be. Scott Hanselman on ViewState Compression (2005) ViewState Compression with System.IO.Compression (20...
How to get the value of built, encoded ViewState? I need to grab the base64-encoded representation of the ViewState. Obviously, this would not be available until fairly late in the request lifecycle, which is OK. For example, if the output of the page includes: I need a way on the server-side to get the value "/wEPDwUJ...
TITLE: How to get the value of built, encoded ViewState? QUESTION: I need to grab the base64-encoded representation of the ViewState. Obviously, this would not be available until fairly late in the request lifecycle, which is OK. For example, if the output of the page includes: I need a way on the server-side to get t...
[ "c#", "asp.net", "viewstate" ]
31
13
2,611
3
0
2008-08-04T03:59:42.557000
2008-08-04T08:04:41.737000
1,024
171,170
How do I fix 'Unprocessed view path found' error with ExceptionNotifier plugin in rails 2.1?
After upgrading a rails 1.2 website to 2.1, the ExceptionNotifier plugin no longer works, complaining about this error: ActionView::TemplateFinder::InvalidViewPath: Unprocessed view path found: "/path/to/appname/vendor/plugins/exception_notification/lib/../views". Set your view paths with #append_view_path, #prepend_vi...
You ought to upgrade to the newest Exception Notification plugin which is in its new home at GitHub.
How do I fix 'Unprocessed view path found' error with ExceptionNotifier plugin in rails 2.1? After upgrading a rails 1.2 website to 2.1, the ExceptionNotifier plugin no longer works, complaining about this error: ActionView::TemplateFinder::InvalidViewPath: Unprocessed view path found: "/path/to/appname/vendor/plugins/...
TITLE: How do I fix 'Unprocessed view path found' error with ExceptionNotifier plugin in rails 2.1? QUESTION: After upgrading a rails 1.2 website to 2.1, the ExceptionNotifier plugin no longer works, complaining about this error: ActionView::TemplateFinder::InvalidViewPath: Unprocessed view path found: "/path/to/appna...
[ "ruby-on-rails", "ruby", "exception", "plugins" ]
24
0
1,290
2
0
2008-08-04T04:48:38.013000
2008-10-04T23:18:41.483000
1,033
1,056
How to get the Country according to a certain IP?
Does anyone know any simple way to retrieve the country from a given IP Address, preferably in ISO_3166-1 format?
A lot of people (including my company) seem to use MaxMind GeoIP. They have a free version GeoLite which is not as accurate as the paid version, but if you're just after something simple, it may be good enough.
How to get the Country according to a certain IP? Does anyone know any simple way to retrieve the country from a given IP Address, preferably in ISO_3166-1 format?
TITLE: How to get the Country according to a certain IP? QUESTION: Does anyone know any simple way to retrieve the country from a given IP Address, preferably in ISO_3166-1 format? ANSWER: A lot of people (including my company) seem to use MaxMind GeoIP. They have a free version GeoLite which is not as accurate as th...
[ "ip", "lookup", "country" ]
61
38
19,980
15
0
2008-08-04T05:15:35.773000
2008-08-04T06:26:22.370000
1,037
1,039
Displaying Flash content in a C# WinForms application
What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox ) that will be able to display images and flash content. It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.
While I haven't used a flash object inside a windows form application myself, I do know that it's possible. In Visual studio on your toolbox, choose to add a new component. Then in the new window that appears choose the "COM Components" tab to get a list in which you can find the "Shockwave Flash Object" Once added to ...
Displaying Flash content in a C# WinForms application What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox ) that will be able to display images and flash content. It would be great to be able to load the flash content from ...
TITLE: Displaying Flash content in a C# WinForms application QUESTION: What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox ) that will be able to display images and flash content. It would be great to be able to load the f...
[ "c#", "winforms", "flash", "adobe", "macromedia" ]
40
34
37,469
2
0
2008-08-04T05:35:52.240000
2008-08-04T05:44:45.887000
1,040
1,044
How do I delete a file which is locked by another process in C#?
I'm looking for a way to delete a file which is locked by another process using C#. I suspect the method must be able to find which process is locking the file (perhaps by tracking the handles, although I'm not sure how to do this in C#) then close that process before being able to complete the file delete using File.D...
Killing other processes is not a healthy thing to do. If your scenario involves something like uninstallation, you could use the MoveFileEx API function to mark the file for deletion upon next reboot. If it appears that you really need to delete a file in use by another process, I'd recommend re-considering the actual ...
How do I delete a file which is locked by another process in C#? I'm looking for a way to delete a file which is locked by another process using C#. I suspect the method must be able to find which process is locking the file (perhaps by tracking the handles, although I'm not sure how to do this in C#) then close that p...
TITLE: How do I delete a file which is locked by another process in C#? QUESTION: I'm looking for a way to delete a file which is locked by another process using C#. I suspect the method must be able to find which process is locking the file (perhaps by tracking the handles, although I'm not sure how to do this in C#)...
[ "c#", "file-locking" ]
58
37
56,005
9
0
2008-08-04T05:45:22.080000
2008-08-04T06:01:52.873000
1,042
1,061
Why doesn't SQL Full Text Indexing return results for words containing #?
For instance, my query is like the following using SQL Server 2005: SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#') I have a full text index defined to use the column SearchField which returns results when using: SELECT * FROM Table WHERE SearchField LIKE '%c#%' I believe # is a special letter, so how do I allow ...
The # char is indexed as punctuation and therefore ignored, so it looks like we'll remove the letter C from our word indexing ignore lists. Tested it locally after doing that and rebuilding the indexes and I get results! Looking at using a different word breaker language on the indexed column, so that those special cha...
Why doesn't SQL Full Text Indexing return results for words containing #? For instance, my query is like the following using SQL Server 2005: SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#') I have a full text index defined to use the column SearchField which returns results when using: SELECT * FROM Table WHERE S...
TITLE: Why doesn't SQL Full Text Indexing return results for words containing #? QUESTION: For instance, my query is like the following using SQL Server 2005: SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#') I have a full text index defined to use the column SearchField which returns results when using: SELECT * ...
[ "sql", "sql-server", "sql-server-2005", "indexing", "full-text-search" ]
26
14
9,411
2
0
2008-08-04T05:51:56.683000
2008-08-04T06:39:40.003000
1,053
394,225
A little diversion into floating point (im)precision, part 1
Most mathematicians agree that: e πi + 1 = 0 However, most floating point implementations disagree. How well can we settle this dispute? I'm keen to hear about different languages and implementations, and various methods to make the result as close to zero as possible. Be creative!
It's not that most floating point implementations disagree, it's just that they cannot get the accuracy necessary to get a 100% answer. And the correct answer is that they can't. PI is an infinite series of digits that nobody has been able to denote by anything other than a symbolic representation, and e^X is the same,...
A little diversion into floating point (im)precision, part 1 Most mathematicians agree that: e πi + 1 = 0 However, most floating point implementations disagree. How well can we settle this dispute? I'm keen to hear about different languages and implementations, and various methods to make the result as close to zero as...
TITLE: A little diversion into floating point (im)precision, part 1 QUESTION: Most mathematicians agree that: e πi + 1 = 0 However, most floating point implementations disagree. How well can we settle this dispute? I'm keen to hear about different languages and implementations, and various methods to make the result a...
[ "math", "language-agnostic", "floating-point" ]
23
18
2,220
10
0
2008-08-04T06:21:38.293000
2008-12-26T20:22:01.910000
1,064
1,096
Displaying 100 Floating Cubes Using DirectX OR OpenGL
I'd like to display 100 floating cubes using DirectX or OpenGL. I'm looking for either some sample source code, or a description of the technique. I have trouble getting more one cube to display correctly. I've combed the net for a good series of tutorials and although they talk about how to do 3D primitives, what I ca...
You say you have enough trouble getting one cube to display... so I am not sure if you have got one to display or not. Basically... put your code for writing a cube in one function, then just call that function 100 times. void DrawCube() { //code to draw the cube } void DisplayCubes() { for(int i = 0; i < 10; ++i) { f...
Displaying 100 Floating Cubes Using DirectX OR OpenGL I'd like to display 100 floating cubes using DirectX or OpenGL. I'm looking for either some sample source code, or a description of the technique. I have trouble getting more one cube to display correctly. I've combed the net for a good series of tutorials and altho...
TITLE: Displaying 100 Floating Cubes Using DirectX OR OpenGL QUESTION: I'd like to display 100 floating cubes using DirectX or OpenGL. I'm looking for either some sample source code, or a description of the technique. I have trouble getting more one cube to display correctly. I've combed the net for a good series of t...
[ "language-agnostic", "opengl", "3d", "directx" ]
19
8
1,964
3
0
2008-08-04T06:51:20.323000
2008-08-04T09:12:37.543000
1,069
1,073
Heap corruption under Win32; how to locate?
I'm working on a multithreaded C++ application that is corrupting the heap. The usual tools to locate this corruption seem to be inapplicable. Old builds (18 months old) of the source code exhibit the same behavior as the most recent release, so this has been around for a long time and just wasn't noticed; on the downs...
My first choice would be a dedicated heap tool such as pageheap.exe. Rewriting new and delete might be useful, but that doesn't catch the allocs committed by lower-level code. If this is what you want, better to Detour the low-level alloc API s using Microsoft Detours. Also sanity checks such as: verify your run-time l...
Heap corruption under Win32; how to locate? I'm working on a multithreaded C++ application that is corrupting the heap. The usual tools to locate this corruption seem to be inapplicable. Old builds (18 months old) of the source code exhibit the same behavior as the most recent release, so this has been around for a lon...
TITLE: Heap corruption under Win32; how to locate? QUESTION: I'm working on a multithreaded C++ application that is corrupting the heap. The usual tools to locate this corruption seem to be inapplicable. Old builds (18 months old) of the source code exhibit the same behavior as the most recent release, so this has bee...
[ "c++", "windows", "multithreading", "debugging", "memory" ]
65
29
39,110
15
0
2008-08-04T07:30:01.727000
2008-08-04T07:51:02.997000
1,070
1,773
Process size on UNIX
What is the correct way to get the process size on Solaris, HP-UX and AIX? Should we use top or ps -o vsz or something else?
The exact definitions of vsize, rss, rprvt, rshrd, and other obscure-looking abbreviations vary from OS to OS. The manual pages for the top and ps commands will have some sort of description, but all such descriptions are simplified greatly (or are based on long-extinct kernel implementations). "Process size" as a conc...
Process size on UNIX What is the correct way to get the process size on Solaris, HP-UX and AIX? Should we use top or ps -o vsz or something else?
TITLE: Process size on UNIX QUESTION: What is the correct way to get the process size on Solaris, HP-UX and AIX? Should we use top or ps -o vsz or something else? ANSWER: The exact definitions of vsize, rss, rprvt, rshrd, and other obscure-looking abbreviations vary from OS to OS. The manual pages for the top and ps ...
[ "unix", "size" ]
28
16
21,919
4
0
2008-08-04T07:34:44.137000
2008-08-05T01:07:50.657000
1,083
42,406
Object Oriented Bayesian Spam Filtering?
I was wondering if there is any good and clean object-oriented programming (OOP) implementation of Bayesian filtering for spam and text classification? This is just for learning purposes.
I definitely recommend Weka which is an Open Source Data Mining Software written in Java: Weka is a collection of machine learning algorithms for data mining tasks. The algorithms can either be applied directly to a dataset or called from your own Java code. Weka contains tools for data pre-processing, classification, ...
Object Oriented Bayesian Spam Filtering? I was wondering if there is any good and clean object-oriented programming (OOP) implementation of Bayesian filtering for spam and text classification? This is just for learning purposes.
TITLE: Object Oriented Bayesian Spam Filtering? QUESTION: I was wondering if there is any good and clean object-oriented programming (OOP) implementation of Bayesian filtering for spam and text classification? This is just for learning purposes. ANSWER: I definitely recommend Weka which is an Open Source Data Mining ...
[ "oop", "artificial-intelligence", "naivebayes", "email-spam" ]
29
12
4,036
6
0
2008-08-04T08:21:42.043000
2008-09-03T19:46:47.923000
1,104
1,109
Ensuring that Exceptions are always caught
Exceptions in C++ don't need to be caught (no compile time errors) by the calling function. So it's up to the developer's judgment whether to catch them using try/catch (unlike in Java). Is there a way one can ensure that the exceptions thrown are always caught using try/catch by the calling function?
No. See A Pragmatic Look at Exception Specifications for reasons why not. The only way you can "help" this is to document the exceptions your function can throw, say as a comment in the header file declaring it. This is not enforced by the compiler or anything. Use code reviews for that purpose.
Ensuring that Exceptions are always caught Exceptions in C++ don't need to be caught (no compile time errors) by the calling function. So it's up to the developer's judgment whether to catch them using try/catch (unlike in Java). Is there a way one can ensure that the exceptions thrown are always caught using try/catch...
TITLE: Ensuring that Exceptions are always caught QUESTION: Exceptions in C++ don't need to be caught (no compile time errors) by the calling function. So it's up to the developer's judgment whether to catch them using try/catch (unlike in Java). Is there a way one can ensure that the exceptions thrown are always caug...
[ "c++", "exception", "try-catch", "exception-safety" ]
31
27
3,032
7
0
2008-08-04T10:01:37.927000
2008-08-04T10:10:15.727000
1,108
1,130
How does database indexing work?
Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level? For information on queries to index a field, check out How do I index a database column.
Why is it needed? When data is stored on disk-based storage devices, it is stored as blocks of data. These blocks are accessed in their entirety, making them the atomic disk access operation. Disk blocks are structured in much the same way as linked lists; both contain a section for data, a pointer to the location of t...
How does database indexing work? Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level? For information on queries to index a field, check out How do I index a database column.
TITLE: How does database indexing work? QUESTION: Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level? For information on queries to index a field, check out How do I index a database column. ANSWER: Why is it needed? When data is...
[ "sql", "database", "performance", "indexing", "database-indexes" ]
2,882
4,140
1,116,553
7
0
2008-08-04T10:07:12.673000
2008-08-04T10:41:04.620000
1,131
1,135
Windows Help files - what are the options?
Back in the old days, Help was not trivial but possible: generate some funky.rtf file with special tags, run it through a compiler, and you got a WinHelp file (.hlp) that actually works really well. Then, Microsoft decided that WinHelp was not hip and cool anymore and switched to CHM, up to the point they actually axed...
HTML would be the next best choice, ONLY IF you would serve them from a public web server. If you tried to bundle it with your app, all the files (and images (and stylesheets (and...) ) ) would make CHM look like a gift from gods. That said, when actually bundled in the installation package, (instead of being served ov...
Windows Help files - what are the options? Back in the old days, Help was not trivial but possible: generate some funky.rtf file with special tags, run it through a compiler, and you got a WinHelp file (.hlp) that actually works really well. Then, Microsoft decided that WinHelp was not hip and cool anymore and switched...
TITLE: Windows Help files - what are the options? QUESTION: Back in the old days, Help was not trivial but possible: generate some funky.rtf file with special tags, run it through a compiler, and you got a WinHelp file (.hlp) that actually works really well. Then, Microsoft decided that WinHelp was not hip and cool an...
[ "windows", "language-agnostic", "chm", "winhelp" ]
39
14
5,199
10
0
2008-08-04T10:43:05.707000
2008-08-04T10:51:39.560000
1,145
1,154
Why am I getting a double free or corruption error with realloc()?
I've tried to write a string replace function in C, which works on a char *, which has been allocated using malloc(). It's a little different in that it will find and replace strings, rather than characters in the starting string. It's trivial to do if the search and replace strings are the same length (or the replace ...
As a general rule, you should never do a free or realloc on a user provided buffer. You don't know where the user allocated the space (in your module, in another DLL) so you cannot use any of the allocation functions on a user buffer. Provided that you now cannot do any reallocation within your function, you should cha...
Why am I getting a double free or corruption error with realloc()? I've tried to write a string replace function in C, which works on a char *, which has been allocated using malloc(). It's a little different in that it will find and replace strings, rather than characters in the starting string. It's trivial to do if ...
TITLE: Why am I getting a double free or corruption error with realloc()? QUESTION: I've tried to write a string replace function in C, which works on a char *, which has been allocated using malloc(). It's a little different in that it will find and replace strings, rather than characters in the starting string. It's...
[ "c", "malloc" ]
19
15
9,107
8
0
2008-08-04T11:06:00.560000
2008-08-04T11:19:54.447000
1,156
1,157
How do I index a database column
Hopefully, I can get answers for each database server. For an outline of how indexing works check out: How does database indexing work?
The following is SQL92 standard so should be supported by the majority of RDMBS that use SQL: CREATE INDEX [index name] ON [table name] ( [column name] )
How do I index a database column Hopefully, I can get answers for each database server. For an outline of how indexing works check out: How does database indexing work?
TITLE: How do I index a database column QUESTION: Hopefully, I can get answers for each database server. For an outline of how indexing works check out: How does database indexing work? ANSWER: The following is SQL92 standard so should be supported by the majority of RDMBS that use SQL: CREATE INDEX [index name] ON [...
[ "sql", "database", "indexing" ]
66
70
50,057
9
0
2008-08-04T11:21:26.567000
2008-08-04T11:25:14.017000
1,160
975,299
Use SVN Revision to label build in CCNET
I am using CCNET on a sample project with SVN as my source control. CCNET is configured to create a build on every check in. CCNET uses MSBuild to build the source code. I would like to use the latest revision number to generate AssemblyInfo.cs while compiling. How can I retrieve the latest revision from subversion and...
CruiseControl.Net 1.4.4 has now an Assembly Version Labeller, which generates version numbers compatible with.Net assembly properties. In my project I have it configured as: (Caveat: assemblyVersionLabeller won't start generating svn revision based labels until an actual commit-triggered build occurs.) and then consume...
Use SVN Revision to label build in CCNET I am using CCNET on a sample project with SVN as my source control. CCNET is configured to create a build on every check in. CCNET uses MSBuild to build the source code. I would like to use the latest revision number to generate AssemblyInfo.cs while compiling. How can I retriev...
TITLE: Use SVN Revision to label build in CCNET QUESTION: I am using CCNET on a sample project with SVN as my source control. CCNET is configured to create a build on every check in. CCNET uses MSBuild to build the source code. I would like to use the latest revision number to generate AssemblyInfo.cs while compiling....
[ "svn", "msbuild", "cruisecontrol.net" ]
42
45
18,980
12
0
2008-08-04T11:37:24.863000
2009-06-10T12:37:30.197000
1,171
28,705
What is the most efficient graph data structure in Python?
I need to be able to manipulate a large (10^7 nodes) graph in python. The data corresponding to each node/edge is minimal, say, a small number of strings. What is the most efficient, in terms of memory and speed, way of doing this? A dict of dicts is more flexible and simpler to implement, but I intuitively expect a li...
I would strongly advocate you look at NetworkX. It's a battle-tested war horse and the first tool most 'research' types reach for when they need to do analysis of network based data. I have manipulated graphs with 100s of thousands of edges without problem on a notebook. Its feature rich and very easy to use. You will ...
What is the most efficient graph data structure in Python? I need to be able to manipulate a large (10^7 nodes) graph in python. The data corresponding to each node/edge is minimal, say, a small number of strings. What is the most efficient, in terms of memory and speed, way of doing this? A dict of dicts is more flexi...
TITLE: What is the most efficient graph data structure in Python? QUESTION: I need to be able to manipulate a large (10^7 nodes) graph in python. The data corresponding to each node/edge is minimal, say, a small number of strings. What is the most efficient, in terms of memory and speed, way of doing this? A dict of d...
[ "python", "performance", "data-structures", "graph-theory" ]
73
56
31,896
7
0
2008-08-04T12:00:57.297000
2008-08-26T17:43:06.413000
1,180
1,232
How to make subdomain user accounts in a webapp
I am looking to allow users to control of subdomain of an app I am toying with, much like Basecamp where it is customusername.seework.com. What is required on the DNS end to allow these to be created dynamically and be available instantly. And how do you recommend dealing with this in the logic of the site? Htaccess ru...
The way we do this is to have a 'catch all' for our domain name registered in DNS so that anything.ourdomain.com will point to our server. With Apache you can set up a similar catch-all for your vhosts. The ServerName must be a single static name but the ServerAlias directive can contain a pattern. Servername www.ourdo...
How to make subdomain user accounts in a webapp I am looking to allow users to control of subdomain of an app I am toying with, much like Basecamp where it is customusername.seework.com. What is required on the DNS end to allow these to be created dynamically and be available instantly. And how do you recommend dealing...
TITLE: How to make subdomain user accounts in a webapp QUESTION: I am looking to allow users to control of subdomain of an app I am toying with, much like Basecamp where it is customusername.seework.com. What is required on the DNS end to allow these to be created dynamically and be available instantly. And how do you...
[ "web-applications", "dns", "subdomain", "account" ]
25
15
6,151
4
0
2008-08-04T12:22:07.910000
2008-08-04T13:39:39.423000
1,189
1,190
ViewState invalid only in Safari
One of the sites I maintain relies heavily on the use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error. This appears to only happen in Safari. Firefox, IE and Opera all load successfully in the same scenario.
I've been doing a little research into this and whilst I'm not entirely sure its the cause I believe it is because Safari is not returning the full result set (hence cropping it). I have been in dicussion with another developer and found the following post on Channel 9 as well which recommends making use of the SQL Sta...
ViewState invalid only in Safari One of the sites I maintain relies heavily on the use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error. This appears to only happen in Safari. Firefox, IE and Opera all load succes...
TITLE: ViewState invalid only in Safari QUESTION: One of the sites I maintain relies heavily on the use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error. This appears to only happen in Safari. Firefox, IE and Ope...
[ "c#", ".net", "safari", "viewstate" ]
16
2
3,400
3
0
2008-08-04T12:38:21.263000
2008-08-04T12:40:49.137000
1,237
1,243
Regex: To pull out a sub-string between two tags in a string
I have a file in the following format: Data Data Data [Start] Data I want [End] Data I'd like to grab the Data I want from between the [Start] and [End] tags using a Regex. Can anyone show me how this might be done?
\[start\]\s*(((?!\[start\]|\[end\]).)+)\s*\[end\] This should hopefully drop the [start] and [end] markers as well.
Regex: To pull out a sub-string between two tags in a string I have a file in the following format: Data Data Data [Start] Data I want [End] Data I'd like to grab the Data I want from between the [Start] and [End] tags using a Regex. Can anyone show me how this might be done?
TITLE: Regex: To pull out a sub-string between two tags in a string QUESTION: I have a file in the following format: Data Data Data [Start] Data I want [End] Data I'd like to grab the Data I want from between the [Start] and [End] tags using a Regex. Can anyone show me how this might be done? ANSWER: \[start\]\s*(((?...
[ "regex", "parsing" ]
48
23
87,240
9
0
2008-08-04T13:47:10.547000
2008-08-04T13:55:05.647000
1,241
1,275
Asynchronous multi-direction server-client communication over the same open socket?
I have a client-server app where the client is on a Windows Mobile 6 device, written in C++ and the server is on full Windows and written in C#. Originally, I only needed it to send messages from the client to the server, with the server only ever sending back an acknowledgment that it received the message. Now, I woul...
When I needed to write an application with a client-server model where the clients could leave and enter whenever they want, (I assume that's also the case for your application as you use mobile devices) I made sure that the clients send an online message to the server, indicating they were connected and ready to do wh...
Asynchronous multi-direction server-client communication over the same open socket? I have a client-server app where the client is on a Windows Mobile 6 device, written in C++ and the server is on full Windows and written in C#. Originally, I only needed it to send messages from the client to the server, with the serve...
TITLE: Asynchronous multi-direction server-client communication over the same open socket? QUESTION: I have a client-server app where the client is on a Windows Mobile 6 device, written in C++ and the server is on full Windows and written in C#. Originally, I only needed it to send messages from the client to the serv...
[ "c#", "c++", "sockets" ]
27
9
2,963
4
0
2008-08-04T13:52:25.090000
2008-08-04T14:30:12.223000
1,261
1,272
What are the advantages of using SVN over CVS?
My company is using CVS as our de-facto standard for source control. However, I've heard a lot of people say that SVN is better. I know SVN is newer, but other than that, I'm unfamiliar with its benefits. What I'm looking for is a good, succinct comparison of the two systems, noting any advantages or disadvantages of e...
CVS only tracks modification on a file-by-file basis, while SVN tracks a whole commit as a new revision, which means that it is easier to follow the history of your project. Add the fact that all modern source control software use the concept of revision so it is far easier to migrate from SVN than it is from CVS. Ther...
What are the advantages of using SVN over CVS? My company is using CVS as our de-facto standard for source control. However, I've heard a lot of people say that SVN is better. I know SVN is newer, but other than that, I'm unfamiliar with its benefits. What I'm looking for is a good, succinct comparison of the two syste...
TITLE: What are the advantages of using SVN over CVS? QUESTION: My company is using CVS as our de-facto standard for source control. However, I've heard a lot of people say that SVN is better. I know SVN is newer, but other than that, I'm unfamiliar with its benefits. What I'm looking for is a good, succinct compariso...
[ "svn", "version-control", "cvs" ]
66
67
43,004
12
0
2008-08-04T14:06:48.540000
2008-08-04T14:17:59.080000
1,276
1,338
How big can a MySQL database get before performance starts to degrade
At what point does a MySQL database start to lose performance? Does physical database size matter? Do number of records matter? Is any performance degradation linear or exponential? I have what I believe to be a large database, with roughly 15M records which take up almost 2GB. Based on these numbers, is there any ince...
The physical database size doesn't matter. The number of records don't matter. In my experience the biggest problem that you are going to run in to is not size, but the number of queries you can handle at a time. Most likely you are going to have to move to a master/slave configuration so that the read queries can run ...
How big can a MySQL database get before performance starts to degrade At what point does a MySQL database start to lose performance? Does physical database size matter? Do number of records matter? Is any performance degradation linear or exponential? I have what I believe to be a large database, with roughly 15M recor...
TITLE: How big can a MySQL database get before performance starts to degrade QUESTION: At what point does a MySQL database start to lose performance? Does physical database size matter? Do number of records matter? Is any performance degradation linear or exponential? I have what I believe to be a large database, with...
[ "mysql", "database", "database-performance" ]
340
225
227,922
15
0
2008-08-04T14:31:11.410000
2008-08-04T15:26:55.807000
1,292
1,305
Limit size of Queue<T> in .NET?
I have a Queue object that I have initialised to a capacity of 2, but obviously that is just the capacity and it keeps expanding as I add items. Is there already an object that automatically dequeues an item when the limit is reached, or is the best solution to create my own inherited class?
I've knocked up a basic version of what I'm looking for, it's not perfect but it'll do the job until something better comes along. public class LimitedQueue: Queue { public int Limit { get; set; } public LimitedQueue(int limit): base(limit) { Limit = limit; } public new void Enqueue(T item) { while (Count >= Limit) {...
Limit size of Queue<T> in .NET? I have a Queue object that I have initialised to a capacity of 2, but obviously that is just the capacity and it keeps expanding as I add items. Is there already an object that automatically dequeues an item when the limit is reached, or is the best solution to create my own inherited cl...
TITLE: Limit size of Queue<T> in .NET? QUESTION: I have a Queue object that I have initialised to a capacity of 2, but obviously that is just the capacity and it keeps expanding as I add items. Is there already an object that automatically dequeues an item when the limit is reached, or is the best solution to create m...
[ ".net", "collections", "queue" ]
63
48
36,962
8
0
2008-08-04T14:47:10.970000
2008-08-04T14:57:28.767000
1,300
1,673
Is nAnt still supported and suitable for .net 3.5/VS2008?
I am using MSBuild to build my stuff. I want to use CruiseControl.net as by Build Server. Now, CCNET refers nAnt a lot, but it looks as if ccnet can do most of the stuff nant could do through the project configuration and msbuild. Also, nAnt seems a bit unsupported, with a Beta release that is almost a year old now. In...
If you are quite happy with MSBuild, then I would stick with MSBuild. This may be one of those cases where the tool you learn first is the one you will prefer. I started with NAnt and can't quite get used to MSBuild. I'm sure they will both be around for quite some time. There are some fundamental differences between t...
Is nAnt still supported and suitable for .net 3.5/VS2008? I am using MSBuild to build my stuff. I want to use CruiseControl.net as by Build Server. Now, CCNET refers nAnt a lot, but it looks as if ccnet can do most of the stuff nant could do through the project configuration and msbuild. Also, nAnt seems a bit unsuppor...
TITLE: Is nAnt still supported and suitable for .net 3.5/VS2008? QUESTION: I am using MSBuild to build my stuff. I want to use CruiseControl.net as by Build Server. Now, CCNET refers nAnt a lot, but it looks as if ccnet can do most of the stuff nant could do through the project configuration and msbuild. Also, nAnt se...
[ ".net", ".net-3.5", "msbuild", "nant" ]
31
15
4,052
7
0
2008-08-04T14:55:04.433000
2008-08-04T22:52:31.677000
1,304
1,309
How to check for file lock?
Is there any way to check whether a file is locked without using a try/catch block? Right now, the only way I know of is to just open the file and catch any System.IO.IOException.
No, unfortunately, and if you think about it, that information would be worthless anyway since the file could become locked the very next second (read: short timespan). Why specifically do you need to know if the file is locked anyway? Knowing that might give us some other way of giving you good advice. If your code wo...
How to check for file lock? Is there any way to check whether a file is locked without using a try/catch block? Right now, the only way I know of is to just open the file and catch any System.IO.IOException.
TITLE: How to check for file lock? QUESTION: Is there any way to check whether a file is locked without using a try/catch block? Right now, the only way I know of is to just open the file and catch any System.IO.IOException. ANSWER: No, unfortunately, and if you think about it, that information would be worthless any...
[ "c#", ".net", "io", "filelock" ]
270
133
240,613
12
0
2008-08-04T14:56:57.490000
2008-08-04T14:59:24.410000
1,306
1,318
How do I use (n)curses in Ruby?
I'd like to create a progress bar to indicate the status of an a batch job in Ruby. I've read some tutorials / libraries on using (n)curses, none of which were particularly helpful in explaining how to create an "animated" progress bar in the terminal or using curses with Ruby. I'm already aware of using a separate thr...
You might be able to get some implementation ideas from the Ruby/ProgressBar library, which generates text progress bars. I stumbled across it a couple of months back but haven't made any use of it.
How do I use (n)curses in Ruby? I'd like to create a progress bar to indicate the status of an a batch job in Ruby. I've read some tutorials / libraries on using (n)curses, none of which were particularly helpful in explaining how to create an "animated" progress bar in the terminal or using curses with Ruby. I'm alrea...
TITLE: How do I use (n)curses in Ruby? QUESTION: I'd like to create a progress bar to indicate the status of an a batch job in Ruby. I've read some tutorials / libraries on using (n)curses, none of which were particularly helpful in explaining how to create an "animated" progress bar in the terminal or using curses wi...
[ "ruby", "unix", "curses" ]
46
21
12,787
4
0
2008-08-04T14:57:59.547000
2008-08-04T15:11:19.770000
1,313
74,033
Followup: Finding an accurate "distance" between colors
Original Question I am looking for a function that attempts to quantify how "distant" (or distinct) two colors are. This question is really in two parts: What color space best represents human vision? What distance metric in that space best represents human vision (euclidean?)
Convert to La*b* (aka just plain "Lab", and you'll also see reference to "CIELAB"). A good quick measaure of color difference is (L1-L2)^2 + (a1-a2)^2 + (b1-b2)^2 Color scientists have other more refined measures, which may not be worth the bother, depending on accuracy needed for what you're doing. The a and b values ...
Followup: Finding an accurate "distance" between colors Original Question I am looking for a function that attempts to quantify how "distant" (or distinct) two colors are. This question is really in two parts: What color space best represents human vision? What distance metric in that space best represents human vision...
TITLE: Followup: Finding an accurate "distance" between colors QUESTION: Original Question I am looking for a function that attempts to quantify how "distant" (or distinct) two colors are. This question is really in two parts: What color space best represents human vision? What distance metric in that space best repre...
[ "language-agnostic", "colors" ]
53
48
20,891
7
0
2008-08-04T15:08:13.143000
2008-09-16T16:08:42.313000
1,314
1,319
Using MSTest with CruiseControl.NET
We have been using CruiseControl for quite a while with NUnit and NAnt. For a recent project we decided to use the testing framework that comes with Visual Studio, which so far has been adequate. I'm attempting to get the solution running in CruiseControl. I've finally got the build itself to work; however, I have been...
Not sure if that helps (i found the ccnet Documentation somewhat unhelpful at times): Using CruiseControl.NET with MSTest
Using MSTest with CruiseControl.NET We have been using CruiseControl for quite a while with NUnit and NAnt. For a recent project we decided to use the testing framework that comes with Visual Studio, which so far has been adequate. I'm attempting to get the solution running in CruiseControl. I've finally got the build ...
TITLE: Using MSTest with CruiseControl.NET QUESTION: We have been using CruiseControl for quite a while with NUnit and NAnt. For a recent project we decided to use the testing framework that comes with Visual Studio, which so far has been adequate. I'm attempting to get the solution running in CruiseControl. I've fina...
[ "msbuild", "build-process", "cruisecontrol.net" ]
19
5
2,076
2
0
2008-08-04T15:09:07.043000
2008-08-04T15:12:13.917000
1,329
1,339
What is a better file copy alternative than the Windows default?
I need to copy hundreds of gigs of random files around on my computer and am pretty leery of using the vanilla file copy built into Windows. I don't want it to hang on a "Are you sure?", "Are you really sure?", "Even zip files?", "Surely not read-only files too!" loop as soon as I step away. I don't want it to work for...
How about good old Command-Line Xcopy? With S: being the source and T: the target: xcopy /K /R /E /I /S /C /H /G /X /Y s:\*.* t:\ /K Copies attributes. Normal Xcopy will reset read-only attributes. /R Overwrites read-only files. /E Copies directories and subdirectories, including empty ones. /I If destination does not ...
What is a better file copy alternative than the Windows default? I need to copy hundreds of gigs of random files around on my computer and am pretty leery of using the vanilla file copy built into Windows. I don't want it to hang on a "Are you sure?", "Are you really sure?", "Even zip files?", "Surely not read-only fil...
TITLE: What is a better file copy alternative than the Windows default? QUESTION: I need to copy hundreds of gigs of random files around on my computer and am pretty leery of using the vanilla file copy built into Windows. I don't want it to hang on a "Are you sure?", "Are you really sure?", "Even zip files?", "Surely...
[ "windows", "file", "filesystems", "utilities" ]
38
20
101,345
22
0
2008-08-04T15:20:42.683000
2008-08-04T15:28:23.527000
1,383
1,393
What is unit testing?
I saw many questions asking 'how' to unit test in a specific language, but no question asking 'what', 'why', and 'when'. What is it? What does it do for me? Why should I use it? When should I use it (also when not)? What are some common pitfalls and misconceptions
Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are: Running the tests becomes automate-able and repeatable You can test at a much more granular level than point-and-click testing via a GUI Note that if your test code writes to a file,...
What is unit testing? I saw many questions asking 'how' to unit test in a specific language, but no question asking 'what', 'why', and 'when'. What is it? What does it do for me? Why should I use it? When should I use it (also when not)? What are some common pitfalls and misconceptions
TITLE: What is unit testing? QUESTION: I saw many questions asking 'how' to unit test in a specific language, but no question asking 'what', 'why', and 'when'. What is it? What does it do for me? Why should I use it? When should I use it (also when not)? What are some common pitfalls and misconceptions ANSWER: Unit t...
[ "unit-testing" ]
229
219
54,349
20
0
2008-08-04T16:27:39.787000
2008-08-04T16:36:51.750000
1,390
1,394
Is Windows Server 2008 "Server Core" appropriate for a SQL Server instance?
I'm setting up a dedicated SQL Server 2005 box on Windows Server 2008 this week, and would like to pare it down to be as barebones as possible while still being fully functional. To that end, the "Server Core" option sounds appealing, but I'm not clear about whether or not I can run SQL Server on that SKU. Several serv...
Not sure how credible this source is, but: The Windows Server 2008 Core edition can: Run the file server role. Run the Hyper-V virtualization server role. Run the Directory Services role. Run the DHCP server role. Run the IIS Web server role. Run the DNS server role. Run Active Directory Lightweight Directory Services....
Is Windows Server 2008 "Server Core" appropriate for a SQL Server instance? I'm setting up a dedicated SQL Server 2005 box on Windows Server 2008 this week, and would like to pare it down to be as barebones as possible while still being fully functional. To that end, the "Server Core" option sounds appealing, but I'm n...
TITLE: Is Windows Server 2008 "Server Core" appropriate for a SQL Server instance? QUESTION: I'm setting up a dedicated SQL Server 2005 box on Windows Server 2008 this week, and would like to pare it down to be as barebones as possible while still being fully functional. To that end, the "Server Core" option sounds ap...
[ "sql-server", "windows-server-2008" ]
27
16
2,183
6
0
2008-08-04T16:33:36.390000
2008-08-04T16:38:03.667000
1,401
1,418
ASP.Net Custom Client-Side Validation
I have a custom validation function in JavaScript in a user control on a.Net 2.0 web site which checks to see that the fee paid is not in excess of the fee amount due. I've placed the validator code in the ascx file, and I have also tried using Page.ClientScript.RegisterClientScriptBlock() and in both cases the validat...
Try changing the argument names to sender and args. And, after you have it working, switch the call over to ScriptManager.RegisterClientScriptBlock, regardless of AJAX use.
ASP.Net Custom Client-Side Validation I have a custom validation function in JavaScript in a user control on a.Net 2.0 web site which checks to see that the fee paid is not in excess of the fee amount due. I've placed the validator code in the ascx file, and I have also tried using Page.ClientScript.RegisterClientScrip...
TITLE: ASP.Net Custom Client-Side Validation QUESTION: I have a custom validation function in JavaScript in a user control on a.Net 2.0 web site which checks to see that the fee paid is not in excess of the fee amount due. I've placed the validator code in the ascx file, and I have also tried using Page.ClientScript.R...
[ "asp.net", "javascript", "validation" ]
38
19
3,694
4
0
2008-08-04T16:44:25.167000
2008-08-04T17:02:56.237000
1,408
1,421
Make XAMPP / Apache serve file outside of htdocs folder
Is it possible to configure xampp to serve up a file outside of the htdocs directory? For instance, say I have a file located as follows: C:\projects\transitCalculator\trunk\TransitCalculator.php and my xampp files are normally served out from: C:\xampp\htdocs\ (because that's the default configuration) Is there some w...
Ok, per pix0r 's, Sparks ' and Dave 's answers it looks like there are three ways to do this: Virtual Hosts Open C:\xampp\apache\conf\extra\httpd-vhosts.conf. Un-comment ~line 19 ( NameVirtualHost *:80 ). Add your virtual host (~line 36): DocumentRoot C:\Projects\transitCalculator\trunk ServerName transitcalculator.loc...
Make XAMPP / Apache serve file outside of htdocs folder Is it possible to configure xampp to serve up a file outside of the htdocs directory? For instance, say I have a file located as follows: C:\projects\transitCalculator\trunk\TransitCalculator.php and my xampp files are normally served out from: C:\xampp\htdocs\ (b...
TITLE: Make XAMPP / Apache serve file outside of htdocs folder QUESTION: Is it possible to configure xampp to serve up a file outside of the htdocs directory? For instance, say I have a file located as follows: C:\projects\transitCalculator\trunk\TransitCalculator.php and my xampp files are normally served out from: C...
[ "php", "apache", "xampp", "server-configuration" ]
334
384
279,039
6
0
2008-08-04T16:54:49.293000
2008-08-04T17:05:48.680000
1,409
27,335
Bandwith throttling in IIS 6 by IP Address
I am writing an application that downloads large files in the background. All clients are logged in locally, or through a VPN. When they are logged in locally, I do not want to throttle downloads. However, I would like to limit downloads to 10 KBps when the user is connected via VPN. I can differentiate between these u...
My first thought is this. I don't know if it would work but it would only take a few minutes to try. Create two IIS web sites on the same server. The first site is bound to the public IP, but the second site is bound to the private IP. Both point to the same folder on the file system. Your VPN users will be accessing v...
Bandwith throttling in IIS 6 by IP Address I am writing an application that downloads large files in the background. All clients are logged in locally, or through a VPN. When they are logged in locally, I do not want to throttle downloads. However, I would like to limit downloads to 10 KBps when the user is connected v...
TITLE: Bandwith throttling in IIS 6 by IP Address QUESTION: I am writing an application that downloads large files in the background. All clients are logged in locally, or through a VPN. When they are logged in locally, I do not want to throttle downloads. However, I would like to limit downloads to 10 KBps when the u...
[ "asp.net", "iis" ]
20
12
2,268
1
0
2008-08-04T16:55:31.243000
2008-08-26T03:14:53.987000
1,417
1,425
How can I get the authenticated user name under Apache using plain HTTP authentication and PHP?
First, let's get the security considerations out of the way. I'm using simple authentication under Apache for a one-off, internal use only, non-internet connected LAN, PHP web app. How can get I the HTTP authenticated user name in PHP?
I think that you are after this $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW'];
How can I get the authenticated user name under Apache using plain HTTP authentication and PHP? First, let's get the security considerations out of the way. I'm using simple authentication under Apache for a one-off, internal use only, non-internet connected LAN, PHP web app. How can get I the HTTP authenticated user n...
TITLE: How can I get the authenticated user name under Apache using plain HTTP authentication and PHP? QUESTION: First, let's get the security considerations out of the way. I'm using simple authentication under Apache for a one-off, internal use only, non-internet connected LAN, PHP web app. How can get I the HTTP au...
[ "php", "apache", "authentication", "http-authentication" ]
54
40
24,179
2
0
2008-08-04T17:02:31.790000
2008-08-04T17:08:26.037000
1,451
1,477
What is the best way to handle multiple permission types?
I often encounter the following scenario where I need to offer many different types of permissions. I primarily use ASP.NET / VB.NET with SQL Server 2000. Scenario I want to offer a dynamic permission system that can work on different parameters. Let's say that I want to give either a department or just a specific pers...
I agree with John Downey. Personally, I sometimes use a flagged enumeration of permissions. This way you can use AND, OR, NOT and XOR bitwise operations on the enumeration's items. "[Flags] public enum Permission { VIEWUSERS = 1, // 2^0 // 0000 0001 EDITUSERS = 2, // 2^1 // 0000 0010 VIEWPRODUCTS = 4, // 2^2 // 0000 01...
What is the best way to handle multiple permission types? I often encounter the following scenario where I need to offer many different types of permissions. I primarily use ASP.NET / VB.NET with SQL Server 2000. Scenario I want to offer a dynamic permission system that can work on different parameters. Let's say that ...
TITLE: What is the best way to handle multiple permission types? QUESTION: I often encounter the following scenario where I need to offer many different types of permissions. I primarily use ASP.NET / VB.NET with SQL Server 2000. Scenario I want to offer a dynamic permission system that can work on different parameter...
[ "sql", "permissions" ]
25
14
4,506
5
0
2008-08-04T17:46:28.207000
2008-08-04T18:23:40.537000
1,453
1,456
Using object property as default for method property
I'm trying to do this (which produces an unexpected T_VARIABLE error): public function createShipment($startZip, $endZip, $weight = $this->getDefaultWeight()){} I don't want to put a magic number in there for weight since the object I am using has a "defaultWeight" parameter that all new shipments get if you don't spec...
This isn't much better: public function createShipment($startZip, $endZip, $weight=null){ $weight =!$weight? $this->getDefaultWeight(): $weight; } // or... public function createShipment($startZip, $endZip, $weight=null){ if (!$weight ) $weight = $this->getDefaultWeight(); }
Using object property as default for method property I'm trying to do this (which produces an unexpected T_VARIABLE error): public function createShipment($startZip, $endZip, $weight = $this->getDefaultWeight()){} I don't want to put a magic number in there for weight since the object I am using has a "defaultWeight" p...
TITLE: Using object property as default for method property QUESTION: I'm trying to do this (which produces an unexpected T_VARIABLE error): public function createShipment($startZip, $endZip, $weight = $this->getDefaultWeight()){} I don't want to put a magic number in there for weight since the object I am using has a...
[ "php", "parameters", "error-handling" ]
28
15
2,027
5
0
2008-08-04T17:51:13.003000
2008-08-04T17:53:00.410000
1,457
1,468
Modify Address Bar URL in AJAX App to Match Current State
I'm writing an AJAX app, but as the user moves through the app, I'd like the URL in the address bar to update despite the lack of page reloads. Basically, I'd like for them to be able to bookmark at any point and thereby return to the current state. How are people handling maintaining RESTfulness in AJAX apps?
The way to do this is to manipulate location.hash when AJAX updates result in a state change that you'd like to have a discrete URL. For example, if your page's url is: http://example.com/ If a client side function executed this code: // AJAX code to display the "foo" state goes here. location.hash = 'foo'; Then, the ...
Modify Address Bar URL in AJAX App to Match Current State I'm writing an AJAX app, but as the user moves through the app, I'd like the URL in the address bar to update despite the lack of page reloads. Basically, I'd like for them to be able to bookmark at any point and thereby return to the current state. How are peop...
TITLE: Modify Address Bar URL in AJAX App to Match Current State QUESTION: I'm writing an AJAX app, but as the user moves through the app, I'd like the URL in the address bar to update despite the lack of page reloads. Basically, I'd like for them to be able to bookmark at any point and thereby return to the current s...
[ "ajax", "url", "rest", "address-bar" ]
166
116
74,361
8
0
2008-08-04T17:53:32.500000
2008-08-04T18:04:48.547000
1,476
13,107
How do you express binary literals in Python?
How do you express an integer as a binary number with Python literals? I was easily able to find the answer for hex: >>> 0x12AF 4783 >>> 0x100 256 and octal: >>> 01267 695 >>> 0100 64 How do you use literals to express binary in Python? Summary of Answers Python 2.5 and earlier: can express binary using int('0101010111...
For reference— future Python possibilities: Starting with Python 2.6 you can express binary literals using the prefix 0b or 0B: >>> 0b101111 47 You can also use the new bin function to get the binary representation of a number: >>> bin(173) '0b10101101' Development version of the documentation: What's New in Python 2.6
How do you express binary literals in Python? How do you express an integer as a binary number with Python literals? I was easily able to find the answer for hex: >>> 0x12AF 4783 >>> 0x100 256 and octal: >>> 01267 695 >>> 0100 64 How do you use literals to express binary in Python? Summary of Answers Python 2.5 and ear...
TITLE: How do you express binary literals in Python? QUESTION: How do you express an integer as a binary number with Python literals? I was easily able to find the answer for hex: >>> 0x12AF 4783 >>> 0x100 256 and octal: >>> 01267 695 >>> 0100 64 How do you use literals to express binary in Python? Summary of Answers ...
[ "python", "syntax", "binary", "integer", "literals" ]
407
358
340,928
8
0
2008-08-04T18:20:36.487000
2008-08-16T12:35:36.170000
1,496
1,517
What are the preferred versions of Vim and Emacs on Mac OS X?
For those of us that like to use the graphical version of Vim or Emacs, instead of the console version, which version do you recommend? For Vim, there's Mac OS X Vim, MacVim, Vim-Cocoa. For Emacs, CarbonEmacs, XEmacs, and Aquamacs. Are there more? Which of these are ready for prime-time? If it's a tough call, what are ...
MacVim works well and certainly looks more mature than Vim-Cocoa, moreover there is a Cocoa plugin architecture in the pipeline for MacVim (and someone is already working on a TextMate style file browser tray plugin which is a huge ++ IMHO). There was also a Carbon version of Vim, but this didn't offer a great deal ove...
What are the preferred versions of Vim and Emacs on Mac OS X? For those of us that like to use the graphical version of Vim or Emacs, instead of the console version, which version do you recommend? For Vim, there's Mac OS X Vim, MacVim, Vim-Cocoa. For Emacs, CarbonEmacs, XEmacs, and Aquamacs. Are there more? Which of t...
TITLE: What are the preferred versions of Vim and Emacs on Mac OS X? QUESTION: For those of us that like to use the graphical version of Vim or Emacs, instead of the console version, which version do you recommend? For Vim, there's Mac OS X Vim, MacVim, Vim-Cocoa. For Emacs, CarbonEmacs, XEmacs, and Aquamacs. Are ther...
[ "macos", "vim", "emacs", "editor" ]
35
21
9,888
13
0
2008-08-04T18:51:38.543000
2008-08-04T19:11:02.140000
1,503
1,514
Integrating Visual Studio Test Project with Cruise Control
I'm looking into using Visual Studio 2008's built in unit test projects instead of NUnit and I was wondering if anyone has any experience in trying to integrate this type of unit test project with Cruise Control.Net.
From some of the initial research it doesn't appear to be a super simple solution. It appears that doing this involves having Visual Studio 2008 actually installed on the continuous integration server, which could be a deal breaker. Then configure the MSTest.exe to run in the tasks list, but first you'll have to make a...
Integrating Visual Studio Test Project with Cruise Control I'm looking into using Visual Studio 2008's built in unit test projects instead of NUnit and I was wondering if anyone has any experience in trying to integrate this type of unit test project with Cruise Control.Net.
TITLE: Integrating Visual Studio Test Project with Cruise Control QUESTION: I'm looking into using Visual Studio 2008's built in unit test projects instead of NUnit and I was wondering if anyone has any experience in trying to integrate this type of unit test project with Cruise Control.Net. ANSWER: From some of the ...
[ "visual-studio", "unit-testing", "continuous-integration", "cruisecontrol.net" ]
20
10
4,348
1
0
2008-08-04T19:01:14.157000
2008-08-04T19:09:44.717000
1,508
1,525
Different Distributed Version Control Systems working together
My office has a central Source Safe 2005 install that we use for source control. I can't change what the office uses on the server. I develop on a laptop and would like to have a different local source control repository that can sync with the central server (when available) regardless of the what that central provider...
Well... KernelTrap has something on this. Looks like you can use vss2svn to pipe the Source Safe repo into a Subversion repository, then use the very nice git-svn to pull into a local git repo. I would assume the commits back to VSS would not be a smooth, automatic process using this method.
Different Distributed Version Control Systems working together My office has a central Source Safe 2005 install that we use for source control. I can't change what the office uses on the server. I develop on a laptop and would like to have a different local source control repository that can sync with the central serve...
TITLE: Different Distributed Version Control Systems working together QUESTION: My office has a central Source Safe 2005 install that we use for source control. I can't change what the office uses on the server. I develop on a laptop and would like to have a different local source control repository that can sync with...
[ "version-control", "dvcs" ]
18
2
733
4
0
2008-08-04T19:04:47.347000
2008-08-04T19:13:23.197000
1,528
1,556
Hiding inherited members
I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency properties which have become vestigial and can be a little confusing when using IntelliSense or using the classes in a visual ...
Override them like Michael Suggests above and to prevent folks from using the overridden (sp?) methods, mark them as obsolete: [Obsolete("These are not supported in this class.", true)] public override void dontcallmeanymore() { } If the second parm is set to true, a compiler error will be generated if anyone tries to ...
Hiding inherited members I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency properties which have become vestigial and can be a little confusing when using IntelliSense or using...
TITLE: Hiding inherited members QUESTION: I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency properties which have become vestigial and can be a little confusing when using Int...
[ "c#", "wpf", "silverlight", "polymorphism", "dependency-properties" ]
51
39
34,163
9
0
2008-08-04T19:13:54.693000
2008-08-04T20:14:30.547000
1,535
2,047
Reducing duplicate error handling code in C#?
I've never been completely happy with the way exception handling works, there's a lot exceptions and try/catch brings to the table (stack unwinding, etc.), but it seems to break a lot of the OO model in the process. Anyway, here's the problem: Let's say you have some class which wraps or includes networked file IO oper...
This looks like an excellent opportunity to have a look at Aspect Oriented Programming. Here is a good article on AOP in.NET. The general idea is that you'd extract the cross-functional concern (i.e. Retry for x hours) into a separate class and then you'd annotate any methods that need to modify their behaviour in that...
Reducing duplicate error handling code in C#? I've never been completely happy with the way exception handling works, there's a lot exceptions and try/catch brings to the table (stack unwinding, etc.), but it seems to break a lot of the OO model in the process. Anyway, here's the problem: Let's say you have some class ...
TITLE: Reducing duplicate error handling code in C#? QUESTION: I've never been completely happy with the way exception handling works, there's a lot exceptions and try/catch brings to the table (stack unwinding, etc.), but it seems to break a lot of the OO model in the process. Anyway, here's the problem: Let's say yo...
[ "c#", "exception", "error-handling" ]
40
14
2,780
4
0
2008-08-04T19:21:48.530000
2008-08-05T09:43:55
1,584
44,389
Linux shell equivalent on IIS
As a LAMP developer considering moving to a.Net IIS platform, one of my concerns is the loss of productivity due to lack of shell... Has anyone else had this experience? Is there possibly a Linux shell equivalent for Windows?
Depending on what version of IIS you're considering, I would second lbrandy's recommendation to check out PowerShell. Microsoft is working on a PowerShell provider for IIS (specifically version 7). There is a decent post about this at http://blogs.iis.net/thomad/archive/2008/04/14/iis-7-0-powershell-provider-tech-previ...
Linux shell equivalent on IIS As a LAMP developer considering moving to a.Net IIS platform, one of my concerns is the loss of productivity due to lack of shell... Has anyone else had this experience? Is there possibly a Linux shell equivalent for Windows?
TITLE: Linux shell equivalent on IIS QUESTION: As a LAMP developer considering moving to a.Net IIS platform, one of my concerns is the loss of productivity due to lack of shell... Has anyone else had this experience? Is there possibly a Linux shell equivalent for Windows? ANSWER: Depending on what version of IIS you'...
[ "windows", "iis", "shell", "command-line", "terminal" ]
21
7
3,502
8
0
2008-08-04T21:04:06.407000
2008-09-04T18:22:38.787000
1,598
3,490,980
What are the correct pixel dimensions for an apple-touch-icon?
I'm not sure what the correct size should be. Many sites seem to repeat that the apple-touch-icon should be 57x57 pixels but cite a broken link as their source. Hanselman 's and playgroundblues 's comments suggest different sizes including 163x163 and 60x60. Apple's own apple.com icon is 129x129! See my related questio...
It seems that Apple guidelines as of August 3, 2010 now include the "High resolution" images (for iPhone 4) in their "required" icon sizes. Looks like we need to provide both a 57x57 and a 114x114 image now, as well as a 640x960 title image. See Custom Icon and Image Creation Guidelines (Javascript required) which is p...
What are the correct pixel dimensions for an apple-touch-icon? I'm not sure what the correct size should be. Many sites seem to repeat that the apple-touch-icon should be 57x57 pixels but cite a broken link as their source. Hanselman 's and playgroundblues 's comments suggest different sizes including 163x163 and 60x60...
TITLE: What are the correct pixel dimensions for an apple-touch-icon? QUESTION: I'm not sure what the correct size should be. Many sites seem to repeat that the apple-touch-icon should be 57x57 pixels but cite a broken link as their source. Hanselman 's and playgroundblues 's comments suggest different sizes including...
[ "iphone", "favicon", "apple-touch-icon" ]
73
40
52,507
7
0
2008-08-04T21:17:51.150000
2010-08-16T06:15:28.777000
1,600
1,793
What is the best way to copy a database?
When I want to make a copy of a database, I always create a new empty database, and then restore a backup of the existing database into it. However, I'm wondering if this is really the least error-prone, least complicated, and most efficient way to do this?
Backup and Restore is the most straight-forward way I know. You have to be careful between servers as security credentials don't come with the restored database.
What is the best way to copy a database? When I want to make a copy of a database, I always create a new empty database, and then restore a backup of the existing database into it. However, I'm wondering if this is really the least error-prone, least complicated, and most efficient way to do this?
TITLE: What is the best way to copy a database? QUESTION: When I want to make a copy of a database, I always create a new empty database, and then restore a backup of the existing database into it. However, I'm wondering if this is really the least error-prone, least complicated, and most efficient way to do this? AN...
[ "sql-server", "sql-server-2008" ]
28
3
4,334
5
0
2008-08-04T21:27:53.003000
2008-08-05T01:31:16.583000
1,607
1,666
Mechanisms for tracking DB schema changes
What are the best methods for tracking and/or automating DB schema changes? Our team uses Subversion for version control and we've been able to automate some of our tasks this way (pushing builds up to a staging server, deploying tested code to a production server) but we're still doing database updates manually. I wou...
In the Rails world, there's the concept of migrations, scripts in which changes to the database are made in Ruby rather than a database-specific flavour of SQL. Your Ruby migration code ends up being converted into the DDL specific to your current database; this makes switching database platforms very easy. For every c...
Mechanisms for tracking DB schema changes What are the best methods for tracking and/or automating DB schema changes? Our team uses Subversion for version control and we've been able to automate some of our tasks this way (pushing builds up to a staging server, deploying tested code to a production server) but we're st...
TITLE: Mechanisms for tracking DB schema changes QUESTION: What are the best methods for tracking and/or automating DB schema changes? Our team uses Subversion for version control and we've been able to automate some of our tasks this way (pushing builds up to a staging server, deploying tested code to a production se...
[ "php", "mysql", "database", "svn", "migration" ]
139
57
44,917
20
0
2008-08-04T21:31:40.390000
2008-08-04T22:45:11.443000
1,610
1,621
Can I logically reorder columns in a table?
If I'm adding a column to a table in Microsoft SQL Server, can I control where the column is displayed logically in queries? I don't want to mess with the physical layout of columns on disk, but I would like to logically group columns together when possible so that tools like SQL Server Management Studio list the conte...
You can not do this programatically (in a safe way that is) without creating a new table. What Enterprise Manager does when you commit a reordering is to create a new table, move the data and then delete the old table and rename the new table to the existing name. If you want your columns in a particular order/grouping...
Can I logically reorder columns in a table? If I'm adding a column to a table in Microsoft SQL Server, can I control where the column is displayed logically in queries? I don't want to mess with the physical layout of columns on disk, but I would like to logically group columns together when possible so that tools like...
TITLE: Can I logically reorder columns in a table? QUESTION: If I'm adding a column to a table in Microsoft SQL Server, can I control where the column is displayed logically in queries? I don't want to mess with the physical layout of columns on disk, but I would like to logically group columns together when possible ...
[ "sql-server" ]
105
85
93,027
9
0
2008-08-04T21:37:31.720000
2008-08-04T21:54:18.707000
1,615
1,628
How can I modify .xfdl files? (Update #1)
The.XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications. I know how to view XFDL files using a file viewer I found h...
If the encoding is base64 then this is the solution I've stumbled upon on the web: "Decoding XDFL files saved with 'encoding=base64'. Files saved with: application/vnd.xfdl;content-encoding="base64-gzip" are simple base64-encoded gzip files. They can be easily restored to XML by first decoding and then unzipping them. ...
How can I modify .xfdl files? (Update #1) The.XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications. I know how to vie...
TITLE: How can I modify .xfdl files? (Update #1) QUESTION: The.XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications....
[ "ruby", "language-agnostic", "xfdl" ]
17
5
7,918
3
0
2008-08-04T21:42:37.933000
2008-08-04T22:02:35.180000
1,623
1,667
Folders or Projects in a Visual Studio Solution?
When spliting a solution in to logical layers, when is it best to use a separate project over just grouping by a folder?
By default, always just create new folder within the same project You will get single assembly (without additional ILMerge gymnastic) Easier to obfuscate (because you will have less public types and methods, ideally none at all) Separating your source code into multiple projects makes only sense if you... Have some por...
Folders or Projects in a Visual Studio Solution? When spliting a solution in to logical layers, when is it best to use a separate project over just grouping by a folder?
TITLE: Folders or Projects in a Visual Studio Solution? QUESTION: When spliting a solution in to logical layers, when is it best to use a separate project over just grouping by a folder? ANSWER: By default, always just create new folder within the same project You will get single assembly (without additional ILMerge ...
[ "visual-studio", "projects-and-solutions" ]
31
18
5,361
7
0
2008-08-04T22:00:41.347000
2008-08-04T22:45:32.940000
1,625
1,627
XML Editing/Viewing Software
What software is recommended for working with and editing large XML schemas? I'm looking for both Windows and Linux software (doesn't have to be cross platform, just want suggestions for both) that help with dealing with huge XML files.
I may be old fashioned, but I prefer my text editor. I use emacs, and it has a fairly decent xml mode. Most good text editors will have decent syntax hi-lighting and tag matching facilities. Your IDE might already do it (IntelliJ idea does, and I believe Eclipse does as well). Good text editors will be able to deal wit...
XML Editing/Viewing Software What software is recommended for working with and editing large XML schemas? I'm looking for both Windows and Linux software (doesn't have to be cross platform, just want suggestions for both) that help with dealing with huge XML files.
TITLE: XML Editing/Viewing Software QUESTION: What software is recommended for working with and editing large XML schemas? I'm looking for both Windows and Linux software (doesn't have to be cross platform, just want suggestions for both) that help with dealing with huge XML files. ANSWER: I may be old fashioned, but...
[ "windows", "xml", "linux" ]
40
9
19,050
17
0
2008-08-04T22:01:10.317000
2008-08-04T22:01:59.580000
1,669
1,672
Learning to write a compiler
Preferred languages: C/C++, Java, and Ruby. I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java, and Ruby, so I prefer resources that involve one of those three, but any good resource is acceptable.
Big List of Resources: A Nanopass Framework for Compiler Education ¶ Advanced Compiler Design and Implementation $ An Incremental Approach to Compiler Construction ¶ ANTLR 3.x Video Tutorial Basics of Compiler Design Building a Parrot Compiler Compiler Basics Compiler Construction $ Compiler Design and Construction $ C...
Learning to write a compiler Preferred languages: C/C++, Java, and Ruby. I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java, and Ruby, so I prefer resources that involve one of those three, but any good resource is accepta...
TITLE: Learning to write a compiler QUESTION: Preferred languages: C/C++, Java, and Ruby. I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java, and Ruby, so I prefer resources that involve one of those three, but any good r...
[ "compiler-construction", "language-agnostic" ]
697
1,196
361,322
38
0
2008-08-04T22:46:36.900000
2008-08-04T22:52:00.650000
1,679
1,704
How do I calculate these statistics?
I'm writing an app to help facilitate some research, and part of this involves doing some statistical calculations. Right now, the researchers are using a program called SPSS. Part of the output that they care about looks like this: They're really only concerned about the F and Sig. values. My problem is that I have no...
This website might help you out a bit more. Also this one. I'm working from a fairly rusty memory of a statistics course, but here goes nothing: When you're doing analysis of variance (ANOVA), you actually calculate the F statistic as the ratio from the mean-square variances "between the groups" and the mean-square var...
How do I calculate these statistics? I'm writing an app to help facilitate some research, and part of this involves doing some statistical calculations. Right now, the researchers are using a program called SPSS. Part of the output that they care about looks like this: They're really only concerned about the F and Sig....
TITLE: How do I calculate these statistics? QUESTION: I'm writing an app to help facilitate some research, and part of this involves doing some statistical calculations. Right now, the researchers are using a program called SPSS. Part of the output that they care about looks like this: They're really only concerned ab...
[ "statistics", "spss" ]
16
3
10,739
6
0
2008-08-04T22:56:45.540000
2008-08-04T23:32:54.797000
1,683
3,020
ASP.NET built in user profile vs. old style user class/tables
I am looking for guidance regarding the best practice around the use of the Profile feature in ASP.NET. How do you decide what should be kept in the built-in user Profile, or if you should create your own database table and add a column for the desired fields? For example, a user has a zip code, should I save the zip c...
Ive only built 2 applications that used the profile provider. Since then I have stayed away from using it. For both of the apps I used it to store information about the user such as their company name, address and phone number. This worked fine until our client wanted to be able to find a user by one of these fields. S...
ASP.NET built in user profile vs. old style user class/tables I am looking for guidance regarding the best practice around the use of the Profile feature in ASP.NET. How do you decide what should be kept in the built-in user Profile, or if you should create your own database table and add a column for the desired field...
TITLE: ASP.NET built in user profile vs. old style user class/tables QUESTION: I am looking for guidance regarding the best practice around the use of the Profile feature in ASP.NET. How do you decide what should be kept in the built-in user Profile, or if you should create your own database table and add a column for...
[ "asp.net", "profile" ]
24
11
3,568
5
0
2008-08-04T23:06:23.443000
2008-08-06T02:26:35.333000
1,709
1,724
How to pass enumerated values to a web service
My dilemma is, basically, how to share an enumeration between two applications. The users upload documents through a front-end application that is on the web. This application calls a web service of the back-end application and passes the document to it. The back-end app saves the document and inserts a row in the Docu...
I can only speak about.net, but if you have an ASP.net Webservice, you should be able to add an enumeration directly to it. When you then use the "Add Web Reference" in your Client Application, the resulting Class should include that enum But this is from the top of my head, i'm pretty sure i've done it in the past, bu...
How to pass enumerated values to a web service My dilemma is, basically, how to share an enumeration between two applications. The users upload documents through a front-end application that is on the web. This application calls a web service of the back-end application and passes the document to it. The back-end app s...
TITLE: How to pass enumerated values to a web service QUESTION: My dilemma is, basically, how to share an enumeration between two applications. The users upload documents through a front-end application that is on the web. This application calls a web service of the back-end application and passes the document to it. ...
[ "web-services", "application-integration" ]
24
3
18,290
8
0
2008-08-04T23:43:34.757000
2008-08-04T23:56:54.403000
1,734
1,780
Any experiences with Protocol Buffers?
I was just looking through some information about Google's protocol buffers data interchange format. Has anyone played around with the code or even created a project around it? I'm currently using XML in a Python project for structured content created by hand in a text editor, and I was wondering what the general opini...
If you are looking for user facing interaction, stick with xml. It has more support, understanding, and general acceptance currently. If it's internal, I would say that protocol buffers are a great idea. Maybe in a few years as more tools come out to support protocol buffers, then start looking towards that for a publi...
Any experiences with Protocol Buffers? I was just looking through some information about Google's protocol buffers data interchange format. Has anyone played around with the code or even created a project around it? I'm currently using XML in a Python project for structured content created by hand in a text editor, and...
TITLE: Any experiences with Protocol Buffers? QUESTION: I was just looking through some information about Google's protocol buffers data interchange format. Has anyone played around with the code or even created a project around it? I'm currently using XML in a Python project for structured content created by hand in ...
[ "python", "xml", "database", "protocol-buffers" ]
36
13
2,455
4
0
2008-08-05T00:12:55.290000
2008-08-05T01:14:30.423000
1,746
1,749
How can I get at the matches when using preg_replace in PHP?
I am trying to grab the capital letters of a couple of words and wrap them in span tags. I am using preg_replace for extract and wrapping purposes, but it's not outputting anything. preg_replace("/[A-Z]/", " $1 ", $str)
You need to put the pattern in parentheses /([A-Z])/, like this: preg_replace("/([A-Z])/", " $1 ", $str)
How can I get at the matches when using preg_replace in PHP? I am trying to grab the capital letters of a couple of words and wrap them in span tags. I am using preg_replace for extract and wrapping purposes, but it's not outputting anything. preg_replace("/[A-Z]/", " $1 ", $str)
TITLE: How can I get at the matches when using preg_replace in PHP? QUESTION: I am trying to grab the capital letters of a couple of words and wrap them in span tags. I am using preg_replace for extract and wrapping purposes, but it's not outputting anything. preg_replace("/[A-Z]/", " $1 ", $str) ANSWER: You need to ...
[ "php", "regex", "html-parsing", "preg-replace" ]
59
59
22,319
4
0
2008-08-05T00:35:17.493000
2008-08-05T00:36:08.350000
1,760
1,821
.NET unit testing packages
I am getting back into a bit more.NET after a few-years of not using it full-time and am wondering what the good unit testing packages are these days. I'm familiar with NUnit (a few years ago) and have played briefly around with IronRuby, with the goal of getting something like RSpec going, but I don't know much beyond...
There are so many it's crazy. Crazy good, I guess. For the conservative types (me), NUnit is still available and still more than capable. For the Microsoft-types, MSTest is adequate, but it is slow and clunky compared to NUnit. It also lacks code coverage without paying the big bucks for the pricey versions of Visual S...
.NET unit testing packages I am getting back into a bit more.NET after a few-years of not using it full-time and am wondering what the good unit testing packages are these days. I'm familiar with NUnit (a few years ago) and have played briefly around with IronRuby, with the goal of getting something like RSpec going, b...
TITLE: .NET unit testing packages QUESTION: I am getting back into a bit more.NET after a few-years of not using it full-time and am wondering what the good unit testing packages are these days. I'm familiar with NUnit (a few years ago) and have played briefly around with IronRuby, with the goal of getting something l...
[ "c#", ".net", "unit-testing", "testing" ]
63
55
11,645
11
0
2008-08-05T00:51:49.177000
2008-08-05T02:15:24.873000
1,762
1,771
Why is my ternary expression not working?
I am trying to set a flag to show or hide a page element, but it always displays even when the expression is false. $canMerge = ($condition1 && $condition2)? 'true': 'false';... Stuff What's up?
This is broken because 'false' as a string will evaluate to true as a boolean. However, this is an unneeded ternary expression, because the resulting values are simple true and false. This would be equivalent: $canMerge = ($condition1 && $condition2);
Why is my ternary expression not working? I am trying to set a flag to show or hide a page element, but it always displays even when the expression is false. $canMerge = ($condition1 && $condition2)? 'true': 'false';... Stuff What's up?
TITLE: Why is my ternary expression not working? QUESTION: I am trying to set a flag to show or hide a page element, but it always displays even when the expression is false. $canMerge = ($condition1 && $condition2)? 'true': 'false';... Stuff What's up? ANSWER: This is broken because 'false' as a string will evaluate...
[ "php", "ternary-operator" ]
26
41
1,142
5
0
2008-08-05T00:56:43.813000
2008-08-05T01:03:12.553000
1,790
2,017
Federated (Synced) Subversion servers?
Is it possible to create "federated" Subversion servers? As in one server at location A and another at location B that sync up their local versions of the repository automatically. That way when someone at either location interacts with the repository they are accessing their respective local server and therefore has f...
This is more or less the perfect use case for SVK. SVK is a command line front end for subversion that works with an entire local copy of the repository. So your commits, updates, etc. work on the local repository and you can then sync with a master. I would generally recommend SVK over plain subversion anyway as it ma...
Federated (Synced) Subversion servers? Is it possible to create "federated" Subversion servers? As in one server at location A and another at location B that sync up their local versions of the repository automatically. That way when someone at either location interacts with the repository they are accessing their resp...
TITLE: Federated (Synced) Subversion servers? QUESTION: Is it possible to create "federated" Subversion servers? As in one server at location A and another at location B that sync up their local versions of the repository automatically. That way when someone at either location interacts with the repository they are ac...
[ "svn", "version-control" ]
20
4
3,208
5
0
2008-08-05T01:27:34.610000
2008-08-05T08:22:05.943000
1,836
1,843
Wiggling the mouse
OK. This is a bit of a vanity app, but I had a situation today at work where I was in a training class and the machine was set to lock every 10 minutes. Well, if the trainers got excited about talking - as opposed to changing slides - the machine would lock up. I'd like to write a teeny app that has nothing but a taskb...
for C# 3.5 without notifyicon therefore you will need to terminate this application in task manager manually using System; using System.Drawing; using System.Windows.Forms; static class Program { static void Main() { Timer timer = new Timer(); // timer.Interval = 4 minutes timer.Interval = (int)(TimeSpan.TicksPerMinut...
Wiggling the mouse OK. This is a bit of a vanity app, but I had a situation today at work where I was in a training class and the machine was set to lock every 10 minutes. Well, if the trainers got excited about talking - as opposed to changing slides - the machine would lock up. I'd like to write a teeny app that has ...
TITLE: Wiggling the mouse QUESTION: OK. This is a bit of a vanity app, but I had a situation today at work where I was in a training class and the machine was set to lock every 10 minutes. Well, if the trainers got excited about talking - as opposed to changing slides - the machine would lock up. I'd like to write a t...
[ "c#", "winapi", "mouse" ]
41
28
17,631
6
0
2008-08-05T02:51:37.420000
2008-08-05T03:00:24.750000
1,848
1,856
Locating Text within image
I am currently working on a project and my goal is to locate text in an image. OCR'ing the text is not my intention as of yet. I want to basically obtain the bounds of text within an image. I am using the AForge.Net imaging component for manipulation. Any assistance in some sense or another? Update 2/5/09: I've since w...
This is an active area of research. There are literally oodles of academic papers on the subject. It's going to be difficult to give you assistance especially w/o more deatails. Are you looking for specific types of text? Fonts? English-only? Are you familiar with the academic literature? "Text detection" is a standard...
Locating Text within image I am currently working on a project and my goal is to locate text in an image. OCR'ing the text is not my intention as of yet. I want to basically obtain the bounds of text within an image. I am using the AForge.Net imaging component for manipulation. Any assistance in some sense or another? ...
TITLE: Locating Text within image QUESTION: I am currently working on a project and my goal is to locate text in an image. OCR'ing the text is not my intention as of yet. I want to basically obtain the bounds of text within an image. I am using the AForge.Net imaging component for manipulation. Any assistance in some ...
[ "c#", "image", "image-processing", "artificial-intelligence" ]
30
14
6,130
4
0
2008-08-05T03:04:43.683000
2008-08-05T03:24:27.840000
1,854
1,857
How to identify which OS Python is running on
What do I need to look at to see whether I'm on Windows or Unix, etc.?
>>> import os >>> os.name 'posix' >>> import platform >>> platform.system() 'Linux' >>> platform.release() '2.6.22-15-generic' The output of platform.system() is as follows: Linux: Linux Mac: Darwin Windows: Windows See: platform — Access to underlying platform’s identifying data
How to identify which OS Python is running on What do I need to look at to see whether I'm on Windows or Unix, etc.?
TITLE: How to identify which OS Python is running on QUESTION: What do I need to look at to see whether I'm on Windows or Unix, etc.? ANSWER: >>> import os >>> os.name 'posix' >>> import platform >>> platform.system() 'Linux' >>> platform.release() '2.6.22-15-generic' The output of platform.system() is as follows...
[ "python", "operating-system", "cross-platform", "platform-agnostic" ]
953
1,265
520,422
27
0
2008-08-05T03:23:18.917000
2008-08-05T03:27:03.760000
1,873
1,886
Triple Quotes? How do I delimit a databound Javascript string parameter in ASP.NET?
How do I delimit a Javascript data-bound string parameter in an anchor OnClick event? I have an anchor tag in an ASP.NET Repeater control. The OnClick event of the anchor contains a call to a Javascript function. The Javascript function takes a string for its input parameter. The string parameter is populated with a da...
I had recently similar problem and the only way to solve it was to use plain old HTML codes for single ( ' ) and double quotes ( " ). Source code was total mess of course but it worked. Try Show/Hide or Show/Hide
Triple Quotes? How do I delimit a databound Javascript string parameter in ASP.NET? How do I delimit a Javascript data-bound string parameter in an anchor OnClick event? I have an anchor tag in an ASP.NET Repeater control. The OnClick event of the anchor contains a call to a Javascript function. The Javascript function...
TITLE: Triple Quotes? How do I delimit a databound Javascript string parameter in ASP.NET? QUESTION: How do I delimit a Javascript data-bound string parameter in an anchor OnClick event? I have an anchor tag in an ASP.NET Repeater control. The OnClick event of the anchor contains a call to a Javascript function. The J...
[ "asp.net", "javascript", "anchor", "quotes" ]
47
32
23,470
5
0
2008-08-05T04:05:53.230000
2008-08-05T04:28:21.983000
1,908
1,945
How to map a latitude/longitude to a distorted map?
I have a bunch of latitude/longitude pairs that map to known x/y coordinates on a (geographically distorted) map. Then I have one more latitude/longitude pair. I want to plot it on the map as best is possible. How do I go about doing this? At first I decided to create a system of linear equations for the three nearest ...
Are there any more specific details on the kind of distortion? If, for example, your latitudes and longitudes are "distorted" onto your 2D map using a Mercator projection, the conversion math is readily available. If the map is distorted truly arbitrarily, there are lots of things you could try, but the simplest would ...
How to map a latitude/longitude to a distorted map? I have a bunch of latitude/longitude pairs that map to known x/y coordinates on a (geographically distorted) map. Then I have one more latitude/longitude pair. I want to plot it on the map as best is possible. How do I go about doing this? At first I decided to create...
TITLE: How to map a latitude/longitude to a distorted map? QUESTION: I have a bunch of latitude/longitude pairs that map to known x/y coordinates on a (geographically distorted) map. Then I have one more latitude/longitude pair. I want to plot it on the map as best is possible. How do I go about doing this? At first I...
[ "math", "maps", "mapping", "latitude-longitude" ]
25
8
6,451
4
0
2008-08-05T04:55:28.683000
2008-08-05T05:48:22.353000
1,936
1,940
How to RedirectToAction in ASP.NET MVC without losing request data
Using ASP.NET MVC there are situations (such as form submission) that may require a RedirectToAction. One such situation is when you encounter validation errors after a form submission and need to redirect back to the form, but would like the URL to reflect the URL of the form, not the action page it submits to. As I r...
The solution is to use the TempData property to store the desired Request components. For instance: public ActionResult Send() { TempData["form"] = Request.Form; return this.RedirectToAction(a => a.Form()); } Then in your "Form" action you can go: public ActionResult Form() { /* Declare viewData etc. */ if (TempData["...
How to RedirectToAction in ASP.NET MVC without losing request data Using ASP.NET MVC there are situations (such as form submission) that may require a RedirectToAction. One such situation is when you encounter validation errors after a form submission and need to redirect back to the form, but would like the URL to ref...
TITLE: How to RedirectToAction in ASP.NET MVC without losing request data QUESTION: Using ASP.NET MVC there are situations (such as form submission) that may require a RedirectToAction. One such situation is when you encounter validation errors after a form submission and need to redirect back to the form, but would l...
[ "c#", "asp.net-mvc" ]
123
82
93,516
6
0
2008-08-05T05:33:41.697000
2008-08-05T05:43:27.900000
1,949
5,310
Are Multiple DataContext classes ever appropriate?
In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary to create DataContext classes (which is usually done using the designer in VS 2008). From the UI perspective, the DataContext is a design of the sections of your database that you would like to expose to through LinqToSql and is integral in ...
I disagree with John's answer. The DataContext (or Linq to Entities ObjectContext) is more of a "unit of work" than a connection. It manages change tracking, etc. See this blog post for a description: Lifetime of a LINQ to SQL DataContext The four main points of this blog post are that DataContext: Is ideally suited fo...
Are Multiple DataContext classes ever appropriate? In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary to create DataContext classes (which is usually done using the designer in VS 2008). From the UI perspective, the DataContext is a design of the sections of your database that you would like...
TITLE: Are Multiple DataContext classes ever appropriate? QUESTION: In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary to create DataContext classes (which is usually done using the designer in VS 2008). From the UI perspective, the DataContext is a design of the sections of your database t...
[ "asp.net", ".net", "linq-to-sql", "datacontext" ]
32
28
5,860
5
0
2008-08-05T05:54:34.697000
2008-08-07T21:02:30.057000
1,982
47,086
CPU throttling in C++
I was just wondering if there is an elegant way to set the maximum CPU load for a particular thread doing intensive calculations. Right now I have located the most time-consuming loop in the thread (it does only compression) and use GetTickCount() and Sleep() with hardcoded values. It makes sure that the loop continues...
I am not aware of any API to do get the OS's scheduler to do what you want (even if your thread is idle-priority, if there are no higher-priority ready threads, yours will run). However, I think you can improvise a fairly elegant throttling function based on what you are already doing. Essentially (I don't have a Windo...
CPU throttling in C++ I was just wondering if there is an elegant way to set the maximum CPU load for a particular thread doing intensive calculations. Right now I have located the most time-consuming loop in the thread (it does only compression) and use GetTickCount() and Sleep() with hardcoded values. It makes sure t...
TITLE: CPU throttling in C++ QUESTION: I was just wondering if there is an elegant way to set the maximum CPU load for a particular thread doing intensive calculations. Right now I have located the most time-consuming loop in the thread (it does only compression) and use GetTickCount() and Sleep() with hardcoded value...
[ "c++", "performance", "cpu", "throttling" ]
49
22
6,095
5
0
2008-08-05T07:11:08.427000
2008-09-05T23:33:42.087000
1,983
2,277
Python: what is the difference between (1,2,3) and [1,2,3], and when should I use each?
In many places, (1,2,3) (a tuple) and [1,2,3] (a list) can be used interchangeably. When should I use one or the other, and why?
From the Python FAQ: Lists and tuples, while similar in many respects, are generally used in fundamentally different ways. Tuples can be thought of as being similar to Pascal records or C structs; they're small collections of related data which may be of different types which are operated on as a group. For example, a ...
Python: what is the difference between (1,2,3) and [1,2,3], and when should I use each? In many places, (1,2,3) (a tuple) and [1,2,3] (a list) can be used interchangeably. When should I use one or the other, and why?
TITLE: Python: what is the difference between (1,2,3) and [1,2,3], and when should I use each? QUESTION: In many places, (1,2,3) (a tuple) and [1,2,3] (a list) can be used interchangeably. When should I use one or the other, and why? ANSWER: From the Python FAQ: Lists and tuples, while similar in many respects, are g...
[ "python", "list", "tuples" ]
60
36
18,463
18
0
2008-08-05T07:18:55.853000
2008-08-05T13:22:43.030000
1,988
63,737
How far can LISP macros go?
I have read a lot that LISP can redefine syntax on the fly, presumably with macros. I am curious how far does this actually go? Can you redefine the language structure so much that it borderline becomes a compiler for another language? For example, could you change the functional nature of LISP into a more object orien...
That's a really good question. I think it's nuanced but definitely answerable: Macros are not stuck in s-expressions. See the LOOP macro for a very complex language written using keywords (symbols). So, while you may start and end the loop with parentheses, inside it has its own syntax. Example: (loop for x from 0 belo...
How far can LISP macros go? I have read a lot that LISP can redefine syntax on the fly, presumably with macros. I am curious how far does this actually go? Can you redefine the language structure so much that it borderline becomes a compiler for another language? For example, could you change the functional nature of L...
TITLE: How far can LISP macros go? QUESTION: I have read a lot that LISP can redefine syntax on the fly, presumably with macros. I am curious how far does this actually go? Can you redefine the language structure so much that it borderline becomes a compiler for another language? For example, could you change the func...
[ "macros", "lisp" ]
50
36
7,515
14
0
2008-08-05T07:32:54.437000
2008-09-15T15:07:21.940000
2,034
2,036
What do the result codes in SVN mean?
What do the result codes in SVN mean? I need a quick reference.
For additional details see the SVNBook: "Status of working copy files and directories". The common statuses: U: Working file was updated G: Changes on the repo were automatically merged into the working copy M: Working copy is modified C: This file conflicts with the version in the repo?: This file is not under version...
What do the result codes in SVN mean? What do the result codes in SVN mean? I need a quick reference.
TITLE: What do the result codes in SVN mean? QUESTION: What do the result codes in SVN mean? I need a quick reference. ANSWER: For additional details see the SVNBook: "Status of working copy files and directories". The common statuses: U: Working file was updated G: Changes on the repo were automatically merged into ...
[ "svn" ]
318
545
227,216
9
0
2008-08-05T09:11:54.877000
2008-08-05T09:12:29.947000
2,041
2,310
How do I create a branch?
How do I create a branch in SVN?
Branching in Subversion is facilitated by a very very light and efficient copying facility. Branching and tagging are effectively the same. Just copy a whole folder in the repository to somewhere else in the repository using the svn copy command. Basically this means that it is by convention what copying a folder means...
How do I create a branch? How do I create a branch in SVN?
TITLE: How do I create a branch? QUESTION: How do I create a branch in SVN? ANSWER: Branching in Subversion is facilitated by a very very light and efficient copying facility. Branching and tagging are effectively the same. Just copy a whole folder in the repository to somewhere else in the repository using the svn c...
[ "svn", "version-control", "branch", "branching-and-merging" ]
671
377
702,296
10
0
2008-08-05T09:25:29
2008-08-05T13:40:20.777000
2,043
2,044
Can a Windows dll retrieve its own filename?
A Windows process created from an exe file has access to the command string that invoked it, including its file's path and filename. eg. C:\MyApp\MyApp.exe --help. But this is not so for a DLL invoked via LoadLibrary. Does anyone know of a way for a function loaded via DLL to find out what its path and filename are? Sp...
I think you're looking for GetModuleFileName. http://www.swissdelphicenter.ch/torry/showcode.php?id=143: { If you are working on a DLL and are interested in the filename of the DLL rather than the filename of the application, then you can use this function: } function GetModuleName: string; var szFileName: array[0..MA...
Can a Windows dll retrieve its own filename? A Windows process created from an exe file has access to the command string that invoked it, including its file's path and filename. eg. C:\MyApp\MyApp.exe --help. But this is not so for a DLL invoked via LoadLibrary. Does anyone know of a way for a function loaded via DLL t...
TITLE: Can a Windows dll retrieve its own filename? QUESTION: A Windows process created from an exe file has access to the command string that invoked it, including its file's path and filename. eg. C:\MyApp\MyApp.exe --help. But this is not so for a DLL invoked via LoadLibrary. Does anyone know of a way for a functio...
[ "windows", "delphi", "winapi", "dll", "path" ]
34
41
10,492
2
0
2008-08-05T09:34:49.073000
2008-08-05T09:37:13.577000
2,046
7,641
How do I unit test persistence?
As a novice in practicing test-driven development, I often end up in a quandary as to how to unit test persistence to a database. I know that technically this would be an integration test (not a unit test), but I want to find out the best strategies for the following: Testing queries. Testing inserts. How do I know tha...
Look into DB Unit. It is a Java library, but there must be a C# equivalent. It lets you prepare the database with a set of data so that you know what is in the database, then you can interface with DB Unit to see what is in the database. It can run against many database systems, so you can use your actual database setu...
How do I unit test persistence? As a novice in practicing test-driven development, I often end up in a quandary as to how to unit test persistence to a database. I know that technically this would be an integration test (not a unit test), but I want to find out the best strategies for the following: Testing queries. Te...
TITLE: How do I unit test persistence? QUESTION: As a novice in practicing test-driven development, I often end up in a quandary as to how to unit test persistence to a database. I know that technically this would be an integration test (not a unit test), but I want to find out the best strategies for the following: T...
[ "sql-server", "unit-testing", "tdd" ]
50
18
9,373
10
0
2008-08-05T09:43:01.257000
2008-08-11T09:40:44.607000
2,048
2,080
Monitor a specific RSS
For all the RSS feeds I subscribe to I use Google Reader, which I love. I do however have a couple of specific RSS feeds that I'd like to be notified of as soon as they get updated (say, for example, an RSS feed for a forum I like to monitor and respond to as quickly as possible). Are there any tools out there for this...
If you have access to Microsoft Outlook 2007 or Thunderbird, these email clients allow you to add RSS feeds in the same way you would add an email account. I use Google Reader generally but when I want to keep up-to-date with something specific, I add the RSS feed to Outlook and it arrives in my inbox as if it was an e...
Monitor a specific RSS For all the RSS feeds I subscribe to I use Google Reader, which I love. I do however have a couple of specific RSS feeds that I'd like to be notified of as soon as they get updated (say, for example, an RSS feed for a forum I like to monitor and respond to as quickly as possible). Are there any t...
TITLE: Monitor a specific RSS QUESTION: For all the RSS feeds I subscribe to I use Google Reader, which I love. I do however have a couple of specific RSS feeds that I'd like to be notified of as soon as they get updated (say, for example, an RSS feed for a forum I like to monitor and respond to as quickly as possible...
[ "rss" ]
13
4
4,075
9
0
2008-08-05T09:45:41.377000
2008-08-05T10:50:35.393000
2,056
101,561
What are MVP and MVC and what is the difference?
When looking beyond the RAD (drag-drop and configure) way of building user interfaces that many tools encourage you are likely to come across three design patterns called Model-View-Controller, Model-View-Presenter and Model-View-ViewModel. My question has three parts to it: What issues do these patterns address? How a...
Model-View-Presenter In MVP, the Presenter contains the UI business logic for the View. All invocations from the View delegate directly to the Presenter. The Presenter is also decoupled directly from the View and talks to it through an interface. This is to allow mocking of the View in a unit test. One common attribute...
What are MVP and MVC and what is the difference? When looking beyond the RAD (drag-drop and configure) way of building user interfaces that many tools encourage you are likely to come across three design patterns called Model-View-Controller, Model-View-Presenter and Model-View-ViewModel. My question has three parts to...
TITLE: What are MVP and MVC and what is the difference? QUESTION: When looking beyond the RAD (drag-drop and configure) way of building user interfaces that many tools encourage you are likely to come across three design patterns called Model-View-Controller, Model-View-Presenter and Model-View-ViewModel. My question ...
[ "user-interface", "model-view-controller", "design-patterns", "terminology", "mvp" ]
2,368
2,130
570,601
24
0
2008-08-05T10:06:33.020000
2008-09-19T12:46:52.687000
2,120
2,382
Convert HashBytes to VarChar
I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command: SELECT HashBytes('MD5', 'HelloWorld') However, this returns a VarBinary instead of a VarChar value. If I attempt to convert 0x68E109F0F40CA72A15E05CC22786F8E6 into a VarChar I get há ðô§*à\Â'†øæ instead of 68E109F0F40...
I have found the solution else where: SELECT SUBSTRING(master.dbo.fn_varbintohexstr(HashBytes('MD5', 'HelloWorld')), 3, 32)
Convert HashBytes to VarChar I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command: SELECT HashBytes('MD5', 'HelloWorld') However, this returns a VarBinary instead of a VarChar value. If I attempt to convert 0x68E109F0F40CA72A15E05CC22786F8E6 into a VarChar I get há ðô§*à...
TITLE: Convert HashBytes to VarChar QUESTION: I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command: SELECT HashBytes('MD5', 'HelloWorld') However, this returns a VarBinary instead of a VarChar value. If I attempt to convert 0x68E109F0F40CA72A15E05CC22786F8E6 into a VarC...
[ "sql", "sql-server" ]
141
163
165,677
7
0
2008-08-05T11:49:11.360000
2008-08-05T14:26:41.870000
2,123
2,223
How do I make a checkbox toggle from clicking on the text label as well?
Checkboxes in HTML forms don't have implicit labels with them. Adding an explicit label (some text) next to it doesn't toggle the checkbox. How do I make a checkbox toggle from clicking on the text label as well?
Set the CSS display property for the label to be a block element and use that instead of your div - it keeps the semantic meaning of a label while allowing whatever styling you like. For example: label { width: 100px; height: 100px; display: block; background-color: #e0e0ff; } A ticky box!
How do I make a checkbox toggle from clicking on the text label as well? Checkboxes in HTML forms don't have implicit labels with them. Adding an explicit label (some text) next to it doesn't toggle the checkbox. How do I make a checkbox toggle from clicking on the text label as well?
TITLE: How do I make a checkbox toggle from clicking on the text label as well? QUESTION: Checkboxes in HTML forms don't have implicit labels with them. Adding an explicit label (some text) next to it doesn't toggle the checkbox. How do I make a checkbox toggle from clicking on the text label as well? ANSWER: Set the...
[ "html", "checkbox" ]
47
26
32,530
8
0
2008-08-05T11:51:16.507000
2008-08-05T12:52:50.047000
2,134
2,183
Do sealed classes really offer performance benefits?
I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits. I ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing the case where sealed classes will give better results? Has anyone run te...
The JITter will sometimes use non-virtual calls to methods in sealed classes since there is no way they can be extended further. There are complex rules regarding calling type, virtual/nonvirtual, and I don't know them all so I can't really outline them for you, but if you google for sealed classes and virtual methods ...
Do sealed classes really offer performance benefits? I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits. I ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing the case where seale...
TITLE: Do sealed classes really offer performance benefits? QUESTION: I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits. I ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing th...
[ ".net", "performance", "optimization" ]
171
65
42,794
13
0
2008-08-05T12:00:28.733000
2008-08-05T12:32:40.510000
2,138
2,147
LINQ on the .NET 2.0 Runtime
Can a LINQ enabled app run on a machine that only has the.NET 2.0 runtime installed? In theory, LINQ is nothing more than syntactic sugar, and the resulting IL code should look the same as it would have in.NET 2.0. How can I write LINQ without using the.NET 3.5 libraries? Will it run on.NET 2.0?
There are some "Hacks" that involve using a System.Core.dll from the 3.5 Framework to make it run with.net 2.0, but personally I would not want use such a somewhat shaky foundation. See here: LINQ support on.NET 2.0 Create a new console application Keep only System and System.Core as referenced assemblies Set Copy Loca...
LINQ on the .NET 2.0 Runtime Can a LINQ enabled app run on a machine that only has the.NET 2.0 runtime installed? In theory, LINQ is nothing more than syntactic sugar, and the resulting IL code should look the same as it would have in.NET 2.0. How can I write LINQ without using the.NET 3.5 libraries? Will it run on.NET...
TITLE: LINQ on the .NET 2.0 Runtime QUESTION: Can a LINQ enabled app run on a machine that only has the.NET 2.0 runtime installed? In theory, LINQ is nothing more than syntactic sugar, and the resulting IL code should look the same as it would have in.NET 2.0. How can I write LINQ without using the.NET 3.5 libraries? ...
[ ".net", "linq", ".net-3.5", ".net-2.0", "clr" ]
61
34
57,342
8
0
2008-08-05T12:03:10.927000
2008-08-05T12:07:41.603000
2,154
2,335
Developing for ASP.NET-MVC without Visual Studio
Instead of writing my ASP.NET C# applications in Visual Studio, I used my favorite text editor UltraEdit32. Is there any way I can implement MVC without the use of VS?
There is nothing VS specific with the MVC framework - it is just a bunch of DLLs that you can use. The wizards in VS just build you a quick-start framework. ASP.NET MVC is "bin-deployable" - there is nothing too clever to set up on the server either - just point the wildcard ISAPI filter to ASP.NET
Developing for ASP.NET-MVC without Visual Studio Instead of writing my ASP.NET C# applications in Visual Studio, I used my favorite text editor UltraEdit32. Is there any way I can implement MVC without the use of VS?
TITLE: Developing for ASP.NET-MVC without Visual Studio QUESTION: Instead of writing my ASP.NET C# applications in Visual Studio, I used my favorite text editor UltraEdit32. Is there any way I can implement MVC without the use of VS? ANSWER: There is nothing VS specific with the MVC framework - it is just a bunch of ...
[ "c#", "asp.net-mvc", "visual-studio" ]
31
12
6,383
4
0
2008-08-05T12:13:40.483000
2008-08-05T13:58:52.473000
2,155
2,928
How do I define custom web.config sections with potential child elements and attributes for the properties?
The web applications I develop often require co-dependent configuration settings and there are also settings that have to change as we move between each of our environments. All our settings are currently simple key-value pairs but it would be useful to create custom config sections so that it is obvious when two value...
Using attributes, child config sections and constraints There is also the possibility to use attributes which automatically takes care of the plumbing, as well as providing the ability to easily add constraints. I here present an example from code I use myself in one of my sites. With a constraint I dictate the maximum...
How do I define custom web.config sections with potential child elements and attributes for the properties? The web applications I develop often require co-dependent configuration settings and there are also settings that have to change as we move between each of our environments. All our settings are currently simple ...
TITLE: How do I define custom web.config sections with potential child elements and attributes for the properties? QUESTION: The web applications I develop often require co-dependent configuration settings and there are also settings that have to change as we move between each of our environments. All our settings are...
[ "asp.net" ]
72
84
44,592
5
0
2008-08-05T12:13:40.640000
2008-08-05T22:17:29.610000
2,158
2,245
Creating a custom JButton in Java
Is there a way to create a JButton with your own button graphic and not just with an image inside the button? If not, is there another way to create a custom JButton in java?
When I was first learning Java we had to make Yahtzee and I thought it would be cool to create custom Swing components and containers instead of just drawing everything on one JPanel. The benefit of extending Swing components, of course, is to have the ability to add support for keyboard shortcuts and other accessibili...
Creating a custom JButton in Java Is there a way to create a JButton with your own button graphic and not just with an image inside the button? If not, is there another way to create a custom JButton in java?
TITLE: Creating a custom JButton in Java QUESTION: Is there a way to create a JButton with your own button graphic and not just with an image inside the button? If not, is there another way to create a custom JButton in java? ANSWER: When I was first learning Java we had to make Yahtzee and I thought it would be cool...
[ "java", "swing", "jbutton" ]
104
99
114,853
5
0
2008-08-05T12:15:08.283000
2008-08-05T13:03:43.707000
2,196
2,373
Easy way to AJAX WebControls
I've got a web application that I'm trying to optimize. Some of the controls are hidden in dialog-style DIVs. So, I'd like to have them load in via AJAX only when the user wants to see them. This is fine for controls that are mostly literal-based (various menus and widgets), but when I have what I call "dirty" controls...
Check out the RadAjax control from Telerik - it allows you to avoid using UpdatePanels, and limit the amount of info passed back and forth between server and client by declaring direct relationships between calling controls, and controls that should be "Ajaxified" when the calling controls submit postbacks.
Easy way to AJAX WebControls I've got a web application that I'm trying to optimize. Some of the controls are hidden in dialog-style DIVs. So, I'd like to have them load in via AJAX only when the user wants to see them. This is fine for controls that are mostly literal-based (various menus and widgets), but when I have...
TITLE: Easy way to AJAX WebControls QUESTION: I've got a web application that I'm trying to optimize. Some of the controls are hidden in dialog-style DIVs. So, I'd like to have them load in via AJAX only when the user wants to see them. This is fine for controls that are mostly literal-based (various menus and widgets...
[ "asp.net", "ajax", "web-controls" ]
20
5
1,027
3
0
2008-08-05T12:40:30.680000
2008-08-05T14:19:26.860000
2,209
2,233
How can I change the background of a masterpage from the code behind of a content page?
I specifically want to add the style of background-color to the tag of a master page, from the code behind (C#) of a content page that uses that master page. I have different content pages that need to make the master page has different colors depending on which content page is loaded, so that the master page matches t...
What I would do for the particular case is: i. Define the body as a server side control ii. In your content aspx page, register the MasterPage with the register: <% MasterPageFile="..." %> iii. In the Content Page, you can now simply use Master.FindControl("masterpageBody") and have access to the control. Now, you can ...
How can I change the background of a masterpage from the code behind of a content page? I specifically want to add the style of background-color to the tag of a master page, from the code behind (C#) of a content page that uses that master page. I have different content pages that need to make the master page has diffe...
TITLE: How can I change the background of a masterpage from the code behind of a content page? QUESTION: I specifically want to add the style of background-color to the tag of a master page, from the code behind (C#) of a content page that uses that master page. I have different content pages that need to make the mas...
[ "c#", "asp.net", ".net", "master-pages" ]
25
10
13,982
3
0
2008-08-05T12:46:45.003000
2008-08-05T12:56:54.220000
2,214
3,443
What's the best way to implement BDD/TDD in .NET 2.0?
I'm looking to add a testing suite to my application, however I can't move to the newer testing frameworks for.NET 3.5. Does anyone have a suggestion about good testing frameworks to use?
We use MbUnit and Rihno Mocks and they prove to work very well together. When doing TDD you will almost certainly need to do some form of dependency injection, while this can be done manually, its worth looking at an IoC container such as Castle Windsor. It well worth looking at John Paul Bodhood's screen casts to get ...
What's the best way to implement BDD/TDD in .NET 2.0? I'm looking to add a testing suite to my application, however I can't move to the newer testing frameworks for.NET 3.5. Does anyone have a suggestion about good testing frameworks to use?
TITLE: What's the best way to implement BDD/TDD in .NET 2.0? QUESTION: I'm looking to add a testing suite to my application, however I can't move to the newer testing frameworks for.NET 3.5. Does anyone have a suggestion about good testing frameworks to use? ANSWER: We use MbUnit and Rihno Mocks and they prove to wor...
[ "c#", ".net", "testing", "tdd", "bdd" ]
26
9
3,198
12
0
2008-08-05T12:50:15.543000
2008-08-06T14:16:35.790000
2,222
8,753
How can I unit test Flex applications from within the IDE or a build script?
I'm currently working on an application with a frontend written in Adobe Flex 3. I'm aware of FlexUnit but what I'd really like is a unit test runner for Ant/NAnt and a runner that integrates with the Flex Builder IDE (AKA Eclipse). Does one exist? Also, are there any other resources on how to do Flex development "the ...
The dpUint testing framework has a test runner built with AIR which can be integrated with a build script. There is also my FlexUnit automation kit which does more or less the same for FlexUnit. It has an Ant macro that makes it possible to run the tests as a part of an Ant script, for example:
How can I unit test Flex applications from within the IDE or a build script? I'm currently working on an application with a frontend written in Adobe Flex 3. I'm aware of FlexUnit but what I'd really like is a unit test runner for Ant/NAnt and a runner that integrates with the Flex Builder IDE (AKA Eclipse). Does one e...
TITLE: How can I unit test Flex applications from within the IDE or a build script? QUESTION: I'm currently working on an application with a frontend written in Adobe Flex 3. I'm aware of FlexUnit but what I'd really like is a unit test runner for Ant/NAnt and a runner that integrates with the Flex Builder IDE (AKA Ec...
[ "apache-flex", "eclipse", "unit-testing", "build-automation", "cairngorm" ]
18
5
2,752
4
0
2008-08-05T12:52:42.573000
2008-08-12T12:28:18.340000
2,232
2,400
How to call shell commands from Ruby
How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
This explanation is based on a commented Ruby script from a friend of mine. If you want to improve the script, feel free to update it at the link. First, note that when Ruby calls out to a shell, it typically calls /bin/sh, not Bash. Some Bash syntax is not supported by /bin/sh on all systems. Here are ways to execute ...
How to call shell commands from Ruby How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
TITLE: How to call shell commands from Ruby QUESTION: How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby? ANSWER: This explanation is based on a commented Ruby script from a friend of mine. If you want to improve the script, feel free to update it a...
[ "ruby", "shell", "interop" ]
1,264
1,473
646,565
22
0
2008-08-05T12:56:52.770000
2008-08-05T14:42:45.927000
2,250
2,258
Datatable vs Dataset
I currently use a DataTable to get results from a database which I can use in my code. However, many example on the web show using a DataSet instead and accessing the table(s) through the collections method. Is there any advantage, performance wise or otherwise, of using DataSets or DataTables as a storage method for S...
It really depends on the sort of data you're bringing back. Since a DataSet is (in effect) just a collection of DataTable objects, you can return multiple distinct sets of data into a single, and therefore more manageable, object. Performance-wise, you're more likely to get inefficiency from unoptimized queries than fr...
Datatable vs Dataset I currently use a DataTable to get results from a database which I can use in my code. However, many example on the web show using a DataSet instead and accessing the table(s) through the collections method. Is there any advantage, performance wise or otherwise, of using DataSets or DataTables as a...
TITLE: Datatable vs Dataset QUESTION: I currently use a DataTable to get results from a database which I can use in my code. However, many example on the web show using a DataSet instead and accessing the table(s) through the collections method. Is there any advantage, performance wise or otherwise, of using DataSets ...
[ "c#", "dataset", "datatable" ]
144
104
135,245
7
0
2008-08-05T13:07:40.563000
2008-08-05T13:12:15.873000
2,256
2,490
Mapping Stream data to data structures in C#
Is there a way of mapping data collected on a stream or array to a data structure or vice-versa? In C++ this would simply be a matter of casting a pointer to the stream as a data type I want to use (or vice-versa for the reverse). e.g in C++: Mystruct * pMyStrct = (Mystruct*)&SomeDataStream pMyStrct->Item1 = 25; int i...
Most people use.NET serialization (there is faster binary and slower XML formatter, they both depend on reflection and are version tolerant to certain degree) However, if you want the fastest (unsafe) way - why not: Writing: YourStruct o = new YourStruct(); byte[] buffer = new byte[Marshal.SizeOf(typeof(YourStruct))]; ...
Mapping Stream data to data structures in C# Is there a way of mapping data collected on a stream or array to a data structure or vice-versa? In C++ this would simply be a matter of casting a pointer to the stream as a data type I want to use (or vice-versa for the reverse). e.g in C++: Mystruct * pMyStrct = (Mystruct*...
TITLE: Mapping Stream data to data structures in C# QUESTION: Is there a way of mapping data collected on a stream or array to a data structure or vice-versa? In C++ this would simply be a matter of casting a pointer to the stream as a data type I want to use (or vice-versa for the reverse). e.g in C++: Mystruct * pMy...
[ "c#", "c++", "data-structures" ]
29
20
8,509
4
0
2008-08-05T13:11:14.223000
2008-08-05T15:46:35.157000
2,262
2,268
ASP.NET URL Rewriting
How do I rewrite a URL in ASP.NET? I would like users to be able to go to http://www.website.com/users/smith instead of http://www.website.com/?user=smith
Try the Managed Fusion Url Rewriter and Reverse Proxy: http://urlrewriter.codeplex.com The rule for rewriting this would be: # clean up old rules and forward to new URL RewriteRule ^/?user=(.*) /users/$1 [NC,R=301] # rewrite the rule internally RewriteRule ^/users/(.*) /?user=$1 [NC,L]
ASP.NET URL Rewriting How do I rewrite a URL in ASP.NET? I would like users to be able to go to http://www.website.com/users/smith instead of http://www.website.com/?user=smith
TITLE: ASP.NET URL Rewriting QUESTION: How do I rewrite a URL in ASP.NET? I would like users to be able to go to http://www.website.com/users/smith instead of http://www.website.com/?user=smith ANSWER: Try the Managed Fusion Url Rewriter and Reverse Proxy: http://urlrewriter.codeplex.com The rule for rewriting this w...
[ "asp.net", "url", "url-rewriting", "url-routing" ]
36
25
10,666
3
0
2008-08-05T13:14:48.350000
2008-08-05T13:18:39.340000
2,279
2,314
Add Custom Tag to Visual Studio Validation
How can I add rules to Visual Studio (2005 and up) for validating property markup (HTML) for a vendor's proprietary controls? My client uses a control which requires several properties to be set as tags in the aspx file which generates something like 215 validation errors on each build. It's not preventing me from buil...
Right-click on the Source view of an HTML / ASP page and select "Formatting and Validation". Click "Tag Specific Options". Expand "Client HTML Tags" and select the heading. Click "New Tag...". And just fill it in! I wish that I could add custom CSS values as well.
Add Custom Tag to Visual Studio Validation How can I add rules to Visual Studio (2005 and up) for validating property markup (HTML) for a vendor's proprietary controls? My client uses a control which requires several properties to be set as tags in the aspx file which generates something like 215 validation errors on e...
TITLE: Add Custom Tag to Visual Studio Validation QUESTION: How can I add rules to Visual Studio (2005 and up) for validating property markup (HTML) for a vendor's proprietary controls? My client uses a control which requires several properties to be set as tags in the aspx file which generates something like 215 vali...
[ "visual-studio" ]
19
5
1,836
1
0
2008-08-05T13:24:11.763000
2008-08-05T13:43:27.387000
2,300
2,312
How do I traverse a collection in classic ASP?
I want to be able to do: For Each thing In things End For CLASSIC ASP - NOT.NET!
Whatever your [things] are need to be written outside of VBScript. In VB6, you can write a Custom Collection class, then you'll need to compile to an ActiveX DLL and register it on your webserver to access it.
How do I traverse a collection in classic ASP? I want to be able to do: For Each thing In things End For CLASSIC ASP - NOT.NET!
TITLE: How do I traverse a collection in classic ASP? QUESTION: I want to be able to do: For Each thing In things End For CLASSIC ASP - NOT.NET! ANSWER: Whatever your [things] are need to be written outside of VBScript. In VB6, you can write a Custom Collection class, then you'll need to compile to an ActiveX DLL and...
[ "asp-classic", "vbscript" ]
16
4
11,462
6
0
2008-08-05T13:30:46.290000
2008-08-05T13:42:15.593000
2,308
2,320
ASP.NET Display SVN Revision Number
I see in the Stack Overflow footer that the SVN Revision number is displayed. Is this automated and if so, how does one implement it in ASP.NET? (Solutions in other languages are acceptable)
Make sure that the file has s vn:keywords "Rev Id" and then put $Rev$ somewhere in there. See this question and the answers to it.
ASP.NET Display SVN Revision Number I see in the Stack Overflow footer that the SVN Revision number is displayed. Is this automated and if so, how does one implement it in ASP.NET? (Solutions in other languages are acceptable)
TITLE: ASP.NET Display SVN Revision Number QUESTION: I see in the Stack Overflow footer that the SVN Revision number is displayed. Is this automated and if so, how does one implement it in ASP.NET? (Solutions in other languages are acceptable) ANSWER: Make sure that the file has s vn:keywords "Rev Id" and then put $R...
[ "asp.net", "svn" ]
18
6
2,935
3
0
2008-08-05T13:38:42.310000
2008-08-05T13:47:00.077000
2,311
2,316
File size differences after copying a file to a server vía FTP
I have created a PHP-script to update a web server that is live inside a local directory. I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the size of the file is different from that of the file on the server. Once I download a...
Do you need to open the locfile in binary using rb? f = open (locfile, "rb")
File size differences after copying a file to a server vía FTP I have created a PHP-script to update a web server that is live inside a local directory. I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the size of the file is d...
TITLE: File size differences after copying a file to a server vía FTP QUESTION: I have created a PHP-script to update a web server that is live inside a local directory. I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the siz...
[ "php", "python", "ftp", "webserver", "ftplib" ]
46
17
5,593
3
0
2008-08-05T13:40:47.470000
2008-08-05T13:45:38.413000
2,328
4,910
Tracking state using ASP.NET AJAX / ICallbackEventHandler
I have a problem with maintaining state in an ASP.NET AJAX page. Short version: I need some way to update the page ViewState after an async callback has been made, to reflect any state changes the server made during the async call. This seems to be a common problem, but I will describe my scenario to help explain: I ha...
If you're already shuffling the ViewState around anyway, you might as well use an UpdatePanel. Its partial postbacks will update the page's ViewState automatically.
Tracking state using ASP.NET AJAX / ICallbackEventHandler I have a problem with maintaining state in an ASP.NET AJAX page. Short version: I need some way to update the page ViewState after an async callback has been made, to reflect any state changes the server made during the async call. This seems to be a common prob...
TITLE: Tracking state using ASP.NET AJAX / ICallbackEventHandler QUESTION: I have a problem with maintaining state in an ASP.NET AJAX page. Short version: I need some way to update the page ViewState after an async callback has been made, to reflect any state changes the server made during the async call. This seems t...
[ "asp.net", "ajax", "asp.net-ajax", "viewstate" ]
13
2
3,205
5
0
2008-08-05T13:52:12.720000
2008-08-07T16:19:34.683000