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
123,862
123,887
Delaying an exception
I have a method that periodically (e.g. once in every 10 secs) try to connect to a server and read some data from it. The server might not be available all the time. If the server is not available the method throws an exception. What would be the best way to implement a wrapper method that doesn't throw an exception ex...
Keep track of when the last time you successfully reached the server was. If the server throws an exception, catch it and compare to the last time you reached the server. If that time is more than a minute, rethrow the exception.
Delaying an exception I have a method that periodically (e.g. once in every 10 secs) try to connect to a server and read some data from it. The server might not be available all the time. If the server is not available the method throws an exception. What would be the best way to implement a wrapper method that doesn't...
TITLE: Delaying an exception QUESTION: I have a method that periodically (e.g. once in every 10 secs) try to connect to a server and read some data from it. The server might not be available all the time. If the server is not available the method throws an exception. What would be the best way to implement a wrapper m...
[ "java", "exception" ]
1
7
727
7
0
2008-09-23T21:02:20.917000
2008-09-23T21:05:52.750000
123,886
133,939
Where can I find good Domain Driven Design resources?
What are the best places to find out everything there is to know about Domain-Driven Design, from beginner to advanced. Books Websites Mailing lists User groups Conferences etc
Here are some interesting sources: the DDD book by Eric Evans the free DDD Quickly book the DDD newsgroup
Where can I find good Domain Driven Design resources? What are the best places to find out everything there is to know about Domain-Driven Design, from beginner to advanced. Books Websites Mailing lists User groups Conferences etc
TITLE: Where can I find good Domain Driven Design resources? QUESTION: What are the best places to find out everything there is to know about Domain-Driven Design, from beginner to advanced. Books Websites Mailing lists User groups Conferences etc ANSWER: Here are some interesting sources: the DDD book by Eric Evans ...
[ "domain-driven-design" ]
26
15
12,723
9
0
2008-09-23T21:05:42.577000
2008-09-25T15:20:09.240000
123,900
124,230
Ways to do "related searches" functionality
I've seen a few sites that list related searches when you perform a search, namely they suggest other search queries you may be interested in. I'm wondering the best way to model this in a medium-sized site (not enough traffic to rely on visitor stats to infer relationships). My initial thought is to store the top 10 r...
have you considered a matrix of with keywords on 1 axis vs. documents on another axis. once you find the set of vetors representing the keywords, find sets of keyword(s) found in your initial result set and then find a way to rank the other keywords by how many documents they reference or how many times they interset t...
Ways to do "related searches" functionality I've seen a few sites that list related searches when you perform a search, namely they suggest other search queries you may be interested in. I'm wondering the best way to model this in a medium-sized site (not enough traffic to rely on visitor stats to infer relationships)....
TITLE: Ways to do "related searches" functionality QUESTION: I've seen a few sites that list related searches when you perform a search, namely they suggest other search queries you may be interested in. I'm wondering the best way to model this in a medium-sized site (not enough traffic to rely on visitor stats to inf...
[ "search", "information-retrieval" ]
3
2
382
2
0
2008-09-23T21:08:12.353000
2008-09-23T22:08:21.820000
123,911
123,968
C# Download all files in HTTP directory
How do I download all files in a directory and all subdirectories on an HTTP server?
If directory browsing is enabled on the server then you can crawl the directory listings, i.e. Use HttpWebRequest to get the listing page, parse the response to find the file links, download each file (also with HttpWebRequest), navigate to each subfolder, rinse and repeat. If directory browsing isn't enabled then you ...
C# Download all files in HTTP directory How do I download all files in a directory and all subdirectories on an HTTP server?
TITLE: C# Download all files in HTTP directory QUESTION: How do I download all files in a directory and all subdirectories on an HTTP server? ANSWER: If directory browsing is enabled on the server then you can crawl the directory listings, i.e. Use HttpWebRequest to get the listing page, parse the response to find th...
[ "c#", "http", "download" ]
3
3
7,972
2
0
2008-09-23T21:11:34.780000
2008-09-23T21:20:45.817000
123,918
155,297
How can one simplify network byte-order conversion from a BinaryReader?
System.IO.BinaryReader reads values in a little-endian format. I have a C# application connecting to a proprietary networking library on the server side. The server-side sends everything down in network byte order, as one would expect, but I find that dealing with this on the client side is awkward, particularly for un...
There is no built-in converter. Here's my wrapper (as you can see, I only implemented the functionality I needed but the structure is pretty easy to change to your liking): /// /// Utilities for reading big-endian files /// public class BigEndianReader { public BigEndianReader(BinaryReader baseReader) { mBaseReader = b...
How can one simplify network byte-order conversion from a BinaryReader? System.IO.BinaryReader reads values in a little-endian format. I have a C# application connecting to a proprietary networking library on the server side. The server-side sends everything down in network byte order, as one would expect, but I find t...
TITLE: How can one simplify network byte-order conversion from a BinaryReader? QUESTION: System.IO.BinaryReader reads values in a little-endian format. I have a C# application connecting to a proprietary networking library on the server side. The server-side sends everything down in network byte order, as one would ex...
[ "c#", ".net", "networking" ]
9
7
13,056
2
0
2008-09-23T21:13:55.663000
2008-09-30T22:00:25.857000
123,927
123,948
How to find USB drive letter?
I'm writing a setup program to install an application to a USB drive. The application is meant to be used only from USB drives, so it would save an extra step for the user by automatically selecting USB drive to install to. I might explore using Nullsoft or MSI for install, but since I'm mostly familiar with.NET I init...
You could use: from driveInfo in DriveInfo.GetDrives() where driveInfo.DriveType == DriveType.Removable && driveInfo.IsReady select driveInfo.RootDirectory.FullName
How to find USB drive letter? I'm writing a setup program to install an application to a USB drive. The application is meant to be used only from USB drives, so it would save an extra step for the user by automatically selecting USB drive to install to. I might explore using Nullsoft or MSI for install, but since I'm m...
TITLE: How to find USB drive letter? QUESTION: I'm writing a setup program to install an application to a USB drive. The application is meant to be used only from USB drives, so it would save an extra step for the user by automatically selecting USB drive to install to. I might explore using Nullsoft or MSI for instal...
[ ".net", "usb" ]
14
18
28,091
3
0
2008-09-23T21:15:13.927000
2008-09-23T21:18:01.847000
123,936
123,954
Do you use special comments on bug fixes in your code?
Some of my colleagues use special comments on their bug fixes, for example: // 2008-09-23 John Doe - bug 12345 // Does this make sense? Do you comment bug fixes in a special way? Please let me know.
I don't put in comments like that, the source control system already maintains that history and I am already able to log the history of a file. I do put in comments that describe why something non-obvious is being done though. So if the bug fix makes the code less predictable and clear, then I explain why.
Do you use special comments on bug fixes in your code? Some of my colleagues use special comments on their bug fixes, for example: // 2008-09-23 John Doe - bug 12345 // Does this make sense? Do you comment bug fixes in a special way? Please let me know.
TITLE: Do you use special comments on bug fixes in your code? QUESTION: Some of my colleagues use special comments on their bug fixes, for example: // 2008-09-23 John Doe - bug 12345 // Does this make sense? Do you comment bug fixes in a special way? Please let me know. ANSWER: I don't put in comments like that, the ...
[ "comments" ]
17
34
4,139
21
0
2008-09-23T21:16:54.143000
2008-09-23T21:18:51.453000
123,958
123,985
How to get/set logical directory path in python
In python is it possible to get or set a logical directory (as opposed to an absolute one). For example if I have: /real/path/to/dir and I have /linked/path/to/dir linked to the same directory. using os.getcwd and os.chdir will always use the absolute path >>> import os >>> os.chdir('/linked/path/to/dir') >>> print os....
The underlying operational system / shell reports real paths to python. So, there really is no way around it, since os.getcwd() is a wrapped call to C Library getcwd() function. There are some workarounds in the spirit of the one that you already know which is launching pwd. Another one would involve using os.environ['...
How to get/set logical directory path in python In python is it possible to get or set a logical directory (as opposed to an absolute one). For example if I have: /real/path/to/dir and I have /linked/path/to/dir linked to the same directory. using os.getcwd and os.chdir will always use the absolute path >>> import os >...
TITLE: How to get/set logical directory path in python QUESTION: In python is it possible to get or set a logical directory (as opposed to an absolute one). For example if I have: /real/path/to/dir and I have /linked/path/to/dir linked to the same directory. using os.getcwd and os.chdir will always use the absolute pa...
[ "python", "path", "symlink" ]
10
13
12,696
2
0
2008-09-23T21:19:37.100000
2008-09-23T21:22:43.443000
123,979
124,010
Is there a better way to get hold of a reference to a movie clip in actionscript using a string without eval
I have created a bunch of movie clips which all have similar names and then after some other event I have built up a string like: var clipName = "barLeft42" which is held inside another movie clip called 'thing'. I have been able to get hold of a reference using: var movieClip = Eval( "_root.thing." + clipName ) But th...
Movie clips are collections in actionscript (like most and similar to javascript, everything is basically key-value pairs). You can index into the collection using square brackets and a string for the key name like: _root.thing[ "barLeft42" ] That should do the trick for you...
Is there a better way to get hold of a reference to a movie clip in actionscript using a string without eval I have created a bunch of movie clips which all have similar names and then after some other event I have built up a string like: var clipName = "barLeft42" which is held inside another movie clip called 'thing'...
TITLE: Is there a better way to get hold of a reference to a movie clip in actionscript using a string without eval QUESTION: I have created a bunch of movie clips which all have similar names and then after some other event I have built up a string like: var clipName = "barLeft42" which is held inside another movie c...
[ "actionscript" ]
1
4
156
3
0
2008-09-23T21:22:22.647000
2008-09-23T21:27:17.830000
123,986
124,149
how to determine USB Flash drive manufacturer?
I need my program to work only with certain USB Flash drives (from a single manufacturer) and ignore all other USB Flash drives (from any other manufacturers). is it possible to check that specific USB card is inserted on windows using.NET 2.0? how? if I find it through WMI, can I somehow determine which drive letter t...
EDIT: Added code to print drive letter. Check if this example works for you. It uses WMI. Console.WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]);... Console.WriteLine(" Name: {0}", c["Name"]); // here it will print drive letter The full code sample: namespace WMISample { using System; using System.Management;...
how to determine USB Flash drive manufacturer? I need my program to work only with certain USB Flash drives (from a single manufacturer) and ignore all other USB Flash drives (from any other manufacturers). is it possible to check that specific USB card is inserted on windows using.NET 2.0? how? if I find it through WM...
TITLE: how to determine USB Flash drive manufacturer? QUESTION: I need my program to work only with certain USB Flash drives (from a single manufacturer) and ignore all other USB Flash drives (from any other manufacturers). is it possible to check that specific USB card is inserted on windows using.NET 2.0? how? if I ...
[ ".net", "usb" ]
7
12
11,255
8
0
2008-09-23T21:22:47.950000
2008-09-23T21:53:27.767000
123,994
124,027
QueryString malformed after URLDecode
I'm trying to pass in a Base64 string into a C#.Net web application via the QueryString. When the string arrives the "+" (plus) sign is being replaced by a space. It appears that the automatic URLDecode process is doing this. I have no control over what is being passed via the QueryString. Is there any way to handle th...
You could manually replace the value ( argument.Replace(' ', '+') ) or consult the HttpRequest.ServerVariables["QUERY_STRING"] (even better the HttpRequest.Url.Query) and parse it yourself. You should however try to solve the problem where the URL is given; a plus sign needs to get encoded as "%2B" in the URL because a...
QueryString malformed after URLDecode I'm trying to pass in a Base64 string into a C#.Net web application via the QueryString. When the string arrives the "+" (plus) sign is being replaced by a space. It appears that the automatic URLDecode process is doing this. I have no control over what is being passed via the Quer...
TITLE: QueryString malformed after URLDecode QUESTION: I'm trying to pass in a Base64 string into a C#.Net web application via the QueryString. When the string arrives the "+" (plus) sign is being replaced by a space. It appears that the automatic URLDecode process is doing this. I have no control over what is being p...
[ "c#", "asp.net", "url" ]
15
11
33,701
11
0
2008-09-23T21:24:08.697000
2008-09-23T21:29:48.013000
123,999
125,106
How can I tell if a DOM element is visible in the current viewport?
Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the viewport )? (The question refers to Firefox.)
Update: Time marches on and so have our browsers. This technique is no longer recommended and you should use Dan's solution if you do not need to support version of Internet Explorer before 7. Original solution (now outdated): This will check if the element is entirely visible in the current viewport: function elementI...
How can I tell if a DOM element is visible in the current viewport? Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the viewport )? (The question refers to Firefox.)
TITLE: How can I tell if a DOM element is visible in the current viewport? QUESTION: Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the viewport )? (The question refers to Firefox.) ANSWER: Update: Time marches on and so have our browsers. This technique is n...
[ "javascript", "html", "firefox", "dom", "browser" ]
1,269
422
837,395
31
0
2008-09-23T21:24:56.057000
2008-09-24T02:40:09.047000
124,031
124,106
SQL Server Management Studio 2005 - Change Default Directory for Backup Location
Using MS SQL Server Management Studio 2005 - To Restore a Database: Restore Database (*) From Device: Click "... " Button Backup media: File Click " Add " Button Popup Window: " Locate Backup File " That window Defaults to C:\Program Files\Microsoft SQL Server\MSSQL.1\Backup How do I configure MS SQL Server Management ...
In the registry, edit the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\BackupDirectory value to point to d:\data\databases
SQL Server Management Studio 2005 - Change Default Directory for Backup Location Using MS SQL Server Management Studio 2005 - To Restore a Database: Restore Database (*) From Device: Click "... " Button Backup media: File Click " Add " Button Popup Window: " Locate Backup File " That window Defaults to C:\Program Files...
TITLE: SQL Server Management Studio 2005 - Change Default Directory for Backup Location QUESTION: Using MS SQL Server Management Studio 2005 - To Restore a Database: Restore Database (*) From Device: Click "... " Button Backup media: File Click " Add " Button Popup Window: " Locate Backup File " That window Defaults t...
[ "sql-server", "sql-server-2005", "configuration", "ssms" ]
11
15
11,588
3
0
2008-09-23T21:30:54.997000
2008-09-23T21:47:23.820000
124,035
124,069
Are ruby command line switches -rubygems & -r incompatible?
I recently converted a ruby library to a gem, which seemed to break the command line usability Worked fine as a library $ ruby -r foobar -e 'p FooBar.question' # => "answer" And as a gem, irb knows how to require a gem from command-line switches $ irb -rubygems -r foobar irb(main):001:0> FooBar.question # => "answer" B...
-rubygems is actually the same as -r ubygems. It doesn't mess with your search path, as far as I understand, but I think it doesn't add anything to your -r search path either. I was able to do something like this: ruby -rubygems -r /usr/lib/ruby/gems/myhelpfulclass-0.0.1/lib/MyHelpfulClass -e "puts MyHelpfulClass" MyHe...
Are ruby command line switches -rubygems & -r incompatible? I recently converted a ruby library to a gem, which seemed to break the command line usability Worked fine as a library $ ruby -r foobar -e 'p FooBar.question' # => "answer" And as a gem, irb knows how to require a gem from command-line switches $ irb -rubygem...
TITLE: Are ruby command line switches -rubygems & -r incompatible? QUESTION: I recently converted a ruby library to a gem, which seemed to break the command line usability Worked fine as a library $ ruby -r foobar -e 'p FooBar.question' # => "answer" And as a gem, irb knows how to require a gem from command-line switc...
[ "ruby", "rubygems" ]
6
7
3,028
2
0
2008-09-23T21:31:24.857000
2008-09-23T21:39:03.747000
124,040
124,061
Is MEF a replacement for System.Addin?
Possible Duplicate: Choosing between MEF and MAF (System.AddIn) Is the Managed Extensibility Framework a replacement for System.Addin? Or are they complementary?
It is touched in the MSDN Forums here: Comparison to the AddIn libraries? And also by Krzysztof Cwalina in his blog on the release of MEF: Managed Extensibility Framework Summary: they live side by side.
Is MEF a replacement for System.Addin? Possible Duplicate: Choosing between MEF and MAF (System.AddIn) Is the Managed Extensibility Framework a replacement for System.Addin? Or are they complementary?
TITLE: Is MEF a replacement for System.Addin? QUESTION: Possible Duplicate: Choosing between MEF and MAF (System.AddIn) Is the Managed Extensibility Framework a replacement for System.Addin? Or are they complementary? ANSWER: It is touched in the MSDN Forums here: Comparison to the AddIn libraries? And also by Krzysz...
[ ".net", "inversion-of-control", "mef" ]
17
11
5,406
4
0
2008-09-23T21:32:06.557000
2008-09-23T21:36:49.617000
124,055
124,169
What do you put in your webservice?
I have a website (ASP.NET) and some winforms(.Net 2.0) for a project (written in C#). I use the webservice (IIS6) for task that both require like sending email inside the business. I think Webservice is nice but I would like from your experience what should and what should not be in a webservice?
In My Opinion: Web services should be reserved for code that You either can't or don't want to distribute; or, code that needs to seriously scale up. One example is custom business logic that multiple applications need access to. Code you don't want to put into web services include: code that is performance based; code...
What do you put in your webservice? I have a website (ASP.NET) and some winforms(.Net 2.0) for a project (written in C#). I use the webservice (IIS6) for task that both require like sending email inside the business. I think Webservice is nice but I would like from your experience what should and what should not be in ...
TITLE: What do you put in your webservice? QUESTION: I have a website (ASP.NET) and some winforms(.Net 2.0) for a project (written in C#). I use the webservice (IIS6) for task that both require like sending email inside the business. I think Webservice is nice but I would like from your experience what should and what...
[ "web-services", "architecture" ]
0
1
231
4
0
2008-09-23T21:35:21.243000
2008-09-23T21:56:27.247000
124,066
124,120
SQL Server 2005 vs. ASP.net datetime format confusion
I've found a similar question on stack overflow, but it didn't really answer the question I have. I need to make sure that my asp.net application is formatting the date dd/mm/yyyy the same as my SQL Server 2005. How do I verify the date culture (if that's what it's called) of the server matches how I've programmed my a...
When you get a DateTime out of the database, it should be in a non-cultured format (like the DateTime object, based on the number of ticks since a certain date). It is only when you are converting that value into a string that you need to be concerned with culture. In those cases, you can use yourDateTimeValue.ToString...
SQL Server 2005 vs. ASP.net datetime format confusion I've found a similar question on stack overflow, but it didn't really answer the question I have. I need to make sure that my asp.net application is formatting the date dd/mm/yyyy the same as my SQL Server 2005. How do I verify the date culture (if that's what it's ...
TITLE: SQL Server 2005 vs. ASP.net datetime format confusion QUESTION: I've found a similar question on stack overflow, but it didn't really answer the question I have. I need to make sure that my asp.net application is formatting the date dd/mm/yyyy the same as my SQL Server 2005. How do I verify the date culture (if...
[ "asp.net", "sql-server-2005", "datetime", "culture" ]
0
6
8,531
5
0
2008-09-23T21:38:22.780000
2008-09-23T21:49:12.630000
124,067
124,109
php String Concatenation, Performance
In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time. In said languages, there are library classes to reduce this cost such as C# System.Text.StringBuilder and Java java.lang.StringBuilder. Does php (4 or 5; I'm interested in both) share ...
No, there is no type of stringbuilder class in PHP, since strings are mutable. That being said, there are different ways of building a string, depending on what you're doing. echo, for example, will accept comma-separated tokens for output. // This... echo 'one', 'two'; // Is the same as this echo 'one'; echo 'two'; W...
php String Concatenation, Performance In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time. In said languages, there are library classes to reduce this cost such as C# System.Text.StringBuilder and Java java.lang.StringBuilder. Does php (...
TITLE: php String Concatenation, Performance QUESTION: In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time. In said languages, there are library classes to reduce this cost such as C# System.Text.StringBuilder and Java java.lang.StringB...
[ "php", "string", "concatenation" ]
77
66
58,742
12
0
2008-09-23T21:38:46.837000
2008-09-23T21:47:50.403000
124,076
124,217
What do these abbreviations in network hostnames mean?
When I use traceroute, I often see abbreviations in the hostnames along the route, such as "ge", "so", "ic", "gw", "bb" etc. I can guess "bb" means backbone. Does anyone know what any these strings abbreviate, or know any other common abbreviations?
The examples you provided makes me think it's not about country codes. I guess it's just what you thought: ISP network admins using shorcut when naming their servers. bb = backbone gw = gateway ic = interconnect? ge =? so = stackoverflow?:)
What do these abbreviations in network hostnames mean? When I use traceroute, I often see abbreviations in the hostnames along the route, such as "ge", "so", "ic", "gw", "bb" etc. I can guess "bb" means backbone. Does anyone know what any these strings abbreviate, or know any other common abbreviations?
TITLE: What do these abbreviations in network hostnames mean? QUESTION: When I use traceroute, I often see abbreviations in the hostnames along the route, such as "ge", "so", "ic", "gw", "bb" etc. I can guess "bb" means backbone. Does anyone know what any these strings abbreviate, or know any other common abbreviation...
[ "networking", "hostname", "traceroute" ]
2
2
2,910
8
0
2008-09-23T21:40:18.283000
2008-09-23T22:05:01.203000
124,079
124,282
How do I quickly slice and dice large data files?
I'd like to slice and dice large datafiles, up to a gig, in a fairly quick and efficient manner. If I use something like UNIX's "CUT", it's extremely fast, even in a CYGWIN environment. I've tried developing and benchmarking various Ruby scripts to process these files, and always end up with glacial results. What would...
Why not combine them together - using cut to do what it does best and ruby to provide the glue/value add with the results from CUT? you can run shell scripts by putting them in backticks like this: puts `cut somefile > foo.fil` # process each line of the output from cut f = File.new("foo.fil") f.each{|line| }
How do I quickly slice and dice large data files? I'd like to slice and dice large datafiles, up to a gig, in a fairly quick and efficient manner. If I use something like UNIX's "CUT", it's extremely fast, even in a CYGWIN environment. I've tried developing and benchmarking various Ruby scripts to process these files, ...
TITLE: How do I quickly slice and dice large data files? QUESTION: I'd like to slice and dice large datafiles, up to a gig, in a fairly quick and efficient manner. If I use something like UNIX's "CUT", it's extremely fast, even in a CYGWIN environment. I've tried developing and benchmarking various Ruby scripts to pro...
[ "ruby", "data-files" ]
5
1
1,290
4
0
2008-09-23T21:41:20.933000
2008-09-23T22:20:42.540000
124,117
124,144
.NET + Copying large amounts of memory tricks
Back in the olden days, there were tricks used (often for blitting offscreen framebuffers), to copy large chunks of memory from one location to another. Now that I'm working in C#, I've found the need to move an array of bytes (roughly 32k in size) from one memory location to another approximately 60 times per second. ...
I think you can count on Buffer.BlockCopy() to do the right thing http://msdn.microsoft.com/en-us/library/system.buffer.blockcopy.aspx
.NET + Copying large amounts of memory tricks Back in the olden days, there were tricks used (often for blitting offscreen framebuffers), to copy large chunks of memory from one location to another. Now that I'm working in C#, I've found the need to move an array of bytes (roughly 32k in size) from one memory location ...
TITLE: .NET + Copying large amounts of memory tricks QUESTION: Back in the olden days, there were tricks used (often for blitting offscreen framebuffers), to copy large chunks of memory from one location to another. Now that I'm working in C#, I've found the need to move an array of bytes (roughly 32k in size) from on...
[ "c#", ".net", "memory-management" ]
4
8
971
1
0
2008-09-23T21:48:56.610000
2008-09-23T21:52:31.997000
124,118
139,790
IIS 6.0 on Enterprise Server - Memory Limit
We want to switch a web server from Windows 2003 to Windows 2003 Enterprise (64 bits) to use 8GB of RAM. Will IIS 6.0 and an ASPNET 1.1 application be able to benefit from the change?
Since ASP.Net 1.1 has no x64 support, you are limited to running IIS 6 using 32 bit worker processes. The /3GB switch doesn't do anything on x64, but x64 natively gives 32bit processes 4 GB instead of 2GB, so you will have more memory available for your worker proces. You will need to set the AppPools to 32 bit: cscrip...
IIS 6.0 on Enterprise Server - Memory Limit We want to switch a web server from Windows 2003 to Windows 2003 Enterprise (64 bits) to use 8GB of RAM. Will IIS 6.0 and an ASPNET 1.1 application be able to benefit from the change?
TITLE: IIS 6.0 on Enterprise Server - Memory Limit QUESTION: We want to switch a web server from Windows 2003 to Windows 2003 Enterprise (64 bits) to use 8GB of RAM. Will IIS 6.0 and an ASPNET 1.1 application be able to benefit from the change? ANSWER: Since ASP.Net 1.1 has no x64 support, you are limited to running ...
[ "asp.net", "windows", "iis-6" ]
1
3
5,881
3
0
2008-09-23T21:48:59.167000
2008-09-26T14:16:28.330000
124,123
132,169
Moving the child nodes of an XML node upwards
Imagine I have the folling XML file: before middle after I want to convert it into something like this: beforemiddleafter In other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this command: "mv./directory/*.", but for xml nodes. I'd like to do ...
If your actual goal is to remove the links from a web page, then you should use a stylesheet like this, which matches all XHTML elements (I'm assuming you're using XHTML?) and simply applies templates to their content: This stylesheet will deal with a situation where you have something nested within the element that yo...
Moving the child nodes of an XML node upwards Imagine I have the folling XML file: before middle after I want to convert it into something like this: beforemiddleafter In other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this command: "mv./dir...
TITLE: Moving the child nodes of an XML node upwards QUESTION: Imagine I have the folling XML file: before middle after I want to convert it into something like this: beforemiddleafter In other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this...
[ "xml", "xslt", "command-line-interface" ]
1
2
3,304
5
0
2008-09-23T21:49:21.240000
2008-09-25T08:44:15.713000
124,143
124,175
Why are Exceptions not Checked in .NET?
I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions. What is the main reason of the difference between Java and C# in throwing exceptions? In Java the signature of a method that throws an exception has to use the "throws" keyword, while in C# you don'...
Because the response to checked exceptions is almost always: try { // exception throwing code } catch(Exception e) { // either log.error("Error fooing bar",e); // OR throw new RuntimeException(e); } If you actually know that there is something you can do if a particular exception is thrown, then you can catch it and th...
Why are Exceptions not Checked in .NET? I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions. What is the main reason of the difference between Java and C# in throwing exceptions? In Java the signature of a method that throws an exception has to use th...
TITLE: Why are Exceptions not Checked in .NET? QUESTION: I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions. What is the main reason of the difference between Java and C# in throwing exceptions? In Java the signature of a method that throws an excep...
[ "java", ".net", "exception" ]
43
43
10,692
9
0
2008-09-23T21:52:24.603000
2008-09-23T21:57:26.637000
124,148
124,196
Should I never use primitive types again?
Mixing the use of primitive data types and their respective wrapper classes, in Java, can lead to a lot of bugs. The following example illustrates the issue: int i = 4;... if (i == 10) doStuff(); Later on you figure that you want the variable i to be either defined or undefined, so you change the above instantiation to...
Using the boxed types does have both performance and memory issues. When doing comparisons (eg (i == 10) ), java has to unbox the type before doing the comparison. Even using i.equals(TEN) uses a method call, which is costlier and (IMO) uglier than the == syntax. Re memory, the object has to be stored on the heap (whic...
Should I never use primitive types again? Mixing the use of primitive data types and their respective wrapper classes, in Java, can lead to a lot of bugs. The following example illustrates the issue: int i = 4;... if (i == 10) doStuff(); Later on you figure that you want the variable i to be either defined or undefined...
TITLE: Should I never use primitive types again? QUESTION: Mixing the use of primitive data types and their respective wrapper classes, in Java, can lead to a lot of bugs. The following example illustrates the issue: int i = 4;... if (i == 10) doStuff(); Later on you figure that you want the variable i to be either de...
[ "java", "types" ]
16
18
4,122
8
0
2008-09-23T21:53:01.437000
2008-09-23T22:00:15.583000
124,166
124,181
Make a div fade away nicely after a given amount of time
What is the best way to make a fade away after a given amount of time (without using some of the JavaScript libraries available). I'm looking for a very lightweight solution not requiring a huge JavaScript library to be sent to the browser.
Not sure why you'd be so against using something like jQuery, which would make accomplishing this effect all but trivial, but essentially, you need to wrap a series of changes to the -moz-opacity, opacity, and filter:alpha CSS rules in a setTimeout(). Or, use jQuery, and wrap a fadeOut() call in setTimeout. Your choice...
Make a div fade away nicely after a given amount of time What is the best way to make a fade away after a given amount of time (without using some of the JavaScript libraries available). I'm looking for a very lightweight solution not requiring a huge JavaScript library to be sent to the browser.
TITLE: Make a div fade away nicely after a given amount of time QUESTION: What is the best way to make a fade away after a given amount of time (without using some of the JavaScript libraries available). I'm looking for a very lightweight solution not requiring a huge JavaScript library to be sent to the browser. ANS...
[ "javascript", "css", "html", "fade" ]
6
12
12,773
6
0
2008-09-23T21:55:32.053000
2008-09-23T21:58:38.240000
124,167
124,321
Bash variable scope
Please explain to me why the very last echo statement is blank? I expect that XCODE is incremented in the while loop to a value of 1: #!/bin/bash OUTPUT="name1 ip ip status" # normally output of another command with multi line output if [ -z "$OUTPUT" ] then echo "Status WARN: No messages from SMcli" exit $STATE_WARNI...
Because you're piping into the while loop, a sub-shell is created to run the while loop. Now this child process has its own copy of the environment and can't pass any variables back to its parent (as in any unix process). Therefore you'll need to restructure so that you're not piping into the loop. Alternatively you co...
Bash variable scope Please explain to me why the very last echo statement is blank? I expect that XCODE is incremented in the while loop to a value of 1: #!/bin/bash OUTPUT="name1 ip ip status" # normally output of another command with multi line output if [ -z "$OUTPUT" ] then echo "Status WARN: No messages from SMcl...
TITLE: Bash variable scope QUESTION: Please explain to me why the very last echo statement is blank? I expect that XCODE is incremented in the while loop to a value of 1: #!/bin/bash OUTPUT="name1 ip ip status" # normally output of another command with multi line output if [ -z "$OUTPUT" ] then echo "Status WARN: No ...
[ "bash", "scope", "pipe" ]
128
160
119,852
7
0
2008-09-23T21:56:10.850000
2008-09-23T22:29:16.607000
124,170
126,153
A Delphi/FreePascal lib or function that emulates the PHP's function parse_url
I'm doing a sitemap producer in Object Pascal and need a good function or lib to emulate the parse_url function on PHP. Does anyone know of any good ones?
Freepascal has the unit URIParser with the ParseURI function. An example how to use it can be found in one of the example in Freepascal's source. Or an old example which is somewhat easier to understand.
A Delphi/FreePascal lib or function that emulates the PHP's function parse_url I'm doing a sitemap producer in Object Pascal and need a good function or lib to emulate the parse_url function on PHP. Does anyone know of any good ones?
TITLE: A Delphi/FreePascal lib or function that emulates the PHP's function parse_url QUESTION: I'm doing a sitemap producer in Object Pascal and need a good function or lib to emulate the parse_url function on PHP. Does anyone know of any good ones? ANSWER: Freepascal has the unit URIParser with the ParseURI functio...
[ "delphi", "parsing", "freepascal", "url-parsing" ]
2
2
2,405
5
0
2008-09-23T21:56:29.913000
2008-09-24T09:11:45.780000
124,205
124,224
How can I do the equivalent of "SHOW TABLES" in T-SQL?
I would like to do a lookup of tables in my SQL Server 2005 Express database based on table name. In MySQL I would use SHOW TABLES LIKE "Datasheet%", but in T-SQL this throws an error (it tries to look for a SHOW stored procedure and fails). Is this possible, and if so, how?
This will give you a list of the tables in the current database: Select Table_name as "Table name" From Information_schema.Tables Where Table_type = 'BASE TABLE' and Objectproperty (Object_id(Table_name), 'IsMsShipped') = 0 Some other useful T-SQL bits can be found here: http://www.devx.com/tips/Tip/28529
How can I do the equivalent of "SHOW TABLES" in T-SQL? I would like to do a lookup of tables in my SQL Server 2005 Express database based on table name. In MySQL I would use SHOW TABLES LIKE "Datasheet%", but in T-SQL this throws an error (it tries to look for a SHOW stored procedure and fails). Is this possible, and i...
TITLE: How can I do the equivalent of "SHOW TABLES" in T-SQL? QUESTION: I would like to do a lookup of tables in my SQL Server 2005 Express database based on table name. In MySQL I would use SHOW TABLES LIKE "Datasheet%", but in T-SQL this throws an error (it tries to look for a SHOW stored procedure and fails). Is th...
[ "sql", "t-sql", "sql-server-2005" ]
48
46
93,597
11
0
2008-09-23T22:02:03.410000
2008-09-23T22:06:33.727000
124,207
124,263
IMAP: "immediate" delete, without going through Trash folder?
I currently filter some message from my inbox with these steps: select inbox pick messages set \Deleted tag and then repeat the process after selecting Trash. Is there a more direct way of disposing of these messages? Or is it just the feature of the Mail server that deleting a message puts it in the trash, and deletin...
I believe you have to call EXPUNGE after setting the tag Deleted. RFC 3501
IMAP: "immediate" delete, without going through Trash folder? I currently filter some message from my inbox with these steps: select inbox pick messages set \Deleted tag and then repeat the process after selecting Trash. Is there a more direct way of disposing of these messages? Or is it just the feature of the Mail se...
TITLE: IMAP: "immediate" delete, without going through Trash folder? QUESTION: I currently filter some message from my inbox with these steps: select inbox pick messages set \Deleted tag and then repeat the process after selecting Trash. Is there a more direct way of disposing of these messages? Or is it just the feat...
[ "imap" ]
1
4
2,109
3
0
2008-09-23T22:02:21.943000
2008-09-23T22:15:45.530000
124,210
125,572
Best Practices of Test Driven Development Using C# and RhinoMocks
In order to help my team write testable code, I came up with this simple list of best practices for making our C# code base more testable. (Some of the points refer to limitations of Rhino Mocks, a mocking framework for C#, but the rules may apply more generally as well.) Does anyone have any best practices that they f...
Definitely a good list. Here are a few thoughts on it: Write the test first, then the code. I agree, at a high level. But, I'd be more specific: "Write a test first, then write just enough code to pass the test, and repeat." Otherwise, I'd be afraid that my unit tests would look more like integration or acceptance test...
Best Practices of Test Driven Development Using C# and RhinoMocks In order to help my team write testable code, I came up with this simple list of best practices for making our C# code base more testable. (Some of the points refer to limitations of Rhino Mocks, a mocking framework for C#, but the rules may apply more g...
TITLE: Best Practices of Test Driven Development Using C# and RhinoMocks QUESTION: In order to help my team write testable code, I came up with this simple list of best practices for making our C# code base more testable. (Some of the points refer to limitations of Rhino Mocks, a mocking framework for C#, but the rule...
[ "c#", "unit-testing", "tdd", "rhino-mocks" ]
88
59
29,428
7
0
2008-09-23T22:03:18.900000
2008-09-24T05:32:30.427000
124,235
124,312
Does Git work in Windows?
I work on Linux all the time and I'm clueless about Windows, not even having a Windows box. Is Git nowadays working on Windows? Or am I making problems for my Windows pals by using it?
As far as I can tell msysgit works perfectly well under Windows Vista. This after a whole 2-month experience checking out plugins and applications for Ruby on Rails:-) Anyway, it was a breeze to install, no problem.
Does Git work in Windows? I work on Linux all the time and I'm clueless about Windows, not even having a Windows box. Is Git nowadays working on Windows? Or am I making problems for my Windows pals by using it?
TITLE: Does Git work in Windows? QUESTION: I work on Linux all the time and I'm clueless about Windows, not even having a Windows box. Is Git nowadays working on Windows? Or am I making problems for my Windows pals by using it? ANSWER: As far as I can tell msysgit works perfectly well under Windows Vista. This after ...
[ "windows", "git", "version-control", "dvcs" ]
16
14
3,986
8
0
2008-09-23T22:09:28.713000
2008-09-23T22:26:49.777000
124,240
124,308
Mysql results in PHP - arrays or objects?
Been using PHP/MySQL for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using mysql_fetch_object() vs mysql_fetch_assoc() / mysql_fetch_array().
Performance-wise it doesn't matter what you use. The difference is that mysql_fetch_object returns object: while ($row = mysql_fetch_object($result)) { echo $row->user_id; echo $row->fullname; } mysql_fetch_assoc() returns associative array: while ($row = mysql_fetch_assoc($result)) { echo $row["userid"]; echo $row["fu...
Mysql results in PHP - arrays or objects? Been using PHP/MySQL for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using mysql_fetch_object() vs mysql_fetch_assoc() / mysql_fetch_array().
TITLE: Mysql results in PHP - arrays or objects? QUESTION: Been using PHP/MySQL for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using mysql_fetch_object() vs mysql_fetch_assoc() / mysql_fetch_array(). ANSWER: Performance-wise it doesn't matter what you use....
[ "php", "mysql", "arrays", "object" ]
28
42
42,185
9
0
2008-09-23T22:10:15.857000
2008-09-23T22:25:46.817000
124,254
124,661
Visual Studio 2008 Documentation
I've installed the MSDN Library for Visual Studio 2008 SP1, however, dynamic help in Visual Studio still spawns the RTM Document Explorer. Anyone know how to change it to the SP1 version?
Sometimes you see someone else struggling with the same things and that quickly reminds you are not alone. So here is what you have to do: Open Registry Editor using regedit.exe Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Help\0x0409 - 0x0409 is for US english. HKEY_LOCAL_MACHINE\SOFTWARE\Microso...
Visual Studio 2008 Documentation I've installed the MSDN Library for Visual Studio 2008 SP1, however, dynamic help in Visual Studio still spawns the RTM Document Explorer. Anyone know how to change it to the SP1 version?
TITLE: Visual Studio 2008 Documentation QUESTION: I've installed the MSDN Library for Visual Studio 2008 SP1, however, dynamic help in Visual Studio still spawns the RTM Document Explorer. Anyone know how to change it to the SP1 version? ANSWER: Sometimes you see someone else struggling with the same things and that ...
[ "visual-studio-2008" ]
2
3
1,541
1
0
2008-09-23T22:14:10.853000
2008-09-24T00:08:17.397000
124,258
215,825
How would you allow users to edit attachments in a web application?
We have created a web application, using ASP.NET, that allows users to upload documents and attach them to business entities, like customers, contacts and so on. The application runs on the intranet and all files are uploaded through the web application into a shared folder on the server. I would like, right from the w...
If all your client computers are Windows, map a shared folder on the server to the same drive letter on every client and use the file:// format. Let's say you share \ServerName\ShareName to H: on every client's computer, the you can make the link as file://h:\pat_to_the_file_under_your_share\fileName.doc If not every o...
How would you allow users to edit attachments in a web application? We have created a web application, using ASP.NET, that allows users to upload documents and attach them to business entities, like customers, contacts and so on. The application runs on the intranet and all files are uploaded through the web applicatio...
TITLE: How would you allow users to edit attachments in a web application? QUESTION: We have created a web application, using ASP.NET, that allows users to upload documents and attach them to business entities, like customers, contacts and so on. The application runs on the intranet and all files are uploaded through ...
[ "asp.net", "file" ]
3
0
725
6
0
2008-09-23T22:14:53.957000
2008-10-19T01:12:52.120000
124,266
124,283
Sort Object in PHP
What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this. $sortedObjectArary = sort($unsortedObjectArray, $Object->weight); Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional array sorting and there might be someth...
Almost verbatim from the manual: function compare_weights($a, $b) { if($a->weight == $b->weight) { return 0; } return ($a->weight < $b->weight)? -1: 1; } usort($unsortedObjectArray, 'compare_weights'); If you want objects to be able to sort themselves, see example 3 here: http://php.net/usort
Sort Object in PHP What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this. $sortedObjectArary = sort($unsortedObjectArray, $Object->weight); Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional array sorting and th...
TITLE: Sort Object in PHP QUESTION: What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this. $sortedObjectArary = sort($unsortedObjectArray, $Object->weight); Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional ar...
[ "php", "arrays", "sorting" ]
43
73
53,361
11
0
2008-09-23T22:16:45.717000
2008-09-23T22:20:54.770000
124,275
124,287
Does anyone know of any cross platform GUI log viewers for Ruby On Rails?
I'm tired of using: tail -f development.log To keep track of my rails logs. Instead I would like something that displays the info in a grid and allows my to sort, filter and look at stack traces per log message. Does anyone know of a GUI tool for displaying rails logs. Ideally I would like a standalone app (not somethi...
FWIW I started this project at GitHub to try and solve this problem, its far from functional.
Does anyone know of any cross platform GUI log viewers for Ruby On Rails? I'm tired of using: tail -f development.log To keep track of my rails logs. Instead I would like something that displays the info in a grid and allows my to sort, filter and look at stack traces per log message. Does anyone know of a GUI tool for...
TITLE: Does anyone know of any cross platform GUI log viewers for Ruby On Rails? QUESTION: I'm tired of using: tail -f development.log To keep track of my rails logs. Instead I would like something that displays the info in a grid and allows my to sort, filter and look at stack traces per log message. Does anyone know...
[ "ruby-on-rails", "ruby", "user-interface", "logging" ]
10
1
1,718
5
0
2008-09-23T22:19:43.883000
2008-09-23T22:21:42.600000
124,295
124,528
How do I deploy a managed stored procedure without using Visual Studio?
Everything I have read says that when making a managed stored procedure, to right click in Visual Studio and choose deploy. That works fine, but what if I want to deploy it outside of Visual Studio to a number of different locations? I tried creating the assembly with the dll the project built in SQL, and while it did ...
Copy your assembly DLL file to the local drive on your various servers. Then register your assembly with the database: create assembly [YOUR_ASSEMBLY] from '(PATH_TO_DLL)'...then you create a function referencing the appropriate public method in the DLL: create proc [YOUR_FUNCTION] as external name [YOUR_ASSEMBLY].[NAM...
How do I deploy a managed stored procedure without using Visual Studio? Everything I have read says that when making a managed stored procedure, to right click in Visual Studio and choose deploy. That works fine, but what if I want to deploy it outside of Visual Studio to a number of different locations? I tried creati...
TITLE: How do I deploy a managed stored procedure without using Visual Studio? QUESTION: Everything I have read says that when making a managed stored procedure, to right click in Visual Studio and choose deploy. That works fine, but what if I want to deploy it outside of Visual Studio to a number of different locatio...
[ "sql", "stored-procedures", "clr" ]
7
6
3,133
2
0
2008-09-23T22:23:02.113000
2008-09-23T23:24:38.703000
124,296
125,005
Widget Data Across Multiple Controllers
Let's say that I have a widget that displays summary information about how many posts or comments that I have on a site. What's the cleanest way to persist this information across controllers? Including the instance variables in the application controller seems like a bad idea. Having a before filter that loads the dat...
Presumably, you have a single partial that displays this info. You can put the methods that fetch the data you need in ApplicationHelper or as class methods on whatever model(s) you're getting the data from. Then call that method in the partial when you need to display it.
Widget Data Across Multiple Controllers Let's say that I have a widget that displays summary information about how many posts or comments that I have on a site. What's the cleanest way to persist this information across controllers? Including the instance variables in the application controller seems like a bad idea. H...
TITLE: Widget Data Across Multiple Controllers QUESTION: Let's say that I have a widget that displays summary information about how many posts or comments that I have on a site. What's the cleanest way to persist this information across controllers? Including the instance variables in the application controller seems ...
[ "ruby-on-rails", "ruby" ]
3
1
157
3
0
2008-09-23T22:23:19.663000
2008-09-24T02:06:39.017000
124,299
124,334
What is the best way to manage Time in a Java application?
So I'm using hibernate and working with an application that manages time. What is the best way to deal with times in a 24 hour clock? I do not need to worry about TimeZone issues at the beginning of this application but it would be best to ensure that this functionality is built in at the beginning. I'm using hibernate...
Store them as long ts = System.currentTimeMillis(). That format is actually TimeZone-safe as it return time in UTC. If you only need time part, well, I'm not aware of built-in type in Hib, but writing your own type Time24 is trivial -- just implement either org.hibernate.UserType or org.hibernate.CompositeUserType (loa...
What is the best way to manage Time in a Java application? So I'm using hibernate and working with an application that manages time. What is the best way to deal with times in a 24 hour clock? I do not need to worry about TimeZone issues at the beginning of this application but it would be best to ensure that this func...
TITLE: What is the best way to manage Time in a Java application? QUESTION: So I'm using hibernate and working with an application that manages time. What is the best way to deal with times in a 24 hour clock? I do not need to worry about TimeZone issues at the beginning of this application but it would be best to ens...
[ "java", "hibernate" ]
2
4
2,871
5
0
2008-09-23T22:24:12.437000
2008-09-23T22:32:43.383000
124,313
124,763
IsolationLevel.RepeatableRead to prevent duplicates
I'm working on an application that is supposed to create products (like shipping insurance policies) when PayPal Instant Payment Notifications are received. Unfortunately, PayPal sometimes sends duplicate notifications. Furthermore, there is another third-party that is performing web-service updates simultaneously when...
It would be safer and cleaner if insert into Policy just hit some uniqueness table constraint on attempt to insert duplicate. Raising isolation level can lower concurrency and lead to other nasty issues like deadlocks. Another way is to always insert Policy row, then roll it back if Package has been attached to a Polic...
IsolationLevel.RepeatableRead to prevent duplicates I'm working on an application that is supposed to create products (like shipping insurance policies) when PayPal Instant Payment Notifications are received. Unfortunately, PayPal sometimes sends duplicate notifications. Furthermore, there is another third-party that i...
TITLE: IsolationLevel.RepeatableRead to prevent duplicates QUESTION: I'm working on an application that is supposed to create products (like shipping insurance policies) when PayPal Instant Payment Notifications are received. Unfortunately, PayPal sometimes sends duplicate notifications. Furthermore, there is another ...
[ "c#", "sql-server", "database", "transactions", "data-access-layer" ]
2
1
1,915
3
0
2008-09-23T22:26:50.293000
2008-09-24T00:40:42.077000
124,314
124,537
To Update blindly or to Update Where?
I have a table that holds information about cities in a game, you can build one building each turn and this is recorded with the value "usedBuilding". Each turn I will run a script that alters usedBuilding to 0, the question is, which of the following two ways is faster and does it actually matter which way is used? UP...
In general, the 2nd case (with the WHERE) clause would be faster - as it won't cause trigger evaluation, transaction logging, index updating, etc. on the unused rows. Potentially - depending on the distribution of 0/1 values, it could actually be faster to update all rows rather than doing the comparison - but that's a...
To Update blindly or to Update Where? I have a table that holds information about cities in a game, you can build one building each turn and this is recorded with the value "usedBuilding". Each turn I will run a script that alters usedBuilding to 0, the question is, which of the following two ways is faster and does it...
TITLE: To Update blindly or to Update Where? QUESTION: I have a table that holds information about cities in a game, you can build one building each turn and this is recorded with the value "usedBuilding". Each turn I will run a script that alters usedBuilding to 0, the question is, which of the following two ways is ...
[ "mysql", "optimization", "sql-update" ]
1
4
404
8
0
2008-09-23T22:27:28.980000
2008-09-23T23:28:49.223000
124,318
124,337
Is it worth it to use Wap to have cellular webpage?
Is it worth it to develop WAP webpage for cellular since now cellular have browser that is really better than before? I have a PHP website and I would like to increase the use of portable device to use it. Is it worth it to implement.
Frankly, no. I've written WAP pages (it's painful), I've never seen a person use a WAP browser, and for the 4.25 people in the world who do, there are WAP Gateways. Unless your site is geared towards providing WAP friendly content (e.g. bitesize) that people will reload regularly, it's probably more cost effective to p...
Is it worth it to use Wap to have cellular webpage? Is it worth it to develop WAP webpage for cellular since now cellular have browser that is really better than before? I have a PHP website and I would like to increase the use of portable device to use it. Is it worth it to implement.
TITLE: Is it worth it to use Wap to have cellular webpage? QUESTION: Is it worth it to develop WAP webpage for cellular since now cellular have browser that is really better than before? I have a PHP website and I would like to increase the use of portable device to use it. Is it worth it to implement. ANSWER: Frankl...
[ "mobile-browser", "wap" ]
2
3
452
3
0
2008-09-23T22:28:30.303000
2008-09-23T22:33:20.217000
124,325
124,514
.NET Generic Method Question
I'm trying to grasp the concept of.NET Generics and actually use them in my own code but I keep running into a problem. Can someone try to explain to me why the following setup does not compile? public class ClassA { ClassB b = new ClassB(); public void MethodA (IRepo repo) where T: ITypeEntity { b.MethodB(repo); } } ...
Inheritance doesn't work the same when using generics. As Smashery points out, even if TypeA inherits from TypeB, myType doesn't inherit from myType. As such, you can't make a call to a method defined as MethodA(myType b) expecting a myType and give it a myType instead. The types in question have to match exactly. Thus...
.NET Generic Method Question I'm trying to grasp the concept of.NET Generics and actually use them in my own code but I keep running into a problem. Can someone try to explain to me why the following setup does not compile? public class ClassA { ClassB b = new ClassB(); public void MethodA (IRepo repo) where T: ITypeE...
TITLE: .NET Generic Method Question QUESTION: I'm trying to grasp the concept of.NET Generics and actually use them in my own code but I keep running into a problem. Can someone try to explain to me why the following setup does not compile? public class ClassA { ClassB b = new ClassB(); public void MethodA (IRepo rep...
[ "c#", ".net", "generics" ]
5
3
3,396
10
0
2008-09-23T22:30:44.823000
2008-09-23T23:16:06.307000
124,326
124,533
How to convert an "object" into a function in JavaScript?
JavaScript allows functions to be treated as objects--if you first define a variable as a function, you can subsequently add properties to that function. How do you do the reverse, and add a function to an "object"? This works: var foo = function() { return 1; }; foo.baz = "qqqq"; At this point, foo() calls the functio...
You can't (as far as I know) do what you're asking, but hopefully this will clear up any confusion. First, most objects in Javascript inherit from the Object prototype. // these do the same thing var foo = new Object(); var bar = {}; console.log(foo instanceof Object); // true console.log(bar instanceof Object); // tr...
How to convert an "object" into a function in JavaScript? JavaScript allows functions to be treated as objects--if you first define a variable as a function, you can subsequently add properties to that function. How do you do the reverse, and add a function to an "object"? This works: var foo = function() { return 1; }...
TITLE: How to convert an "object" into a function in JavaScript? QUESTION: JavaScript allows functions to be treated as objects--if you first define a variable as a function, you can subsequently add properties to that function. How do you do the reverse, and add a function to an "object"? This works: var foo = functi...
[ "javascript", "function", "properties" ]
50
30
32,250
9
0
2008-09-23T22:30:54.573000
2008-09-23T23:27:40.520000
124,336
124,347
A way of casting a base type to a derived type
I'm not sure if this is a strange thing to do or not, or if it is some how code smell...but I was wondering if there was a way (some sort of oop pattern would be nice) to "cast" a base type to a form of its derived type. I know this makes little sense as the derived type will have additional functionality that the pare...
Not soundly, in "managed" languages. This is downcasting, and there is no sane down way to handle it, for exactly the reason you described (subclasses provide more than base classes - where does this "more" come from?). If you really want a similar behaviour for a particular hierarchy, you could use constructors for de...
A way of casting a base type to a derived type I'm not sure if this is a strange thing to do or not, or if it is some how code smell...but I was wondering if there was a way (some sort of oop pattern would be nice) to "cast" a base type to a form of its derived type. I know this makes little sense as the derived type w...
TITLE: A way of casting a base type to a derived type QUESTION: I'm not sure if this is a strange thing to do or not, or if it is some how code smell...but I was wondering if there was a way (some sort of oop pattern would be nice) to "cast" a base type to a form of its derived type. I know this makes little sense as ...
[ "c#", "oop", "inheritance", "design-patterns" ]
50
30
71,261
18
0
2008-09-23T22:32:54.460000
2008-09-23T22:37:16.460000
124,358
124,452
Reuse MVC arhitecture; Have two layers of UI : ASP.NET MVC and .NET Winforms
Although my question might seem abstract I hope it's not. Suppose I develop an application, an ASP.NET MVC site and later I am tasked to build an Winforms client for this application how much and how can I reuse from the existing application? I defined the models, I defined controllers and views. They all work well. No...
I have done this previously, not with asp.net MVC but with pure asp.net web forms. I used a home-grown MVP (Model-View-Presenter) pattern, and the absolute most important thing to allow the Presenter (== Controller in your case) to be used in a WinForms app was to not reference anything to do with system.web So the fir...
Reuse MVC arhitecture; Have two layers of UI : ASP.NET MVC and .NET Winforms Although my question might seem abstract I hope it's not. Suppose I develop an application, an ASP.NET MVC site and later I am tasked to build an Winforms client for this application how much and how can I reuse from the existing application? ...
TITLE: Reuse MVC arhitecture; Have two layers of UI : ASP.NET MVC and .NET Winforms QUESTION: Although my question might seem abstract I hope it's not. Suppose I develop an application, an ASP.NET MVC site and later I am tasked to build an Winforms client for this application how much and how can I reuse from the exis...
[ "asp.net-mvc", "winforms", "refactoring", "reusability" ]
8
10
1,347
2
0
2008-09-23T22:39:08.733000
2008-09-23T22:58:17.720000
124,360
124,428
What is the best way to run asynchronous jobs in a Rails application?
I know there are several plugins that do asynchronous processing. Which one is the best one and why? The ones I know about are: BackgrounDRb
starling and workling seem pretty interesting (see the screencast ) if you might have several such process, and you want to queue them. you might also be interested by the previous screencast that use rake for background process, and by the future one that will probably be about another solution to the same question.
What is the best way to run asynchronous jobs in a Rails application? I know there are several plugins that do asynchronous processing. Which one is the best one and why? The ones I know about are: BackgrounDRb
TITLE: What is the best way to run asynchronous jobs in a Rails application? QUESTION: I know there are several plugins that do asynchronous processing. Which one is the best one and why? The ones I know about are: BackgrounDRb ANSWER: starling and workling seem pretty interesting (see the screencast ) if you might h...
[ "ruby-on-rails", "asynchronous" ]
15
8
13,841
8
0
2008-09-23T22:39:24.647000
2008-09-23T22:53:36.127000
124,364
124,426
AD locks my account
I had developed an application in visual Studio 2005. whenever i run that application active directory locks domain my account. I really cant understand what am i doing wrong.
I can't tell you exactly what's causing it, but here are some tips for troubleshooting. Install the Account Lockout and Management Tools from Microsoft so you can get a bit more detail about the why's and whens on a lockout. Here's an excellent article of debugging that walks you though everything and is more resourcef...
AD locks my account I had developed an application in visual Studio 2005. whenever i run that application active directory locks domain my account. I really cant understand what am i doing wrong.
TITLE: AD locks my account QUESTION: I had developed an application in visual Studio 2005. whenever i run that application active directory locks domain my account. I really cant understand what am i doing wrong. ANSWER: I can't tell you exactly what's causing it, but here are some tips for troubleshooting. Install t...
[ "visual-studio-2005", "active-directory" ]
1
3
887
4
0
2008-09-23T22:41:24.470000
2008-09-23T22:53:23.957000
124,374
124,404
Shell script to recursively browse a directory and replace a string
I need to recursively search directories and replace a string (say http://development:port/URI ) with another (say http://production:port/URI ) in all the files where ever it's found. Can anyone help? It would be much better if that script can print out the files that it modified and takes the search/replace patterns a...
Try this: find. -type f | xargs grep -l development | xargs perl -i.bak -p -e 's(http://development)(http://production)g' Another approach with slightly more feedback: find. -type f | while read file do grep development $file && echo "modifying $file" && perl -i.bak -p -e 's(http://development)(http://prodution)g' $fil...
Shell script to recursively browse a directory and replace a string I need to recursively search directories and replace a string (say http://development:port/URI ) with another (say http://production:port/URI ) in all the files where ever it's found. Can anyone help? It would be much better if that script can print ou...
TITLE: Shell script to recursively browse a directory and replace a string QUESTION: I need to recursively search directories and replace a string (say http://development:port/URI ) with another (say http://production:port/URI ) in all the files where ever it's found. Can anyone help? It would be much better if that s...
[ "regex", "scripting" ]
3
5
4,464
5
0
2008-09-23T22:44:44.277000
2008-09-23T22:49:13.500000
124,375
125,224
Editing Embedded PowerPoint from Excel VBA
I have an embedded PowerPoint presentation in an Excel workbook. How can I edit this (open, copy slides, add data to slides, close) using VBA?
1. Add a reference to the PowerPoint Object Model to your VBA application From the VBA window, choose Tools | References Look for Microsoft Powerpoint 12.0 Object Library and check it 2. Select and activate the PowerPoint presentation object ActiveSheet.Shapes("Object 1").Select Selection.Verb Verb:=xlOpen Note: this c...
Editing Embedded PowerPoint from Excel VBA I have an embedded PowerPoint presentation in an Excel workbook. How can I edit this (open, copy slides, add data to slides, close) using VBA?
TITLE: Editing Embedded PowerPoint from Excel VBA QUESTION: I have an embedded PowerPoint presentation in an Excel workbook. How can I edit this (open, copy slides, add data to slides, close) using VBA? ANSWER: 1. Add a reference to the PowerPoint Object Model to your VBA application From the VBA window, choose Tools...
[ "excel", "powerpoint", "vba" ]
4
8
10,898
1
0
2008-09-23T22:44:49.453000
2008-09-24T03:16:06.900000
124,396
124,563
When do transactions start when using (restful) rails
Is it the case that the entire restful verb is under a single all encompassing transaction? That is to say, if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may have performed in previous callbacks also rolled bac...
Is it the case that the entire restful verb is under a single all encompassing transaction? No if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may have performed in previous callbacks also rolled back? No. does r...
When do transactions start when using (restful) rails Is it the case that the entire restful verb is under a single all encompassing transaction? That is to say, if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I ma...
TITLE: When do transactions start when using (restful) rails QUESTION: Is it the case that the entire restful verb is under a single all encompassing transaction? That is to say, if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database o...
[ "ruby-on-rails", "ruby", "rest", "transactions" ]
7
4
4,228
3
0
2008-09-23T22:48:09.697000
2008-09-23T23:37:03.433000
124,405
124,454
How to get GCC to use more than two SIMD registers when using intrinsics?
I am writing some code and trying to speed it up using SIMD intrinsics SSE2/3. My code is of such nature that I need to load some data into an XMM register and act on it many times. When I'm looking at the assembler code generated, it seems that GCC keeps flushing the data back to the memory, in order to reload somethi...
Yes, you can. Explicit Reg Vars talks about the syntax you need to pin a variable to a specific register.
How to get GCC to use more than two SIMD registers when using intrinsics? I am writing some code and trying to speed it up using SIMD intrinsics SSE2/3. My code is of such nature that I need to load some data into an XMM register and act on it many times. When I'm looking at the assembler code generated, it seems that ...
TITLE: How to get GCC to use more than two SIMD registers when using intrinsics? QUESTION: I am writing some code and trying to speed it up using SIMD intrinsics SSE2/3. My code is of such nature that I need to load some data into an XMM register and act on it many times. When I'm looking at the assembler code generat...
[ "gcc", "assembly", "x86", "sse", "simd" ]
12
2
2,690
3
0
2008-09-23T22:49:22.830000
2008-09-23T22:58:57.500000
124,411
5,182,747
Using .Net, how can I determine if a type is a Numeric ValueType?
But here's an example: Dim desiredType as Type if IsNumeric(desiredType) then... EDIT: I only know the Type, not the Value as a string. Ok, so unfortunately I have to cycle through the TypeCode. But this is a nice way to do it: if ((desiredType.IsArray)) return 0; switch (Type.GetTypeCode(desiredType)) { case 3: case ...
A few years late here, but here's my solution (you can choose whether to include boolean). Solves for the Nullable case. XUnit test included /// /// Determines if a type is numeric. Nullable numeric types are considered numeric. /// /// /// Boolean is not considered numeric. /// public static bool IsNumericType( Type t...
Using .Net, how can I determine if a type is a Numeric ValueType? But here's an example: Dim desiredType as Type if IsNumeric(desiredType) then... EDIT: I only know the Type, not the Value as a string. Ok, so unfortunately I have to cycle through the TypeCode. But this is a nice way to do it: if ((desiredType.IsArray))...
TITLE: Using .Net, how can I determine if a type is a Numeric ValueType? QUESTION: But here's an example: Dim desiredType as Type if IsNumeric(desiredType) then... EDIT: I only know the Type, not the Value as a string. Ok, so unfortunately I have to cycle through the TypeCode. But this is a nice way to do it: if ((des...
[ ".net", "reflection" ]
49
106
33,708
10
0
2008-09-23T22:50:40.173000
2011-03-03T15:24:52.837000
124,417
124,474
Is there a Max function in SQL Server that takes two values like Math.Max in .NET?
I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o But this isn't how the MAX function works, right? It is an aggregate function so it expects a single parameter and then returns the MAX of all rows. Does anyone know how to do it my way?
You'd need to make a User-Defined Function if you wanted to have syntax similar to your example, but could you do what you want to do, inline, fairly easily with a CASE statement, as the others have said. The UDF could be something like this: create function dbo.InlineMax(@val1 int, @val2 int) returns int as begin if @...
Is there a Max function in SQL Server that takes two values like Math.Max in .NET? I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o But this isn't how the MAX function works, right? It is an aggregate function so it expects a single parameter and then returns th...
TITLE: Is there a Max function in SQL Server that takes two values like Math.Max in .NET? QUESTION: I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o But this isn't how the MAX function works, right? It is an aggregate function so it expects a single parameter a...
[ "sql", "sql-server", "max" ]
638
191
668,901
31
0
2008-09-23T22:52:03.837000
2008-09-23T23:03:06.697000
124,453
124,483
Why does Hibernate seem to be designed for short lived sessions?
I know this is a subjective question, but why does Hibernate seem to be designed for short lived sessions? Generally in my apps I create DAOs to abstract my data layer, but since I can't predict how the entity objects are going to be used some of its collections are lazy loaded, or I should say fail to load once the se...
Becuase once you move out of your transaction boundary you can't hit the database again without starting a new transaction. Having long running transactions 'just in case' is a bad thing (tm). I guess you want to lazy load object from your view - take a look here for some options. I prefer to define exactly how much of...
Why does Hibernate seem to be designed for short lived sessions? I know this is a subjective question, but why does Hibernate seem to be designed for short lived sessions? Generally in my apps I create DAOs to abstract my data layer, but since I can't predict how the entity objects are going to be used some of its coll...
TITLE: Why does Hibernate seem to be designed for short lived sessions? QUESTION: I know this is a subjective question, but why does Hibernate seem to be designed for short lived sessions? Generally in my apps I create DAOs to abstract my data layer, but since I can't predict how the entity objects are going to be use...
[ "java", "hibernate" ]
2
4
1,161
6
0
2008-09-23T22:58:52.680000
2008-09-23T23:06:03.273000
124,457
124,470
.net - How do you Register a startup script?
I have limited experience with.net. My app throws an error this.dateTimeFormat is undefined which I tracked down to a known ajax bug. The workaround posted said to: "Register the following as a startup script:" Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { if (!this._upperAbbrMonths) { this._upperAbb...
You would use ClientScriptManager.RegisterStartupScript() string str = @"Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { if (!this._upperAbbrMonths) { this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames); } return Array.indexOf(this._upperAbbrMonths, this._toUpper(value...
.net - How do you Register a startup script? I have limited experience with.net. My app throws an error this.dateTimeFormat is undefined which I tracked down to a known ajax bug. The workaround posted said to: "Register the following as a startup script:" Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) {...
TITLE: .net - How do you Register a startup script? QUESTION: I have limited experience with.net. My app throws an error this.dateTimeFormat is undefined which I tracked down to a known ajax bug. The workaround posted said to: "Register the following as a startup script:" Sys.CultureInfo.prototype._getAbbrMonthIndex =...
[ ".net", "ajax", "debugging", "startupscript", "clientscriptmanager" ]
7
9
5,034
3
0
2008-09-23T22:59:36.877000
2008-09-23T23:02:24.607000
124,462
124,557
How to make HTTP requests in PHP and not wait on the response
Is there a way in PHP to make HTTP calls and not wait for a response? I don't care about the response, I just want to do something like file_get_contents(), but not wait for the request to finish before executing the rest of my code. This would be super useful for setting off "events" of a sort in my application, or tr...
You can do trickery by using exec() to invoke something that can do HTTP requests, like wget, but you must direct all output from the program to somewhere, like a file or /dev/null, otherwise the PHP process will wait for that output. If you want to separate the process from the apache thread entirely, try something li...
How to make HTTP requests in PHP and not wait on the response Is there a way in PHP to make HTTP calls and not wait for a response? I don't care about the response, I just want to do something like file_get_contents(), but not wait for the request to finish before executing the rest of my code. This would be super usef...
TITLE: How to make HTTP requests in PHP and not wait on the response QUESTION: Is there a way in PHP to make HTTP calls and not wait for a response? I don't care about the response, I just want to do something like file_get_contents(), but not wait for the request to finish before executing the rest of my code. This w...
[ "php", "http", "asynchronous" ]
249
24
230,789
17
0
2008-09-23T23:00:53.440000
2008-09-23T23:35:26.947000
124,481
124,532
SQL Server Adapter for Rails
Trying to find the sqlserver adapter for rails on windows. I have tried getting it from (without luck): gem install activerecord-sqlserver-adapter --source= http://gems.rubyonrails.org Where else can I get this gem? UPDATE: Make sure to run the command prompt as the administrator. Right click on the command prompt and ...
I just ran the exact command line you did, and the gem installs fine. Questions: Are you running Vista? If so, make sure you run your command prompt with administrative access, so it can write to the gems folder Do you have the latest version of gems? Run gem --version to find out what you have, if it's not 1.2.0, then...
SQL Server Adapter for Rails Trying to find the sqlserver adapter for rails on windows. I have tried getting it from (without luck): gem install activerecord-sqlserver-adapter --source= http://gems.rubyonrails.org Where else can I get this gem? UPDATE: Make sure to run the command prompt as the administrator. Right cli...
TITLE: SQL Server Adapter for Rails QUESTION: Trying to find the sqlserver adapter for rails on windows. I have tried getting it from (without luck): gem install activerecord-sqlserver-adapter --source= http://gems.rubyonrails.org Where else can I get this gem? UPDATE: Make sure to run the command prompt as the admini...
[ "sql-server", "ruby-on-rails", "windows", "ruby" ]
3
2
1,098
1
0
2008-09-23T23:05:25.520000
2008-09-23T23:27:36.857000
124,492
124,522
C# HttpWebRequest command to get directory listing
I need a short code snippet to get a directory listing from an HTTP server. Thanks
A few important considerations before the code: The HTTP Server has to be configured to allow directories listing for the directories you want; Because directory listings are normal HTML pages there is no standard that defines the format of a directory listing; Due to consideration 2 you are in the land where you have ...
C# HttpWebRequest command to get directory listing I need a short code snippet to get a directory listing from an HTTP server. Thanks
TITLE: C# HttpWebRequest command to get directory listing QUESTION: I need a short code snippet to get a directory listing from an HTTP server. Thanks ANSWER: A few important considerations before the code: The HTTP Server has to be configured to allow directories listing for the directories you want; Because directo...
[ "c#", "http" ]
15
32
67,548
7
0
2008-09-23T23:08:03.907000
2008-09-23T23:20:37.277000
124,549
124,550
What exactly are DLL files, and how do they work?
How exactly do DLL files work? There seems to be an awful lot of them, but I don't know what they are or how they work. So, what's the deal with them?
What is a DLL? Dynamic Link Libraries (DLL)s are like EXEs but they are not directly executable. They are similar to.so files in Linux/Unix. That is to say, DLLs are MS's implementation of shared libraries. DLLs are so much like an EXE that the file format itself is the same. Both EXE and DLLs are based on the Portable...
What exactly are DLL files, and how do they work? How exactly do DLL files work? There seems to be an awful lot of them, but I don't know what they are or how they work. So, what's the deal with them?
TITLE: What exactly are DLL files, and how do they work? QUESTION: How exactly do DLL files work? There seems to be an awful lot of them, but I don't know what they are or how they work. So, what's the deal with them? ANSWER: What is a DLL? Dynamic Link Libraries (DLL)s are like EXEs but they are not directly executa...
[ "windows", "winapi", "dll" ]
318
410
404,582
9
0
2008-09-23T23:33:39.243000
2008-09-23T23:34:19.197000
124,571
141,980
Grails with YUI table example
Does anyone have an example using the table object in YUI library. More specifically, I'd like to dynamically load it from JSON or SQL? http://www.grails.org/YUI+Plugin
I just found this example. Will be trying it out this weekend. Looks like exactly what I was looking for. http://marceloverdijk.blogspot.com/2008/06/grails-yui-datatable-example.html
Grails with YUI table example Does anyone have an example using the table object in YUI library. More specifically, I'd like to dynamically load it from JSON or SQL? http://www.grails.org/YUI+Plugin
TITLE: Grails with YUI table example QUESTION: Does anyone have an example using the table object in YUI library. More specifically, I'd like to dynamically load it from JSON or SQL? http://www.grails.org/YUI+Plugin ANSWER: I just found this example. Will be trying it out this weekend. Looks like exactly what I was l...
[ "grails", "yui" ]
2
2
4,080
2
0
2008-09-23T23:38:23.787000
2008-09-26T21:07:05.537000
124,585
124,598
Java equals(): to reflect or not to reflect
This question is specifically related to overriding the equals() method for objects with a large number of fields. First off, let me say that this large object cannot be broken down into multiple components without violating OO principles, so telling me "no class should have more than x fields" won't help. Moving on, t...
If you did want to whitelist for performance reasons, consider using an annotation to indicate which fields to compare. Also, this implementation won't work if your fields don't have good implementations for equals(). P.S. If you go this route for equals(), don't forget to do something similar for hashCode(). P.P.S. I ...
Java equals(): to reflect or not to reflect This question is specifically related to overriding the equals() method for objects with a large number of fields. First off, let me say that this large object cannot be broken down into multiple components without violating OO principles, so telling me "no class should have ...
TITLE: Java equals(): to reflect or not to reflect QUESTION: This question is specifically related to overriding the equals() method for objects with a large number of fields. First off, let me say that this large object cannot be broken down into multiple components without violating OO principles, so telling me "no ...
[ "java", "reflection", "equals" ]
9
13
6,148
9
0
2008-09-23T23:44:01.170000
2008-09-23T23:49:02.497000
124,586
124,594
compression library for c and php
To save network traffic I'd like to compress my data. The only trick is that I the client is a c application and the server is php. I'm looking for an open source compression library that's available for both c and php. I guess I could write an external c application to decompress my data, but I'm trying to avoid spawn...
Zlib provides C APIs, and is part of the PHP functional API as well.
compression library for c and php To save network traffic I'd like to compress my data. The only trick is that I the client is a c application and the server is php. I'm looking for an open source compression library that's available for both c and php. I guess I could write an external c application to decompress my d...
TITLE: compression library for c and php QUESTION: To save network traffic I'd like to compress my data. The only trick is that I the client is a c application and the server is php. I'm looking for an open source compression library that's available for both c and php. I guess I could write an external c application ...
[ "php", "c", "compression" ]
3
2
759
6
0
2008-09-23T23:44:22.760000
2008-09-23T23:48:55.103000
124,606
124,611
"SELECT * FROM users WHERE id IN ( )" == FAIL
I have a function that I use called sqlf(), it emulates prepared statements. For instance I can do things like: $sql = sqlf("SELECT * FROM Users WHERE name=:1 AND email=:2",'Big "John"','bj@example.com'); For various reasons, I cannot use prepared statements, but I would like to emulate them. The problem that I run int...
Null is the only value that you can guarantee is not in the set. How come it is not an option? Anything else can be seen as part of the potential set, they are all values.
"SELECT * FROM users WHERE id IN ( )" == FAIL I have a function that I use called sqlf(), it emulates prepared statements. For instance I can do things like: $sql = sqlf("SELECT * FROM Users WHERE name=:1 AND email=:2",'Big "John"','bj@example.com'); For various reasons, I cannot use prepared statements, but I would li...
TITLE: "SELECT * FROM users WHERE id IN ( )" == FAIL QUESTION: I have a function that I use called sqlf(), it emulates prepared statements. For instance I can do things like: $sql = sqlf("SELECT * FROM Users WHERE name=:1 AND email=:2",'Big "John"','bj@example.com'); For various reasons, I cannot use prepared statemen...
[ "php", "mysql" ]
4
7
6,910
6
0
2008-09-23T23:51:14.007000
2008-09-23T23:52:30.337000
124,623
124,676
Computing pseudo-inverse of a matrix in C++
I'm looking to compute the Moore-Penrose pseudo-inverse of a matrix in C++, can someone point me to a library implementation or a numerical recipe? Thanks!
You need 'Single Value Decomposition', from which you can find a C implementation here from Numerical Recipes in C. This other site describes how to use single value decomposition to calculate the pseudo-inverse.
Computing pseudo-inverse of a matrix in C++ I'm looking to compute the Moore-Penrose pseudo-inverse of a matrix in C++, can someone point me to a library implementation or a numerical recipe? Thanks!
TITLE: Computing pseudo-inverse of a matrix in C++ QUESTION: I'm looking to compute the Moore-Penrose pseudo-inverse of a matrix in C++, can someone point me to a library implementation or a numerical recipe? Thanks! ANSWER: You need 'Single Value Decomposition', from which you can find a C implementation here from N...
[ "c++", "matrix-inverse", "recipe" ]
4
5
10,543
1
0
2008-09-23T23:58:24.347000
2008-09-24T00:13:22.207000
124,630
125,013
Turn an array of pixels into an Image object with Java's ImageIO?
I'm currently turning an array of pixel values (originally created with a java.awt.image.PixelGrabber object) into an Image object using the following code: public Image getImageFromArray(int[] pixels, int width, int height) { MemoryImageSource mis = new MemoryImageSource(width, height, pixels, 0, width); Toolkit tk = ...
You can create the image without using ImageIO. Just create a BufferedImage using an image type matching the contents of the pixel array. public static Image getImageFromArray(int[] pixels, int width, int height) { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); WritableRaster raste...
Turn an array of pixels into an Image object with Java's ImageIO? I'm currently turning an array of pixel values (originally created with a java.awt.image.PixelGrabber object) into an Image object using the following code: public Image getImageFromArray(int[] pixels, int width, int height) { MemoryImageSource mis = new...
TITLE: Turn an array of pixels into an Image object with Java's ImageIO? QUESTION: I'm currently turning an array of pixel values (originally created with a java.awt.image.PixelGrabber object) into an Image object using the following code: public Image getImageFromArray(int[] pixels, int width, int height) { MemoryIma...
[ "java", "image", "awt", "toolkit", "javax.imageio" ]
28
29
63,075
6
0
2008-09-24T00:00:12.237000
2008-09-24T02:08:37.950000
124,647
124,734
How do I generate an array of pairwise distances in Ruby?
Say I have an array that represents a set of points: x = [2, 5, 8, 33, 58] How do I generate an array of all the pairwise distances?
x = [2, 5, 8, 33, 58] print x.collect {|n| x.collect {|i| (n-i).abs}}.flatten I think that would do it.
How do I generate an array of pairwise distances in Ruby? Say I have an array that represents a set of points: x = [2, 5, 8, 33, 58] How do I generate an array of all the pairwise distances?
TITLE: How do I generate an array of pairwise distances in Ruby? QUESTION: Say I have an array that represents a set of points: x = [2, 5, 8, 33, 58] How do I generate an array of all the pairwise distances? ANSWER: x = [2, 5, 8, 33, 58] print x.collect {|n| x.collect {|i| (n-i).abs}}.flatten I think that would do it...
[ "ruby", "algorithm" ]
1
5
735
3
0
2008-09-24T00:04:53.707000
2008-09-24T00:28:31.250000
124,649
129,167
How Do I Give a Textbox Focus in Silverlight?
In my Silverlight application, I can't seem to bring focus to a TextBox control. On the recommendation of various posts, I've set the IsTabStop property to True and I'm using TextBox.Focus(). Though the UserControl_Loaded event is firing, the TextBox control isn't getting focus. I've included my very simple code below....
I found this on silverlight.net, and was able to get it to work for me by adding a call to System.Windows.Browser.HtmlPage.Plugin.Focus() prior to calling RegularTextBox.Focus(): private void UserControl_Loaded(object sender, RoutedEventArgs e) { System.Windows.Browser.HtmlPage.Plugin.Focus(); RegularTextBox.Focus(); }
How Do I Give a Textbox Focus in Silverlight? In my Silverlight application, I can't seem to bring focus to a TextBox control. On the recommendation of various posts, I've set the IsTabStop property to True and I'm using TextBox.Focus(). Though the UserControl_Loaded event is firing, the TextBox control isn't getting f...
TITLE: How Do I Give a Textbox Focus in Silverlight? QUESTION: In my Silverlight application, I can't seem to bring focus to a TextBox control. On the recommendation of various posts, I've set the IsTabStop property to True and I'm using TextBox.Focus(). Though the UserControl_Loaded event is firing, the TextBox contr...
[ "silverlight", "textbox", "focus" ]
32
41
42,954
15
0
2008-09-24T00:05:13.147000
2008-09-24T19:03:58.307000
124,650
363,515
Have you integrated Mantis and Subversion?
I do mostly Windows development. We use Mantis and Subversion for our development but they aren't integrated together, in fact they are on different servers. I did a little googling about integrating the two together and came across this post. It looked interesting. I was wondering if anyone is doing this or has done t...
We've used scmbug for quite some time to link SVN to Bugzilla. Worked very well until we upgraded to Bugzilla 3.2 recently, which broke the integration. It takes a little while for the scmbug team to catch up when new releases of the SCM tools come out, which is understandable.
Have you integrated Mantis and Subversion? I do mostly Windows development. We use Mantis and Subversion for our development but they aren't integrated together, in fact they are on different servers. I did a little googling about integrating the two together and came across this post. It looked interesting. I was wond...
TITLE: Have you integrated Mantis and Subversion? QUESTION: I do mostly Windows development. We use Mantis and Subversion for our development but they aren't integrated together, in fact they are on different servers. I did a little googling about integrating the two together and came across this post. It looked inter...
[ "svn", "mantis", "scmbug" ]
8
3
6,191
6
0
2008-09-24T00:05:50.943000
2008-12-12T17:29:36.750000
124,667
124,711
Learning how to use Subversion
This is probably a really stupid newbie-sounding question to you developer type people, but I'm at a loss:( I've been trying to learn how to use Subversion for keeping the history of my code, but I'm finding it pretty confusing. I read the 'book' that comes with Subversion, but I didn't find it all that helpful. I'm us...
The recommended directory structure for a subversion repo contains three folders: "branches", "tags" and "trunk". So, create these folders somewhere convenient, in a new folder. Right click in the parent folder of these folders, go to TortoiseSVN and select Import. Enter the url to the repository you created here (ie_ ...
Learning how to use Subversion This is probably a really stupid newbie-sounding question to you developer type people, but I'm at a loss:( I've been trying to learn how to use Subversion for keeping the history of my code, but I'm finding it pretty confusing. I read the 'book' that comes with Subversion, but I didn't f...
TITLE: Learning how to use Subversion QUESTION: This is probably a really stupid newbie-sounding question to you developer type people, but I'm at a loss:( I've been trying to learn how to use Subversion for keeping the history of my code, but I'm finding it pretty confusing. I read the 'book' that comes with Subversi...
[ "svn", "version-control" ]
18
11
8,405
9
0
2008-09-24T00:10:17.907000
2008-09-24T00:23:10.793000
124,671
124,693
Picking a random element from a set
How do I pick a random element from a set? I'm particularly interested in picking a random element from a HashSet or a LinkedHashSet, in Java.
int size = myHashSet.size(); int item = new Random().nextInt(size); // In real life, the Random object should be rather more shared than this int i = 0; for(Object obj: myhashSet) { if (i == item) return obj; i++; }
Picking a random element from a set How do I pick a random element from a set? I'm particularly interested in picking a random element from a HashSet or a LinkedHashSet, in Java.
TITLE: Picking a random element from a set QUESTION: How do I pick a random element from a set? I'm particularly interested in picking a random element from a HashSet or a LinkedHashSet, in Java. ANSWER: int size = myHashSet.size(); int item = new Random().nextInt(size); // In real life, the Random object should be r...
[ "java", "algorithm", "random", "set" ]
216
102
263,018
34
0
2008-09-24T00:12:17.747000
2008-09-24T00:17:08.267000
124,674
124,720
How can you find available ldap servers from a computer in the same network, but different domain?
My company has code that integrates with activedirectory/LDAP for centralized userid/password login. Currently, the configuration page can only show the LDAP server linked to the Exchange domain the current computer is on. I'd like to list all available LDAP servers, similar to when you go to Windows Explorer and view ...
There are a few things you can attempt: You can look for SRV records in DNS for the domain you're on. These look like _protoname._transportname.domain.tld - I suspect this might be what you're already doing. You can attempt to use Service Location Protocol as documented in RFC 2608. There might be some MS-specific way ...
How can you find available ldap servers from a computer in the same network, but different domain? My company has code that integrates with activedirectory/LDAP for centralized userid/password login. Currently, the configuration page can only show the LDAP server linked to the Exchange domain the current computer is on...
TITLE: How can you find available ldap servers from a computer in the same network, but different domain? QUESTION: My company has code that integrates with activedirectory/LDAP for centralized userid/password login. Currently, the configuration page can only show the LDAP server linked to the Exchange domain the curr...
[ "c#", "active-directory", "ldap" ]
1
2
2,897
1
0
2008-09-24T00:12:46.887000
2008-09-24T00:25:07.373000
124,682
125,193
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators?
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For instance use a asp:RequiredFieldValidator leave the server side code alone but implement your own client notification using jQuery to highlight the field or background color for example.
The standard CustomValidator has a ClientValidationFunction property for that:
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For instance use a asp:RequiredFieldValidator leave the server side code alone but implement your own client notification using ...
TITLE: Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? QUESTION: Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For instance use a asp:RequiredFieldValidator leave the server side code alone but implement your own client n...
[ "asp.net", "jquery", "webforms", "validation" ]
18
11
15,526
3
0
2008-09-24T00:14:38.740000
2008-09-24T03:04:30.780000
124,685
124,777
How to map a Servlet to get extra path information with getPathInfo()
I am having an issue where Tomcat is treating extra path information as part of the servlet name. This is breaking a bunch of RESTFul functionality in our webapp (we use extra path info rather than?name=value pairs for crawler friendly links). It was working correctly before, but it broke after adding explicit mappings...
You need to map it to /servlet/MyServlet/* You are missing the trailing "/*".
How to map a Servlet to get extra path information with getPathInfo() I am having an issue where Tomcat is treating extra path information as part of the servlet name. This is breaking a bunch of RESTFul functionality in our webapp (we use extra path info rather than?name=value pairs for crawler friendly links). It was...
TITLE: How to map a Servlet to get extra path information with getPathInfo() QUESTION: I am having an issue where Tomcat is treating extra path information as part of the servlet name. This is breaking a bunch of RESTFul functionality in our webapp (we use extra path info rather than?name=value pairs for crawler frien...
[ "java", "tomcat", "rest", "servlets" ]
0
2
3,063
1
0
2008-09-24T00:15:09.190000
2008-09-24T00:47:15.197000
124,692
124,785
What is the intended use of the DEFAULT section in config files used by ConfigParser?
I've used ConfigParser for quite a while for simple configs. One thing that's bugged me for a long time is the DEFAULT section. I'm not really sure what's an appropriate use. I've read the documentation, but I would really like to see some clever examples of its use and how it affects other sections in the file (someth...
I found an explanation here by googling for "windows ini" "default section". Summary: whatever you put in the [DEFAULT] section gets propagated to every other section. Using the example from the linked website, let's say I have a config file called test1.ini: [host 1] lh_server=192.168.0.1 vh_hosts = PloneSite1:8080 lh...
What is the intended use of the DEFAULT section in config files used by ConfigParser? I've used ConfigParser for quite a while for simple configs. One thing that's bugged me for a long time is the DEFAULT section. I'm not really sure what's an appropriate use. I've read the documentation, but I would really like to see...
TITLE: What is the intended use of the DEFAULT section in config files used by ConfigParser? QUESTION: I've used ConfigParser for quite a while for simple configs. One thing that's bugged me for a long time is the DEFAULT section. I'm not really sure what's an appropriate use. I've read the documentation, but I would ...
[ "python", "parsing", "configuration-files" ]
42
58
15,358
1
0
2008-09-24T00:16:34.867000
2008-09-24T00:49:13.460000
124,695
124,731
Web Services or Custom Protocol?
I have no experience with web services. Historically I've built client-server systems using proprietary communication protocols (even they happen to be XML). I just spent a few hours looking over Axis2 and it sent a shudder down my spine. The learning curve of WS scares me, and seeing all that XML surround so little fu...
Build RESTful web APIs; then you get a lot of automatic caching and etc benefits that you don't get if you use other methods (SOAP, XML-RPC, etc) See this post for more details Another benefit is that if you build a RESTful API for your code to use, you can potentially let your users take advantage of it too - they oft...
Web Services or Custom Protocol? I have no experience with web services. Historically I've built client-server systems using proprietary communication protocols (even they happen to be XML). I just spent a few hours looking over Axis2 and it sent a shudder down my spine. The learning curve of WS scares me, and seeing a...
TITLE: Web Services or Custom Protocol? QUESTION: I have no experience with web services. Historically I've built client-server systems using proprietary communication protocols (even they happen to be XML). I just spent a few hours looking over Axis2 and it sent a shudder down my spine. The learning curve of WS scare...
[ "web-services", "web-applications" ]
3
4
1,438
8
0
2008-09-24T00:17:38.983000
2008-09-24T00:27:37.133000
124,721
124,748
Query to retrieve names of group nodes
If I had some XML such as this loaded into an XDocument object: What would a query look like to retrieve the names of the group nodes? For example, I'd like a query to return: GroupA GroupB GroupC
Something like this: XDocument doc; // populate somehow // this will give the names as XName var names = from child in doc.Root.Elements() select child.Name; // if you want just the local (no-namespaces) name as a string, use this var simpleNames = from child in doc.Root.Elements() select child.Name.LocalName;
Query to retrieve names of group nodes If I had some XML such as this loaded into an XDocument object: What would a query look like to retrieve the names of the group nodes? For example, I'd like a query to return: GroupA GroupB GroupC
TITLE: Query to retrieve names of group nodes QUESTION: If I had some XML such as this loaded into an XDocument object: What would a query look like to retrieve the names of the group nodes? For example, I'd like a query to return: GroupA GroupB GroupC ANSWER: Something like this: XDocument doc; // populate somehow ...
[ "c#", ".net", "linq", "linq-to-xml" ]
2
8
293
1
0
2008-09-24T00:25:22.707000
2008-09-24T00:35:05.040000
124,722
124,773
Breaking event cycles in GUIs
When writing GUIs, I've frequently come over the following problem: Assume you have a model and a controller. The controller has a widget W that is used to show a property X of the model. Because the model might be changed from outside the controller (there might be other controllers using the same model, undo operatio...
Usually you should respond to input events in the widget and not to change events. This prevents this type of loop from occuring. User changes input in the widget Widget emits change event (scroll done / enter clicked / mouse leave, etc.) Controller responds, translates to change in the model Model emits event Controll...
Breaking event cycles in GUIs When writing GUIs, I've frequently come over the following problem: Assume you have a model and a controller. The controller has a widget W that is used to show a property X of the model. Because the model might be changed from outside the controller (there might be other controllers using...
TITLE: Breaking event cycles in GUIs QUESTION: When writing GUIs, I've frequently come over the following problem: Assume you have a model and a controller. The controller has a widget W that is used to show a property X of the model. Because the model might be changed from outside the controller (there might be other...
[ "user-interface", "events" ]
17
3
294
3
0
2008-09-24T00:25:42.473000
2008-09-24T00:45:03.800000
124,742
124,766
Max length of send() data param on XMLHttpRequest Post
Is there a documented max to the length of the string data you can use in the send method of an XMLHttpRequest for the major browser implementations? I am running into an issue with a JavaScript XMLHttpRequest Post failing in FireFox 3 when the data is over approx 3k. I was assuming the Post would behave the same as a ...
I believe the maximum length depends not only on the browser, but also on the web server. For example, the Apache HTTP server has a LimitRequestBody directive which allows anywhere from 0 bytes to 2GB worth of data.
Max length of send() data param on XMLHttpRequest Post Is there a documented max to the length of the string data you can use in the send method of an XMLHttpRequest for the major browser implementations? I am running into an issue with a JavaScript XMLHttpRequest Post failing in FireFox 3 when the data is over approx ...
TITLE: Max length of send() data param on XMLHttpRequest Post QUESTION: Is there a documented max to the length of the string data you can use in the send method of an XMLHttpRequest for the major browser implementations? I am running into an issue with a JavaScript XMLHttpRequest Post failing in FireFox 3 when the da...
[ "javascript", "ajax", "xmlhttprequest" ]
11
8
44,287
4
0
2008-09-24T00:31:25.220000
2008-09-24T00:41:05.353000
124,745
124,760
Sniffing network traffic for signs of viruses/spyware
How can I connect a system to a network and sniff for virus/spyware related traffic? I'd like to plug in a network cable, fire up an appropriate tool sand have it scan the data for any signs of problems. I don't expect this to find everything, and this is not to prevent initial infection but to help determine if there ...
I highly recommend running Snort on a machine somewhere near the core of your network, and span (mirror) one (or more) ports from somewhere along your core network path to the machine in question. Snort has the ability to scan network traffic it sees, and automatically notify you via various methods if it sees somethin...
Sniffing network traffic for signs of viruses/spyware How can I connect a system to a network and sniff for virus/spyware related traffic? I'd like to plug in a network cable, fire up an appropriate tool sand have it scan the data for any signs of problems. I don't expect this to find everything, and this is not to pre...
TITLE: Sniffing network traffic for signs of viruses/spyware QUESTION: How can I connect a system to a network and sniff for virus/spyware related traffic? I'd like to plug in a network cable, fire up an appropriate tool sand have it scan the data for any signs of problems. I don't expect this to find everything, and ...
[ "networking", "system-administration", "virus", "sniffing", "spyware" ]
12
14
37,645
8
0
2008-09-24T00:33:51.500000
2008-09-24T00:37:08.810000
124,764
124,832
Are Mutexes needed in javascript?
I have seen this link: Implementing Mutual Exclusion in JavaScript. On the other hand, I have read that there are no threads in javascript, but what exactly does that mean? When events occur, where in the code can they interrupt? And if there are no threads in JS, do I need to use mutexes in JS or not? Specifically, I ...
Javascript is defined as a reentrant language which means there is no threading exposed to the user, there may be threads in the implementation. Functions like setTimeout() and asynchronous callbacks need to wait for the script engine to sleep before they're able to run. That means that everything that happens in an ev...
Are Mutexes needed in javascript? I have seen this link: Implementing Mutual Exclusion in JavaScript. On the other hand, I have read that there are no threads in javascript, but what exactly does that mean? When events occur, where in the code can they interrupt? And if there are no threads in JS, do I need to use mute...
TITLE: Are Mutexes needed in javascript? QUESTION: I have seen this link: Implementing Mutual Exclusion in JavaScript. On the other hand, I have read that there are no threads in javascript, but what exactly does that mean? When events occur, where in the code can they interrupt? And if there are no threads in JS, do ...
[ "javascript", "multithreading", "mutex" ]
123
120
88,259
7
0
2008-09-24T00:40:43.030000
2008-09-24T01:04:31.787000
124,786
124,823
GetPrivateProfileString Oddity
I was just tinkering around with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from.NET and came across something odd I don't understand. Let's start with this encantation: Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringW" ( _ ByVal lpApp...
Check to see if the file you are opening has a byte order mark (a few bytes marking the type of text encoding). These Windows API calls don't seem to grok byte order marks and is causes them to miss the first section (hence everything works fine if there is a blank line).
GetPrivateProfileString Oddity I was just tinkering around with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from.NET and came across something odd I don't understand. Let's start with this encantation: Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivate...
TITLE: GetPrivateProfileString Oddity QUESTION: I was just tinkering around with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from.NET and came across something odd I don't understand. Let's start with this encantation: Private Declare Unicode Function GetPrivateProfileString Lib "kernel32"...
[ "winapi", "unicode", "encoding", "ini" ]
5
10
3,328
2
0
2008-09-24T00:49:16.237000
2008-09-24T01:00:17.757000
124,841
124,846
Could not load type from assembly error
I have written the following simple test in trying to learn Castle Windsor's Fluent Interface: using NUnit.Framework; using Castle.Windsor; using System.Collections; using Castle.MicroKernel.Registration; namespace WindsorSample { public class MyComponent: IMyComponent { public MyComponent(int start_at) { this.Value =...
Is the assembly in the Global Assembly Cache (GAC) or any place the might be overriding the assembly that you think is being loaded? This is usually the result of an incorrect assembly being loaded, for me it means I usually have something in the GAC overriding the version I have in bin/Debug.
Could not load type from assembly error I have written the following simple test in trying to learn Castle Windsor's Fluent Interface: using NUnit.Framework; using Castle.Windsor; using System.Collections; using Castle.MicroKernel.Registration; namespace WindsorSample { public class MyComponent: IMyComponent { public ...
TITLE: Could not load type from assembly error QUESTION: I have written the following simple test in trying to learn Castle Windsor's Fluent Interface: using NUnit.Framework; using Castle.Windsor; using System.Collections; using Castle.MicroKernel.Registration; namespace WindsorSample { public class MyComponent: IMyC...
[ ".net" ]
157
130
341,239
31
0
2008-09-24T01:09:34.630000
2008-09-24T01:13:10.987000
124,844
124,858
Flags in a database rows, best practices
I am asking this out of a curiosity. Basically my question is when you have a database which needs a row entry to have things which act like flags, what is the best practice? A good example of this would be the badges on stack overflow, or the operating system field in bugzilla. Any subset of the flags may be set for a...
If you really need an unbounded selection from a closed set of flags (e.g. stackoverflow badges), then the "relational way" would be to create a table of flags and a separate table which relates those flags to your target entities. Thus, users, flags and usersToFlags. However, if space efficiency is a serious concern a...
Flags in a database rows, best practices I am asking this out of a curiosity. Basically my question is when you have a database which needs a row entry to have things which act like flags, what is the best practice? A good example of this would be the badges on stack overflow, or the operating system field in bugzilla....
TITLE: Flags in a database rows, best practices QUESTION: I am asking this out of a curiosity. Basically my question is when you have a database which needs a row entry to have things which act like flags, what is the best practice? A good example of this would be the badges on stack overflow, or the operating system ...
[ "sql", "database", "flags" ]
39
30
51,851
8
0
2008-09-24T01:12:08.273000
2008-09-24T01:19:03
124,851
342,526
OpenGL still better than Direct3D for non-games?
The standard model has been that OpenGL is for professional apps (CAD) and Direct3D is for games. With the debacle of openGL 3.0, is openGl still the natural choice for technical 3D apps (cad/GIS)? Are there scenegraph libraries for Direct3D? (Of course Direct3D is windows only.)
D3D makes you pay the Microsoft "strategy tax." That is, D3D serves two masters. One is giving you features and performance. The other is to ensure lock-in to other MS products and the Windows platform generally. This has some consequences for you: A D3D app won't run on anything but Windows (including Xbox). Maybe you...
OpenGL still better than Direct3D for non-games? The standard model has been that OpenGL is for professional apps (CAD) and Direct3D is for games. With the debacle of openGL 3.0, is openGl still the natural choice for technical 3D apps (cad/GIS)? Are there scenegraph libraries for Direct3D? (Of course Direct3D is windo...
TITLE: OpenGL still better than Direct3D for non-games? QUESTION: The standard model has been that OpenGL is for professional apps (CAD) and Direct3D is for games. With the debacle of openGL 3.0, is openGl still the natural choice for technical 3D apps (cad/GIS)? Are there scenegraph libraries for Direct3D? (Of course...
[ "opengl", "directx", "direct3d" ]
24
35
8,706
8
0
2008-09-24T01:15:50.777000
2008-12-05T00:27:35.970000
124,854
124,929
How can I select an <img> element programmatically using JavaScript?
I have an in an HTML document that I would like to highlight as though the user had highlighted it using the mouse. Is there a way to do that using JavaScript? I only need it to work in Mozilla, but any and all information is welcome. EDIT: The reason I want to select the image is actually not so that it appears highli...
Here's an example which selects the first image on the page (which will be the Stack Overflow logo if you test it out on this page in Firebug): var s = window.getSelection() var r = document.createRange(); r.selectNode(document.images[0]); s.addRange(r) Relevant documentation: http://developer.mozilla.org/en/DOM/window...
How can I select an <img> element programmatically using JavaScript? I have an in an HTML document that I would like to highlight as though the user had highlighted it using the mouse. Is there a way to do that using JavaScript? I only need it to work in Mozilla, but any and all information is welcome. EDIT: The reason...
TITLE: How can I select an <img> element programmatically using JavaScript? QUESTION: I have an in an HTML document that I would like to highlight as though the user had highlighted it using the mouse. Is there a way to do that using JavaScript? I only need it to work in Mozilla, but any and all information is welcome...
[ "javascript", "html", "firefox", "dom" ]
7
12
9,338
7
0
2008-09-24T01:17:48.760000
2008-09-24T01:42:34.067000
124,863
125,178
Options for Dynamic content in ASP.Net
What choices do I have for creating stateful dynamic content in an ASP.Net web site? Here's my scenario. I have a site that has multiple, nested content regions. The top level are actions tied to a functional area Catalog, Subscriptions, Settings. When you click on the functional action, I want to dynamically add conte...
Some other options: Content only appears to be dynamic. You load enough controls on the page to handle anything and only actually show what you need. This saves a lot of hassle messing with view state and such, but means your page has a bigger footprint. Add controls to the page dynamically. You've already been playing...
Options for Dynamic content in ASP.Net What choices do I have for creating stateful dynamic content in an ASP.Net web site? Here's my scenario. I have a site that has multiple, nested content regions. The top level are actions tied to a functional area Catalog, Subscriptions, Settings. When you click on the functional ...
TITLE: Options for Dynamic content in ASP.Net QUESTION: What choices do I have for creating stateful dynamic content in an ASP.Net web site? Here's my scenario. I have a site that has multiple, nested content regions. The top level are actions tied to a functional area Catalog, Subscriptions, Settings. When you click ...
[ "asp.net", "ajax", "iframe", "user-controls" ]
1
1
2,047
4
0
2008-09-24T01:19:35.697000
2008-09-24T03:01:59.133000
124,865
129,401
XML Schema (XSD) validation tool?
At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an.XSD file. Are there tool or libraries that we can use for automated testing to check that the generated XML matches the schema? We would prefer free tools that are appropriate...
After some research, I think the best answer is Xerces, as it implements all of XSD, is cross-platform and widely used. I've created a small Java project on github to validate from the command line using the default JRE parser, which is normally Xerces. This can be used on Windows/Mac/Linux. There is also a C++ version...
XML Schema (XSD) validation tool? At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an.XSD file. Are there tool or libraries that we can use for automated testing to check that the generated XML matches the schema? We would pref...
TITLE: XML Schema (XSD) validation tool? QUESTION: At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an.XSD file. Are there tool or libraries that we can use for automated testing to check that the generated XML matches the sch...
[ "xml", "validation", "xsd", "schema" ]
275
251
301,482
14
0
2008-09-24T01:19:54.137000
2008-09-24T19:41:21.853000
124,869
124,874
How does the .doc format work?
I recently learned about the basic structure of the.docx file (it's a specially structured zip archive). However, docx is not formated like a doc. How does a doc file work? What is the file format, structure, etc?
The full format for binary.doc files is documented in this pdf from ( the Wikipedia article on.doc )
How does the .doc format work? I recently learned about the basic structure of the.docx file (it's a specially structured zip archive). However, docx is not formated like a doc. How does a doc file work? What is the file format, structure, etc?
TITLE: How does the .doc format work? QUESTION: I recently learned about the basic structure of the.docx file (it's a specially structured zip archive). However, docx is not formated like a doc. How does a doc file work? What is the file format, structure, etc? ANSWER: The full format for binary.doc files is document...
[ "zip", "format", "docx", "doc" ]
15
12
10,676
6
0
2008-09-24T01:23:02.773000
2008-09-24T01:25:10.597000
124,871
124,898
What is Castle Windsor, and why should I care?
I'm a long-time Windows developer, having cut my teeth on win32 and early COM. I've been working with.NET since 2001, so I'm pretty fluent in C# and the CLR. I'd never heard of Castle Windsor until I started participating in Stack Overflow. I've read the Castle Windsor "Getting Started" guide, but it's not clicking. Te...
Castle Windsor is an inversion of control tool. There are others like it. It can give you objects with pre-built and pre-wired dependencies right in there. An entire object graph created via reflection and configuration rather than the "new" operator. Start here: http://tech.groups.yahoo.com/group/altdotnet/message/104...
What is Castle Windsor, and why should I care? I'm a long-time Windows developer, having cut my teeth on win32 and early COM. I've been working with.NET since 2001, so I'm pretty fluent in C# and the CLR. I'd never heard of Castle Windsor until I started participating in Stack Overflow. I've read the Castle Windsor "Ge...
TITLE: What is Castle Windsor, and why should I care? QUESTION: I'm a long-time Windows developer, having cut my teeth on win32 and early COM. I've been working with.NET since 2001, so I'm pretty fluent in C# and the CLR. I'd never heard of Castle Windsor until I started participating in Stack Overflow. I've read the ...
[ "c#", "dependency-injection", "inversion-of-control", "castle-windsor" ]
199
378
78,359
5
0
2008-09-24T01:23:36.547000
2008-09-24T01:31:16.417000
124,880
124,904
Is it possible to prevent stack allocation of an object and only allow it to be instantiated with 'new'?
Is it possible to prevent stack allocation of an object and only allow it to be instiated with 'new' on the heap?
One way you could do this would be to make the constructors private and only allow construction through a static method that returns a pointer. For example: class Foo { public: ~Foo(); static Foo* createFoo() { return new Foo(); } private: Foo(); Foo(const Foo&); Foo& operator=(const Foo&); };
Is it possible to prevent stack allocation of an object and only allow it to be instantiated with 'new'? Is it possible to prevent stack allocation of an object and only allow it to be instiated with 'new' on the heap?
TITLE: Is it possible to prevent stack allocation of an object and only allow it to be instantiated with 'new'? QUESTION: Is it possible to prevent stack allocation of an object and only allow it to be instiated with 'new' on the heap? ANSWER: One way you could do this would be to make the constructors private and on...
[ "c++", "c++-faq" ]
56
88
14,683
6
0
2008-09-24T01:27:01.263000
2008-09-24T01:32:04.497000
124,885
125,091
Access Intranet via SSL using WebBrowser Winforms Control
I have a.Net 2.0 app that is used internally and we want to use the WebBrowser control to access some Web resources. We want to add encryption to these sites using SSL using self signed certificates. My question is if there is way to disable all the warnings about the SSL keys coming from an untrusted source? I would l...
I do not believe there is a work around for this, you will always get the warning when accessing the above mentioned web resources via the WebBrowser control (or Internet Explorer for that matter) You could however distribute the root cert via Group Policy.
Access Intranet via SSL using WebBrowser Winforms Control I have a.Net 2.0 app that is used internally and we want to use the WebBrowser control to access some Web resources. We want to add encryption to these sites using SSL using self signed certificates. My question is if there is way to disable all the warnings abo...
TITLE: Access Intranet via SSL using WebBrowser Winforms Control QUESTION: I have a.Net 2.0 app that is used internally and we want to use the WebBrowser control to access some Web resources. We want to add encryption to these sites using SSL using self signed certificates. My question is if there is way to disable al...
[ "c#", ".net", "user-interface", "browser" ]
2
1
7,538
3
0
2008-09-24T01:29:01.197000
2008-09-24T02:33:22.463000
124,886
124,901
How to get the application executable name in WindowsC++/CLI?
I need to change the functionality of an application based on the executable name. Nothing huge, just changing strings that are displayed and some internal identifiers. The application is written in a mixture of native and.Net C++-CLI code. Two ways that I have looked at are to parse the GetCommandLine() function in Wi...
Call GetModuleFileName() using 0 as a module handle. Note: you can also use the argv[0] parameter to main or call GetCommandLine() if there is no main. However, keep in mind that these methods will not necessarily give you the complete path to the executable file. They will give back the same string of characters that ...
How to get the application executable name in WindowsC++/CLI? I need to change the functionality of an application based on the executable name. Nothing huge, just changing strings that are displayed and some internal identifiers. The application is written in a mixture of native and.Net C++-CLI code. Two ways that I h...
TITLE: How to get the application executable name in WindowsC++/CLI? QUESTION: I need to change the functionality of an application based on the executable name. Nothing huge, just changing strings that are displayed and some internal identifiers. The application is written in a mixture of native and.Net C++-CLI code....
[ ".net", "winapi", "c++-cli" ]
22
42
34,633
8
0
2008-09-24T01:29:02.320000
2008-09-24T01:31:38.227000
124,932
124,963
XMLDocument.Load(url) through a proxy
I have a bit of code that basically reads an XML document using the XMLDocument.Load(uri) method which works fine, but doesn't work so well if the call is made through a proxy. I was wondering if anyone knew of a way to make this call (or achieve the same effect) through a proxy?
Do you have to provide credentials to the proxy? If so, this should help: "Supplying Authentication Credentials to XmlResolver when Reading from a File" http://msdn.microsoft.com/en-us/library/aa720674.aspx Basically, you... Create an XmlTextReader using the URL Set the Credentials property of the reader's XmlResolver ...
XMLDocument.Load(url) through a proxy I have a bit of code that basically reads an XML document using the XMLDocument.Load(uri) method which works fine, but doesn't work so well if the call is made through a proxy. I was wondering if anyone knew of a way to make this call (or achieve the same effect) through a proxy?
TITLE: XMLDocument.Load(url) through a proxy QUESTION: I have a bit of code that basically reads an XML document using the XMLDocument.Load(uri) method which works fine, but doesn't work so well if the call is made through a proxy. I was wondering if anyone knew of a way to make this call (or achieve the same effect) ...
[ "c#", "xml", "proxy" ]
13
11
20,697
6
0
2008-09-24T01:43:49.430000
2008-09-24T01:54:21.543000
124,952
124,961
dTrace scripts and tools
I've recently began using dTrace and have noticed just how awesome it is. Its the perfect tool for profiling without placing the burden on programmers to set up hundreds of probes in their applications. I've found some nice one liner and sample scripts here and there, but I was wondering about what scripts, tools and l...
Here are some links I've found useful A Powerpoint presentation about dTrace: http://www.nbl.fi/~nbl97/solaris/dtrace/dtt_present.pdf 200+ useful scripts: http://www.brendangregg.com/
dTrace scripts and tools I've recently began using dTrace and have noticed just how awesome it is. Its the perfect tool for profiling without placing the burden on programmers to set up hundreds of probes in their applications. I've found some nice one liner and sample scripts here and there, but I was wondering about ...
TITLE: dTrace scripts and tools QUESTION: I've recently began using dTrace and have noticed just how awesome it is. Its the perfect tool for profiling without placing the burden on programmers to set up hundreds of probes in their applications. I've found some nice one liner and sample scripts here and there, but I wa...
[ "performance", "profiling", "sun", "bsd", "dtrace" ]
5
6
2,061
4
0
2008-09-24T01:50:39.663000
2008-09-24T01:53:08.643000
124,958
125,047
glob() - sort array of files by last modified datetime stamp
I'm trying to display an array of files in order of date (last modified). I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way to do this?
Warning create_function() has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged. For the sake of posterity, in case the forum post linked in the accepted answer is lost or unclear to some, the relevant code needed is: Tested this on my system and verified it does sort by file mtime as desi...
glob() - sort array of files by last modified datetime stamp I'm trying to display an array of files in order of date (last modified). I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way to do this?
TITLE: glob() - sort array of files by last modified datetime stamp QUESTION: I'm trying to display an array of files in order of date (last modified). I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way to do this? ANSWER: Warning create_funct...
[ "php", "arrays", "sorting", "filemtime" ]
62
101
50,964
6
0
2008-09-24T01:51:54.230000
2008-09-24T02:19:13.853000
124,968
124,982
Lower than low level common bsd sockets
How do you do low low level sockets in C, example: actually sending a SYN.
What you actually want is a raw socket... you can completely control the headers and flags with the raw socket interface, but programming them is much more challenging. Here's a great tutorial to get you started: http://www.cs.binghamton.edu/~steflik/cs455/rawip.txt.
Lower than low level common bsd sockets How do you do low low level sockets in C, example: actually sending a SYN.
TITLE: Lower than low level common bsd sockets QUESTION: How do you do low low level sockets in C, example: actually sending a SYN. ANSWER: What you actually want is a raw socket... you can completely control the headers and flags with the raw socket interface, but programming them is much more challenging. Here's a ...
[ "c", "sockets", "network-programming" ]
8
10
2,088
4
0
2008-09-24T01:56:22.800000
2008-09-24T02:00:10.983000
124,975
125,115
Windows Forms textbox that has line numbers?
I'm looking for a free winforms component for an application I'm writing. I basicly need a textbox that contains line numbers in a side column. Being able to tabulate data within it would be a major plus too. Does anyone know of a premade component that could do this?
Referencing Wayne's post, here is the relevant code. It is using GDI to draw line numbers next to the text box. Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call SetStyle(ControlStyles.UserPaint, True) ...
Windows Forms textbox that has line numbers? I'm looking for a free winforms component for an application I'm writing. I basicly need a textbox that contains line numbers in a side column. Being able to tabulate data within it would be a major plus too. Does anyone know of a premade component that could do this?
TITLE: Windows Forms textbox that has line numbers? QUESTION: I'm looking for a free winforms component for an application I'm writing. I basicly need a textbox that contains line numbers in a side column. Being able to tabulate data within it would be a major plus too. Does anyone know of a premade component that cou...
[ "c#", ".net", "winforms" ]
7
6
9,266
6
0
2008-09-24T01:58:08.960000
2008-09-24T02:44:55.803000
125,016
125,032
Switching to a Standing Desk
At work I have a standard desk (4 legs, flat surface, you get the picture). For a while now I've been thinking about converting to a standing desk. What would be the best way to go about this on a limited budget? Are there some good laptop/keyboard stands I could place on my existing desk? Which ones are the best? I'm ...
Talk to an occupational therapist and get their advice because you'll be drastically changing the way you posture yourself for hours at a time. Agencies that assist people with disabilities and their carers (if you're in Australia, look up the Independent Living Centre in your capital city) would be a good start. You'l...
Switching to a Standing Desk At work I have a standard desk (4 legs, flat surface, you get the picture). For a while now I've been thinking about converting to a standing desk. What would be the best way to go about this on a limited budget? Are there some good laptop/keyboard stands I could place on my existing desk? ...
TITLE: Switching to a Standing Desk QUESTION: At work I have a standard desk (4 legs, flat surface, you get the picture). For a while now I've been thinking about converting to a standing desk. What would be the best way to go about this on a limited budget? Are there some good laptop/keyboard stands I could place on ...
[ "environment", "ergonomics" ]
5
4
1,873
2
0
2008-09-24T02:09:18.697000
2008-09-24T02:14:50.480000