PostId
int64
4
11.8M
PostCreationDate
stringlengths
19
19
OwnerUserId
int64
1
1.57M
OwnerCreationDate
stringlengths
10
19
ReputationAtPostCreation
int64
-55
461k
OwnerUndeletedAnswerCountAtPostTime
int64
0
21.5k
Title
stringlengths
3
250
BodyMarkdown
stringlengths
5
30k
Tag1
stringlengths
1
25
Tag2
stringlengths
1
25
Tag3
stringlengths
1
25
Tag4
stringlengths
1
25
Tag5
stringlengths
1
25
PostClosedDate
stringlengths
19
19
OpenStatus
stringclasses
5 values
unified_texts
stringlengths
32
30.1k
OpenStatus_id
int64
0
4
30,833
08/27/2008 18:38:31
777
08/08/2008 19:35:20
11
3
Compile a referenced dll
Using VS2005 and vb.net ... I have a project that is an api for a datastore that I created. When compiled creates api.dll. I have a second project in the same solution that has a project reference to the api project which when compiled will create wrapper.dll. This is basically a wrapper for the api that is specific to an application. When I use wrapper.dll in that other application, I have to copy wrapper.dll and api.dll to my new application. How can I get the wrapper project to compile the api.dll into itself so that i only have one dll to move around?
net
visualstudio
null
null
null
null
open
Compile a referenced dll === Using VS2005 and vb.net ... I have a project that is an api for a datastore that I created. When compiled creates api.dll. I have a second project in the same solution that has a project reference to the api project which when compiled will create wrapper.dll. This is basically a wrapper for the api that is specific to an application. When I use wrapper.dll in that other application, I have to copy wrapper.dll and api.dll to my new application. How can I get the wrapper project to compile the api.dll into itself so that i only have one dll to move around?
0
30,835
08/27/2008 18:38:54
2,535
08/22/2008 17:36:15
21
2
Source Versioning for Visual Studio Express
Is there any Visual Studio Express plug ins for source versioning? I am starting a project on my own and only have the Express version of Visual Studio 2008.
visual-studio-2008-expre
version-control
plugins
null
null
null
open
Source Versioning for Visual Studio Express === Is there any Visual Studio Express plug ins for source versioning? I am starting a project on my own and only have the Express version of Visual Studio 2008.
0
30,847
08/27/2008 18:43:21
80
08/01/2008 16:11:11
124
4
Regex to validate URIs
How do you produce a regex that matches only valid URI. The description for URIs can be found here: http://en.wikipedia.org/wiki/URI_scheme. It doesn't need to extract any parts, just test if a URI is valid. (preferred format is .Net RegularExpression)
regex
.net
null
null
null
null
open
Regex to validate URIs === How do you produce a regex that matches only valid URI. The description for URIs can be found here: http://en.wikipedia.org/wiki/URI_scheme. It doesn't need to extract any parts, just test if a URI is valid. (preferred format is .Net RegularExpression)
0
30,856
08/27/2008 18:48:04
2,363
08/21/2008 20:55:49
408
15
MySQL Results to a File
How do I write the results from a mysql query to file? I just need something quick. Output can be CSV, XML, HTML, etc.
database
mysql
db
null
null
null
open
MySQL Results to a File === How do I write the results from a mysql query to file? I just need something quick. Output can be CSV, XML, HTML, etc.
0
30,877
08/27/2008 18:54:44
3,063
08/26/2008 14:19:28
1
0
Fastest way to calculate primes in C#?
I actually have an answer to my question but it is not parallelized so I am interested in ways to improve the algorithm. Anyway it might be useful as-is for some people. int Until = 20000000; BitArray PrimeBits = new BitArray(Until, true); /* * Sieve of Eratosthenes * PrimeBits is a simple BitArray where all bit is an integer * and we mark composite numbers as false */ PrimeBits.Set(0, false); // You don't actually need this, just PrimeBits.Set(1, false); // remindig you that 2 is the smallest prime for (int P = 2; P < (int)Math.Sqrt(Until) + 1; P++) if (PrimeBits.Get(P)) // These are going to be the multiples of P if it is a prime for (int PMultiply = P * 2; PMultiply < Until; PMultiply += P) PrimeBits.Set(PMultiply, false); // We use this to store the actual prime numbers List<int> Primes = new List<int>(); for (int i = 2; i < Until; i++) if (PrimeBits.Get(i)) Primes.Add(i); Maybe I could use multiple `BitArray`s and `[BitArray.And()![MSDN][1]` them together? [1]: http://msdn.microsoft.com/en-us/library/system.collections.bitarray.and.aspx
c#
.net
primes
performance
null
null
open
Fastest way to calculate primes in C#? === I actually have an answer to my question but it is not parallelized so I am interested in ways to improve the algorithm. Anyway it might be useful as-is for some people. int Until = 20000000; BitArray PrimeBits = new BitArray(Until, true); /* * Sieve of Eratosthenes * PrimeBits is a simple BitArray where all bit is an integer * and we mark composite numbers as false */ PrimeBits.Set(0, false); // You don't actually need this, just PrimeBits.Set(1, false); // remindig you that 2 is the smallest prime for (int P = 2; P < (int)Math.Sqrt(Until) + 1; P++) if (PrimeBits.Get(P)) // These are going to be the multiples of P if it is a prime for (int PMultiply = P * 2; PMultiply < Until; PMultiply += P) PrimeBits.Set(PMultiply, false); // We use this to store the actual prime numbers List<int> Primes = new List<int>(); for (int i = 2; i < Until; i++) if (PrimeBits.Get(i)) Primes.Add(i); Maybe I could use multiple `BitArray`s and `[BitArray.And()![MSDN][1]` them together? [1]: http://msdn.microsoft.com/en-us/library/system.collections.bitarray.and.aspx
0
30,879
08/27/2008 18:55:30
2,858
08/25/2008 15:42:32
11
0
Is there a pattern using Linq to dynamically create a filter?
Is there a pattern using Linq to dynamically create a filter? I have the need to create custom filtering on a list, in the past I would just dynamically create the SQL...it doesn't seem like this is possible with Linq.
linq
linq-to-sql
.net-3.5
null
null
null
open
Is there a pattern using Linq to dynamically create a filter? === Is there a pattern using Linq to dynamically create a filter? I have the need to create custom filtering on a list, in the past I would just dynamically create the SQL...it doesn't seem like this is possible with Linq.
0
30,884
08/27/2008 18:57:17
247
08/04/2008 00:50:51
26
7
What is the best way to share MasterPages across projects
Suppose you have two seperate ASP.NET Web Application projects that both need to use a common MasterPage. What's the best way to share the MasterPage across projects without having to duplicate code?
asp.net
null
null
null
null
null
open
What is the best way to share MasterPages across projects === Suppose you have two seperate ASP.NET Web Application projects that both need to use a common MasterPage. What's the best way to share the MasterPage across projects without having to duplicate code?
0
30,903
08/27/2008 19:00:34
3,071
08/26/2008 14:30:11
22
6
Good Mercurial repository viewer for Mac
Is there a good, native Mac tool to view Mercurial repositories, similar to gitnub for Git?
mercurial
null
null
null
null
12/20/2011 14:02:22
not constructive
Good Mercurial repository viewer for Mac === Is there a good, native Mac tool to view Mercurial repositories, similar to gitnub for Git?
4
30,915
08/27/2008 19:05:24
1,063
08/12/2008 05:40:42
389
40
Cool open source projects
This is a similar question to [one posted earlier][1], but slightly different. I'm interested in what your favorite Open Source app is. I don't care if it's well coded or if it isn't active anymore, I just am interesteed in apps that work and do something useful. The internet is a big place, so with a few suggestions some of us may find a new favorite app. [1]: http://stackoverflow.com/questions/27793/well-written-open-source-projects-for-learning
opensource
program
suggestions
null
null
null
open
Cool open source projects === This is a similar question to [one posted earlier][1], but slightly different. I'm interested in what your favorite Open Source app is. I don't care if it's well coded or if it isn't active anymore, I just am interesteed in apps that work and do something useful. The internet is a big place, so with a few suggestions some of us may find a new favorite app. [1]: http://stackoverflow.com/questions/27793/well-written-open-source-projects-for-learning
0
30,928
08/27/2008 19:11:30
1,600
08/17/2008 13:46:47
634
51
A WYSIWYG Markdown control for Windows Forms?
[We have a Windows Forms database front-end application that, among other things, can be used as a CMS; clients create the structure, fill it, and then use a ASP.NET WebForms-based site to present the results to publicly on the Web. For added flexibility, they are sometimes forced to input actual HTML markup right into a text field, which then ends up as a varchar in the database. This works, but it's far from user-friendly.] As such… some clients want a WYSIWYG editor for HTML. I'd like to convince them that they'd benefit from using simpler language (namely, Markdown). Ideally, what I'd like to have is a WYSIWYG editor for that. They don't need tables, or anything sophisticated like that. A cursory search reveals [a .NET Markdown to HTML converter][1], and then we have [a Windows Forms-based text editor that outputs HTML][2], but apparently nothing that brings the two together. As a result, we'd still have our varchars with markup in there, but at least it would be both quite human-readable and still easily parseable. Would this — a WYSIWYG editor that outputs Markdown, which is then later on parsed into HTML in ASP.NET — be feasible? Any alternative suggestions? [1]: http://aspnetresources.com/blog/markdown_announced.aspx [2]: http://www.codeproject.com/KB/edit/editor_in_windows_forms.aspx
markdown
html
winforms
asp.net
null
null
open
A WYSIWYG Markdown control for Windows Forms? === [We have a Windows Forms database front-end application that, among other things, can be used as a CMS; clients create the structure, fill it, and then use a ASP.NET WebForms-based site to present the results to publicly on the Web. For added flexibility, they are sometimes forced to input actual HTML markup right into a text field, which then ends up as a varchar in the database. This works, but it's far from user-friendly.] As such… some clients want a WYSIWYG editor for HTML. I'd like to convince them that they'd benefit from using simpler language (namely, Markdown). Ideally, what I'd like to have is a WYSIWYG editor for that. They don't need tables, or anything sophisticated like that. A cursory search reveals [a .NET Markdown to HTML converter][1], and then we have [a Windows Forms-based text editor that outputs HTML][2], but apparently nothing that brings the two together. As a result, we'd still have our varchars with markup in there, but at least it would be both quite human-readable and still easily parseable. Would this — a WYSIWYG editor that outputs Markdown, which is then later on parsed into HTML in ASP.NET — be feasible? Any alternative suggestions? [1]: http://aspnetresources.com/blog/markdown_announced.aspx [2]: http://www.codeproject.com/KB/edit/editor_in_windows_forms.aspx
0
30,931
08/27/2008 19:12:36
3,306
08/27/2008 19:12:36
1
0
Register file extensions / mime types in Linux
I'm developing a Linux application that has its own file format. I want my app to open when you double-click on those files. How can I register a file extension and associate it with my application on Linux? I'm looking for a way that that is standard (works with GNOME and KDE based systems) and can be done automatic when my program is installed or run for the first time.
mime
file-type
freedesktop
linux
installation
null
open
Register file extensions / mime types in Linux === I'm developing a Linux application that has its own file format. I want my app to open when you double-click on those files. How can I register a file extension and associate it with my application on Linux? I'm looking for a way that that is standard (works with GNOME and KDE based systems) and can be done automatic when my program is installed or run for the first time.
0
30,940
08/27/2008 19:14:29
2,025
08/19/2008 20:59:50
1,087
119
How to handle error logging
Until recently I've been using `syslog` in my `System_Exception` exception handler to log important errors - a pretty useful concept I thought. However my host just cut me off, and it appears that loveable `syslog` has actually been sending my error reports to everyone on the server (it's a shared server). They weren't too pleased. I've now switched to using a log.txt (and will now have to secure this with chmod or something) - but does anyone have any other suggestions for me to try? This seems a bit rusty. Oh, and don't use `syslog` on anything except a dedicated server or somewhere that can handle it ;-)
php
error-logging
null
null
null
null
open
How to handle error logging === Until recently I've been using `syslog` in my `System_Exception` exception handler to log important errors - a pretty useful concept I thought. However my host just cut me off, and it appears that loveable `syslog` has actually been sending my error reports to everyone on the server (it's a shared server). They weren't too pleased. I've now switched to using a log.txt (and will now have to secure this with chmod or something) - but does anyone have any other suggestions for me to try? This seems a bit rusty. Oh, and don't use `syslog` on anything except a dedicated server or somewhere that can handle it ;-)
0
30,946
08/27/2008 19:17:47
2,147
08/20/2008 15:14:13
229
36
Simple password encryption
What is a good, simple encryption scheme for protecting passwords in a database? I don't necessarily need anything that's hyper-secure nor do I need anything that's lightning fast, but those things would be nice. Primarily, I just want something that's easy to implement without being terribly slow or insecure.
database
language-agnostic
passwords
null
null
null
open
Simple password encryption === What is a good, simple encryption scheme for protecting passwords in a database? I don't necessarily need anything that's hyper-secure nor do I need anything that's lightning fast, but those things would be nice. Primarily, I just want something that's easy to implement without being terribly slow or insecure.
0
30,947
08/27/2008 19:17:55
1,946
08/19/2008 14:53:06
93
4
Visual Studio 08 Spell Check Addin?
If possible one that supports at least spell checking: - C# string literals - HTML content - Comments
visualstudio
vs2008
add-in
null
null
null
open
Visual Studio 08 Spell Check Addin? === If possible one that supports at least spell checking: - C# string literals - HTML content - Comments
0
30,953
08/27/2008 19:19:52
3,022
08/26/2008 12:28:45
31
2
Is there a multiplatform framework for developing iPhone / Android applications?
I am interested in writing applications for the iPhone and the Android platform. I was hoping to find a middleware / framework that abstracted away some of the differences in the APIs and allow me to specify the target platform at build time. Is there such a framework existing or planned?
iphone
framework
android
middleware
null
null
open
Is there a multiplatform framework for developing iPhone / Android applications? === I am interested in writing applications for the iPhone and the Android platform. I was hoping to find a middleware / framework that abstracted away some of the differences in the APIs and allow me to specify the target platform at build time. Is there such a framework existing or planned?
0
30,962
08/27/2008 19:24:18
1,175
08/13/2008 10:21:54
794
82
Finding City and Zip Code for a Location
Given a latitude and longitude, what is the easiest way to find the name of the city and the US zip code of that location. (This is similar to http://beta.stackoverflow.com/questions/23572/latitude-longitude-database, except I want to convert in the opposite direction.)
maps
gis
mapping
geocoding
location
null
open
Finding City and Zip Code for a Location === Given a latitude and longitude, what is the easiest way to find the name of the city and the US zip code of that location. (This is similar to http://beta.stackoverflow.com/questions/23572/latitude-longitude-database, except I want to convert in the opposite direction.)
0
30,972
08/27/2008 19:26:47
260
08/04/2008 08:21:41
71
4
OS X InputManager, anything similar on Windows
Is there anything similar on Windows what would achieve the same as the InputManager on OS X?
windows
osx
apple
windows-api
null
null
open
OS X InputManager, anything similar on Windows === Is there anything similar on Windows what would achieve the same as the InputManager on OS X?
0
30,985
08/27/2008 19:31:40
292
08/04/2008 13:14:31
390
16
querying 2 tables with the same spec for the differences.
I recently had to solve this problem and find I've needed this info many times in the past so I thought I would post it. Assuming the following table def, how would you write a query to find all differences between the two? table def: CREATE TABLE feed_tbl ( code varchar(15), name varchar(40), status char(1), update char(1) CONSTRAINT feed_tbl_PK PRIMARY KEY (code) CREATE TABLE data_tbl ( code varchar(15), name varchar(40), status char(1), update char(1) CONSTRAINT data_tbl_PK PRIMARY KEY (code) here is my solution, as a view of three union queries, the diff_type specified if the record needs deleted from _data(2), updated in _data(1), or added to _data(0) CREATE VIEW delta_vw AS ( SELECT feed_tbl.code, feed_tbl.name, feed_tbl.status, feed_tbl.update, 0 as diff_type FROM feed_tbl LEFT OUTER JOIN data_tbl ON feed_tbl.code = data_tbl.code WHERE (data_tbl.code IS NULL) UNION SELECT feed_tbl.code, feed_tbl.name, feed_tbl.status, feed_tbl.update, 1 as diff_type FROM data_tbl RIGHT OUTER JOIN feed_tbl ON data_tbl.code = feed_tbl.code where (feed_tbl.name <> data_tbl.name) OR (data_tbl.status <> feed_tbl.status) OR (data_tbl.update <> feed_tbl.update) UNION SELECT data_tbl.code, data_tbl.name, data_tbl.status, data_tbl.update, 2 as diff_type FROM feed_tbl LEFT OUTER JOIN data_tbl ON data_tbl.code = feed_tbl.code WHERE (feed_tbl.code IS NULL) )
sql
delta
null
null
null
null
open
querying 2 tables with the same spec for the differences. === I recently had to solve this problem and find I've needed this info many times in the past so I thought I would post it. Assuming the following table def, how would you write a query to find all differences between the two? table def: CREATE TABLE feed_tbl ( code varchar(15), name varchar(40), status char(1), update char(1) CONSTRAINT feed_tbl_PK PRIMARY KEY (code) CREATE TABLE data_tbl ( code varchar(15), name varchar(40), status char(1), update char(1) CONSTRAINT data_tbl_PK PRIMARY KEY (code) here is my solution, as a view of three union queries, the diff_type specified if the record needs deleted from _data(2), updated in _data(1), or added to _data(0) CREATE VIEW delta_vw AS ( SELECT feed_tbl.code, feed_tbl.name, feed_tbl.status, feed_tbl.update, 0 as diff_type FROM feed_tbl LEFT OUTER JOIN data_tbl ON feed_tbl.code = data_tbl.code WHERE (data_tbl.code IS NULL) UNION SELECT feed_tbl.code, feed_tbl.name, feed_tbl.status, feed_tbl.update, 1 as diff_type FROM data_tbl RIGHT OUTER JOIN feed_tbl ON data_tbl.code = feed_tbl.code where (feed_tbl.name <> data_tbl.name) OR (data_tbl.status <> feed_tbl.status) OR (data_tbl.update <> feed_tbl.update) UNION SELECT data_tbl.code, data_tbl.name, data_tbl.status, data_tbl.update, 2 as diff_type FROM feed_tbl LEFT OUTER JOIN data_tbl ON data_tbl.code = feed_tbl.code WHERE (feed_tbl.code IS NULL) )
0
30,995
08/27/2008 19:35:40
3,012
08/26/2008 11:55:24
11
4
"File Save Failed" error when working with Crystal Reports in VS2008
Occasionally while attempting to save a Crystal Report that I'm working on in VS2008, a dialog titled "File Save Failed" pops up saying "The document could not be saved in C:\Users\Phillip\AppData\Local\Temp\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}.rpt. It has been saved in C:\Users\Phillip\AppData\Local\Temp\~zzz{YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY}.tmp." If I OK the dialog, I get a "Save File As" dialog. If I specify the correct location of the report file, I'm asked if I want to replace the existing file. If I say "Yes", I get an error message saying "The operation could not be completed. The system cannot find the file specified." Even if I specify a completely different filename, in a different folder (e.g. C:/test.rpt) I get the same "operation could not be completed" error. Sometimes if I wait a moment, then try to save again, it works fine. More frequently, however, I keep getting the "Save File As" dialog. My only option then is to close the report and discard my changes. This is an intermittent problem - much of the time, saving the report works just fine. Any ideas?
crystal-reports
vs2008
vb.net
null
null
null
open
"File Save Failed" error when working with Crystal Reports in VS2008 === Occasionally while attempting to save a Crystal Report that I'm working on in VS2008, a dialog titled "File Save Failed" pops up saying "The document could not be saved in C:\Users\Phillip\AppData\Local\Temp\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}.rpt. It has been saved in C:\Users\Phillip\AppData\Local\Temp\~zzz{YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY}.tmp." If I OK the dialog, I get a "Save File As" dialog. If I specify the correct location of the report file, I'm asked if I want to replace the existing file. If I say "Yes", I get an error message saying "The operation could not be completed. The system cannot find the file specified." Even if I specify a completely different filename, in a different folder (e.g. C:/test.rpt) I get the same "operation could not be completed" error. Sometimes if I wait a moment, then try to save again, it works fine. More frequently, however, I keep getting the "Save File As" dialog. My only option then is to close the report and discard my changes. This is an intermittent problem - much of the time, saving the report works just fine. Any ideas?
0
30,998
08/27/2008 19:36:18
2,566
08/22/2008 22:30:40
1
0
using too much static bad or good ?
i like to use static functions in c++ as a way to categorize them, like c# does. Console::WriteLine("hello") but is it good or bad ? if the functions are often used i guess it doesn't matter, but if not do they put pressure on memory ? The same goes for static const...
c++
static
null
null
null
null
open
using too much static bad or good ? === i like to use static functions in c++ as a way to categorize them, like c# does. Console::WriteLine("hello") but is it good or bad ? if the functions are often used i guess it doesn't matter, but if not do they put pressure on memory ? The same goes for static const...
0
31,007
08/27/2008 19:39:07
2,723
08/24/2008 17:49:45
13
0
Pass reference to element in C# Array
I build up an array of strings with string[] parts = string.spilt(" "); And get an array with X parts in it, I would like to get a copy of the array of strings starting at element parts[x-2] Other than the obvious brute force approach (make a new array and insert strings), is there a more elegant way to do this in C#?
c#
arrays
null
null
null
null
open
Pass reference to element in C# Array === I build up an array of strings with string[] parts = string.spilt(" "); And get an array with X parts in it, I would like to get a copy of the array of strings starting at element parts[x-2] Other than the obvious brute force approach (make a new array and insert strings), is there a more elegant way to do this in C#?
0
31,031
08/27/2008 19:45:34
177
08/03/2008 02:15:39
48
3
What's the best way to allow a user to browse for a file in C#?
What's the best way to allow a user to browse for a file in C#?
c#
null
null
null
null
null
open
What's the best way to allow a user to browse for a file in C#? === What's the best way to allow a user to browse for a file in C#?
0
31,044
08/27/2008 19:49:41
302
08/04/2008 13:39:41
343
14
Is there an "exists" function for jQuery
So I know that you can do: if ($(selector).length>0) { // Do something } But is there a more elegant method?
jquery
exists
null
null
null
null
open
Is there an "exists" function for jQuery === So I know that you can do: if ($(selector).length>0) { // Do something } But is there a more elegant method?
0
31,051
08/27/2008 19:51:09
2,170
08/20/2008 17:55:07
96
5
Setting up replicated repositories in Plastic SCM
So we're trying to set up replicated repositories using PlasticSCM, one in the US, and one in Australia and running into a bit of a snag. The US configuration is Active Directory, the AU configuration is User/Password. This in itself is not a big deal, I've already set up the SID translation table. The problem is with plasticscm's replicate command itself. This is the command which should replicate from the US to AU, run ON the AU server. cm replicate br:/main@rep:default@repserver:US:8084 rep:myrep@repserver:AU:9090 --trmode=name --trtable=trans.txt --authdata=ActiveDirectory:192.168.1.3:389:[email protected]:fPBea2rPsQaagEW3pKNveA==:dc=factory,dc=com The part I'm stuck at is the authdata part (the above is an EXAMPLE only). How can I generate the obscured password? I think it's the only thing preventing these two repositories from talking to each other.
plasticscm
repositories
version-control
distributed
null
null
open
Setting up replicated repositories in Plastic SCM === So we're trying to set up replicated repositories using PlasticSCM, one in the US, and one in Australia and running into a bit of a snag. The US configuration is Active Directory, the AU configuration is User/Password. This in itself is not a big deal, I've already set up the SID translation table. The problem is with plasticscm's replicate command itself. This is the command which should replicate from the US to AU, run ON the AU server. cm replicate br:/main@rep:default@repserver:US:8084 rep:myrep@repserver:AU:9090 --trmode=name --trtable=trans.txt --authdata=ActiveDirectory:192.168.1.3:389:[email protected]:fPBea2rPsQaagEW3pKNveA==:dc=factory,dc=com The part I'm stuck at is the authdata part (the above is an EXAMPLE only). How can I generate the obscured password? I think it's the only thing preventing these two repositories from talking to each other.
0
31,053
08/27/2008 19:51:30
838
08/09/2008 08:08:30
217
7
Regex (C#): Replace \n with \r\n
How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#? Sorry if it's a stupid question, I'm new to Regex. I know to do it by: myStr.Replace("\n", "\r\n"); myStr.Replace("\r\r\n", "\r\n"); But this is inelegant, and would destroy any "\r+\r\n" already in the text (not that it's likely to be there).
c#
regex
null
null
null
null
open
Regex (C#): Replace \n with \r\n === How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#? Sorry if it's a stupid question, I'm new to Regex. I know to do it by: myStr.Replace("\n", "\r\n"); myStr.Replace("\r\r\n", "\r\n"); But this is inelegant, and would destroy any "\r+\r\n" already in the text (not that it's likely to be there).
0
31,057
08/27/2008 19:53:01
1,284
08/14/2008 11:34:29
3
4
How to insert a line break in a SQL Server VARCHAR/NVARCHAR string
I didn't see any similar questions asked on this topic, and I had to research this for something I'm working on right now. Thought I would post the answer for it in case anyone else had the same question.
sql
sql-server
null
null
null
null
open
How to insert a line break in a SQL Server VARCHAR/NVARCHAR string === I didn't see any similar questions asked on this topic, and I had to research this for something I'm working on right now. Thought I would post the answer for it in case anyone else had the same question.
0
31,059
08/27/2008 19:54:16
2,547
08/22/2008 19:10:02
48
5
How do you configure an OpenFileDIalog to select folders?
In VS .NET, when you are selecting a folder for a project, a dialog that looks like an OpenFileDialog or SaveFileDialog is displayed, but is set up to accept only folders. Ever since I've seen this I've wanted to know how it's done. I am aware of the FolderBrowserDialog, but I've never really liked that dialog. It starts too small and doesn't let me take advantage of being able to type a path. I'm almost certain by now there's not a way to do this from .NET, but I'm just as curious how you do it from unmanaged code as well. Short of completely reimplementing the dialog from scratch, how do you modify the dialog to have this behavior?
.net
windows
null
null
null
null
open
How do you configure an OpenFileDIalog to select folders? === In VS .NET, when you are selecting a folder for a project, a dialog that looks like an OpenFileDialog or SaveFileDialog is displayed, but is set up to accept only folders. Ever since I've seen this I've wanted to know how it's done. I am aware of the FolderBrowserDialog, but I've never really liked that dialog. It starts too small and doesn't let me take advantage of being able to type a path. I'm almost certain by now there's not a way to do this from .NET, but I'm just as curious how you do it from unmanaged code as well. Short of completely reimplementing the dialog from scratch, how do you modify the dialog to have this behavior?
0
31,068
08/27/2008 19:56:44
3,313
08/27/2008 19:56:44
1
0
How do I find the 'temp' directory in Linux?
How do I find the 'temp' directory in Linux? I am writing a platform neutral C++ function that returns the temp directory. In Mac an Windows, there is an API that returns these results. In Linux, I'm stomped.
linux
directory
temp
null
null
null
open
How do I find the 'temp' directory in Linux? === How do I find the 'temp' directory in Linux? I am writing a platform neutral C++ function that returns the temp directory. In Mac an Windows, there is an API that returns these results. In Linux, I'm stomped.
0
31,077
08/27/2008 19:58:50
26
08/01/2008 12:18:14
1,917
96
How do I display a PDF in Adobe Flex?
Looking for a way to display a PDF in Flex. I'm sure there are several ways. Looking for the easiest to maintain / integrate / most user friendly. I'm guessing it's possible to display a browser window in the app and render it, but if it goes off of IE / FireFox it's not acceptable for this project. Thanks...
flex
pdf
adobe
null
null
null
open
How do I display a PDF in Adobe Flex? === Looking for a way to display a PDF in Flex. I'm sure there are several ways. Looking for the easiest to maintain / integrate / most user friendly. I'm guessing it's possible to display a browser window in the app and render it, but if it goes off of IE / FireFox it's not acceptable for this project. Thanks...
0
31,088
08/27/2008 20:02:00
327
08/04/2008 17:08:49
468
26
What is the best way to inherit an array that needs to store subclass specific data?
I'm trying to set up an inheritance hierarchy similar to the following: abstract class Vehicle { public string Name; public List<Axle> Axles; } class Motorcycle : Vehicle { } class Car : Vehicle { } abstract class Axle { public int Length; public void Turn(int numTurns) { ... } } class MotorcycleAxle : Axle { public bool WheelAttached; } class CarAxle : Axle { public bool LeftWheelAttached; public bool RightWheelAttached; } I would like to only store MotorcycleAxle objects in a Motorcycle object's Axles array, and CarAxle objects in a Car object's Axles array. The problem is there is no way to override the array in the subclass to force one or the other. Ideally something like the following would be valid for the Motorcycle class: class Motorcycle : Vehicle { public override List<MotorcycleAxle> Axles; } but the types have to match when overriding. How can I support this architecture? Will I just have to do a lot of run-time type checking and casting wherever the Axles member is accessed? I don't like adding run-time type checks because you start to lose the benefits of strong typing and polymorphism. There have to be at least some run-time checks in this scenario since the WheelAttached and Left/RightWheelAttached properties depend on the type, but I would like to minimize them.
c#
oop
inheritance
null
null
null
open
What is the best way to inherit an array that needs to store subclass specific data? === I'm trying to set up an inheritance hierarchy similar to the following: abstract class Vehicle { public string Name; public List<Axle> Axles; } class Motorcycle : Vehicle { } class Car : Vehicle { } abstract class Axle { public int Length; public void Turn(int numTurns) { ... } } class MotorcycleAxle : Axle { public bool WheelAttached; } class CarAxle : Axle { public bool LeftWheelAttached; public bool RightWheelAttached; } I would like to only store MotorcycleAxle objects in a Motorcycle object's Axles array, and CarAxle objects in a Car object's Axles array. The problem is there is no way to override the array in the subclass to force one or the other. Ideally something like the following would be valid for the Motorcycle class: class Motorcycle : Vehicle { public override List<MotorcycleAxle> Axles; } but the types have to match when overriding. How can I support this architecture? Will I just have to do a lot of run-time type checking and casting wherever the Axles member is accessed? I don't like adding run-time type checks because you start to lose the benefits of strong typing and polymorphism. There have to be at least some run-time checks in this scenario since the WheelAttached and Left/RightWheelAttached properties depend on the type, but I would like to minimize them.
0
31,090
08/27/2008 20:03:03
3,043
08/26/2008 13:24:14
281
41
What control is this?
The "Open" button on the open file dialog used in certain windows applications includes a dropdown arrow with a list of additional options -- namely "Open with..". I haven't seen this in every windows application, so you may have to try a few to get it, but SQL Server Management Studio and Visual Studio 2005 will both show the button that way if you go to the menu and choose _File->Open->File..._ I want to use a button like this with a built-in list in one of my applications, but I can't find the control they're using anywhere in visual studio. Any thoughts?
.net
.net-2.0
windowscontrols
null
null
null
open
What control is this? === The "Open" button on the open file dialog used in certain windows applications includes a dropdown arrow with a list of additional options -- namely "Open with..". I haven't seen this in every windows application, so you may have to try a few to get it, but SQL Server Management Studio and Visual Studio 2005 will both show the button that way if you go to the menu and choose _File->Open->File..._ I want to use a button like this with a built-in list in one of my applications, but I can't find the control they're using anywhere in visual studio. Any thoughts?
0
31,096
08/27/2008 20:05:23
3,314
08/27/2008 20:05:23
1
0
Process Memory Size - Different Counters
I'm trying to find out how much memory my own .Net server process is using (for monitoring and logging purposes). I'm using: Process.GetCurrentProcess().PrivateMemorySize64 However, the Process object has several different properties that let me read the memory space used: Paged, NonPaged, PagedSystem, NonPagedSystem, Private, Virtual, WorkingSet and then the "peaks": which i'm guessing just store the maximum values these last ones ever took. Reading through the MSDN definition of each property hasn't proved too helpful for me. I have to admit my knowledge regarding how memory is managed (as far as paging and virtual goes) is very limited. So my question is obviously "which one should I use?", and I know the answer is "it depends". This process will basically hold a bunch of lists in memory of things that are going on, while other processes communicate with it and query it for stuff. I'm expecting the server where this will run on to require lots of RAM, and so i'm querying this data over time to be able to estimate RAM requirements when compared to the sizes of the lists it keeps inside. So... Which one should I use and why?
memory
process
.net
null
null
null
open
Process Memory Size - Different Counters === I'm trying to find out how much memory my own .Net server process is using (for monitoring and logging purposes). I'm using: Process.GetCurrentProcess().PrivateMemorySize64 However, the Process object has several different properties that let me read the memory space used: Paged, NonPaged, PagedSystem, NonPagedSystem, Private, Virtual, WorkingSet and then the "peaks": which i'm guessing just store the maximum values these last ones ever took. Reading through the MSDN definition of each property hasn't proved too helpful for me. I have to admit my knowledge regarding how memory is managed (as far as paging and virtual goes) is very limited. So my question is obviously "which one should I use?", and I know the answer is "it depends". This process will basically hold a bunch of lists in memory of things that are going on, while other processes communicate with it and query it for stuff. I'm expecting the server where this will run on to require lots of RAM, and so i'm querying this data over time to be able to estimate RAM requirements when compared to the sizes of the lists it keeps inside. So... Which one should I use and why?
0
31,097
08/27/2008 20:05:30
83
08/01/2008 16:31:56
808
70
Is there a lang-vb or lang-basic option for prettify.js from Google?
Visual Basic code does not render correctly with [prettify.js][1] from Google. on Stack Overflow: Partial Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'set page title Page.Title = "Something" End Sub End Class in Visual Studio... ![Visual Basic in Visual Studio][2] I found this in the [README][3] document: > How do I specify which language my > code is in? > > You don't need to specify the language > since prettyprint() will guess. You > can specify a language by specifying > the language extension along with the > prettyprint class like so: > > <pre class="prettyprint lang-html"> > The lang-* class specifies the language file extensions. > Supported file extensions include > "c", "cc", "cpp", "cs", "cyc", "java", "bsh", "csh", "sh", > "cv", "py", "perl", "pl", "pm", "rb", "js", > "html", "html", "xhtml", "xml", "xsl". > </pre> I see no *lang-vb* or *lang-basic* option. Does anyone know if one exists? [1]: http://code.google.com/p/google-code-prettify/ [2]: http://img524.imageshack.us/img524/7321/vbcodejr5.jpg [3]: http://google-code-prettify.googlecode.com/svn/trunk/README.html
prettify
stackoverflow
visual-basic
null
null
null
open
Is there a lang-vb or lang-basic option for prettify.js from Google? === Visual Basic code does not render correctly with [prettify.js][1] from Google. on Stack Overflow: Partial Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'set page title Page.Title = "Something" End Sub End Class in Visual Studio... ![Visual Basic in Visual Studio][2] I found this in the [README][3] document: > How do I specify which language my > code is in? > > You don't need to specify the language > since prettyprint() will guess. You > can specify a language by specifying > the language extension along with the > prettyprint class like so: > > <pre class="prettyprint lang-html"> > The lang-* class specifies the language file extensions. > Supported file extensions include > "c", "cc", "cpp", "cs", "cyc", "java", "bsh", "csh", "sh", > "cv", "py", "perl", "pl", "pm", "rb", "js", > "html", "html", "xhtml", "xml", "xsl". > </pre> I see no *lang-vb* or *lang-basic* option. Does anyone know if one exists? [1]: http://code.google.com/p/google-code-prettify/ [2]: http://img524.imageshack.us/img524/7321/vbcodejr5.jpg [3]: http://google-code-prettify.googlecode.com/svn/trunk/README.html
0
31,121
08/27/2008 20:13:07
3,305
08/27/2008 18:56:35
1
2
Multi-site development
Most of the development teams I have worked with have been geographically dispersed often across several continents. What techniques and tools have you found effective when working with a team which does not sit together in the same office?
teamwork
outsourcing
null
null
null
09/23/2011 05:06:27
off topic
Multi-site development === Most of the development teams I have worked with have been geographically dispersed often across several continents. What techniques and tools have you found effective when working with a team which does not sit together in the same office?
2
31,127
08/27/2008 20:14:07
2,598
08/23/2008 13:13:34
102
14
Java Swing: Displaying images from within a Jar
When running a Java app from eclipse my ImageIcon shows up just fine. But after creating a jar the path to the image obviously gets screwed up. Is there a way to extract an image from the jar at runtime so I can then open it up? Or, is there a better way to do this? I'd like to distribute a single jar file if possible.
java
image
null
null
null
null
open
Java Swing: Displaying images from within a Jar === When running a Java app from eclipse my ImageIcon shows up just fine. But after creating a jar the path to the image obviously gets screwed up. Is there a way to extract an image from the jar at runtime so I can then open it up? Or, is there a better way to do this? I'd like to distribute a single jar file if possible.
0
31,128
08/27/2008 20:14:15
2,822
08/25/2008 11:42:23
122
7
Enforcing web standards
The HTML standard defines a clear separation of concerns between CSS (presentation) and HTML (semantics or structure). Does anyone use a coding standards document for CSS and XHTML that has clauses which help to maintain this separation? What would be good clauses to include in such a coding standards document?
css
xhtml
coding-style
null
null
null
open
Enforcing web standards === The HTML standard defines a clear separation of concerns between CSS (presentation) and HTML (semantics or structure). Does anyone use a coding standards document for CSS and XHTML that has clauses which help to maintain this separation? What would be good clauses to include in such a coding standards document?
0
31,129
08/27/2008 20:14:19
2,993
08/26/2008 10:45:59
211
9
How can I return a variable from a $.getJSON function
I want to return StudentId to use elsewhere outside of the scope of the $.getJSON() j.getJSON(url, data, function(result) { var studentId = result.Something; }); //use studentId here I would imagine this has to do with scoping, but it doesn't seem to work the same way c# does
jquery
javascript
null
null
null
null
open
How can I return a variable from a $.getJSON function === I want to return StudentId to use elsewhere outside of the scope of the $.getJSON() j.getJSON(url, data, function(result) { var studentId = result.Something; }); //use studentId here I would imagine this has to do with scoping, but it doesn't seem to work the same way c# does
0
31,140
08/27/2008 20:16:58
2,899
08/25/2008 20:31:14
11
2
Accessing a Component on an inherited form from the base form
A number of forms in my project inherit from a base form. It is easy to get at the Controls collection of the derived forms, but I have not found a simple way to access the Components collection, since VS marks this as private. I assume this could be done with reflection, but I'm not really sure how best to go about it, not having worked with reflection before. Right now, I'm using a sort of clunky workaround, in which I override a function GetComponents and return an array of the components I'm interested in. This is obviously prone to errors, since it's easy to forget to implement the overridden function or update it when components are added. If anyone has any tips or can suggest a better way, I'd be glad to hear.
.net
winforms
reflection
inheritance
null
null
open
Accessing a Component on an inherited form from the base form === A number of forms in my project inherit from a base form. It is easy to get at the Controls collection of the derived forms, but I have not found a simple way to access the Components collection, since VS marks this as private. I assume this could be done with reflection, but I'm not really sure how best to go about it, not having worked with reflection before. Right now, I'm using a sort of clunky workaround, in which I override a function GetComponents and return an array of the components I'm interested in. This is obviously prone to errors, since it's easy to forget to implement the overridden function or update it when components are added. If anyone has any tips or can suggest a better way, I'd be glad to hear.
0
31,151
08/27/2008 20:19:45
366
08/05/2008 06:49:49
96
4
ASP.NET - How do you Unit Test WebControls?
Alright. So I figure it's about time I get into unit testing, since everyone's been banging on about it for long enough. I've installed NUnit and gone through a few "intro to unit testing" type tutorials. I'm currently putting together a small framework to help with the rebuild of one of our web apps, so I've created a VS2008 project for my framework and I want to unit test it as I go. How on earth do I go about unit testing the WebControls? The methods are all protected or private, and since it's a framework, there isn't much else but WebControls. Any pointers? Burns
asp.net
unit-testing
null
null
null
null
open
ASP.NET - How do you Unit Test WebControls? === Alright. So I figure it's about time I get into unit testing, since everyone's been banging on about it for long enough. I've installed NUnit and gone through a few "intro to unit testing" type tutorials. I'm currently putting together a small framework to help with the rebuild of one of our web apps, so I've created a VS2008 project for my framework and I want to unit test it as I go. How on earth do I go about unit testing the WebControls? The methods are all protected or private, and since it's a framework, there isn't much else but WebControls. Any pointers? Burns
0
31,163
08/27/2008 20:22:53
3,259
08/27/2008 15:24:02
1
0
Forcing the Solution Explorer to select the file in the editor in visual studio 2005
In Visual Studio 2005, whenever I would view a file in the main editor, the Solution Explorer would find and highlight that file. Some time ago, this stopped working and the Solution Explorer would do nothing. This has become quite a pain since following a chain of "Go To Definition"s can lead you all over your solution. Where is the setting to turn this back on?
visual-studio
null
null
null
null
null
open
Forcing the Solution Explorer to select the file in the editor in visual studio 2005 === In Visual Studio 2005, whenever I would view a file in the main editor, the Solution Explorer would find and highlight that file. Some time ago, this stopped working and the Solution Explorer would do nothing. This has become quite a pain since following a chain of "Go To Definition"s can lead you all over your solution. Where is the setting to turn this back on?
0
31,173
08/27/2008 20:25:07
1,372
08/14/2008 21:03:27
13
4
Ubiquity Hack
What's the most useful hack you've discovered for Mozilla's new [Ubiquity][1] tool? [1]: http://labs.mozilla.com/2008/08/introducing-ubiquity/
ubiquity
hacks
firefox
efficiency
null
null
open
Ubiquity Hack === What's the most useful hack you've discovered for Mozilla's new [Ubiquity][1] tool? [1]: http://labs.mozilla.com/2008/08/introducing-ubiquity/
0
31,192
08/27/2008 20:32:18
1,302
08/14/2008 13:04:10
1
1
Migrating from ASP Classic to .NET and pain mitigation
We're in the process of redesigning the customer facing section of our site in .NET 3.5. It's been going well so far, we're using the same workflow and stored procedures for the most part, the biggest changes are the UI, the ORM (from dictionaries to LINQ), and obviously the language. Most of the pages to this point have been trivial, but now we're working on the heaviest workflow pages. The main page of our offer acceptance section is 1500 lines, about 90% of that is ASP, with probably another 1000 lines in function calls to includes. I think the 1500 lines is a bit deceiving too since we're working with gems like this function GetDealText(sUSCurASCII, sUSCurName, sTemplateOptionID, sSellerCompany, sOfferAmount, sSellerPremPercent, sTotalOfferToSeller, sSellerPremium, sMode, sSellerCurASCII, sSellerCurName, sTotalOfferToSeller_SellerCurr, sOfferAmount_SellerCurr, sSellerPremium_SellerCurr, sConditions, sListID, sDescription, sSKU, sInv_tag, sFasc_loc, sSerialNoandModel, sQTY, iLoopCount, iBidCount, sHTMLConditions, sBidStatus, sBidID, byRef bAlreadyAccepted, sFasc_Address1, sFasc_City, sFasc_State_id, sFasc_Country_id, sFasc_Company_name, sListingCustID, sAskPrice_SellerCurr, sMinPrice_SellerCurr, sListingCur, sOrigLocation) I'm wondering if anyone has any tips to make this re-write any easier. The standard practice I've been using so far is to spend maybe an hour or so reading over the app both to familiarize myself with it, but also to strip out commented-out/deprecated code. Then to work in a depth-first fashion. I'll start at the top and copy a segment of code in the aspx.cs file and start rewriting, making obvious refactorings as I go especially to take advantage of our ORM. If I get to a function call that we don't have, I'll write out the definition. After I have everything coded I'll do a few passes at refactoring/testing. I'm just wondering if anyone has any tips on how to make this process a little easier/more efficient.
asp.net
asp
migration
null
null
null
open
Migrating from ASP Classic to .NET and pain mitigation === We're in the process of redesigning the customer facing section of our site in .NET 3.5. It's been going well so far, we're using the same workflow and stored procedures for the most part, the biggest changes are the UI, the ORM (from dictionaries to LINQ), and obviously the language. Most of the pages to this point have been trivial, but now we're working on the heaviest workflow pages. The main page of our offer acceptance section is 1500 lines, about 90% of that is ASP, with probably another 1000 lines in function calls to includes. I think the 1500 lines is a bit deceiving too since we're working with gems like this function GetDealText(sUSCurASCII, sUSCurName, sTemplateOptionID, sSellerCompany, sOfferAmount, sSellerPremPercent, sTotalOfferToSeller, sSellerPremium, sMode, sSellerCurASCII, sSellerCurName, sTotalOfferToSeller_SellerCurr, sOfferAmount_SellerCurr, sSellerPremium_SellerCurr, sConditions, sListID, sDescription, sSKU, sInv_tag, sFasc_loc, sSerialNoandModel, sQTY, iLoopCount, iBidCount, sHTMLConditions, sBidStatus, sBidID, byRef bAlreadyAccepted, sFasc_Address1, sFasc_City, sFasc_State_id, sFasc_Country_id, sFasc_Company_name, sListingCustID, sAskPrice_SellerCurr, sMinPrice_SellerCurr, sListingCur, sOrigLocation) I'm wondering if anyone has any tips to make this re-write any easier. The standard practice I've been using so far is to spend maybe an hour or so reading over the app both to familiarize myself with it, but also to strip out commented-out/deprecated code. Then to work in a depth-first fashion. I'll start at the top and copy a segment of code in the aspx.cs file and start rewriting, making obvious refactorings as I go especially to take advantage of our ORM. If I get to a function call that we don't have, I'll write out the definition. After I have everything coded I'll do a few passes at refactoring/testing. I'm just wondering if anyone has any tips on how to make this process a little easier/more efficient.
0
31,200
08/27/2008 20:36:00
100
08/01/2008 20:41:59
823
27
Outlook synchronization on multiple machines
<i>This isn't much of a programming question, but I'm sure I'm not the only person here who has this issue.</i> Currently I have two machines with Outlook 2007. They both sync e-mail from Google Apps. One of the machines publishes my calendar to a secure server, which my other machine is subscribed to. The problem with this setup is that I have read-only calendar access on one of my machines, which sucks. Also soon I'll be upgrading to a smart-phone, so anything I do will also have to support that scenario. 1. Is there a better way to handle Outlook synchronization without setting up an exchange server in my basement? 2. If I have to setup Exchange, is it possible to make it pull e-mail, via IMAP, from Google Apps?
outlook
exchange
synchronization
null
null
null
open
Outlook synchronization on multiple machines === <i>This isn't much of a programming question, but I'm sure I'm not the only person here who has this issue.</i> Currently I have two machines with Outlook 2007. They both sync e-mail from Google Apps. One of the machines publishes my calendar to a secure server, which my other machine is subscribed to. The problem with this setup is that I have read-only calendar access on one of my machines, which sucks. Also soon I'll be upgrading to a smart-phone, so anything I do will also have to support that scenario. 1. Is there a better way to handle Outlook synchronization without setting up an exchange server in my basement? 2. If I have to setup Exchange, is it possible to make it pull e-mail, via IMAP, from Google Apps?
0
31,201
08/27/2008 20:36:14
1,288
08/14/2008 12:14:17
290
29
How do you get a reference to the enclosing class from an anonymous inner class in Java?
I'm currently creating an explicit reference to this in the outer class so that I have a name to refer to in the anonymous inner class. Is there a better way to do this?
java
null
null
null
null
null
open
How do you get a reference to the enclosing class from an anonymous inner class in Java? === I'm currently creating an explicit reference to this in the outer class so that I have a name to refer to in the anonymous inner class. Is there a better way to do this?
0
31,215
08/27/2008 20:39:51
1,865
08/19/2008 00:17:22
36
12
Constructors with the same argument type
I have a Person object with two constructors - one takes an int (personId), the other a string (logonName). I would like another constructor that takes a string (badgeNumber). I know this can't be done, but seems it might be a common situation. Is there a graceful way of handling this? I suppose this would apply to any overloaded method. Code: public class Person { public Person() {} public Person(int personId) { this.Load(personId); } public Person(string logonName) { this.Load(logonName); } public Person(string badgeNumber) { //load logic here... } ...etc.
c#
.net
oop
null
null
null
open
Constructors with the same argument type === I have a Person object with two constructors - one takes an int (personId), the other a string (logonName). I would like another constructor that takes a string (badgeNumber). I know this can't be done, but seems it might be a common situation. Is there a graceful way of handling this? I suppose this would apply to any overloaded method. Code: public class Person { public Person() {} public Person(int personId) { this.Load(personId); } public Person(string logonName) { this.Load(logonName); } public Person(string badgeNumber) { //load logic here... } ...etc.
0
31,221
08/27/2008 20:41:23
1,226
08/13/2008 13:55:55
125
11
Response.Redirect using ~ Path
I have a method that where I want to redirect the user back to a login page located at the root of my web application. I'm using the following code: Response.Redirect("~/Login.aspx?ReturnPath=" + Request.Url.ToString()); This doesn't work though. My assumption was that ASP.NET would automatically resolve the URL into the correct path. Normally, I would just use Response.Redirect("../Login.aspx?ReturnPath=" + Request.Url.ToString()); but this code is on a master page, and can be executed from any folder level. How do I get around this issue?
c#
asp.net
response.redirect
null
null
null
open
Response.Redirect using ~ Path === I have a method that where I want to redirect the user back to a login page located at the root of my web application. I'm using the following code: Response.Redirect("~/Login.aspx?ReturnPath=" + Request.Url.ToString()); This doesn't work though. My assumption was that ASP.NET would automatically resolve the URL into the correct path. Normally, I would just use Response.Redirect("../Login.aspx?ReturnPath=" + Request.Url.ToString()); but this code is on a master page, and can be executed from any folder level. How do I get around this issue?
0
31,226
08/27/2008 20:42:22
3,044
08/26/2008 13:31:46
222
19
Lightweight rich-text XML format?
I am writing a basic word processing application, and I am trying to settle on a native "internal" format, the one that my code parsers in order to render to the screen. I'd like this to be XML, so that I can, in the future, just write XSLT to convert it to ODF or XHTML or whatever. However, when searching for existing standards to use, the only one that looks promising is ODF. But that looks like massive overkill for what I'm thinking of. All I need is paragraph tags, font selection, font size & decoration... that's pretty much it. It would take me a long time to implement even a minimal ODF renderer and I'm not sure it's worth the trouble. Right now I'm thinking of making my own XML format, but that's not really good practice. Better to use a standard, especially since then I can probably find the XSLTs I might need in the future already written. Or should I just bite the bullet and implement ODF?
xml
standards
null
null
null
null
open
Lightweight rich-text XML format? === I am writing a basic word processing application, and I am trying to settle on a native "internal" format, the one that my code parsers in order to render to the screen. I'd like this to be XML, so that I can, in the future, just write XSLT to convert it to ODF or XHTML or whatever. However, when searching for existing standards to use, the only one that looks promising is ODF. But that looks like massive overkill for what I'm thinking of. All I need is paragraph tags, font selection, font size & decoration... that's pretty much it. It would take me a long time to implement even a minimal ODF renderer and I'm not sure it's worth the trouble. Right now I'm thinking of making my own XML format, but that's not really good practice. Better to use a standard, especially since then I can probably find the XSLTs I might need in the future already written. Or should I just bite the bullet and implement ODF?
0
31,237
08/27/2008 20:45:36
1,075
08/12/2008 10:13:30
1,020
73
Objective-C: Passing around sets of data
A question that has pondered me for the last while. I am primarily a .net developer who dabbles in Objective-C for iPhone and Mac. How do you go about sending "datasets" between methods in objective-c. For example in C# you can populate a custom class with data and pass it around in a List of type custom class. EG if you had a customer class you would just do something like: List<Customer> customers = DataLayer.GetAllCustomers(); The only way I can see how this could be done in obj-c would be to populate an NSArray with custom objects? Is this an efficient way to do things? Any other recommendations? I am using sqlite as the database/data I want to return.
objective-c
sqlite
null
null
null
null
open
Objective-C: Passing around sets of data === A question that has pondered me for the last while. I am primarily a .net developer who dabbles in Objective-C for iPhone and Mac. How do you go about sending "datasets" between methods in objective-c. For example in C# you can populate a custom class with data and pass it around in a List of type custom class. EG if you had a customer class you would just do something like: List<Customer> customers = DataLayer.GetAllCustomers(); The only way I can see how this could be done in obj-c would be to populate an NSArray with custom objects? Is this an efficient way to do things? Any other recommendations? I am using sqlite as the database/data I want to return.
0
31,238
08/27/2008 20:45:53
634
08/07/2008 12:15:58
166
10
C#: instantiating classes from XML
What I have is a collection of classes that all implement the same interface but can be pretty wildly different under the hood. I want to have a config file control which of the classes go into the collection upon starting the program, taking something that looks like <class1 prop1="foo" prop2="bar"/> and turning that into blah = new class1(); blah.prop1="foo"; blah.prop2="bar"; in a very generic way. The thing I don't know how to do is take the string "prop1" in the config file and turn that into the actual property accessor in the code. Are there any metaprogramming facilities in C# to allow that?
c#
xml
null
null
null
null
open
C#: instantiating classes from XML === What I have is a collection of classes that all implement the same interface but can be pretty wildly different under the hood. I want to have a config file control which of the classes go into the collection upon starting the program, taking something that looks like <class1 prop1="foo" prop2="bar"/> and turning that into blah = new class1(); blah.prop1="foo"; blah.prop2="bar"; in a very generic way. The thing I don't know how to do is take the string "prop1" in the config file and turn that into the actual property accessor in the code. Are there any metaprogramming facilities in C# to allow that?
0
31,242
08/27/2008 20:47:09
620,435
08/25/2008 16:34:25
41
2
.Net Compact Framework scrollbars - horizontal always show when vertical shows
I am new to the .Net Compact Framework and have been unable to find an answer via Google. Gasp! Yes, it's true, but that is part of why stackoverflow is here, right? I have a form that is longer than the screen, so a vertical scrollbar appears as expected. However, this appears to force a horizontal scrollbar to appear as well. (If I scroll to the right, there is nothing visible except white space ... about the size of a scrollbar.) Is this a "feature" that is unavoidable? Anyone have experience in this area?
.net
forms
compactframework
null
null
null
open
.Net Compact Framework scrollbars - horizontal always show when vertical shows === I am new to the .Net Compact Framework and have been unable to find an answer via Google. Gasp! Yes, it's true, but that is part of why stackoverflow is here, right? I have a form that is longer than the screen, so a vertical scrollbar appears as expected. However, this appears to force a horizontal scrollbar to appear as well. (If I scroll to the right, there is nothing visible except white space ... about the size of a scrollbar.) Is this a "feature" that is unavoidable? Anyone have experience in this area?
0
31,249
08/27/2008 20:48:17
3,047
08/26/2008 13:36:37
5
3
WPF set ItemTemplate dynamically
Using WPF, I have a TreeView control that I want to set it's ItemTemplate dynamically through procedural code. How do I do this? I assume I need to find the resource somewhere. myTreeViewControl.ItemTemplate = ??
wpf
null
null
null
null
null
open
WPF set ItemTemplate dynamically === Using WPF, I have a TreeView control that I want to set it's ItemTemplate dynamically through procedural code. How do I do this? I assume I need to find the resource somewhere. myTreeViewControl.ItemTemplate = ??
0
31,250
08/27/2008 20:48:23
2,141
08/20/2008 14:38:34
300
5
Content Type for MHT files
What is the content type for MHT files?
content-type
null
null
null
null
null
open
Content Type for MHT files === What is the content type for MHT files?
0
31,285
08/27/2008 21:01:11
45,603
08/25/2008 09:52:34
31
2
VMWare Tools for Ubuntu Hardy
I've been having a very tough time with VMWare tools for Ubuntu Hardy. For some reason, vmware-install.pl finds fault with my linux headers. Saying the "address space size" doesn't match. I have resorted to vmware-any-any-update117 and here is the error I am getting now: <pre> In file included from include/asm/page.h:3, from /tmp/vmware-config0/vmmon-only/common/hostKernel.h:56, from /tmp/vmware-config0/vmmon-only/common/task.c:30: include/asm/page_32.h: In function ‘pte_t native_make_pte(long unsigned int)’: include/asm/page_32.h:112: error: expected primary-expression before ‘)’ token include/asm/page_32.h:112: error: expected ‘;’ before ‘{’ token include/asm/page_32.h:112: error: expected primary-expression before ‘.’ token include/asm/page_32.h:112: error: expected `;' before ‘}’ token </pre>
vmware-tools
ubuntu
hardy
vmware
virtualization
null
open
VMWare Tools for Ubuntu Hardy === I've been having a very tough time with VMWare tools for Ubuntu Hardy. For some reason, vmware-install.pl finds fault with my linux headers. Saying the "address space size" doesn't match. I have resorted to vmware-any-any-update117 and here is the error I am getting now: <pre> In file included from include/asm/page.h:3, from /tmp/vmware-config0/vmmon-only/common/hostKernel.h:56, from /tmp/vmware-config0/vmmon-only/common/task.c:30: include/asm/page_32.h: In function ‘pte_t native_make_pte(long unsigned int)’: include/asm/page_32.h:112: error: expected primary-expression before ‘)’ token include/asm/page_32.h:112: error: expected ‘;’ before ‘{’ token include/asm/page_32.h:112: error: expected primary-expression before ‘.’ token include/asm/page_32.h:112: error: expected `;' before ‘}’ token </pre>
0
31,287
08/27/2008 21:02:03
785
08/08/2008 22:08:29
115
12
Using Virtual PC for Web Development with Oracle
I'm new to the Virtual PC party. I was recently introduced to it while working on a small WinForms application and it has been wonderful. I would love to use it when I go back to my real job, which is far more resource intensive. Namely, maintaining and extending multiple very large websites, in Visual Studio 2003 and 2005, each of which connects to its own fairly large Oracle database. I have thoroughly enjoyed using WinForms because Visual Studio is so much more performant than with WebForms, and also there is not that horrendous delay when you bring a form up after a recompile. Anything that slows things down even more is not going to be helpful. Thanks, Mike
virtual-pc
performance
null
null
null
null
open
Using Virtual PC for Web Development with Oracle === I'm new to the Virtual PC party. I was recently introduced to it while working on a small WinForms application and it has been wonderful. I would love to use it when I go back to my real job, which is far more resource intensive. Namely, maintaining and extending multiple very large websites, in Visual Studio 2003 and 2005, each of which connects to its own fairly large Oracle database. I have thoroughly enjoyed using WinForms because Visual Studio is so much more performant than with WebForms, and also there is not that horrendous delay when you bring a form up after a recompile. Anything that slows things down even more is not going to be helpful. Thanks, Mike
0
31,295
08/27/2008 21:07:38
1,615
08/17/2008 15:19:59
38
1
Javascript Animation with Safari
I'm trying to create web applications that use Javascript. I'd like to be able to use animation in these applications. I've tried to use basic Javascript, but I've decided that the best thing to do is to use a library (such as YUI or JQuery). I'm running into a problem. On Safari, when I run animation scripts, the animation is very chunky, very blocky. This happens with YUI as well as basic Javascript. Does anybody know why this happens? Are there any good libraries that don't create this problem in Safari, but are also good for IE and Firefox (and, hopefully, Opera)? Thanks, Jason
javascript
animation
safari
webapplication
null
null
open
Javascript Animation with Safari === I'm trying to create web applications that use Javascript. I'd like to be able to use animation in these applications. I've tried to use basic Javascript, but I've decided that the best thing to do is to use a library (such as YUI or JQuery). I'm running into a problem. On Safari, when I run animation scripts, the animation is very chunky, very blocky. This happens with YUI as well as basic Javascript. Does anybody know why this happens? Are there any good libraries that don't create this problem in Safari, but are also good for IE and Firefox (and, hopefully, Opera)? Thanks, Jason
0
31,296
08/27/2008 21:08:15
162
08/02/2008 20:09:15
89
7
Fast SQL Server 2005 script generation
It seems like the generation of SQL scripts from the SQL Server Management Studio is terribly slow. I think that the old Enterprise Manager could run laps around the newer script generation tool. I've seen a few posts here and there with other folks complaining about the speed, but I haven't seen much offered in the way of alternatives. Is there a low-cost/free tool for scripting an entire SQL Server 2005 database that will perform better that SSMS? It would be hard to do worse.
sql-server
scripting
null
null
null
null
open
Fast SQL Server 2005 script generation === It seems like the generation of SQL scripts from the SQL Server Management Studio is terribly slow. I think that the old Enterprise Manager could run laps around the newer script generation tool. I've seen a few posts here and there with other folks complaining about the speed, but I haven't seen much offered in the way of alternatives. Is there a low-cost/free tool for scripting an entire SQL Server 2005 database that will perform better that SSMS? It would be hard to do worse.
0
31,297
08/27/2008 21:08:24
1,130,097
08/16/2008 14:58:30
178
22
Cannot access a webservice from mobile device
I developed a program in a mobile device (Pocket PC 2003) to access a web service, the web service is installed on a Windows XP SP2 PC with IIS, the PC has the IP 192.168.5.2. The device obtains from the wireless network the IP 192.168.5.118 and the program works OK, it calls the method from the web service and executes the action that is needed. This program is going to be used in various buildings. Now I have this problem, it turns that when I try to test it in another building (distances neraly about 100 mts. or 200 mts.) connected with the network, the program cannot connect to the webservice, at this moment the device gets from an Access Point the IP 192.168.10.25, and it accesses the same XP machine I stated before (192.168.5.2). I made a mobile aspx page to verify that I can reach the web server over the network and it loads it in the device, I even made a winform that access the same webservice in a PC from that building and also works there so I don't understand what is going on. I also tried to ping that 192.168.5.2 PC and it responds alive. After that fail I returned to the original place where I tested the program before and it happens that it works normally. The only thing that I look different here is that the third number in the IP is 10 instead of 5, another observation is that I can't ping to the mobile device. I feel confused I don't know what happens here? What could be the problem? This is how I call the web service; //Connect to webservice svc = new TheWebService(); svc.Credentials = new System.Net.NetworkCredential(Settings.UserName, Settings.Password); svc.AllowAutoRedirect = false; svc.UserAgent = Settings.UserAgent; svc.PreAuthenticate = true; svc.Url = Settings.Url; svc.Timeout = System.Threading.Timeout.Infinite; //Send information to webservice svc.ExecuteMethod(info); the content of the app.config in the mobile device is; <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="UserName" value="administrator" /> <add key="Password" value="************" /> <add key="UserAgent" value="My User Agent" /> <add key="Url" value="http://192.168.5.2/WebServices/TWUD.asmx" /> </appSettings> </configuration> Does anyone have an idea what is going on?
mobile
null
null
null
null
null
open
Cannot access a webservice from mobile device === I developed a program in a mobile device (Pocket PC 2003) to access a web service, the web service is installed on a Windows XP SP2 PC with IIS, the PC has the IP 192.168.5.2. The device obtains from the wireless network the IP 192.168.5.118 and the program works OK, it calls the method from the web service and executes the action that is needed. This program is going to be used in various buildings. Now I have this problem, it turns that when I try to test it in another building (distances neraly about 100 mts. or 200 mts.) connected with the network, the program cannot connect to the webservice, at this moment the device gets from an Access Point the IP 192.168.10.25, and it accesses the same XP machine I stated before (192.168.5.2). I made a mobile aspx page to verify that I can reach the web server over the network and it loads it in the device, I even made a winform that access the same webservice in a PC from that building and also works there so I don't understand what is going on. I also tried to ping that 192.168.5.2 PC and it responds alive. After that fail I returned to the original place where I tested the program before and it happens that it works normally. The only thing that I look different here is that the third number in the IP is 10 instead of 5, another observation is that I can't ping to the mobile device. I feel confused I don't know what happens here? What could be the problem? This is how I call the web service; //Connect to webservice svc = new TheWebService(); svc.Credentials = new System.Net.NetworkCredential(Settings.UserName, Settings.Password); svc.AllowAutoRedirect = false; svc.UserAgent = Settings.UserAgent; svc.PreAuthenticate = true; svc.Url = Settings.Url; svc.Timeout = System.Threading.Timeout.Infinite; //Send information to webservice svc.ExecuteMethod(info); the content of the app.config in the mobile device is; <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="UserName" value="administrator" /> <add key="Password" value="************" /> <add key="UserAgent" value="My User Agent" /> <add key="Url" value="http://192.168.5.2/WebServices/TWUD.asmx" /> </appSettings> </configuration> Does anyone have an idea what is going on?
0
31,303
08/27/2008 21:11:20
116
08/02/2008 05:51:57
4,255
207
Checklist for Database Schema Upgrades
Having to upgrade a database schema makes installing a new release of software a lot trickier. What are the best practices for doing this? I'm looking for a checklist or timeline of action items, such as - shut down apps - modify schema - install new apps - restart db etc, showing how to minimize risk and downtime. Issues such as - backing out of the upgrade if things go awry - minimizing impact to existing apps - "hot" updates while the database is running - promoting from devel to test to production servers are especially of interest.
database
installation
version-control
null
null
null
open
Checklist for Database Schema Upgrades === Having to upgrade a database schema makes installing a new release of software a lot trickier. What are the best practices for doing this? I'm looking for a checklist or timeline of action items, such as - shut down apps - modify schema - install new apps - restart db etc, showing how to minimize risk and downtime. Issues such as - backing out of the upgrade if things go awry - minimizing impact to existing apps - "hot" updates while the database is running - promoting from devel to test to production servers are especially of interest.
0
31,312
08/27/2008 21:17:17
1,632
08/17/2008 17:09:25
297
24
Problems passing special chars with observe_field
I am working on a rails project. Using the tag observe_field, I am taking text typed into a text area, processing it in a control, and displaying the result in a div (very similar to the preview in stack overflow). Everything works fine until I type certain special chars. 1. ? => causes the variable not to be found in the params object 2. (pound) => causes an invalid authenticity error 3. % => stops the div from being updated 4. & => every thing after the & is no longer passed into the variable on the server. Is there a way to solve this?
ruby-on-rails
ajax
null
null
null
null
open
Problems passing special chars with observe_field === I am working on a rails project. Using the tag observe_field, I am taking text typed into a text area, processing it in a control, and displaying the result in a div (very similar to the preview in stack overflow). Everything works fine until I type certain special chars. 1. ? => causes the variable not to be found in the params object 2. (pound) => causes an invalid authenticity error 3. % => stops the div from being updated 4. & => every thing after the & is no longer passed into the variable on the server. Is there a way to solve this?
0
31,324
08/27/2008 23:33:35
2,894
08/25/2008 20:06:55
121
19
SSIS: Adding a constant column value when doing a CSV to SQL conversion
I am reading in CSV file and translating it to a SQl Table. The kicker is that one of the columns in the table is a type ID that needs to be set to a constant (in this case 2). I am not sure how to do this.
sql-server
csv
ssis
null
null
null
open
SSIS: Adding a constant column value when doing a CSV to SQL conversion === I am reading in CSV file and translating it to a SQl Table. The kicker is that one of the columns in the table is a type ID that needs to be set to a constant (in this case 2). I am not sure how to do this.
0
31,326
08/27/2008 23:34:19
71
08/01/2008 15:05:56
989
98
Is there a browser equivalent to IE's ClearAuthenticationCache?
I have a few internal .net web application here that require users to "log out" of them. I know this may seem moot on an Intranet application, but nonetheless it is there. We are using Windows authentication for our Intranet apps, so we tie in to our Active Directory with Basic Authentication and the credentials get stored in the browser cache, as opposed to a cookie when using .net forms authentication. In IE6+ you can leverage a special JavaScript function they created by doing the following: document.execCommand("ClearAuthenticationCache", "false") However, for the other browsers that are to be supported (namely Firefox at the moment, but I strive for multi-browser support), I simply display message to the user that they need to close their browser to log out of the application, which effectively flushes the application cache. Does anybody know of some commands/hacks/etc. that I can use in other browsers to flush the authentication cache?
cross-browser
authentication
asp.net
null
null
null
open
Is there a browser equivalent to IE's ClearAuthenticationCache? === I have a few internal .net web application here that require users to "log out" of them. I know this may seem moot on an Intranet application, but nonetheless it is there. We are using Windows authentication for our Intranet apps, so we tie in to our Active Directory with Basic Authentication and the credentials get stored in the browser cache, as opposed to a cookie when using .net forms authentication. In IE6+ you can leverage a special JavaScript function they created by doing the following: document.execCommand("ClearAuthenticationCache", "false") However, for the other browsers that are to be supported (namely Firefox at the moment, but I strive for multi-browser support), I simply display message to the user that they need to close their browser to log out of the application, which effectively flushes the application cache. Does anybody know of some commands/hacks/etc. that I can use in other browsers to flush the authentication cache?
0
31,340
08/27/2008 23:44:47
242,853
08/15/2008 16:00:39
126
23
How do threads work in python, and what are common python-threading specific pitfalls?
I've been trying to wrap my head around how threads work in python, and it's hard to find good information on how they operate. I may just be missing a link or something, but it seems like the official docs aren't very thorough on the subject, and I haven't been able to find a good write-up. From what I can tell, only one thread can be running at once, and the active thread switches every 10 instructions or so? Could someone who has a lot of experience with using threads with python either point me towards a good explanation, or write one up? It would also be very nice to be aware of common problems that you run into while using threads with python.
python
multithreading
null
null
null
null
open
How do threads work in python, and what are common python-threading specific pitfalls? === I've been trying to wrap my head around how threads work in python, and it's hard to find good information on how they operate. I may just be missing a link or something, but it seems like the official docs aren't very thorough on the subject, and I haven't been able to find a good write-up. From what I can tell, only one thread can be running at once, and the active thread switches every 10 instructions or so? Could someone who has a lot of experience with using threads with python either point me towards a good explanation, or write one up? It would also be very nice to be aware of common problems that you run into while using threads with python.
0
31,343
08/27/2008 23:46:21
572
08/06/2008 20:56:54
1,862
165
Do you need the .NET 1.0 framework to target the .NET 1.0 framework?
I have a bunch of .NET frameworks installed on my machine. I know that with the Java JDK, I can use the 6.0 version to target 5.0 and earlier. Can I do something similar with the .NET framework - target 1.0 and 2.0 with the 3.0 framework?
.net
null
null
null
null
null
open
Do you need the .NET 1.0 framework to target the .NET 1.0 framework? === I have a bunch of .NET frameworks installed on my machine. I know that with the Java JDK, I can use the 6.0 version to target 5.0 and earlier. Can I do something similar with the .NET framework - target 1.0 and 2.0 with the 3.0 framework?
0
31,346
08/27/2008 23:48:36
5
07/31/2008 14:22:31
2,304
96
What's the best way to display a video with rounded corners in Silverlight?
The MediaElement doesn't support rounded corners (radiusx, radiusy). Should I use a VideoBrush on a Rectangle with rounded corners?
silverlight
null
null
null
null
null
open
What's the best way to display a video with rounded corners in Silverlight? === The MediaElement doesn't support rounded corners (radiusx, radiusy). Should I use a VideoBrush on a Rectangle with rounded corners?
0
31,356
08/27/2008 23:52:39
3,149
08/27/2008 01:05:12
21
1
High School Programming
I have been asked to teach a high schooler how to program. His math skills include Algebra II and Geometry as well as an understanding of computers. My programming experience lies primarily within C# and Java, with a fairly decent understanding of most database technologies. Given I do not do any game programming what should I teach him? One additional note, I am not living in the same state as the potential student so this will be a purely virtual lesson.
teaching
null
null
null
null
null
open
High School Programming === I have been asked to teach a high schooler how to program. His math skills include Algebra II and Geometry as well as an understanding of computers. My programming experience lies primarily within C# and Java, with a fairly decent understanding of most database technologies. Given I do not do any game programming what should I teach him? One additional note, I am not living in the same state as the potential student so this will be a purely virtual lesson.
0
31,366
08/27/2008 23:55:28
274
08/04/2008 10:43:23
277
18
XSLT Find and Replace with Unique
I am performing a find and replace on the line feed character (`&#10;`) and replacing it with the paragraph close and paragraph open tags using the following code: <xsl:template match="/STORIES/STORY"> <component> <xsl:if test="boolean(ARTICLEBODY)"> <p> <xsl:call-template name="replace-text"> <xsl:with-param name="text" select="ARTICLEBODY" /> <xsl:with-param name="replace" select="'&#10;'" /> <xsl:with-param name="by" select="'&lt;/p&gt;&lt;p&gt;'" /> </xsl:call-template> </p> </xsl:if> </component> </xsl:template> <xsl:template name="replace-text"> <xsl:param name="text"/> <xsl:param name="replace" /> <xsl:param name="by" /> <xsl:choose> <xsl:when test="contains($text, $replace)"> <xsl:value-of select="substring-before($text, $replace)"/> <xsl:value-of select="$by" disable-output-escaping="yes"/> <xsl:call-template name="replace-text"> <xsl:with-param name="text" select="substring-after($text, $replace)"/> <xsl:with-param name="replace" select="$replace" /> <xsl:with-param name="by" select="$by" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> This almost works perfectly, except that I really need it to de-dup the line feeds as the paragraphs tend to be separated by 2 or more resulting in `</p><p></p><p>`. Is it possible to get it so that it will only ever replace this once per paragraph?
xslt
null
null
null
null
null
open
XSLT Find and Replace with Unique === I am performing a find and replace on the line feed character (`&#10;`) and replacing it with the paragraph close and paragraph open tags using the following code: <xsl:template match="/STORIES/STORY"> <component> <xsl:if test="boolean(ARTICLEBODY)"> <p> <xsl:call-template name="replace-text"> <xsl:with-param name="text" select="ARTICLEBODY" /> <xsl:with-param name="replace" select="'&#10;'" /> <xsl:with-param name="by" select="'&lt;/p&gt;&lt;p&gt;'" /> </xsl:call-template> </p> </xsl:if> </component> </xsl:template> <xsl:template name="replace-text"> <xsl:param name="text"/> <xsl:param name="replace" /> <xsl:param name="by" /> <xsl:choose> <xsl:when test="contains($text, $replace)"> <xsl:value-of select="substring-before($text, $replace)"/> <xsl:value-of select="$by" disable-output-escaping="yes"/> <xsl:call-template name="replace-text"> <xsl:with-param name="text" select="substring-after($text, $replace)"/> <xsl:with-param name="replace" select="$replace" /> <xsl:with-param name="by" select="$by" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> This almost works perfectly, except that I really need it to de-dup the line feeds as the paragraphs tend to be separated by 2 or more resulting in `</p><p></p><p>`. Is it possible to get it so that it will only ever replace this once per paragraph?
0
31,380
08/28/2008 00:07:06
338
08/04/2008 18:34:44
477
42
Is there a reason to use BufferedReader over InputStreamReader when reading all characters?
I currently use the following function to do a simple HTTP GET. public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); try { s = (java.io.InputStream)new URL(url).getContent(); r = new java.io.InputStreamReader(s); //b = new java.io.BufferedReader(r); char[] buffer = new char[4*1024]; int n = 0; while (n >= 0) { n = r.read(buffer, 0, buffer.length); if (n > 0) { content.append(buffer, 0, n); } } } finally { //if (b != null) b.close(); if (r != null) r.close(); if (s != null) s.close(); } return content.toString(); } I see no reason to use the `BufferedReader` since I am just going to download everything in sequence. Am I right in thinking there is no use for the `BufferedReader` in this case?
java
performance
http
io
buffer
null
open
Is there a reason to use BufferedReader over InputStreamReader when reading all characters? === I currently use the following function to do a simple HTTP GET. public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); try { s = (java.io.InputStream)new URL(url).getContent(); r = new java.io.InputStreamReader(s); //b = new java.io.BufferedReader(r); char[] buffer = new char[4*1024]; int n = 0; while (n >= 0) { n = r.read(buffer, 0, buffer.length); if (n > 0) { content.append(buffer, 0, n); } } } finally { //if (b != null) b.close(); if (r != null) r.close(); if (s != null) s.close(); } return content.toString(); } I see no reason to use the `BufferedReader` since I am just going to download everything in sequence. Am I right in thinking there is no use for the `BufferedReader` in this case?
0
31,394
08/28/2008 00:17:21
2,598
08/23/2008 13:13:34
107
14
Java: Programatic Way to Determine Current Windows User
I see many similar questions, however I want to find the Username of the currently logged in user using Java. Its probably something like: System.getProperty(current.user); But, I'm not quite sure.
java
windows
null
null
null
null
open
Java: Programatic Way to Determine Current Windows User === I see many similar questions, however I want to find the Username of the currently logged in user using Java. Its probably something like: System.getProperty(current.user); But, I'm not quite sure.
0
31,408
08/28/2008 00:23:38
2,993
08/26/2008 10:45:59
247
11
Where can I find a good ASP.NET MVC sample?
I have been using Castle MonoRail for the last two years, but in a new job I am going to be the one to bring in ASP.NET MVC with me. I understand the basics of views, actions and the like. I just need a good sample for someone with MVC experience. Any good links besides Scott's Northwind traders sample?
c#
asp.net-mvc
null
null
null
null
open
Where can I find a good ASP.NET MVC sample? === I have been using Castle MonoRail for the last two years, but in a new job I am going to be the one to bring in ASP.NET MVC with me. I understand the basics of views, actions and the like. I just need a good sample for someone with MVC experience. Any good links besides Scott's Northwind traders sample?
0
31,410
08/28/2008 00:25:47
3,331
08/28/2008 00:25:47
1
0
Visual Studio 2008 debugging issue...
I'm working in VS 2008 and have three projects in one solution. I'm debugging by attaching to a .net process invoked by a third party app (SalesLogix, a CRM app). Once it has attached to the process and I attempt to set a breakpoint in one of the projects, it doesn't set a breakpoint in that file. It actually switches the current tab to another file in another project and sets a breakpoint in that document. If the file isn't open, it even goes so far as to open it for me. I can't explain this. I've got no clue. Anyone seen such odd behavior? I wouldn't believe it if I wasn't seeing it myself. A little more info: if I set a breakpoint before attaching, it shows the "red dot" and says no symbols loaded...no problem...I expect that. When I attach and invoke my .net code from SalesLogix and switch back to VS, my breakpoint is completely gone (not even a warning that the source doesn't match the debug file). When I attempt to manually load the debug file, then I get a message that the symbol file does not match the module. The .pdb and the .dll are timestamped the same, so I'm stumped. Anyone have any ideas? Thx, Jeff
c#
vs2008
debugging
null
null
null
open
Visual Studio 2008 debugging issue... === I'm working in VS 2008 and have three projects in one solution. I'm debugging by attaching to a .net process invoked by a third party app (SalesLogix, a CRM app). Once it has attached to the process and I attempt to set a breakpoint in one of the projects, it doesn't set a breakpoint in that file. It actually switches the current tab to another file in another project and sets a breakpoint in that document. If the file isn't open, it even goes so far as to open it for me. I can't explain this. I've got no clue. Anyone seen such odd behavior? I wouldn't believe it if I wasn't seeing it myself. A little more info: if I set a breakpoint before attaching, it shows the "red dot" and says no symbols loaded...no problem...I expect that. When I attach and invoke my .net code from SalesLogix and switch back to VS, my breakpoint is completely gone (not even a warning that the source doesn't match the debug file). When I attempt to manually load the debug file, then I get a message that the symbol file does not match the module. The .pdb and the .dll are timestamped the same, so I'm stumped. Anyone have any ideas? Thx, Jeff
0
31,412
08/28/2008 00:26:35
3,002
08/26/2008 11:21:07
81
8
Proprietary plug-ins for GPL programs: what about interpreted languages?
I am developing a GPL-licensed application in Python and need to know if the GPL allows my program to use proprietary plug-ins. This is [what the FSF has to say][1] on the issue: > **If a program released under the GPL uses plug-ins, what are the requirements for the licenses of a plug-in?** > It depends on how the program invokes its plug-ins. If the program uses fork and exec to invoke plug-ins, then the plug-ins are separate programs, so the license for the main program makes no requirements for them. > If the program dynamically links plug-ins, and they make function calls to each other and share data structures, we believe they form a single program, which must be treated as an extension of both the main program and the plug-ins. This means the plug-ins must be released under the GPL or a GPL-compatible free software license, and that the terms of the GPL must be followed when those plug-ins are distributed. > If the program dynamically links plug-ins, but the communication between them is limited to invoking the ‘main’ function of the plug-in with some options and waiting for it to return, that is a borderline case. The distinction between fork/exec and dynamic linking, besides being kind of artificial, doesn't carry over to interpreted languages: what about a Python/Perl/Ruby plugin, which gets loaded via `import` or `execfile`? The best solution would be to add an exception to my license to explicitly allow the use of proprietary plugins, but I am unable to do so since I'm using [Qt][2]/[PyQt][3] which is GPL. [1]: http://www.gnu.org/licenses/gpl-faq.html [2]: http://trolltech.com/products/qt [3]: http://www.riverbankcomputing.co.uk/software/pyqt/intro
python
interpreted
licensing
opensource
plugins
null
open
Proprietary plug-ins for GPL programs: what about interpreted languages? === I am developing a GPL-licensed application in Python and need to know if the GPL allows my program to use proprietary plug-ins. This is [what the FSF has to say][1] on the issue: > **If a program released under the GPL uses plug-ins, what are the requirements for the licenses of a plug-in?** > It depends on how the program invokes its plug-ins. If the program uses fork and exec to invoke plug-ins, then the plug-ins are separate programs, so the license for the main program makes no requirements for them. > If the program dynamically links plug-ins, and they make function calls to each other and share data structures, we believe they form a single program, which must be treated as an extension of both the main program and the plug-ins. This means the plug-ins must be released under the GPL or a GPL-compatible free software license, and that the terms of the GPL must be followed when those plug-ins are distributed. > If the program dynamically links plug-ins, but the communication between them is limited to invoking the ‘main’ function of the plug-in with some options and waiting for it to return, that is a borderline case. The distinction between fork/exec and dynamic linking, besides being kind of artificial, doesn't carry over to interpreted languages: what about a Python/Perl/Ruby plugin, which gets loaded via `import` or `execfile`? The best solution would be to add an exception to my license to explicitly allow the use of proprietary plugins, but I am unable to do so since I'm using [Qt][2]/[PyQt][3] which is GPL. [1]: http://www.gnu.org/licenses/gpl-faq.html [2]: http://trolltech.com/products/qt [3]: http://www.riverbankcomputing.co.uk/software/pyqt/intro
0
31,415
08/28/2008 00:28:36
2,644
08/23/2008 21:56:47
242
25
Quick way to find a value in HTML (Java)
Using regex, how is the simplest way to fetch a websites HTML and find the value inside this tag (or any attribute's value for that matter): <html> <head> [snip] <meta name="generator" value="thevalue i'm looking for" /> [snip]
java
html
parse
null
null
null
open
Quick way to find a value in HTML (Java) === Using regex, how is the simplest way to fetch a websites HTML and find the value inside this tag (or any attribute's value for that matter): <html> <head> [snip] <meta name="generator" value="thevalue i'm looking for" /> [snip]
0
31,424
08/28/2008 00:33:45
493
08/06/2008 10:25:05
2,399
158
NHIbernate: Difference between Restriction.In and Restriction.InG
When creating a criteria in NHibernate I can use Restriction.In() or Restriction.InG() What is the difference between them?
c#
nhibernate
orm
null
null
null
open
NHIbernate: Difference between Restriction.In and Restriction.InG === When creating a criteria in NHibernate I can use Restriction.In() or Restriction.InG() What is the difference between them?
0
31,446
08/28/2008 00:53:21
506
08/06/2008 12:56:30
88
10
Detach an entity from JPA/EJB3 persistence context
What would be the easiest way to detach a specific JPA Entity Bean that was acquired through an EntityManager. Alternatively, could I have a query return detached objects in the first place so they would essentially act as 'read only'? The reason why I want to do this is becuase I want to modify the data within the bean - with in my application only, but not ever have it persisted to the database. In my program, I eventually have to call flush() on the EntityManager, which would persist all changes from attached entities to the underyling database, but I want to exclude specific objects.
java
jpa
ejb-3.0
null
null
null
open
Detach an entity from JPA/EJB3 persistence context === What would be the easiest way to detach a specific JPA Entity Bean that was acquired through an EntityManager. Alternatively, could I have a query return detached objects in the first place so they would essentially act as 'read only'? The reason why I want to do this is becuase I want to modify the data within the bean - with in my application only, but not ever have it persisted to the database. In my program, I eventually have to call flush() on the EntityManager, which would persist all changes from attached entities to the underyling database, but I want to exclude specific objects.
0
31,462
08/28/2008 01:20:18
2,644
08/23/2008 21:56:47
242
26
How to fetch HTML in Java
Without the use of any external library, what is the simplest way to fetch a website's HTML content into a String?
java
html
null
null
null
null
open
How to fetch HTML in Java === Without the use of any external library, what is the simplest way to fetch a website's HTML content into a String?
0
31,465
08/28/2008 01:24:10
493
08/06/2008 10:25:05
2,409
162
Stackoverflow Style Notifications in asp.net Ajax
When you get a badge or aren't logged in to stack overflow there's a groovy little notification bar at the top of the page that lets you know there's something going on. I know the SOflow team use JQuery, but I was wondering if anyone knew of an implementation of the same style of notification sytem in asp.net AJAX. On a side note, what's the "official" name for this style of notification bar?
asp.net
ajax
notificationbar
null
null
null
open
Stackoverflow Style Notifications in asp.net Ajax === When you get a badge or aren't logged in to stack overflow there's a groovy little notification bar at the top of the page that lets you know there's something going on. I know the SOflow team use JQuery, but I was wondering if anyone knew of an implementation of the same style of notification sytem in asp.net AJAX. On a side note, what's the "official" name for this style of notification bar?
0
31,466
08/28/2008 01:25:52
446,497
08/18/2008 01:08:53
553
45
Does Amazon S3 fails sometimes?
We just added an autoupdater in our software and got some bug report saying that the autoupdate wouldn't complete properly because the downloaded file's sha1 checksum wasn't matching. We're hosted on Amazon S3... That's either something wrong with my code or something wrong with S3. I reread my code for suspicious stuff and wrote a simple script downloading and checking the checksum of the downloaded file, and indeed got a few errors once in while (1 out of 40 yesterday). Today it seems okay. Did you experience that kind of problem? Is there some kind of workaround ? extra info: test were ran in Japan.
amazon
amazon-s3
experience
download
null
null
open
Does Amazon S3 fails sometimes? === We just added an autoupdater in our software and got some bug report saying that the autoupdate wouldn't complete properly because the downloaded file's sha1 checksum wasn't matching. We're hosted on Amazon S3... That's either something wrong with my code or something wrong with S3. I reread my code for suspicious stuff and wrote a simple script downloading and checking the checksum of the downloaded file, and indeed got a few errors once in while (1 out of 40 yesterday). Today it seems okay. Did you experience that kind of problem? Is there some kind of workaround ? extra info: test were ran in Japan.
0
31,480
08/28/2008 01:38:47
2,976
08/26/2008 09:42:25
85
11
How stable is WPF?
My question is how stable is WPF not in term of stability of a WPF program, but in terms of the 'stability' of the API itself. Let me explain: Microsoft is notorious for changing it's whole methodology around with new technology. Like with the move from silverlight 1 to silverlight 2. With WPF, I know that MS change a bunch of stuff with the release of the .NET service pack. I don't know how much they changed things around. So the bottom line is, in your opinion are they gonna revamp the system again with the next release or do you think that it is stable enough now that they won't change the bulk of the system. I hate to have to unlearn stuff with every release. I hope that the question wasn't too long winded. Thanks in advanced
wpf
null
null
null
null
null
open
How stable is WPF? === My question is how stable is WPF not in term of stability of a WPF program, but in terms of the 'stability' of the API itself. Let me explain: Microsoft is notorious for changing it's whole methodology around with new technology. Like with the move from silverlight 1 to silverlight 2. With WPF, I know that MS change a bunch of stuff with the release of the .NET service pack. I don't know how much they changed things around. So the bottom line is, in your opinion are they gonna revamp the system again with the next release or do you think that it is stable enough now that they won't change the bulk of the system. I hate to have to unlearn stuff with every release. I hope that the question wasn't too long winded. Thanks in advanced
0
31,494
08/28/2008 01:54:18
486
08/06/2008 09:19:11
537
48
How to detect duplicate data?
I have got a simple contacts database but I'm having problems with users entering in duplicate data. I have implemented a simple data comparison but unfortunately the duplicated data that is being entered is not exactly the same. For example, names are incorrectly spelled or one person will put in 'Bill Smith' and another will put in 'William Smith' for the same person. So is there some sort of algorithm that can give a percentage for how similar an entry is to another?
duplicate
data
language-agnostic
algorithm
null
null
open
How to detect duplicate data? === I have got a simple contacts database but I'm having problems with users entering in duplicate data. I have implemented a simple data comparison but unfortunately the duplicated data that is being entered is not exactly the same. For example, names are incorrectly spelled or one person will put in 'Bill Smith' and another will put in 'William Smith' for the same person. So is there some sort of algorithm that can give a percentage for how similar an entry is to another?
0
31,496
08/28/2008 01:56:34
327
08/04/2008 17:08:49
475
29
How do I check the active solution configuration Visual Studio built with at runtime?
I would like to enable/disable some code based on a custom solution configuration I added in Visual Studio. How do I check this value at runtime?
visual-studio
microsoft
null
null
null
null
open
How do I check the active solution configuration Visual Studio built with at runtime? === I would like to enable/disable some code based on a custom solution configuration I added in Visual Studio. How do I check this value at runtime?
0
31,497
08/28/2008 01:58:53
1,635
08/17/2008 17:33:54
38
11
Where do I use delegates?
What are some real world places that call for delegates? I'm curious what situations or patterns are present where this method is the best solution. No code required.
design-patterns
tutorials
software-engineering
null
null
null
open
Where do I use delegates? === What are some real world places that call for delegates? I'm curious what situations or patterns are present where this method is the best solution. No code required.
0
31,498
08/28/2008 02:00:00
67
08/01/2008 14:49:18
94
11
Best way to test if a generic type is a string? (c#)
I have a generic class that should allow any type, primitive or otherwise. The only problem with this is using `default(T)`. When you call default on a value type or a string, it initializes it to a reasonable value (such as empty string). When you call `default(T)` on an object, it returns null. For various reasons we need to ensure that if it is not a primitive type, then we will have a default instance of the type, **not** null. Here is attempt 1: T createDefault() { if(typeof(T).IsValueType) { return default(T); } else { return Activator.CreateInstance<T>(); } } Problem - string is not a value type, but it does not have a parameterless constructor. So, the current solution is: T createDefault() { if(typeof(T).IsValueType || typeof(T).FullName == "System.String") { return default(T); } else { return Activator.CreateInstance<T>(); } } But this feels like a kludge. Is there a nicer way to handle the string case?
c#
generics
null
null
null
null
open
Best way to test if a generic type is a string? (c#) === I have a generic class that should allow any type, primitive or otherwise. The only problem with this is using `default(T)`. When you call default on a value type or a string, it initializes it to a reasonable value (such as empty string). When you call `default(T)` on an object, it returns null. For various reasons we need to ensure that if it is not a primitive type, then we will have a default instance of the type, **not** null. Here is attempt 1: T createDefault() { if(typeof(T).IsValueType) { return default(T); } else { return Activator.CreateInstance<T>(); } } Problem - string is not a value type, but it does not have a parameterless constructor. So, the current solution is: T createDefault() { if(typeof(T).IsValueType || typeof(T).FullName == "System.String") { return default(T); } else { return Activator.CreateInstance<T>(); } } But this feels like a kludge. Is there a nicer way to handle the string case?
0
31,500
08/28/2008 02:00:09
493
08/06/2008 10:25:05
2,416
162
Do indexes work with "IN" clause
If I have a query like: Select EmployeeId From Employee Where EmployeeTypeId IN (1,2,3) and I have an index on the EmployeeTypeId field, does SQL server still use that index?
sql
query
indexing
null
null
05/03/2012 19:49:26
not a real question
Do indexes work with "IN" clause === If I have a query like: Select EmployeeId From Employee Where EmployeeTypeId IN (1,2,3) and I have an index on the EmployeeTypeId field, does SQL server still use that index?
1
31,534
08/28/2008 02:22:19
820
08/09/2008 04:48:45
1
0
Has anyone moved to HNibernate 2.0 in a production environment?
If so, have you run into any immediate gotchas?
nhibernate
c#
persistence
null
null
null
open
Has anyone moved to HNibernate 2.0 in a production environment? === If so, have you run into any immediate gotchas?
0
31,535
08/28/2008 02:23:12
2,644
08/23/2008 21:56:47
249
27
Best way to fetch an "unstandard" HTML tag
I'm trying to fetch some HTML from various blogs and I've noticed that different providers use the same tag in different ways. For example, here are two major providers that use the Generator differently: Blogger: `<meta content='blogger' name='generator'/>` (content first, name later and, yes, single quotes!) Wordpress: `<meta name="generator" content="WordPress.com" />` (name first, content later) Is there a way to extract the value of content for all cases? (single/double quotes, first/last in the row) Thank you. P.S. Although I'm using Java, the answer would probably help more people if it where for Regular Expressions generally
regex
html
null
null
null
null
open
Best way to fetch an "unstandard" HTML tag === I'm trying to fetch some HTML from various blogs and I've noticed that different providers use the same tag in different ways. For example, here are two major providers that use the Generator differently: Blogger: `<meta content='blogger' name='generator'/>` (content first, name later and, yes, single quotes!) Wordpress: `<meta name="generator" content="WordPress.com" />` (name first, content later) Is there a way to extract the value of content for all cases? (single/double quotes, first/last in the row) Thank you. P.S. Although I'm using Java, the answer would probably help more people if it where for Regular Expressions generally
0
31,551
08/28/2008 02:33:56
2,027
08/19/2008 21:06:37
11
1
Good way to use table alias in Update statement?
Using SqlServer, and trying to update rows from within the same table. I want to use a table alias for readability. This is the way I am doing it at the moment: <code><br /> UPDATE ra <br /> SET ra.ItemValue = rb.ItemValue<br /> FROM dbo.Rates ra, dbo.Rates rb<br /> WHERE ra.ResourceID = rb.ResourceID<br /> AND ra.PriceSched = 't8'<br /> AND rb.PriceSched = 't9' </code> Are there easier / better ways?
sql-server
null
null
null
null
null
open
Good way to use table alias in Update statement? === Using SqlServer, and trying to update rows from within the same table. I want to use a table alias for readability. This is the way I am doing it at the moment: <code><br /> UPDATE ra <br /> SET ra.ItemValue = rb.ItemValue<br /> FROM dbo.Rates ra, dbo.Rates rb<br /> WHERE ra.ResourceID = rb.ResourceID<br /> AND ra.PriceSched = 't8'<br /> AND rb.PriceSched = 't9' </code> Are there easier / better ways?
0
31,561
08/28/2008 02:41:53
3,326
08/27/2008 23:34:17
1
0
Keeping CL and Scheme straight in your head
Depending on my mood I seem to waffle back and forth between wanting a Lisp-1 and a Lisp-2. Unfortunately beyond the obvious name space differences, this leaves all kinds of amusing function name/etc problems you run into. Case in point, trying to write some code tonight I tried to do (map #'function listvar) which, of course, doesn't work in CL, at all. Took me a bit to remember I wanted mapcar, not map. Of course it doesn't help when slime/emacs shows map IS defined as something, though obviously not the same function at all. So, pointers on how to minimize this short of picking one or the other and sticking with it?
scheme
lisp
commonlisp
null
null
null
open
Keeping CL and Scheme straight in your head === Depending on my mood I seem to waffle back and forth between wanting a Lisp-1 and a Lisp-2. Unfortunately beyond the obvious name space differences, this leaves all kinds of amusing function name/etc problems you run into. Case in point, trying to write some code tonight I tried to do (map #'function listvar) which, of course, doesn't work in CL, at all. Took me a bit to remember I wanted mapcar, not map. Of course it doesn't help when slime/emacs shows map IS defined as something, though obviously not the same function at all. So, pointers on how to minimize this short of picking one or the other and sticking with it?
0
31,566
08/28/2008 02:50:38
1,293
08/14/2008 12:38:08
380
46
Query to list all tables that contain a specific column with SQL Server 2005.
http://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/ USE AdventureWorks GO SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name, c.name AS column_name FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID WHERE c.name LIKE ‘%EmployeeID%’ ORDER BY schema_name, table_name;
sql-server-2005
null
null
null
null
null
open
Query to list all tables that contain a specific column with SQL Server 2005. === http://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/ USE AdventureWorks GO SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name, c.name AS column_name FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID WHERE c.name LIKE ‘%EmployeeID%’ ORDER BY schema_name, table_name;
0
31,567
08/28/2008 02:50:55
1,880
08/19/2008 03:12:41
114
7
How to properly cast objects created through reflection
I'm trying to wrap my head around reflection, so I decided to add plugin capability to a program that I'm writing. The only way to understand a concept is to get your fingers dirty and write the code, so I went the route of creating a simple interface library consisting of the IPlugin and IHost interfaces, a plugin implementation library of classes that implement IPlugin, and a simple console project that instantiates the IHost implementation class that does simple work with the plugin objects. Using reflection, I wanted to iterate through the types contained inside my plugin implementation dll and create instances of types. I was able to sucessfully instantiate classes with this code, but I could not cast the created object to the interface. I'm using loop through assemblies loop through types in assembly // This successfully created the right object object o = Activator.CreateInstance(type); // This threw an Invalid Cast Exception or returned null for an "as" cast // even though the object implemented IPlugin IPlugin i = (IPlugin) o; I made the code work with this. using System.Runtime.Remoting; ObjectHandle oh = Activator.CreateInstance(assembly.FullName, type.FullName); // This worked as I intended IPlugin i = (IPlugin) oh.Unwrap(); i.DoStuff(); Here are my questions: 1. Activator.CreateInstance(Type t) returns an object, but I couldn't cast the object to an interface that the object implemented. Why? 2. Should I have been using a different overload of CreateInstance()? 3. What are the reflection related tips and tricks? 4. Is there some crucial part of reflection that I'm just not getting?
reflection
.net
c#
null
null
null
open
How to properly cast objects created through reflection === I'm trying to wrap my head around reflection, so I decided to add plugin capability to a program that I'm writing. The only way to understand a concept is to get your fingers dirty and write the code, so I went the route of creating a simple interface library consisting of the IPlugin and IHost interfaces, a plugin implementation library of classes that implement IPlugin, and a simple console project that instantiates the IHost implementation class that does simple work with the plugin objects. Using reflection, I wanted to iterate through the types contained inside my plugin implementation dll and create instances of types. I was able to sucessfully instantiate classes with this code, but I could not cast the created object to the interface. I'm using loop through assemblies loop through types in assembly // This successfully created the right object object o = Activator.CreateInstance(type); // This threw an Invalid Cast Exception or returned null for an "as" cast // even though the object implemented IPlugin IPlugin i = (IPlugin) o; I made the code work with this. using System.Runtime.Remoting; ObjectHandle oh = Activator.CreateInstance(assembly.FullName, type.FullName); // This worked as I intended IPlugin i = (IPlugin) oh.Unwrap(); i.DoStuff(); Here are my questions: 1. Activator.CreateInstance(Type t) returns an object, but I couldn't cast the object to an interface that the object implemented. Why? 2. Should I have been using a different overload of CreateInstance()? 3. What are the reflection related tips and tricks? 4. Is there some crucial part of reflection that I'm just not getting?
0
31,581
08/28/2008 03:01:10
3,279
08/27/2008 16:46:21
11
1
How scalable is System.Threading.Timer?
I'm writing an app that will need to make use of `Timer`s, but potentially very many of them. How scalable is the `System.Threading.Timer` class? The documentation merely say it's "lightweight", but doesn't explain further. Do these timers get sucked into a single thread (or very small threadpool) that processes all the callbacks on behalf of a `Timer`, or does each `Timer` have it's own thread? I guess another way to rephrase the question is: How is `System.Threading.Timer` implemented?
c#
.net
multithreading
timer
null
null
open
How scalable is System.Threading.Timer? === I'm writing an app that will need to make use of `Timer`s, but potentially very many of them. How scalable is the `System.Threading.Timer` class? The documentation merely say it's "lightweight", but doesn't explain further. Do these timers get sucked into a single thread (or very small threadpool) that processes all the callbacks on behalf of a `Timer`, or does each `Timer` have it's own thread? I guess another way to rephrase the question is: How is `System.Threading.Timer` implemented?
0
31,584
08/28/2008 03:03:53
2,644
08/23/2008 21:56:47
274
28
Design: Java and returning self-reference in setter methods
I have already proposed this in [my blog][1], but I find this place the most appropriate. For classes that have a long list of setters that are used frequently, I found this way very useful (although I have recently read about the [Builder pattern][2] in Effective Java that is kinda the same). Basically, all setter methods return the object itself so then you can use code like this: MyClass .setInt(1) .setString("test") .setBoolean(true) ; Setters simply return this in the end: public MyClass setInt(int anInt) { [snip] return this; } What is your opinion? What are the pros and cons? Does this have any impact on performance? [1]: http://pekalicious.treazy.com/idea-rule-for-public-void-method-signatures/ [2]: http://en.wikipedia.org/wiki/Builder_pattern
java
design
null
null
null
null
open
Design: Java and returning self-reference in setter methods === I have already proposed this in [my blog][1], but I find this place the most appropriate. For classes that have a long list of setters that are used frequently, I found this way very useful (although I have recently read about the [Builder pattern][2] in Effective Java that is kinda the same). Basically, all setter methods return the object itself so then you can use code like this: MyClass .setInt(1) .setString("test") .setBoolean(true) ; Setters simply return this in the end: public MyClass setInt(int anInt) { [snip] return this; } What is your opinion? What are the pros and cons? Does this have any impact on performance? [1]: http://pekalicious.treazy.com/idea-rule-for-public-void-method-signatures/ [2]: http://en.wikipedia.org/wiki/Builder_pattern
0
31,592
08/28/2008 03:09:28
2,975
08/26/2008 09:40:04
48
8
How to get the libraries you need into the bin folder when using IoC/DI
I'm using Castle Windsor to do some dependency injection, specifically I've abstracted the DAL layer to interfaces that are now being loaded by DI. Once the project is developed & deployed all the .bin files will be in the same location, but for while I'm developing in Visual Studio, the only ways I can see of getting the dependency injected project's .bin file into the startup project's bin file is to either have a post-build event that copies it in, or to put in a manual reference to the DAL project to pull the file in. I'm not totally thrilled with either solution, so I was wondering if there was a 'standard' way of solving this problem?
inversionofcontrol
dependency-injection
castle-windsor
visual-studio
null
null
open
How to get the libraries you need into the bin folder when using IoC/DI === I'm using Castle Windsor to do some dependency injection, specifically I've abstracted the DAL layer to interfaces that are now being loaded by DI. Once the project is developed & deployed all the .bin files will be in the same location, but for while I'm developing in Visual Studio, the only ways I can see of getting the dependency injected project's .bin file into the startup project's bin file is to either have a post-build event that copies it in, or to put in a manual reference to the DAL project to pull the file in. I'm not totally thrilled with either solution, so I was wondering if there was a 'standard' way of solving this problem?
0
31,598
08/28/2008 03:21:39
1,651
08/17/2008 19:21:26
46
2
Testing a client-server application
I am coding a client-server application using Eclipse's RCP. We are having trouble testing the interaction between the two sides as they both contain a lot of GUI and provide no command-line or other remote API. Got any ideas?
testing
eclipse
rcp
null
null
null
open
Testing a client-server application === I am coding a client-server application using Eclipse's RCP. We are having trouble testing the interaction between the two sides as they both contain a lot of GUI and provide no command-line or other remote API. Got any ideas?
0
31,610
08/28/2008 03:31:47
1,965
08/19/2008 15:51:08
1,702
105
Overcoming Programmers UI
I am decidedly a programmer, and not a UI designer, so when I am working on internal tools, I really struggle with laying out controls in a useful manner. For example, all those questions I've been asking for the last two days have been for building this tool: http://www.gfilter.net/junk/taskmanager.jpg And while I am pretty happy with how it looks, it does not come naturally to me whatsoever, and I'm sure if it wasn't just an internal tool there would be tons of room for improvement. I found a lot of good advice reading Joels UI book, but I was wondering if anyone else had pointers on good sites to teach UI design (Web or Desktop) to the programmer types.
user-interface
design
language-agnostic
null
null
09/19/2011 05:15:33
not constructive
Overcoming Programmers UI === I am decidedly a programmer, and not a UI designer, so when I am working on internal tools, I really struggle with laying out controls in a useful manner. For example, all those questions I've been asking for the last two days have been for building this tool: http://www.gfilter.net/junk/taskmanager.jpg And while I am pretty happy with how it looks, it does not come naturally to me whatsoever, and I'm sure if it wasn't just an internal tool there would be tons of room for improvement. I found a lot of good advice reading Joels UI book, but I was wondering if anyone else had pointers on good sites to teach UI design (Web or Desktop) to the programmer types.
4
31,627
08/28/2008 03:40:16
1,433
08/15/2008 15:34:09
109
20
alternative to VSS for a one man show (army of one?)
I've been programming for 10+ years now for the same employer and only source code control we've ever used is VSS. (Sorry - That's what they had when I stated). There's only ever been a few of us; two right now and we usually work alone, so VSS has worked ok for us. So, I have two questions: 1) Should we switch to something else like subversion, git, TFS, etc what exactly and why (please)? 2) Am I beyond all hope and destined to eternal damnation because VSS has corrupted me (as Jeff says) ?
source
version-control
null
null
null
null
open
alternative to VSS for a one man show (army of one?) === I've been programming for 10+ years now for the same employer and only source code control we've ever used is VSS. (Sorry - That's what they had when I stated). There's only ever been a few of us; two right now and we usually work alone, so VSS has worked ok for us. So, I have two questions: 1) Should we switch to something else like subversion, git, TFS, etc what exactly and why (please)? 2) Am I beyond all hope and destined to eternal damnation because VSS has corrupted me (as Jeff says) ?
0
31,672
08/28/2008 04:36:25
1,390
08/15/2008 02:41:16
21
2
Learning FORTRAN In the Modern Era
I've recently come to maintain a large amount of scientific calculation-intensive FORTRAN code. I'm having difficulties getting a handle on all of the, say, nuances, of a forty year old language, despite google & two introductory level books. The code is rife with "performance enhancing improvements". Does anyone have any guides or practical advice for **de**-optimizing FORTRAN into CS 101 levels? Does anyone have knowledge of how FORTRAN code optimization operated? Are there any typical FORTRAN 'gotchas' that might not occur to a Java/C++/.NET raised developer taking over a FORTRAN 77/90 codebase?
fortran
null
null
null
null
null
open
Learning FORTRAN In the Modern Era === I've recently come to maintain a large amount of scientific calculation-intensive FORTRAN code. I'm having difficulties getting a handle on all of the, say, nuances, of a forty year old language, despite google & two introductory level books. The code is rife with "performance enhancing improvements". Does anyone have any guides or practical advice for **de**-optimizing FORTRAN into CS 101 levels? Does anyone have knowledge of how FORTRAN code optimization operated? Are there any typical FORTRAN 'gotchas' that might not occur to a Java/C++/.NET raised developer taking over a FORTRAN 77/90 codebase?
0
31,673
08/28/2008 04:38:15
2,514
08/22/2008 15:47:48
1
0
Wifi Management on XP (SP2/SP3)
Wifi support on Vista is fine, but [Native Wifi on XP][1] is half baked. [NDIS 802.11 Wireless LAN Miniport Drivers][2] only gets you part of the way there (e.g. network scanning). From what I've read (and tried), the 802.11 NDIS drivers on XP will *not* allow you to configure a wireless connection. You have to use the Native Wifi API in order to do this. (Please, correct me if I'm wrong here.) Applications like [InSSIDer][3] have helped me to understand the APIs, but InSSIDer is just a scanner and is not designed to configure Wifi networks. So, the question is: where can I find some code examples (C# or C++) that deal with the configuration of Wifi networks on XP -- e.g. profile creation and connection management? I should note that this is a XP Embedded application on a closed system where we can't use the built-in Wireless Zero Configuration (WZC). We have to build all Wifi management functionality into our .NET application. Yes, I've Googled myself blue. It seems that someone should have a solution to this problem, but I can't find it. That's why I'm asking here. Thanks. [1]: http://msdn.microsoft.com/en-us/library/bb204766(VS.85).aspx [2]: http://msdn.microsoft.com/en-us/library/aa504121.aspx [3]: http://www.metageek.net/products/inssider
networking
wireless
windows-xp
null
null
null
open
Wifi Management on XP (SP2/SP3) === Wifi support on Vista is fine, but [Native Wifi on XP][1] is half baked. [NDIS 802.11 Wireless LAN Miniport Drivers][2] only gets you part of the way there (e.g. network scanning). From what I've read (and tried), the 802.11 NDIS drivers on XP will *not* allow you to configure a wireless connection. You have to use the Native Wifi API in order to do this. (Please, correct me if I'm wrong here.) Applications like [InSSIDer][3] have helped me to understand the APIs, but InSSIDer is just a scanner and is not designed to configure Wifi networks. So, the question is: where can I find some code examples (C# or C++) that deal with the configuration of Wifi networks on XP -- e.g. profile creation and connection management? I should note that this is a XP Embedded application on a closed system where we can't use the built-in Wireless Zero Configuration (WZC). We have to build all Wifi management functionality into our .NET application. Yes, I've Googled myself blue. It seems that someone should have a solution to this problem, but I can't find it. That's why I'm asking here. Thanks. [1]: http://msdn.microsoft.com/en-us/library/bb204766(VS.85).aspx [2]: http://msdn.microsoft.com/en-us/library/aa504121.aspx [3]: http://www.metageek.net/products/inssider
0
31,693
08/28/2008 05:08:06
2,644
08/23/2008 21:56:47
299
31
Differences in Generics
I mostly use Java and generics are relatively new. I keep reading that Java made the wrong decision or that .NET has better implementations etc. etc. So, what are the main differences between C++, C#, Java in generics? Pros/cons of each?
generics
java
c#
c++
null
null
open
Differences in Generics === I mostly use Java and generics are relatively new. I keep reading that Java made the wrong decision or that .NET has better implementations etc. etc. So, what are the main differences between C++, C#, Java in generics? Pros/cons of each?
0
31,701
08/28/2008 05:17:19
2,785
08/25/2008 03:48:53
51
7
How to control layer ordering in Virtual Earth
I have a mapping application that needs to draw a path, and then display icons on top of the path. I can't find a way to control the order of virtual earth layers, other than the order in which they are added. Does anyone know how to change the z index of Virtual Earth shape layers, or force a layer to the front?
javascript
virtual-earth
null
null
null
null
open
How to control layer ordering in Virtual Earth === I have a mapping application that needs to draw a path, and then display icons on top of the path. I can't find a way to control the order of virtual earth layers, other than the order in which they are added. Does anyone know how to change the z index of Virtual Earth shape layers, or force a layer to the front?
0
31,708
08/28/2008 05:21:26
202
08/03/2008 13:02:31
1,012
47
How can I convert IEnumerable<T> to List<T> in C#?
I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms). Simplified code: Dictionary<Guid, Record> dict = GetAllRecords(); myListView.DataSource = dict.Values.Where(rec => rec.Name == "foo"); myListView.DataBind(); I thought that would work but in fact it throws a **System.InvalidOperationException**: > ListView with id 'myListView' must > have a data source that either > implements ICollection or can perform > data source paging if AllowPaging is > true. In order to get it working I have had to resort to the following: Dictionary<Guid, Record> dict = GetAllRecords(); List<Record> searchResults = new List<Record>(); var matches = dict.Values.Where(rec => rec.Name == "foo"); foreach (Record rec in matches) searchResults.Add(rec); myListView.DataSource = searchResults; myListView.DataBind(); Is there a small gotcha in the first example to make it work? (Wasn't sure what to use as the question title for this one, feel free to edit to something more appropriate)
listview
linq
c#
null
null
null
open
How can I convert IEnumerable<T> to List<T> in C#? === I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms). Simplified code: Dictionary<Guid, Record> dict = GetAllRecords(); myListView.DataSource = dict.Values.Where(rec => rec.Name == "foo"); myListView.DataBind(); I thought that would work but in fact it throws a **System.InvalidOperationException**: > ListView with id 'myListView' must > have a data source that either > implements ICollection or can perform > data source paging if AllowPaging is > true. In order to get it working I have had to resort to the following: Dictionary<Guid, Record> dict = GetAllRecords(); List<Record> searchResults = new List<Record>(); var matches = dict.Values.Where(rec => rec.Name == "foo"); foreach (Record rec in matches) searchResults.Add(rec); myListView.DataSource = searchResults; myListView.DataBind(); Is there a small gotcha in the first example to make it work? (Wasn't sure what to use as the question title for this one, feel free to edit to something more appropriate)
0