question_id
int64
4
6.31M
answer_id
int64
7
6.31M
title
stringlengths
9
150
question_body
stringlengths
0
28.8k
answer_body
stringlengths
60
27.2k
question_text
stringlengths
40
28.9k
combined_text
stringlengths
124
39.6k
tags
listlengths
1
6
question_score
int64
0
26.3k
answer_score
int64
0
28.8k
view_count
int64
15
14M
answer_count
int64
0
182
favorite_count
int64
0
32
question_creation_date
stringdate
2008-07-31 21:42:52
2011-06-10 18:12:18
answer_creation_date
stringdate
2008-07-31 22:17:57
2011-06-10 18:14:17
96,390
96,445
SQL server 2000 Like Statement Usage
I have a SQL statement that looks like: SELECT [Phone] FROM [Table] WHERE ( [Phone] LIKE '[A-Z][a-z]' OR [Phone] = 'N/A' OR [Phone] LIKE '[0]' ) The part I'm having trouble with is the where statement with the "LIKEs". I've seen SQL statements where authors used like statements in the way I'm using them above. At first...
Check here. [] matches a range of characters. I think you want something like this: SELECT [Phone] FROM [Table] WHERE ( [Phone] LIKE '%[A-Z]%' OR [Phone] LIKE '%[a-z]%' OR [Phone] = 'N/A' OR [Phone] LIKE '0' )
SQL server 2000 Like Statement Usage I have a SQL statement that looks like: SELECT [Phone] FROM [Table] WHERE ( [Phone] LIKE '[A-Z][a-z]' OR [Phone] = 'N/A' OR [Phone] LIKE '[0]' ) The part I'm having trouble with is the where statement with the "LIKEs". I've seen SQL statements where authors used like statements in t...
TITLE: SQL server 2000 Like Statement Usage QUESTION: I have a SQL statement that looks like: SELECT [Phone] FROM [Table] WHERE ( [Phone] LIKE '[A-Z][a-z]' OR [Phone] = 'N/A' OR [Phone] LIKE '[0]' ) The part I'm having trouble with is the where statement with the "LIKEs". I've seen SQL statements where authors used li...
[ "sql", "sql-server" ]
0
5
2,551
2
0
2008-09-18T20:10:09.220000
2008-09-18T20:16:47.223000
96,405
96,675
Deploying to multiple servers
I have to deploy my php/html/css/etc code to multiple servers and i am looking at my options for software that allows easy and secure deployment to multiple servers. Also helps if it could be tied into my SVN. Any suggestions?
Capistrano is pretty handy for that. There's a few people using it ( 1, 2, 3 ) for deploying PHP code as evidenced by doing a quick search.
Deploying to multiple servers I have to deploy my php/html/css/etc code to multiple servers and i am looking at my options for software that allows easy and secure deployment to multiple servers. Also helps if it could be tied into my SVN. Any suggestions?
TITLE: Deploying to multiple servers QUESTION: I have to deploy my php/html/css/etc code to multiple servers and i am looking at my options for software that allows easy and secure deployment to multiple servers. Also helps if it could be tied into my SVN. Any suggestions? ANSWER: Capistrano is pretty handy for that....
[ "php", "deployment" ]
8
11
7,824
11
0
2008-09-18T20:11:59.390000
2008-09-18T20:38:37.267000
96,414
101,720
C++: Step 1: ExtractIconEx. Step 2: ??? Step 3: SetMenuItemBitmaps
I'm experimenting with adding icons to a shell extension. I have this code (sanitized for easy reading), which works: InsertMenu(hmenu, index, MF_POPUP|MF_BYPOSITION, (UINT)hParentMenu, namestring); The next step is this code: HICON hIconLarge, hIconSmall; ICONINFO oIconInfo; ExtractIconEx("c:\\progra~1\\winzip\\winzip...
This works, though the back color is black instead of transparent. GetIconInfo(hIconSmall, &oIconInfo); SetMenuItemBitmaps(hmenu, uMenuIndex+i+popUpMenuCount-1, MF_BITMAP | MF_BYPOSITION, oIconInfo.hbmColor, oIconInfo.hbmColor);
C++: Step 1: ExtractIconEx. Step 2: ??? Step 3: SetMenuItemBitmaps I'm experimenting with adding icons to a shell extension. I have this code (sanitized for easy reading), which works: InsertMenu(hmenu, index, MF_POPUP|MF_BYPOSITION, (UINT)hParentMenu, namestring); The next step is this code: HICON hIconLarge, hIconSma...
TITLE: C++: Step 1: ExtractIconEx. Step 2: ??? Step 3: SetMenuItemBitmaps QUESTION: I'm experimenting with adding icons to a shell extension. I have this code (sanitized for easy reading), which works: InsertMenu(hmenu, index, MF_POPUP|MF_BYPOSITION, (UINT)hParentMenu, namestring); The next step is this code: HICON hI...
[ "c++", "winapi", "icons" ]
1
2
3,186
2
0
2008-09-18T20:13:02.147000
2008-09-19T13:13:53.947000
96,428
96,452
How do I split a string, breaking at a particular character?
I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the fastest way to parse this into var name = "john smith"; var street= "123 Street"; //etc...
With JavaScript’s String.prototype.split function: var input = 'john smith~123 Street~Apt 4~New York~NY~12345'; var fields = input.split('~'); var name = fields[0]; var street = fields[1]; // etc.
How do I split a string, breaking at a particular character? I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the fastest way to parse this into var name = "john smith"; var street= "123 Street"; //etc...
TITLE: How do I split a string, breaking at a particular character? QUESTION: I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the fastest way to parse this into var name = "john smith"; var street= "123 Street"; //etc... ANSWER: With JavaScript’s String.prototype.split fun...
[ "javascript", "split" ]
636
994
1,095,374
16
0
2008-09-18T20:14:13.643000
2008-09-18T20:17:59.233000
96,431
96,480
How can I tell how many SQL Connections I have open in a windows service?
I'm seeing some errors that would indicate a "connection leak". That is, connections that were not closed properly and the pool is running out. So, how do I go about instrumenting this to see exactly how many are open at a given time?
If you're using.net, there's the.net data provider for SQL server in PerfMon. You can look at NumberOfPooledConnections there
How can I tell how many SQL Connections I have open in a windows service? I'm seeing some errors that would indicate a "connection leak". That is, connections that were not closed properly and the pool is running out. So, how do I go about instrumenting this to see exactly how many are open at a given time?
TITLE: How can I tell how many SQL Connections I have open in a windows service? QUESTION: I'm seeing some errors that would indicate a "connection leak". That is, connections that were not closed properly and the pool is running out. So, how do I go about instrumenting this to see exactly how many are open at a given...
[ ".net", "sql-server", "ado.net", "sqlconnection" ]
6
6
5,013
7
0
2008-09-18T20:14:29.447000
2008-09-18T20:21:31.770000
96,448
99,976
SQL Bulk import from CSV
I need to import a large CSV file into an SQL server. I'm using this: BULK INSERT CSVTest FROM 'c:\csvfile.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO problem is all my fields are surrounded by quotes (" ") so a row actually looks like: "1","","2","","sometimes with comma, inside", "" Can I somehow bul...
I know this isn't a real solution but I use a dummy table for the import with nvarchar set for everything. Then I do an insert which strips out the " characters and does the conversions. It isn't pretty but it does the job.
SQL Bulk import from CSV I need to import a large CSV file into an SQL server. I'm using this: BULK INSERT CSVTest FROM 'c:\csvfile.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO problem is all my fields are surrounded by quotes (" ") so a row actually looks like: "1","","2","","sometimes with comma, insi...
TITLE: SQL Bulk import from CSV QUESTION: I need to import a large CSV file into an SQL server. I'm using this: BULK INSERT CSVTest FROM 'c:\csvfile.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO problem is all my fields are surrounded by quotes (" ") so a row actually looks like: "1","","2","","sometime...
[ "sql", "sql-server", "t-sql", "bulkinsert" ]
23
3
44,736
14
0
2008-09-18T20:17:14.370000
2008-09-19T05:58:36.700000
96,460
96,686
What's the most current, good practice, and easiest way to use sessions in PHP?
Sessions in PHP seemed to have changed since the last time I used them, so I'm looking for a simple way of using sessions but at the same time for it to be relatively secure and a good common practice.
Session management changed some time back (I think it was around 4.4). The old mechanism still works, but is deprecated. It's rather confusing, so I recommend staying clear of it. Today, you use sessions by accessing the global variable $_SESSION (It's an array). You can put object instances in there, but you need to l...
What's the most current, good practice, and easiest way to use sessions in PHP? Sessions in PHP seemed to have changed since the last time I used them, so I'm looking for a simple way of using sessions but at the same time for it to be relatively secure and a good common practice.
TITLE: What's the most current, good practice, and easiest way to use sessions in PHP? QUESTION: Sessions in PHP seemed to have changed since the last time I used them, so I'm looking for a simple way of using sessions but at the same time for it to be relatively secure and a good common practice. ANSWER: Session man...
[ "php", "session" ]
4
3
1,338
7
0
2008-09-18T20:18:39.170000
2008-09-18T20:39:06.313000
96,463
97,126
How do you get the response from the Request object in MooTools?
How do you access the response from the Request object in MooTools? I've been looking at the documentation and the MooTorial, but I can't seem to make any headway. Other Ajax stuff I've done with MooTools I haven't had to manipulate the response at all, so I've just been able to inject it straight into the document, bu...
I was able to find my answer on the MooTools Group at Google.
How do you get the response from the Request object in MooTools? How do you access the response from the Request object in MooTools? I've been looking at the documentation and the MooTorial, but I can't seem to make any headway. Other Ajax stuff I've done with MooTools I haven't had to manipulate the response at all, s...
TITLE: How do you get the response from the Request object in MooTools? QUESTION: How do you access the response from the Request object in MooTools? I've been looking at the documentation and the MooTorial, but I can't seem to make any headway. Other Ajax stuff I've done with MooTools I haven't had to manipulate the ...
[ "javascript", "ajax", "mootools" ]
1
0
7,238
2
0
2008-09-18T20:18:52.743000
2008-09-18T21:23:20.373000
96,500
96,530
Is there anything wrong with returning default constructed values?
Suppose I have the following code: class some_class{}; some_class some_function() { return some_class(); } This seems to work pretty well and saves me the trouble of having to declare a variable just to make a return value. But I don't think I've ever seen this in any kind of tutorial or reference. Is this a compiler-...
No this is perfectly valid. This will also be more efficient as the compiler is actually able to optimise away the temporary.
Is there anything wrong with returning default constructed values? Suppose I have the following code: class some_class{}; some_class some_function() { return some_class(); } This seems to work pretty well and saves me the trouble of having to declare a variable just to make a return value. But I don't think I've ever ...
TITLE: Is there anything wrong with returning default constructed values? QUESTION: Suppose I have the following code: class some_class{}; some_class some_function() { return some_class(); } This seems to work pretty well and saves me the trouble of having to declare a variable just to make a return value. But I don'...
[ "c++", "oop", "visual-c++", "constructor" ]
7
16
478
7
0
2008-09-18T20:24:18.593000
2008-09-18T20:26:34.860000
96,525
96,682
Change ContextMenu Font Size in C#
Is it possible to change the font size used in a ContextMenu using the.NET Framework 3.5 and C# for a desktop application? It seems it's a system-wide setting, but I would like to change it only within my application.
If you are defining your own context menu via a ContextMenuStrip in Windows Forms, use the Font property. If you are defining your own context menu via a ContextMenu in WPF, use the various Fontxxx properties such as FontFamily and FontSize. You cannot change the default context menus that come with controls; those are...
Change ContextMenu Font Size in C# Is it possible to change the font size used in a ContextMenu using the.NET Framework 3.5 and C# for a desktop application? It seems it's a system-wide setting, but I would like to change it only within my application.
TITLE: Change ContextMenu Font Size in C# QUESTION: Is it possible to change the font size used in a ContextMenu using the.NET Framework 3.5 and C# for a desktop application? It seems it's a system-wide setting, but I would like to change it only within my application. ANSWER: If you are defining your own context men...
[ "c#", ".net", "contextmenu", "font-size" ]
6
8
13,887
4
0
2008-09-18T20:26:31.227000
2008-09-18T20:38:53.333000
96,538
96,634
interacting with a CMutex without MFC
We have multiple MFC apps, which use CMutex( false, "blah" ), where "blah" allows the mutex to work across process boundaries. One of these apps was re-written without MFC (using Qt instead). How can I simulate the CMutex using Win32 calls? (Qt's QMutex is not inter-process.) I prefer not to modify the MFC apps.
For inter-process mutexes you want these calls: CreateMutex WaitForSingleObject ReleaseMutex CloseHandle These are the underlying Win32 API calls that CMutex is a wrapper around. For in-process only mutexes you can also use these calls, which are faster: InitializeCriticalSection EnterCriticalSection LeaveCriticalSecti...
interacting with a CMutex without MFC We have multiple MFC apps, which use CMutex( false, "blah" ), where "blah" allows the mutex to work across process boundaries. One of these apps was re-written without MFC (using Qt instead). How can I simulate the CMutex using Win32 calls? (Qt's QMutex is not inter-process.) I pre...
TITLE: interacting with a CMutex without MFC QUESTION: We have multiple MFC apps, which use CMutex( false, "blah" ), where "blah" allows the mutex to work across process boundaries. One of these apps was re-written without MFC (using Qt instead). How can I simulate the CMutex using Win32 calls? (Qt's QMutex is not int...
[ "qt", "mfc" ]
1
3
941
2
0
2008-09-18T20:27:01.333000
2008-09-18T20:34:58.943000
96,553
96,598
Practical limit to length of SQL query (specifically MySQL)
Is it particularly bad to have a very, very large SQL query with lots of (potentially redundant) WHERE clauses? For example, here's a query I've generated from my web application with everything turned off, which should be the largest possible query for this program to generate: SELECT * FROM 4e_magic_items INNER JOIN ...
Reading your query makes me want to play an RPG. This is definitely not too long. As long as they are well formatted, I'd say a practical limit is about 100 lines. After that, you're better off breaking subqueries into views just to keep your eyes from crossing. I've worked with some queries that are 1000+ lines, and t...
Practical limit to length of SQL query (specifically MySQL) Is it particularly bad to have a very, very large SQL query with lots of (potentially redundant) WHERE clauses? For example, here's a query I've generated from my web application with everything turned off, which should be the largest possible query for this p...
TITLE: Practical limit to length of SQL query (specifically MySQL) QUESTION: Is it particularly bad to have a very, very large SQL query with lots of (potentially redundant) WHERE clauses? For example, here's a query I've generated from my web application with everything turned off, which should be the largest possibl...
[ "mysql", "sql", "optimization" ]
18
21
28,319
6
0
2008-09-18T20:28:19.397000
2008-09-18T20:32:38.653000
96,579
97,536
STL vectors with uninitialized storage?
I'm writing an inner loop that needs to place struct s in contiguous storage. I don't know how many of these struct s there will be ahead of time. My problem is that STL's vector initializes its values to 0, so no matter what I do, I incur the cost of the initialization plus the cost of setting the struct 's members to...
std::vector must initialize the values in the array somehow, which means some constructor (or copy-constructor) must be called. The behavior of vector (or any container class) is undefined if you were to access the uninitialized section of the array as if it were initialized. The best way is to use reserve() and push_b...
STL vectors with uninitialized storage? I'm writing an inner loop that needs to place struct s in contiguous storage. I don't know how many of these struct s there will be ahead of time. My problem is that STL's vector initializes its values to 0, so no matter what I do, I incur the cost of the initialization plus the ...
TITLE: STL vectors with uninitialized storage? QUESTION: I'm writing an inner loop that needs to place struct s in contiguous storage. I don't know how many of these struct s there will be ahead of time. My problem is that STL's vector initializes its values to 0, so no matter what I do, I incur the cost of the initia...
[ "c++", "optimization", "stl", "vector" ]
55
29
36,752
17
0
2008-09-18T20:31:31.480000
2008-09-18T22:12:49.817000
96,597
97,106
How do I Upgrade to Subversion 1.5 On CentOS 5?
My development server (CentOS 5) is running Subversion 1.4.2, and I wish to upgrade it to 1.5. I have read in various blogs and documents scattered around the web that this may be done by using RPMForge. I have followed the instructions found on CentOS Wiki, including installing yum-priorities and setting my priorities...
What you are trying to do is to replace a "core" package (one which is contained in the CentOS repository) with a newer package from a "3rd party" repository (RPMForge), which is what the priorities plugin is designed to prevent. The RPMForge repository contains both additional packages not found in CentOS, as well as ...
How do I Upgrade to Subversion 1.5 On CentOS 5? My development server (CentOS 5) is running Subversion 1.4.2, and I wish to upgrade it to 1.5. I have read in various blogs and documents scattered around the web that this may be done by using RPMForge. I have followed the instructions found on CentOS Wiki, including ins...
TITLE: How do I Upgrade to Subversion 1.5 On CentOS 5? QUESTION: My development server (CentOS 5) is running Subversion 1.4.2, and I wish to upgrade it to 1.5. I have read in various blogs and documents scattered around the web that this may be done by using RPMForge. I have followed the instructions found on CentOS W...
[ "linux", "svn", "version-control", "centos", "centos5" ]
22
45
31,064
9
0
2008-09-18T20:32:37.640000
2008-09-18T21:21:05.510000
96,615
96,924
Git - is it pull or rebase when working on branches with other people
So if I'm using branches that are remote (tracked) branches, and I want to get the lastest, I'm still unclear if I should be doing git pull or git rebase. I thought I had read that doing git rebase when working on a branch with other users, it can screw them up when they pull or rebase. Is that true? Should we all be u...
Git pull is a combination of 2 commands git fetch (syncs your local repo with the newest stuff on the remote) git merge (merges the changes from the distant branch, if any, into your local tracking branch) git rebase is only a rough equivalent to git merge. It doesn't fetch anything remotely. In fact it doesn't do a pr...
Git - is it pull or rebase when working on branches with other people So if I'm using branches that are remote (tracked) branches, and I want to get the lastest, I'm still unclear if I should be doing git pull or git rebase. I thought I had read that doing git rebase when working on a branch with other users, it can sc...
TITLE: Git - is it pull or rebase when working on branches with other people QUESTION: So if I'm using branches that are remote (tracked) branches, and I want to get the lastest, I'm still unclear if I should be doing git pull or git rebase. I thought I had read that doing git rebase when working on a branch with othe...
[ "git", "version-control" ]
33
52
15,272
5
0
2008-09-18T20:33:27.730000
2008-09-18T21:01:49.097000
96,618
188,292
How to scroll only the right side of a table, listview, or datagrid?
Let's say I have data structures that're something like this: Public Class AttendenceRecord Public CourseDate As Date Public StudentsInAttendence As Integer End Class Public Class Course Public Name As String Public CourseID As String Public Attendance As List(Of AttendenceRecord) End Class And I want a table that loo...
You can get this functionality from the System.Windows.Forms.DataGridView control. When you create columns you can set them to be frozen which will then only scroll those columns to the right of the frozen column(s).
How to scroll only the right side of a table, listview, or datagrid? Let's say I have data structures that're something like this: Public Class AttendenceRecord Public CourseDate As Date Public StudentsInAttendence As Integer End Class Public Class Course Public Name As String Public CourseID As String Public Attendan...
TITLE: How to scroll only the right side of a table, listview, or datagrid? QUESTION: Let's say I have data structures that're something like this: Public Class AttendenceRecord Public CourseDate As Date Public StudentsInAttendence As Integer End Class Public Class Course Public Name As String Public CourseID As Stri...
[ "asp.net", ".net", "listview", "datagrid" ]
2
1
1,016
3
0
2008-09-18T20:33:34.780000
2008-10-09T17:25:59.087000
96,624
96,796
How to prevent others from using my .Net assembly?
I have an assembly which should not be used by any application other than the designated executable. Please give me some instructions to do so.
You can sign the assembly and the executable with the same key and then put a check in the constructor of the classes you want to protect: public class NotForAnyoneElse { public NotForAnyoneElse() { if (typeof(NotForAnyoneElse).Assembly.GetName().GetPublicKeyToken()!= Assembly.GetEntryAssembly().GetName().GetPublicKeyT...
How to prevent others from using my .Net assembly? I have an assembly which should not be used by any application other than the designated executable. Please give me some instructions to do so.
TITLE: How to prevent others from using my .Net assembly? QUESTION: I have an assembly which should not be used by any application other than the designated executable. Please give me some instructions to do so. ANSWER: You can sign the assembly and the executable with the same key and then put a check in the constru...
[ ".net", "security", "assemblies" ]
10
14
5,141
13
0
2008-09-18T20:34:04.717000
2008-09-18T20:49:42.030000
96,648
111,980
Problems with Visual Studio Express installation
I just installed 'Visual C# 2008 Express Edition' and 'Visual Web Developer 2008 Express Edition' on my Vista machine. Previously I have been running these in Win XP. When launching the software, starting a new project and trying to build it I get warnings like "The referenced component 'System' could not be found."; o...
Problem solved. I used the most radical solution I could come up with - a clean Vista install. Somehow reinstalling Visual Studio does not include all essential steps. First time the software is launched it configures itself. Something must have gone wrong the first time and when the procedure was done again it tried t...
Problems with Visual Studio Express installation I just installed 'Visual C# 2008 Express Edition' and 'Visual Web Developer 2008 Express Edition' on my Vista machine. Previously I have been running these in Win XP. When launching the software, starting a new project and trying to build it I get warnings like "The refe...
TITLE: Problems with Visual Studio Express installation QUESTION: I just installed 'Visual C# 2008 Express Edition' and 'Visual Web Developer 2008 Express Edition' on my Vista machine. Previously I have been running these in Win XP. When launching the software, starting a new project and trying to build it I get warni...
[ ".net", "visual-studio-2008", "installation", "visual-studio-express" ]
2
1
1,171
4
0
2008-09-18T20:36:07.473000
2008-09-21T20:22:28.097000
96,718
96,788
Organizing Extension Methods
How do you organize your Extension Methods? Say if I had extensions for the object class and string class I'm tempted to separate these extension methods into classes IE: public class ObjectExtensions {... } public class StringExtensions {... } am I making this too complicated or does this make sense?
I organize extension methods using a combination of namespace and class name, and it's similar to the way you describe in the question. Generally I have some sort of "primary assembly" in my solution that provides the majority of the shared functionality (like extension methods). We'll call this assembly "Framework" fo...
Organizing Extension Methods How do you organize your Extension Methods? Say if I had extensions for the object class and string class I'm tempted to separate these extension methods into classes IE: public class ObjectExtensions {... } public class StringExtensions {... } am I making this too complicated or does this...
TITLE: Organizing Extension Methods QUESTION: How do you organize your Extension Methods? Say if I had extensions for the object class and string class I'm tempted to separate these extension methods into classes IE: public class ObjectExtensions {... } public class StringExtensions {... } am I making this too compli...
[ "c#", "extension-methods", "code-organization" ]
19
13
2,051
2
0
2008-09-18T20:41:26.900000
2008-09-18T20:48:31.470000
96,732
97,290
Embedding one dll inside another as an embedded resource and then calling it from my code
I've got a situation where I have a DLL I'm creating that uses another third party DLL, but I would prefer to be able to build the third party DLL into my DLL instead of having to keep them both together if possible. This with is C# and.NET 3.5. The way I would like to do this is by storing the third party DLL as an em...
Once you've embedded the third-party assembly as a resource, add code to subscribe to the AppDomain.AssemblyResolve event of the current domain during application start-up. This event fires whenever the Fusion sub-system of the CLR fails to locate an assembly according to the probing (policies) in effect. In the event ...
Embedding one dll inside another as an embedded resource and then calling it from my code I've got a situation where I have a DLL I'm creating that uses another third party DLL, but I would prefer to be able to build the third party DLL into my DLL instead of having to keep them both together if possible. This with is ...
TITLE: Embedding one dll inside another as an embedded resource and then calling it from my code QUESTION: I've got a situation where I have a DLL I'm creating that uses another third party DLL, but I would prefer to be able to build the third party DLL into my DLL instead of having to keep them both together if possi...
[ "c#", ".net-3.5", "dll" ]
60
44
57,255
6
0
2008-09-18T20:42:59.610000
2008-09-18T21:40:49.083000
96,759
96,870
How do I Sort a Multidimensional Array in PHP
I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. function f_parse_csv($file, $longest, $delimiter) { $mdarray = array(); $file = fopen($file, "r"); while ($line = fgetcsv($file, $...
You can use array_multisort() Try something like this: foreach ($mdarray as $key => $row) { // replace 0 with the field's index/key $dates[$key] = $row[0]; } array_multisort($dates, SORT_DESC, $mdarray); For PHP >= 5.5.0 just extract the column to sort by. No need for the loop: array_multisort(array_column($mdarray, 0...
How do I Sort a Multidimensional Array in PHP I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. function f_parse_csv($file, $longest, $delimiter) { $mdarray = array(); $file = fope...
TITLE: How do I Sort a Multidimensional Array in PHP QUESTION: I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. function f_parse_csv($file, $longest, $delimiter) { $mdarray = arr...
[ "php", "sorting", "multidimensional-array" ]
204
219
201,478
10
0
2008-09-18T20:45:56.123000
2008-09-18T20:57:02.340000
96,780
96,890
Why is Visual Studio constantly crashing?
Visual Studio randomly crashes when adding/removing references and projects. Any thoughts why? Will installing Sp1 help? EDIT: I do not work with any addons except SourceSafe. I do most of my development in connected mode. Developing using: Visual Studio 2008 WinXp Terminal Service -> Win2k3 Sp2 (64bit) VSS 8.0, 32bit
Try deleting your.user and.suo files - these are the user options files that VS creates. You get a.user file for each project and a.suo file for your solution. When they get corrupted, odd things happen. Deleting them will make you lose little things like which project is selected as the startup project when you start ...
Why is Visual Studio constantly crashing? Visual Studio randomly crashes when adding/removing references and projects. Any thoughts why? Will installing Sp1 help? EDIT: I do not work with any addons except SourceSafe. I do most of my development in connected mode. Developing using: Visual Studio 2008 WinXp Terminal Ser...
TITLE: Why is Visual Studio constantly crashing? QUESTION: Visual Studio randomly crashes when adding/removing references and projects. Any thoughts why? Will installing Sp1 help? EDIT: I do not work with any addons except SourceSafe. I do most of my development in connected mode. Developing using: Visual Studio 2008 ...
[ "visual-studio-2008", "version-control", "crash", "visual-sourcesafe" ]
32
60
46,012
11
0
2008-09-18T20:47:24.593000
2008-09-18T20:59:00.850000
96,811
96,886
What are appropriate library naming conventions?
There are two popular naming conventions: vc90/win64/debug/foo.dll foo-vc90-win64-debug.dll Please discuss the problems/benefits associated with either approach. I am also wondering if it is possible to expose meta-data (i.e. compiler, platform, build-type) in approach #1 in an easy to use, cross-platform manner.
#2 is good for distribution, where several variation will be packaged in the same folder/zip file together. However, you probably don't want all that information in the file name itself, as it make it difficult to vary those via parameters to your makefile/csproj/nant script etc. It would be easier to have several file...
What are appropriate library naming conventions? There are two popular naming conventions: vc90/win64/debug/foo.dll foo-vc90-win64-debug.dll Please discuss the problems/benefits associated with either approach. I am also wondering if it is possible to expose meta-data (i.e. compiler, platform, build-type) in approach #...
TITLE: What are appropriate library naming conventions? QUESTION: There are two popular naming conventions: vc90/win64/debug/foo.dll foo-vc90-win64-debug.dll Please discuss the problems/benefits associated with either approach. I am also wondering if it is possible to expose meta-data (i.e. compiler, platform, build-t...
[ "naming-conventions" ]
1
3
880
2
0
2008-09-18T20:50:53.243000
2008-09-18T20:58:18.013000
96,826
97,008
Vim: How do I search for a word which is not followed by another word?
Pretty basic question, I'm trying to write a regex in Vim to match any phrase starting with "abc " directly followed by anything other than "defg". I've used "[^defg]" to match any single character other than d, e, f or g. My first instinct was to try /abc [^\(defg\)] or /abc [^\ ] but neither one of those works.
Here's the search string. /abc \(defg\)\@! The concept you're looking for is called a negative look-ahead assertion. Try this in vim for more info::help \@!
Vim: How do I search for a word which is not followed by another word? Pretty basic question, I'm trying to write a regex in Vim to match any phrase starting with "abc " directly followed by anything other than "defg". I've used "[^defg]" to match any single character other than d, e, f or g. My first instinct was to t...
TITLE: Vim: How do I search for a word which is not followed by another word? QUESTION: Pretty basic question, I'm trying to write a regex in Vim to match any phrase starting with "abc " directly followed by anything other than "defg". I've used "[^defg]" to match any single character other than d, e, f or g. My first...
[ "regex", "vim" ]
57
72
24,525
5
0
2008-09-18T20:52:55.220000
2008-09-18T21:09:43.087000
96,837
96,881
LinkButton not firing on production server
This is a good candidate for the "Works on My Machine Certification Program". I have the following code for a LinkButton... Do you wish to upgrade? It uses a custom control that simply adds code before and after the content to format it as a popup dialog. The Yes button is a HyperLink because it executes javascript to ...
Check the html that is emitted on production and make sure that it has the __doPostback() and that there are no global methods watching click and canceling the event. Other than that if you think it could be related to validation you could try adding CausesValidation or whatever to false and see if that helps. Otherwis...
LinkButton not firing on production server This is a good candidate for the "Works on My Machine Certification Program". I have the following code for a LinkButton... Do you wish to upgrade? It uses a custom control that simply adds code before and after the content to format it as a popup dialog. The Yes button is a H...
TITLE: LinkButton not firing on production server QUESTION: This is a good candidate for the "Works on My Machine Certification Program". I have the following code for a LinkButton... Do you wish to upgrade? It uses a custom control that simply adds code before and after the content to format it as a popup dialog. The...
[ "c#", "asp.net" ]
0
1
3,515
3
0
2008-09-18T20:53:38.073000
2008-09-18T20:57:47.437000
96,840
96,894
Real-world problems with naive shuffling
I'm writing a number of articles meant to teach beginning programming concepts through the use of poker-related topics. Currently, I'm working on the subject of shuffling. As Jeff Atwood points out on CodingHorror.com, one simple shuffling method (iterating through an array and swapping each card with a random card els...
It's not like you're writing a poker program that will be used for an actual online gambling site. An ability for someone to cheat at the program isn't a big deal when you're teaching people how to program. Leave a note saying that this is a poor model of the real world (with a reference to it as a possible security fl...
Real-world problems with naive shuffling I'm writing a number of articles meant to teach beginning programming concepts through the use of poker-related topics. Currently, I'm working on the subject of shuffling. As Jeff Atwood points out on CodingHorror.com, one simple shuffling method (iterating through an array and ...
TITLE: Real-world problems with naive shuffling QUESTION: I'm writing a number of articles meant to teach beginning programming concepts through the use of poker-related topics. Currently, I'm working on the subject of shuffling. As Jeff Atwood points out on CodingHorror.com, one simple shuffling method (iterating thr...
[ "algorithm", "probability", "shuffle" ]
4
0
3,891
6
0
2008-09-18T20:53:45.340000
2008-09-18T20:59:27.777000
96,842
97,152
Is there a way to purge some files from the history of git?
I have migrated a couple of project from Subversion to git. It work really well but when I clone my repository, it's really long because I have all the history of a lot of.jar file included in the transfer. Is there a way to keep only the latest version of certain type of file in my main repository. I mainly want to de...
You can remove old versions with either "git rebase" -i or "git filter-branch" http://schacon.github.com/git/git-filter-branch.html http://schacon.github.com/git/git-rebase.html Other docs and tutorials: http://git-scm.com/documentation Keeping only the current version from now forward is not supported. Your best bet i...
Is there a way to purge some files from the history of git? I have migrated a couple of project from Subversion to git. It work really well but when I clone my repository, it's really long because I have all the history of a lot of.jar file included in the transfer. Is there a way to keep only the latest version of cer...
TITLE: Is there a way to purge some files from the history of git? QUESTION: I have migrated a couple of project from Subversion to git. It work really well but when I clone my repository, it's really long because I have all the history of a lot of.jar file included in the transfer. Is there a way to keep only the lat...
[ "git", "version-control" ]
6
5
2,430
2
0
2008-09-18T20:54:00.147000
2008-09-18T21:25:30.540000
96,848
96,869
Is there any way to use a "constant" as hash key in Perl?
Is there any way to use a constant as a hash key? For example: use constant X => 1; my %x = (X => 'X'); The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key.
use constant actually makes constant subroutines. To do what you want, you need to explicitly call the sub: use constant X => 1; my %x = ( &X => 'X'); or use constant X => 1; my %x = ( X() => 'X');
Is there any way to use a "constant" as hash key in Perl? Is there any way to use a constant as a hash key? For example: use constant X => 1; my %x = (X => 'X'); The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key.
TITLE: Is there any way to use a "constant" as hash key in Perl? QUESTION: Is there any way to use a constant as a hash key? For example: use constant X => 1; my %x = (X => 'X'); The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key. ANSWER: use con...
[ "perl", "hash", "constants" ]
35
51
12,947
9
0
2008-09-18T20:54:25.853000
2008-09-18T20:57:00.840000
96,859
98,508
Package naming conventions for domain object models
What are some good package naming conventions for domain specific object models. For example, say you have a Person.java POJO, would you put it in a mydomain.model or mydomain.entity or mydomain.om (object model) package. The idea is to separate the MVC model objects from the domain object model. Our MVC based applicat...
I use "com.mycompany.domain" personally, but that might not be the best answer.
Package naming conventions for domain object models What are some good package naming conventions for domain specific object models. For example, say you have a Person.java POJO, would you put it in a mydomain.model or mydomain.entity or mydomain.om (object model) package. The idea is to separate the MVC model objects ...
TITLE: Package naming conventions for domain object models QUESTION: What are some good package naming conventions for domain specific object models. For example, say you have a Person.java POJO, would you put it in a mydomain.model or mydomain.entity or mydomain.om (object model) package. The idea is to separate the ...
[ "c#", "java", "naming-conventions", "package" ]
1
3
5,050
4
0
2008-09-18T20:55:39.737000
2008-09-19T01:01:51.547000
96,867
97,085
What causes tables to need to be repaired?
Every so often I get an error saying one of my tables "is marked as crashed and should be repaired". I then do a REPAIR TABLE and repair it. What causes them to be marked as crashed and how can I prevent it? I am using MyISAM tables with MySQL 5.0.45.
There can be a few reasons tables get corrupted, it is discussed in detail in the manual. To combat it, the following things work best: Make sure you always MySQL shutdown properly Consider using --myisam-recover option to automatically check/repair your tables in the event that shutdown wasn't done properly Make sure ...
What causes tables to need to be repaired? Every so often I get an error saying one of my tables "is marked as crashed and should be repaired". I then do a REPAIR TABLE and repair it. What causes them to be marked as crashed and how can I prevent it? I am using MyISAM tables with MySQL 5.0.45.
TITLE: What causes tables to need to be repaired? QUESTION: Every so often I get an error saying one of my tables "is marked as crashed and should be repaired". I then do a REPAIR TABLE and repair it. What causes them to be marked as crashed and how can I prevent it? I am using MyISAM tables with MySQL 5.0.45. ANSWER...
[ "mysql", "database" ]
11
6
8,553
4
0
2008-09-18T20:56:47.300000
2008-09-18T21:18:28.760000
96,871
96,907
How can I build C# ImageList Images from smaller component images?
I'd like to make status icons for a C# WinForms TreeList control. The statuses are combinations of other statuses (eg. a user node might be inactive or banned or inactive and banned), and the status icon is comprised of non-overlapping, smaller glyphs. I'd really like to avoid having to hand-generate all the possibly p...
Bitmap image1 =... Bitmap image2 =... Bitmap combined = new Bitmap(image1.Width, image1.Height); using (Graphics g = Graphics.FromImage(combined)) { g.DrawImage(image1, new Point(0, 0)); g.DrawImage(image2, new Point(0, 0); } imageList.Add(combined);
How can I build C# ImageList Images from smaller component images? I'd like to make status icons for a C# WinForms TreeList control. The statuses are combinations of other statuses (eg. a user node might be inactive or banned or inactive and banned), and the status icon is comprised of non-overlapping, smaller glyphs. ...
TITLE: How can I build C# ImageList Images from smaller component images? QUESTION: I'd like to make status icons for a C# WinForms TreeList control. The statuses are combinations of other statuses (eg. a user node might be inactive or banned or inactive and banned), and the status icon is comprised of non-overlapping...
[ "c#", "winforms", "image", ".net-2.0", "system.drawing" ]
0
1
5,012
2
0
2008-09-18T20:57:03.243000
2008-09-18T21:00:22.393000
96,875
187,466
ADF business components through RMI vs EJB and Toplink
What would the differences be in implementing remote business logic? Currently we are planning on using ADF to develop front-end web applications (moving from Struts ). What are the differences between the front end calling EJBs using TopLink vs ADF Business Components through RMI in terms of scalability as the migrati...
ADF is pretty broad, as it encompasses front end all the way down through data access. It's a great RAD framework if you are going to use the entire stack, but isn't so hot if you are only going to use one portion or the other. I am assuming you are talking about using either TopLink or ADF business components (BC4J) f...
ADF business components through RMI vs EJB and Toplink What would the differences be in implementing remote business logic? Currently we are planning on using ADF to develop front-end web applications (moving from Struts ). What are the differences between the front end calling EJBs using TopLink vs ADF Business Compon...
TITLE: ADF business components through RMI vs EJB and Toplink QUESTION: What would the differences be in implementing remote business logic? Currently we are planning on using ADF to develop front-end web applications (moving from Struts ). What are the differences between the front end calling EJBs using TopLink vs A...
[ "java", "jakarta-ee", "ejb", "oracle-adf" ]
0
2
2,552
3
0
2008-09-18T20:57:24.397000
2008-10-09T14:16:47.690000
96,882
1,513,578
How do I create a nice-looking DMG for Mac OS X using command-line tools?
I need to create a nice installer for a Mac application. I want it to be a disk image (DMG), with a predefined size, layout and background image. I need to do this programmatically in a script, to be integrated in an existing build system (more of a pack system really, since it only create installers. The builds are do...
After lots of research, I've come up with this answer, and I'm hereby putting it here as an answer for my own question, for reference: Make sure that "Enable access for assistive devices" is checked in System Preferences>>Universal Access. It is required for the AppleScript to work. You may have to reboot after this ch...
How do I create a nice-looking DMG for Mac OS X using command-line tools? I need to create a nice installer for a Mac application. I want it to be a disk image (DMG), with a predefined size, layout and background image. I need to do this programmatically in a script, to be integrated in an existing build system (more o...
TITLE: How do I create a nice-looking DMG for Mac OS X using command-line tools? QUESTION: I need to create a nice installer for a Mac application. I want it to be a disk image (DMG), with a predefined size, layout and background image. I need to do this programmatically in a script, to be integrated in an existing bu...
[ "macos", "scripting", "installation", "dmg" ]
233
210
119,562
15
0
2008-09-18T20:57:58.373000
2009-10-03T12:05:26.397000
96,923
96,937
What's the name of Visual Studio Import UI Widget (picture inside)
What's the name of the circled UI element here? And how do I access it using keyboard shortcuts? Sometimes it's nearly impossible to get the mouse to focus on it. catch (ItemNotFoundException e) { }
I don't know the name, but the shortcuts are CTRL-period (.) and ALT-SHIFT-F10. Handy to know:)
What's the name of Visual Studio Import UI Widget (picture inside) What's the name of the circled UI element here? And how do I access it using keyboard shortcuts? Sometimes it's nearly impossible to get the mouse to focus on it. catch (ItemNotFoundException e) { }
TITLE: What's the name of Visual Studio Import UI Widget (picture inside) QUESTION: What's the name of the circled UI element here? And how do I access it using keyboard shortcuts? Sometimes it's nearly impossible to get the mouse to focus on it. catch (ItemNotFoundException e) { } ANSWER: I don't know the name, but...
[ "visual-studio" ]
4
6
236
2
0
2008-09-18T21:01:43.730000
2008-09-18T21:03:08.597000
96,945
113,291
What is the best way to encrypt a clob?
I am using Oracle 9 and JDBC and would like to encyrpt a clob as it is inserted into the DB. Ideally I'd like to be able to just insert the plaintext and have it encrypted by a stored procedure: String SQL = "INSERT INTO table (ID, VALUE) values (?, encrypt(?))"; PreparedStatement ps = connection.prepareStatement(SQL);...
I note you are on Oracle 9, but just for the record in Oracle 10g+ the dbms_obfuscation_toolkit was deprecated in favour of dbms_crypto. dbms_crypto does include CLOB support: DBMS_CRYPTO.ENCRYPT( dst IN OUT NOCOPY BLOB, src IN CLOB CHARACTER SET ANY_CS, typ IN PLS_INTEGER, key IN RAW, iv IN RAW DEFAULT NULL); DBMS_CR...
What is the best way to encrypt a clob? I am using Oracle 9 and JDBC and would like to encyrpt a clob as it is inserted into the DB. Ideally I'd like to be able to just insert the plaintext and have it encrypted by a stored procedure: String SQL = "INSERT INTO table (ID, VALUE) values (?, encrypt(?))"; PreparedStatemen...
TITLE: What is the best way to encrypt a clob? QUESTION: I am using Oracle 9 and JDBC and would like to encyrpt a clob as it is inserted into the DB. Ideally I'd like to be able to just insert the plaintext and have it encrypted by a stored procedure: String SQL = "INSERT INTO table (ID, VALUE) values (?, encrypt(?))"...
[ "java", "oracle", "encryption", "jdbc", "plsql" ]
3
1
4,497
3
0
2008-09-18T21:03:48.080000
2008-09-22T05:21:41.983000
96,952
96,971
how to trim leading zeros from alphanumeric text in mysql function
What mysql functions are there (if any) to trim leading zeros from an alphanumeric text field? Field with value "00345ABC" would need to return "345ABC".
You are looking for the trim() function. Alright, here is your example SELECT TRIM(LEADING '0' FROM myfield) FROM table
how to trim leading zeros from alphanumeric text in mysql function What mysql functions are there (if any) to trim leading zeros from an alphanumeric text field? Field with value "00345ABC" would need to return "345ABC".
TITLE: how to trim leading zeros from alphanumeric text in mysql function QUESTION: What mysql functions are there (if any) to trim leading zeros from an alphanumeric text field? Field with value "00345ABC" would need to return "345ABC". ANSWER: You are looking for the trim() function. Alright, here is your example S...
[ "mysql" ]
91
187
116,254
8
0
2008-09-18T21:04:11.697000
2008-09-18T21:06:01.770000
96,997
97,445
Experience with SQLExpress for a multi-user commercial application?
I have inherited a VB6/Access application that we have developed and sold for many years. We're going to SQL Server 2005 Express Edition and.Net. The application can be multi-user. Currently the setup is simple for the customer -- Navigate to the folder to create the database on first launch; second user browses to the...
A deployment project from Visual Studio allows you to install a SQL Server Express instance with ease. We have the same kind of scenario for our applications and it means you do need separate installations for the client and server. Our server installation deals with either installing a new SQL Server or upgrading the ...
Experience with SQLExpress for a multi-user commercial application? I have inherited a VB6/Access application that we have developed and sold for many years. We're going to SQL Server 2005 Express Edition and.Net. The application can be multi-user. Currently the setup is simple for the customer -- Navigate to the folde...
TITLE: Experience with SQLExpress for a multi-user commercial application? QUESTION: I have inherited a VB6/Access application that we have developed and sold for many years. We're going to SQL Server 2005 Express Edition and.Net. The application can be multi-user. Currently the setup is simple for the customer -- Nav...
[ ".net", "sql-server", "installation", "user-experience" ]
3
3
2,074
8
0
2008-09-18T21:08:41.717000
2008-09-18T22:00:56.430000
97,050
101,980
std::map insert or std::map find?
Assuming a map where you want to preserve existing entries. 20% of the time, the entry you are inserting is new data. Is there an advantage to doing std::map::find then std::map::insert using that returned iterator? Or is it quicker to attempt the insert and then act based on whether or not the iterator indicates the r...
The answer is you do neither. Instead you want to do something suggested by Item 24 of Effective STL by Scott Meyers: typedef map MapType; // Your map type may vary, just change the typedef MapType mymap; // Add elements to map here int k = 4; // assume we're searching for keys equal to 4 int v = 0; // assume we want ...
std::map insert or std::map find? Assuming a map where you want to preserve existing entries. 20% of the time, the entry you are inserting is new data. Is there an advantage to doing std::map::find then std::map::insert using that returned iterator? Or is it quicker to attempt the insert and then act based on whether o...
TITLE: std::map insert or std::map find? QUESTION: Assuming a map where you want to preserve existing entries. 20% of the time, the entry you are inserting is new data. Is there an advantage to doing std::map::find then std::map::insert using that returned iterator? Or is it quicker to attempt the insert and then act ...
[ "c++", "optimization", "stl", "stdmap" ]
110
162
81,152
8
0
2008-09-18T21:14:26.307000
2008-09-19T13:52:25.413000
97,054
98,250
At which point in the lifecycle does GetConnectionInterface get called?
I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer("Filter Data Consumer")] public void GetConnectionInterface(IFilterData filterData) { _filterData = filterData; } Now, before I can call upon _filterData, I need to know when i can expect it to not be null. When is this?! With...
According to this document, it looks like Load. http://msdn.microsoft.com/en-us/library/ms366536.aspx
At which point in the lifecycle does GetConnectionInterface get called? I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer("Filter Data Consumer")] public void GetConnectionInterface(IFilterData filterData) { _filterData = filterData; } Now, before I can call upon _filterData,...
TITLE: At which point in the lifecycle does GetConnectionInterface get called? QUESTION: I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer("Filter Data Consumer")] public void GetConnectionInterface(IFilterData filterData) { _filterData = filterData; } Now, before I can call...
[ "asp.net", "sharepoint", "web-parts", "page-lifecycle", "webpart-connection" ]
1
0
380
1
0
2008-09-18T21:14:48.893000
2008-09-19T00:14:27.730000
97,063
97,240
Can anyone give me a list of the Business Objects Error Codes and what they mean?
Business Objects Web Services returns error codes and I have yet to find a good resource where these are listed and what they mean. I am currently getting an "The resultset was empty. (Error: WBP 42019)". Any ideas on where these might be listed? I've called Business Objects support and the tech couldn't even tell me. ...
The best I have found is the "Error Message Guide" from Business Objects. http://help.sap.com/businessobject/product_guides/boexir2/en/xir2_ErrMsgGde_en.pdf If you can't find the error code in that guide then you end up having to deal with standard debugging of an undocumented application. 1. Read the message, maybe th...
Can anyone give me a list of the Business Objects Error Codes and what they mean? Business Objects Web Services returns error codes and I have yet to find a good resource where these are listed and what they mean. I am currently getting an "The resultset was empty. (Error: WBP 42019)". Any ideas on where these might be...
TITLE: Can anyone give me a list of the Business Objects Error Codes and what they mean? QUESTION: Business Objects Web Services returns error codes and I have yet to find a good resource where these are listed and what they mean. I am currently getting an "The resultset was empty. (Error: WBP 42019)". Any ideas on wh...
[ "business-objects" ]
0
0
20,567
4
0
2008-09-18T21:15:28.503000
2008-09-18T21:35:52.073000
97,081
97,229
"get() const" vs. "getAsConst() const"
Someone told me about a C++ style difference in their team. I have my own viewpoint on the subject, but I would be interested by pros and cons coming from everyone. So, in case you have a class property you want to expose via two getters, one read/write, and the other, readonly (i.e. there is no set method). There are ...
Well, for one thing, getAsConst must be called when the 'this' pointer is const -- not when you want to receive a const object. So, alongside any other issues, it's subtly misnamed. (You can still call it when 'this' is non-const, but that's neither here nor there.) Ignoring that, getAsConst earns you nothing, and puts...
"get() const" vs. "getAsConst() const" Someone told me about a C++ style difference in their team. I have my own viewpoint on the subject, but I would be interested by pros and cons coming from everyone. So, in case you have a class property you want to expose via two getters, one read/write, and the other, readonly (i...
TITLE: "get() const" vs. "getAsConst() const" QUESTION: Someone told me about a C++ style difference in their team. I have my own viewpoint on the subject, but I would be interested by pros and cons coming from everyone. So, in case you have a class property you want to expose via two getters, one read/write, and the ...
[ "c++", "coding-style", "constants" ]
1
8
2,232
11
0
2008-09-18T21:17:50.930000
2008-09-18T21:34:35.697000
97,092
97,689
How do you limit height of a Sytem.Windows.Form to an exact value?
What I am trying to achieve is a form that has a button on it that causes the Form to 'drop-down' and become larger, displaying more information. My current attempt is this: private void btnExpand_Click(object sender, EventArgs e) { if (btnExpand.Text == ">") { btnExpand.Text = "<"; _expanded = true; this.MinimumSize =...
As per the docs, use 0 to denote no maximum or minimum size. Tho, I just tried it and it didn't like 0 at all. So I used int.MaxValue like you did and it worked. What version of the the framework you using?
How do you limit height of a Sytem.Windows.Form to an exact value? What I am trying to achieve is a form that has a button on it that causes the Form to 'drop-down' and become larger, displaying more information. My current attempt is this: private void btnExpand_Click(object sender, EventArgs e) { if (btnExpand.Text =...
TITLE: How do you limit height of a Sytem.Windows.Form to an exact value? QUESTION: What I am trying to achieve is a form that has a button on it that causes the Form to 'drop-down' and become larger, displaying more information. My current attempt is this: private void btnExpand_Click(object sender, EventArgs e) { if...
[ "c#", "winforms" ]
1
1
515
2
0
2008-09-18T21:19:20.273000
2008-09-18T22:36:05.737000
97,097
97,156
What is the C# version of VB.NET's InputBox?
What is the C# version of VB.NET's InputBox?
Add a reference to Microsoft.VisualBasic, InputBox is in the Microsoft.VisualBasic.Interaction namespace: using Microsoft.VisualBasic; string input = Interaction.InputBox("Prompt", "Title", "Default", x_coordinate, y_coordinate); Only the first argument for prompt is mandatory
What is the C# version of VB.NET's InputBox? What is the C# version of VB.NET's InputBox?
TITLE: What is the C# version of VB.NET's InputBox? QUESTION: What is the C# version of VB.NET's InputBox? ANSWER: Add a reference to Microsoft.VisualBasic, InputBox is in the Microsoft.VisualBasic.Interaction namespace: using Microsoft.VisualBasic; string input = Interaction.InputBox("Prompt", "Title", "Default", x_...
[ "c#", "vb.net" ]
178
270
270,305
11
0
2008-09-18T21:20:05.963000
2008-09-18T21:25:56.480000
97,104
98,165
How can I get the current exception in a WinForms TraceListener
I am modifying an existing WinForms app which is setup with a custom TraceListener which logs any unhandled errors that occur in the app. It seems to me like the TraceListener gets the message part of the exception (which is what gets logged), but not the other exception information. I would like to be able to get at t...
I assume that you have set an event handler that catches unhandled domain exceptions and thread exceptions. In that delegate you probably call the trace listener to log the exception. Simply issue an extra call to set the exception context. [STAThread] private static void Main() { // Add the event handler for handling ...
How can I get the current exception in a WinForms TraceListener I am modifying an existing WinForms app which is setup with a custom TraceListener which logs any unhandled errors that occur in the app. It seems to me like the TraceListener gets the message part of the exception (which is what gets logged), but not the ...
TITLE: How can I get the current exception in a WinForms TraceListener QUESTION: I am modifying an existing WinForms app which is setup with a custom TraceListener which logs any unhandled errors that occur in the app. It seems to me like the TraceListener gets the message part of the exception (which is what gets log...
[ "winforms", "exception" ]
1
3
706
1
0
2008-09-18T21:20:44.513000
2008-09-18T23:59:29.343000
97,113
97,131
regular expression to parse LDAP dn
I have the following string: cn=abcd,cn=groups,dc=domain,dc=com Can a regular expression be used here to extract the string after the first cn= and before the first,? In the example above the answer should be abcd.
/cn=([^,]+),/ most languages will extract the match as $1 or matches[1] If you can't for some reason wield subscripts, $x =~ s/^cn=// $x =~ s/,.*$// Thats a way to do it in 2 steps. If you were parsing it out of a log with sed sed -n -r '/cn=/s/^cn=([^,]+),.*$/\1/p' < logfile > dumpfile will get you what you want. ( Ex...
regular expression to parse LDAP dn I have the following string: cn=abcd,cn=groups,dc=domain,dc=com Can a regular expression be used here to extract the string after the first cn= and before the first,? In the example above the answer should be abcd.
TITLE: regular expression to parse LDAP dn QUESTION: I have the following string: cn=abcd,cn=groups,dc=domain,dc=com Can a regular expression be used here to extract the string after the first cn= and before the first,? In the example above the answer should be abcd. ANSWER: /cn=([^,]+),/ most languages will extract ...
[ "regex" ]
4
12
10,857
5
0
2008-09-18T21:21:50.313000
2008-09-18T21:23:33.553000
97,114
97,318
Is conditional compilation a valid mock/stub strategy for unit testing?
In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but one answer suggested using conditional compilation, retaining static binding in the production code. This answer was modded -2 at the time of reading, so at least 2 people really thought this was a wrong answ...
Try to keep production code separate from test code. Maintain different folder hierarchies.. different solutions/projects. Unless.. you're in the world of legacy C++ Code. Here anything goes.. if conditional blocks help you get some of the code testable and you see a benefit.. By all means do it. But try to not let it ...
Is conditional compilation a valid mock/stub strategy for unit testing? In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but one answer suggested using conditional compilation, retaining static binding in the production code. This answer was modded -2 at the ti...
TITLE: Is conditional compilation a valid mock/stub strategy for unit testing? QUESTION: In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but one answer suggested using conditional compilation, retaining static binding in the production code. This answer was m...
[ "unit-testing", "stub", "conditional-compilation" ]
5
3
1,631
6
0
2008-09-18T21:21:55.570000
2008-09-18T21:44:19.417000
97,124
97,966
How to implement paging for asp:DataList in .NET 2.0?
I spent hours researching the problem, and just want to share a solution in case you ever need to implement paging for asp:DataList in.NET 2.0. My specific requirement was to have "Previous" and "Next" links and page number links.
I moved this from the question, so it doesn't appear as "Not Answered"... PagedDataSource solution in this article was the most elegant and simple solution for this problem. If you have a better solution - post it here please. p.s. I'm not affiliated with that website in any way.
How to implement paging for asp:DataList in .NET 2.0? I spent hours researching the problem, and just want to share a solution in case you ever need to implement paging for asp:DataList in.NET 2.0. My specific requirement was to have "Previous" and "Next" links and page number links.
TITLE: How to implement paging for asp:DataList in .NET 2.0? QUESTION: I spent hours researching the problem, and just want to share a solution in case you ever need to implement paging for asp:DataList in.NET 2.0. My specific requirement was to have "Previous" and "Next" links and page number links. ANSWER: I moved ...
[ "c#", "asp.net", ".net-2.0", "paging", "datalist" ]
2
3
2,903
1
0
2008-09-18T21:23:15.490000
2008-09-18T23:24:27.007000
97,137
97,187
How do you run a script on login in *nix?
I know I once know how to do this but... how do you run a script (bash is OK) on login in unix?
From wikipedia Bash When Bash starts, it executes the commands in a variety of different scripts. When Bash is invoked as an interactive login shell, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile...
How do you run a script on login in *nix? I know I once know how to do this but... how do you run a script (bash is OK) on login in unix?
TITLE: How do you run a script on login in *nix? QUESTION: I know I once know how to do this but... how do you run a script (bash is OK) on login in unix? ANSWER: From wikipedia Bash When Bash starts, it executes the commands in a variety of different scripts. When Bash is invoked as an interactive login shell, it fi...
[ "linux", "bash", "macos", "unix", "shell" ]
73
115
163,787
11
0
2008-09-18T21:24:13.880000
2008-09-18T21:29:02.403000
97,179
97,277
Must an SMTP client provide the MTA a globally resolvable hostname in the HELO?
In short: I'm trying to figure out if I should tell a mail administrator of a friend's employer whether their mail configuration should be fixed, or if I should revise my own policy to be more liberal in what I accept, or neither. A friend was complaining of being unable to reach anything on my mailserver. I dug into i...
SMTP RFCs do not require it, but lots of popular systems will reject mail with bogus HELOs. Note that RFC 1033 and RFC 1912 both require all internet-reachable hosts to have a valid name; simply listing that name in the HELO will fix many problems. Some spam filters, unfortunately, also reject mail from hostnames conta...
Must an SMTP client provide the MTA a globally resolvable hostname in the HELO? In short: I'm trying to figure out if I should tell a mail administrator of a friend's employer whether their mail configuration should be fixed, or if I should revise my own policy to be more liberal in what I accept, or neither. A friend ...
TITLE: Must an SMTP client provide the MTA a globally resolvable hostname in the HELO? QUESTION: In short: I'm trying to figure out if I should tell a mail administrator of a friend's employer whether their mail configuration should be fixed, or if I should revise my own policy to be more liberal in what I accept, or ...
[ "smtp", "postfix-mta", "email-spam" ]
3
2
2,895
5
0
2008-09-18T21:28:03.137000
2008-09-18T21:40:04.187000
97,193
97,278
Can I get the calling instance from within a method via reflection/diagnostics?
Is there a way via System.Reflection, System.Diagnostics or other to get a reference to the actual instance that is calling a static method without passing it in to the method itself? For example, something along these lines class A { public void DoSomething() { StaticClass.ExecuteMethod(); } } class B { public void D...
I do not believe you can. Even the StackTrace and StackFrame classes just give you naming information, not access to instances. I'm not sure exactly why you'd want to do this, but know that even if you could do it it would likely be very slow. A better solution would be to push the instance to a thread local context be...
Can I get the calling instance from within a method via reflection/diagnostics? Is there a way via System.Reflection, System.Diagnostics or other to get a reference to the actual instance that is calling a static method without passing it in to the method itself? For example, something along these lines class A { publi...
TITLE: Can I get the calling instance from within a method via reflection/diagnostics? QUESTION: Is there a way via System.Reflection, System.Diagnostics or other to get a reference to the actual instance that is calling a static method without passing it in to the method itself? For example, something along these lin...
[ "c#", ".net", "reflection" ]
13
6
9,686
5
0
2008-09-18T21:29:45.287000
2008-09-18T21:40:08.647000
97,197
97,253
What is the "N+1 selects problem" in ORM (Object-Relational Mapping)?
The "N+1 selects problem" is generally stated as a problem in Object-Relational mapping (ORM) discussions, and I understand that it has something to do with having to make a lot of database queries for something that seems simple in the object world. Does anybody have a more detailed explanation of the problem?
Let's say you have a collection of Car objects (database rows), and each Car has a collection of Wheel objects (also rows). In other words, Car → Wheel is a 1-to-many relationship. Now, let's say you need to iterate through all the cars, and for each one, print out a list of the wheels. The naive O/R implementation wou...
What is the "N+1 selects problem" in ORM (Object-Relational Mapping)? The "N+1 selects problem" is generally stated as a problem in Object-Relational mapping (ORM) discussions, and I understand that it has something to do with having to make a lot of database queries for something that seems simple in the object world....
TITLE: What is the "N+1 selects problem" in ORM (Object-Relational Mapping)? QUESTION: The "N+1 selects problem" is generally stated as a problem in Object-Relational mapping (ORM) discussions, and I understand that it has something to do with having to make a lot of database queries for something that seems simple in...
[ "database", "orm" ]
2,262
1,555
722,388
19
0
2008-09-18T21:30:00.963000
2008-09-18T21:36:40.683000
97,198
97,205
WebDev: What is the best way to do a multi-file upload?
I want (barely computer literate) people to easily submit a large number of files (pictures) through my web application. Is there a simple, robust, free/cheap, widely used, standard tool/component (Flash or.NET - sorry no java runtime on the browser) that allows a web user to select a folder or a bunch of files on thei...
swfupload, the best tool I know that lets you do that. Simple, easy to use and even has a fallback mechanism for the 1% web users that don't have flash 8+.
WebDev: What is the best way to do a multi-file upload? I want (barely computer literate) people to easily submit a large number of files (pictures) through my web application. Is there a simple, robust, free/cheap, widely used, standard tool/component (Flash or.NET - sorry no java runtime on the browser) that allows a...
TITLE: WebDev: What is the best way to do a multi-file upload? QUESTION: I want (barely computer literate) people to easily submit a large number of files (pictures) through my web application. Is there a simple, robust, free/cheap, widely used, standard tool/component (Flash or.NET - sorry no java runtime on the brow...
[ "asp.net", "web-applications", "file-upload" ]
2
5
3,763
3
0
2008-09-18T21:30:13.773000
2008-09-18T21:31:28.027000
97,202
97,268
Windows Installer: How do I create a start menu shortcut for Administrator only?
I have a WSI installer package that I'm using to install my application. The application itself can be run by a normal user, but I have a configuration app that should only be run by a system administrator. Thus, I don't want it to appear in the Start Menu for all users, just for the administrator. Is there any way to ...
since I doubt that you will know the name of every admin and there is no start folder for just admins, then I think a better solution would be for you to have the configuration app check to see if the user running it is an admin then exit gracefully if it is not. EDIT: Perhaps I should explain further why I think addin...
Windows Installer: How do I create a start menu shortcut for Administrator only? I have a WSI installer package that I'm using to install my application. The application itself can be run by a normal user, but I have a configuration app that should only be run by a system administrator. Thus, I don't want it to appear ...
TITLE: Windows Installer: How do I create a start menu shortcut for Administrator only? QUESTION: I have a WSI installer package that I'm using to install my application. The application itself can be run by a normal user, but I have a configuration app that should only be run by a system administrator. Thus, I don't ...
[ "windows-installer" ]
0
2
3,099
4
0
2008-09-18T21:30:46.017000
2008-09-18T21:38:27.030000
97,204
97,373
Comparing C# and Java
I learned Java in college, and then I was hired by a C# shop and have used that ever since. I spent my first week realizing that the two languages were almost identical, and the next two months figuring out the little differences. For the most part, was I noticing the things that Java had that C# doesn't, and thus was ...
Comparing and contrasting the languages between the two can be quite difficult, as in many ways it is the associated libraries that you use in association with the language that best showcases the various advantages of one of another. So I'll try to list out as many things I can remember or that have already been poste...
Comparing C# and Java I learned Java in college, and then I was hired by a C# shop and have used that ever since. I spent my first week realizing that the two languages were almost identical, and the next two months figuring out the little differences. For the most part, was I noticing the things that Java had that C# ...
TITLE: Comparing C# and Java QUESTION: I learned Java in college, and then I was hired by a C# shop and have used that ever since. I spent my first week realizing that the two languages were almost identical, and the next two months figuring out the little differences. For the most part, was I noticing the things that...
[ "c#", "java" ]
6
8
4,557
8
0
2008-09-18T21:31:00.993000
2008-09-18T21:52:18.150000
97,212
112,723
Barcode- and Character Recognition component for .Net
I need to extract and decode barcodes and text from images. Is there any open source library available that helps to accomplish that task? If not, do you know a good commercial product?
Disclaimer: I work for Atalasoft. DotImage + the Barcode Reader addon from Atalasoft offers a Runtime Royalty-Free option that does not use any COM.
Barcode- and Character Recognition component for .Net I need to extract and decode barcodes and text from images. Is there any open source library available that helps to accomplish that task? If not, do you know a good commercial product?
TITLE: Barcode- and Character Recognition component for .Net QUESTION: I need to extract and decode barcodes and text from images. Is there any open source library available that helps to accomplish that task? If not, do you know a good commercial product? ANSWER: Disclaimer: I work for Atalasoft. DotImage + the Barc...
[ ".net", "ocr", "barcode" ]
1
3
7,294
3
0
2008-09-18T21:32:05.560000
2008-09-22T00:58:51.990000
97,228
97,284
VS 2008 Post Build Step funny business
Ok, here's the breakdown of my project: I have a web project with a "Scripts" subfolder. That folder contains a few javascript files and a copy of JSMin.exe along with a batch file that runs the JSMin.exe on a few of the files. I tried to set up a post build step of 'call "$(ProjectDir)Scripts\jsmin.bat"'. When I perfo...
If you have something in your custom build step that returns an error code, you can add: exit 0 as the last line of your build step. This will stop the build from failing.
VS 2008 Post Build Step funny business Ok, here's the breakdown of my project: I have a web project with a "Scripts" subfolder. That folder contains a few javascript files and a copy of JSMin.exe along with a batch file that runs the JSMin.exe on a few of the files. I tried to set up a post build step of 'call "$(Proje...
TITLE: VS 2008 Post Build Step funny business QUESTION: Ok, here's the breakdown of my project: I have a web project with a "Scripts" subfolder. That folder contains a few javascript files and a copy of JSMin.exe along with a batch file that runs the JSMin.exe on a few of the files. I tried to set up a post build step...
[ "visual-studio-2008", "build-process" ]
2
4
3,397
5
0
2008-09-18T21:34:28.037000
2008-09-18T21:40:24.200000
97,270
97,287
How do I capture an asterisk on the form's KeyUp event? OR, How do I get a KeyChar on the KeyUp event?
I'm trying to hijack an asterisk with the form's KeyUp event. I can get the SHIFT key and the D8 key on the KeyUp event, but I can't get the * out of it. I can find it easily in the KeyPress event (e.KeyChar = "*"c), but company standards say that we have to use the KeyUp event for all such occasions. Thanks!
Cache the charcode on KeyPress and then respond to KeyUp. There are other key combinations that will generate the asterisk, especially if you're facing international users who may have different keyboard layouts, so you can't rely on the KeyUp to give you the information you need.
How do I capture an asterisk on the form's KeyUp event? OR, How do I get a KeyChar on the KeyUp event? I'm trying to hijack an asterisk with the form's KeyUp event. I can get the SHIFT key and the D8 key on the KeyUp event, but I can't get the * out of it. I can find it easily in the KeyPress event (e.KeyChar = "*"c), ...
TITLE: How do I capture an asterisk on the form's KeyUp event? OR, How do I get a KeyChar on the KeyUp event? QUESTION: I'm trying to hijack an asterisk with the form's KeyUp event. I can get the SHIFT key and the D8 key on the KeyUp event, but I can't get the * out of it. I can find it easily in the KeyPress event (e...
[ ".net", "vb.net" ]
0
2
734
1
0
2008-09-18T21:38:48.493000
2008-09-18T21:40:31.797000
97,279
97,298
Keyboard shortcut to close all tabs but current one in Visual Studio?
Does anyone know a keyboard shortcut to close all tabs except for the current one in Visual Studio? And while we're at it, the shortcut for closing all tabs? Is there a Resharper option for this? I've looked in the past and have never been able to find it.
I don't think there is one by default, but you can go to Tools>Options>Environment>Keyboard and bind a key to File.CloseAllButThis. I use ctrl + alt + w
Keyboard shortcut to close all tabs but current one in Visual Studio? Does anyone know a keyboard shortcut to close all tabs except for the current one in Visual Studio? And while we're at it, the shortcut for closing all tabs? Is there a Resharper option for this? I've looked in the past and have never been able to fi...
TITLE: Keyboard shortcut to close all tabs but current one in Visual Studio? QUESTION: Does anyone know a keyboard shortcut to close all tabs except for the current one in Visual Studio? And while we're at it, the shortcut for closing all tabs? Is there a Resharper option for this? I've looked in the past and have nev...
[ ".net", "visual-studio", "resharper" ]
84
96
34,437
9
0
2008-09-18T21:40:09.427000
2008-09-18T21:41:33.027000
97,283
97,517
How can I determine the name of the currently focused process in C#
For example if the user is currently running VS2008 then I want the value VS2008.
I am assuming you want to get the name of the process owning the currently focused window. With some P/Invoke: // The GetForegroundWindow function returns a handle to the foreground window // (the window with which the user is currently working). [System.Runtime.InteropServices.DllImport("user32.dll")] private static e...
How can I determine the name of the currently focused process in C# For example if the user is currently running VS2008 then I want the value VS2008.
TITLE: How can I determine the name of the currently focused process in C# QUESTION: For example if the user is currently running VS2008 then I want the value VS2008. ANSWER: I am assuming you want to get the name of the process owning the currently focused window. With some P/Invoke: // The GetForegroundWindow funct...
[ "c#" ]
10
18
7,087
2
0
2008-09-18T21:40:19.270000
2008-09-18T22:09:56.047000
97,293
97,319
LINQ FormatException
I currently have an existing database and I am using the LINQtoSQL generator tool to create the classes for me. The tool is working fine for this database and there are no errors with that tool. When I run a LINQ to SQL query against the data, there is a row that has some invalid data somehow within the table and it is...
Do you have a varchar(1) that stores an empty string? You need to change the type from char to string in the designer (or somehow prohibit empties). The.net char type cannot hold an empty string.
LINQ FormatException I currently have an existing database and I am using the LINQtoSQL generator tool to create the classes for me. The tool is working fine for this database and there are no errors with that tool. When I run a LINQ to SQL query against the data, there is a row that has some invalid data somehow withi...
TITLE: LINQ FormatException QUESTION: I currently have an existing database and I am using the LINQtoSQL generator tool to create the classes for me. The tool is working fine for this database and there are no errors with that tool. When I run a LINQ to SQL query against the data, there is a row that has some invalid ...
[ "linq", "linq-to-sql", "exception" ]
1
2
358
1
0
2008-09-18T21:41:01.610000
2008-09-18T21:44:24.283000
97,312
97,331
How do I find out what directory my console app is running in?
How do I find out what directory my console app is running in with C#?
To get the directory where the.exe file is: AppDomain.CurrentDomain.BaseDirectory To get the current directory: Environment.CurrentDirectory
How do I find out what directory my console app is running in? How do I find out what directory my console app is running in with C#?
TITLE: How do I find out what directory my console app is running in? QUESTION: How do I find out what directory my console app is running in with C#? ANSWER: To get the directory where the.exe file is: AppDomain.CurrentDomain.BaseDirectory To get the current directory: Environment.CurrentDirectory
[ "c#", ".net", "console-application" ]
104
182
74,843
9
0
2008-09-18T21:43:30.480000
2008-09-18T21:45:45.560000
97,324
97,676
WCF faults and exceptions
I'm writing a WCF service for the first time. The service and all of its clients (at least for now) are written in C#. The service has to do a lot of input validation on the data it gets passed, so I need to have some way to indicate invalid data back to the client. I've been reading a lot about faults and exceptions, ...
If you are doing validation on the client and should have valid values once they are passed into the method (the web service call) then I would throw an exception. It could be an exception indicating that a parameters is invalid with the name of the parameter. (see: ArgumentException) But you may not want to rely on th...
WCF faults and exceptions I'm writing a WCF service for the first time. The service and all of its clients (at least for now) are written in C#. The service has to do a lot of input validation on the data it gets passed, so I need to have some way to indicate invalid data back to the client. I've been reading a lot abo...
TITLE: WCF faults and exceptions QUESTION: I'm writing a WCF service for the first time. The service and all of its clients (at least for now) are written in C#. The service has to do a lot of input validation on the data it gets passed, so I need to have some way to indicate invalid data back to the client. I've been...
[ "c#", "wcf", "validation", "exception" ]
6
3
5,585
3
0
2008-09-18T21:44:51.380000
2008-09-18T22:33:44.027000
97,329
97,545
Fastest way to find objects from a collection matched by condition on string member
Suppose I have a collection (be it an array, generic List, or whatever is the fastest solution to this problem) of a certain class, let's call it ClassFoo: class ClassFoo { public string word; public float score; //... etc... } Assume there's going to be like 50.000 items in the collection, all in memory. Now I want to...
With the constraint that the condition clause can be "anything", then you're limited to scanning the entire list and applying the condition. If there are limitations on the condition clause, then you can look at organizing the data to more efficiently handle the queries. For example, the code sample with the "byFirstLe...
Fastest way to find objects from a collection matched by condition on string member Suppose I have a collection (be it an array, generic List, or whatever is the fastest solution to this problem) of a certain class, let's call it ClassFoo: class ClassFoo { public string word; public float score; //... etc... } Assume t...
TITLE: Fastest way to find objects from a collection matched by condition on string member QUESTION: Suppose I have a collection (be it an array, generic List, or whatever is the fastest solution to this problem) of a certain class, let's call it ClassFoo: class ClassFoo { public string word; public float score; //......
[ "c#", "arrays", "string", "collections", "performance" ]
1
2
5,029
9
0
2008-09-18T21:45:39.693000
2008-09-18T22:13:14.887000
97,338
99,282
GCC dependency generation for a different output directory
I'm using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency file it generates for me? gcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) >>$(DEP)
The answer is in the GCC manual: use the -MT flag. -MT target Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, deletes any directory components and any file suffix such as.c, and appends the platform's usual object suffix. The result is the target. An...
GCC dependency generation for a different output directory I'm using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency file it generates for me? gcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) >>$(DEP)
TITLE: GCC dependency generation for a different output directory QUESTION: I'm using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency file it generates for me? gcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) >>...
[ "c++", "gcc", "makefile", "dependencies" ]
23
23
30,053
7
0
2008-09-18T21:46:56.073000
2008-09-19T03:27:25.940000
97,349
100,493
TFSBuild.proj and Importing External Targets
We want to store our overridden build targets in an external file and include that targets file in the TFSBuild.proj. We have a core set steps that happens and would like to get those additional steps by simply adding the import line to the TFSBuild.proj created by the wizard. We cannot have an import on any file in th...
The Team Build has a "bootstrap" phase where everything in the Team Build Configuration folder (the folder with TFSBuild.proj) is downloaded from version control. This is performed by the build agent before the build agent calls MSBuild.exe telling it to run TFSBuild.proj. If you move your targets file from under Solut...
TFSBuild.proj and Importing External Targets We want to store our overridden build targets in an external file and include that targets file in the TFSBuild.proj. We have a core set steps that happens and would like to get those additional steps by simply adding the import line to the TFSBuild.proj created by the wizar...
TITLE: TFSBuild.proj and Importing External Targets QUESTION: We want to store our overridden build targets in an external file and include that targets file in the TFSBuild.proj. We have a core set steps that happens and would like to get those additional steps by simply adding the import line to the TFSBuild.proj cr...
[ "tfs", "msbuild", "tfsbuild" ]
7
16
4,530
3
0
2008-09-18T21:48:17.520000
2008-09-19T08:29:34.077000
97,370
321,738
Run macro automatically OnSave in Word
I have a macro which refreshes all fields in a document (the equivalent of doing an F9 on the fields). I'd like to fire this macro automatically when the user saves the document. Under options I can select "update fields when document is printed", but that's not what I want. In the VBA editor I only seem to find events...
Yes, fencliff is right, you're out of luck with Word 97. If an upgrade is not an option, the only thing that comes to my mind is polling the file's last modification time using a timer. I know it's ugly but you don't get events neither is there a Word command that you could override.
Run macro automatically OnSave in Word I have a macro which refreshes all fields in a document (the equivalent of doing an F9 on the fields). I'd like to fire this macro automatically when the user saves the document. Under options I can select "update fields when document is printed", but that's not what I want. In th...
TITLE: Run macro automatically OnSave in Word QUESTION: I have a macro which refreshes all fields in a document (the equivalent of doing an F9 on the fields). I'd like to fire this macro automatically when the user saves the document. Under options I can select "update fields when document is printed", but that's not ...
[ "vba", "ms-word", "ms-office" ]
1
1
3,182
2
0
2008-09-18T21:52:05.233000
2008-11-26T18:50:18.197000
97,371
97,782
How do I write a Windows batch script to copy the newest file from a directory?
I need to copy the newest file in a directory to a new location. So far I've found resources on the forfiles command, a date-related question here, and another related question. I'm just having a bit of trouble putting the pieces together! How do I copy the newest file in that directory to a new place?
Windows shell, one liner: FOR /F "delims=" %%I IN ('DIR *.* /A-D /B /O:-D') DO COPY "%%I" < > & EXIT
How do I write a Windows batch script to copy the newest file from a directory? I need to copy the newest file in a directory to a new location. So far I've found resources on the forfiles command, a date-related question here, and another related question. I'm just having a bit of trouble putting the pieces together! ...
TITLE: How do I write a Windows batch script to copy the newest file from a directory? QUESTION: I need to copy the newest file in a directory to a new location. So far I've found resources on the forfiles command, a date-related question here, and another related question. I'm just having a bit of trouble putting the...
[ "batch-file", "forfiles" ]
79
72
208,637
10
0
2008-09-18T21:52:05.343000
2008-09-18T22:48:39.620000
97,385
97,489
How can I open a google chrome control in C#
I know there is a way to add a IE control, how do you add a chrome control...? Is it even possible right now? I'm need this because of the fast javascript VM found in chrome.
I searched around and I don't think Google Chrome registers itself as a Windows COM+ component. I think you're out of luck.
How can I open a google chrome control in C# I know there is a way to add a IE control, how do you add a chrome control...? Is it even possible right now? I'm need this because of the fast javascript VM found in chrome.
TITLE: How can I open a google chrome control in C# QUESTION: I know there is a way to add a IE control, how do you add a chrome control...? Is it even possible right now? I'm need this because of the fast javascript VM found in chrome. ANSWER: I searched around and I don't think Google Chrome registers itself as a W...
[ "c#" ]
3
2
8,006
4
0
2008-09-18T21:54:06.477000
2008-09-18T22:05:56.463000
97,421
98,210
Does IE6 Support AES 256 bit encryption?
Will IE6 negotiate a 256 bit AES SSL connection if the server is capable?
Sometimes there is just a plain and simple way of finding out. If you look at the internet explorer help > about internet explorer, it will tell you the max cipher bits that it supports, and on IE6 its 128.
Does IE6 Support AES 256 bit encryption? Will IE6 negotiate a 256 bit AES SSL connection if the server is capable?
TITLE: Does IE6 Support AES 256 bit encryption? QUESTION: Will IE6 negotiate a 256 bit AES SSL connection if the server is capable? ANSWER: Sometimes there is just a plain and simple way of finding out. If you look at the internet explorer help > about internet explorer, it will tell you the max cipher bits that it s...
[ "ssl", "internet-explorer-6", "aes" ]
0
4
13,185
5
0
2008-09-18T21:57:42.020000
2008-09-19T00:07:42.990000
97,433
97,446
Good example of use of AppDomain
I keep getting asked about AppDomains in interviews, and I know the basics: they are an isolation level within an application (making them different from applications) they can have threads (making them different from threads) exceptions in one appdomain do not affect another appdomains cannot access each other's memor...
Probably the most common one is to load assemblies that contain plug-in code from untrusted parties. The code runs in its own AppDomain, isolating the application. Also, it's not possible to unload a particular assembly, but you can unload AppDomains. For the full rundown, Chris Brumme had a massive blog entry on this:...
Good example of use of AppDomain I keep getting asked about AppDomains in interviews, and I know the basics: they are an isolation level within an application (making them different from applications) they can have threads (making them different from threads) exceptions in one appdomain do not affect another appdomains...
TITLE: Good example of use of AppDomain QUESTION: I keep getting asked about AppDomains in interviews, and I know the basics: they are an isolation level within an application (making them different from applications) they can have threads (making them different from threads) exceptions in one appdomain do not affect ...
[ ".net", "appdomain" ]
50
50
21,704
7
0
2008-09-18T21:59:41.517000
2008-09-18T22:01:20.687000
97,435
97,632
Regexes and multiple multi-character delimeters
Suppose you have the following string: white sand, tall waves, warm sun It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall waves" and "warm sun": \s*,\s* Now say you have this string: white s...
This should be pretty resilient, and handle stuff like delimiters at the end of the string ("foo and bar and ", for example) \s*(?:\band\b|,)\s*
Regexes and multiple multi-character delimeters Suppose you have the following string: white sand, tall waves, warm sun It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall waves" and "warm sun...
TITLE: Regexes and multiple multi-character delimeters QUESTION: Suppose you have the following string: white sand, tall waves, warm sun It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall wa...
[ "regex" ]
1
5
3,801
7
0
2008-09-18T21:59:52.593000
2008-09-18T22:25:14.357000
97,452
97,757
How is a web service request handled in ASP.Net
When a client makes a web service request, how does asp.net assign an instance of the service class to handle that request? Is a new instance of the service class created per request or is there pooling happening or is there a singleton instance used to handle all requests?
For classic ASMX services you definitely get a new instance with each request, just like an ASPX request. For a WCF service (.SVC) you do have more options, such as running as a singleton. If you are interested in doing work with a singleton and pooling you can use the ASMX service simply as the lightweight proxy to pa...
How is a web service request handled in ASP.Net When a client makes a web service request, how does asp.net assign an instance of the service class to handle that request? Is a new instance of the service class created per request or is there pooling happening or is there a singleton instance used to handle all request...
TITLE: How is a web service request handled in ASP.Net QUESTION: When a client makes a web service request, how does asp.net assign an instance of the service class to handle that request? Is a new instance of the service class created per request or is there pooling happening or is there a singleton instance used to ...
[ "asp.net", "web-services" ]
3
1
2,003
1
0
2008-09-18T22:01:53.243000
2008-09-18T22:45:29.503000
97,459
102,095
Making a WinForms TextBox behave like your browser's address bar
When a C# WinForms textbox receives focus, I want it to behave like your browser's address bar. To see what I mean, click in your web browser's address bar. You'll notice the following behavior: Clicking in the textbox should select all the text if the textbox wasn't previously focused. Mouse down and drag in the textb...
First of all, thanks for answers! 9 total answers. Thank you. Bad news: all of the answers had some quirks or didn't work quite right (or at all). I've added a comment to each of your posts. Good news: I've found a way to make it work. This solution is pretty straightforward and seems to work in all the scenarios (mous...
Making a WinForms TextBox behave like your browser's address bar When a C# WinForms textbox receives focus, I want it to behave like your browser's address bar. To see what I mean, click in your web browser's address bar. You'll notice the following behavior: Clicking in the textbox should select all the text if the te...
TITLE: Making a WinForms TextBox behave like your browser's address bar QUESTION: When a C# WinForms textbox receives focus, I want it to behave like your browser's address bar. To see what I mean, click in your web browser's address bar. You'll notice the following behavior: Clicking in the textbox should select all ...
[ ".net", "winforms", "user-interface", "textbox" ]
162
110
123,711
31
0
2008-09-18T22:02:18.157000
2008-09-19T14:08:30.040000
97,468
98,697
Rails SSL Requirement plugin -- shouldn't it check to see if you're in production mode before redirecting to https?
Take a look at the ssl_requirement plugin. Shouldn't it check to see if you're in production mode? We're seeing a redirect to https in development mode, which seems odd. Or is that the normal behavior for the plugin? I thought it behaved differently in the past.
I guess they believe that you should probably be using HTTPS (perhaps with a self-signed certificate) in development mode. If that's not the desired behaviour, there's nothing stopping you from special casing SSL behaviour in the development environment yourself: class YourController < ApplicationController ssl_require...
Rails SSL Requirement plugin -- shouldn't it check to see if you're in production mode before redirecting to https? Take a look at the ssl_requirement plugin. Shouldn't it check to see if you're in production mode? We're seeing a redirect to https in development mode, which seems odd. Or is that the normal behavior for...
TITLE: Rails SSL Requirement plugin -- shouldn't it check to see if you're in production mode before redirecting to https? QUESTION: Take a look at the ssl_requirement plugin. Shouldn't it check to see if you're in production mode? We're seeing a redirect to https in development mode, which seems odd. Or is that the n...
[ "ruby-on-rails", "ssl", "https" ]
4
6
4,141
5
0
2008-09-18T22:03:06.190000
2008-09-19T01:37:56.547000
97,474
97,738
Given this XML, is there an xpath that will give me the 'test' and 'name' values?
I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close:..../xsl:template/xsl:choose/xsl:when But that just returns the 'when' elements, not the exact attribute values I need. Here is a snippet of my XML:
Steve Cooper answered the first part. For the second part, you can use:.../xsl:template/xsl:choose/xsl:when[@test="@name='First Name'"]/xsl:call-template/@name Which will match specifically the xsl:when in your above snippet. If you want it to match generally, then you can use:.../xsl:template/xsl:choose/xsl:when/xsl:c...
Given this XML, is there an xpath that will give me the 'test' and 'name' values? I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close:..../xsl:template/xsl:choose/xsl:when But that just returns the 'when' elements, n...
TITLE: Given this XML, is there an xpath that will give me the 'test' and 'name' values? QUESTION: I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close:..../xsl:template/xsl:choose/xsl:when But that just returns the ...
[ "xml", "xslt" ]
0
1
176
2
0
2008-09-18T22:03:55.720000
2008-09-18T22:42:32.897000
97,480
100,430
How to get the ROWID from a Progress database
I have a Progress database that I'm performing an ETL from. One of the tables that I'm reading from does not have a unique key on it, so I need to access the ROWID to be able to uniquely identify the row. What is the syntax for accessing the ROWID in Progress? I understand there are problems with using ROWID for row id...
A quick caveat for my answer - it's nearly 10 years since I worked with Progress so my knowledge is probably more than a little out of date. Checking the Progress Language Reference [PDF] seems to show the two functions I remember are still there: ROWID and RECID. The ROWID function is newer and is preferred. In Progre...
How to get the ROWID from a Progress database I have a Progress database that I'm performing an ETL from. One of the tables that I'm reading from does not have a unique key on it, so I need to access the ROWID to be able to uniquely identify the row. What is the syntax for accessing the ROWID in Progress? I understand ...
TITLE: How to get the ROWID from a Progress database QUESTION: I have a Progress database that I'm performing an ETL from. One of the tables that I'm reading from does not have a unique key on it, so I need to access the ROWID to be able to uniquely identify the row. What is the syntax for accessing the ROWID in Progr...
[ "database", "progress-4gl", "progress-db" ]
4
8
7,638
4
0
2008-09-18T22:04:30.257000
2008-09-19T08:12:16.943000
97,505
97,584
Binding a null value to a property of a web user control
Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings. In one case, there's an email address field on the main table and an "export" configuration that controls how emails are sent out. I created a main...
The Bind can't convert the null value to an int value, to set the ExportInfoID property. That's why it's not getting caught in your code. You can make the property a nullable type (int?) or you can handle the null in the bind logic. so it would be something like this bind receives field to get value from bind uses refl...
Binding a null value to a property of a web user control Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings. In one case, there's an email address field on the main table and an "export" configuratio...
TITLE: Binding a null value to a property of a web user control QUESTION: Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings. In one case, there's an email address field on the main table and an "ex...
[ "c#", ".net", "asp.net" ]
2
0
1,291
3
0
2008-09-18T22:08:04.307000
2008-09-18T22:17:24.440000
97,506
97,526
Formatting of if Statements
This isn't a holy war, this isn't a question of "which is better". What are the pros of using the following format for single statement if blocks. if (x) print "x is true"; if(x) print "x is true"; As opposed to if (x) { print "x is true"; } if(x) { print "x is true"; } If you format your single statement ifs without ...
I find this: if( true ) { DoSomething(); } else { DoSomethingElse(); } better than this: if( true ) DoSomething(); else DoSomethingElse(); This way, if I (or someone else) comes back to this code later to add more code to one of the branches, I won't have to worry about forgetting to surround the code in braces. Our ey...
Formatting of if Statements This isn't a holy war, this isn't a question of "which is better". What are the pros of using the following format for single statement if blocks. if (x) print "x is true"; if(x) print "x is true"; As opposed to if (x) { print "x is true"; } if(x) { print "x is true"; } If you format your s...
TITLE: Formatting of if Statements QUESTION: This isn't a holy war, this isn't a question of "which is better". What are the pros of using the following format for single statement if blocks. if (x) print "x is true"; if(x) print "x is true"; As opposed to if (x) { print "x is true"; } if(x) { print "x is true"; } If...
[ "c", "if-statement" ]
9
52
36,274
42
0
2008-09-18T22:08:15.647000
2008-09-18T22:11:01.863000
97,508
97,534
What libraries can I use to build a GUI with Erlang?
What libraries can I use to build a GUI for an Erlang application? Please one option per answer.
Most people don't code the actual GUI in Erlang. A more common approach would be to write the GUI layer in Java or C# and then talk to your Erlang app via a socket or pipe. With that in mind, you probably want to look into various libraries for doing RPC between java or.Net applications and Erlang: http://weblogs.asp.n...
What libraries can I use to build a GUI with Erlang? What libraries can I use to build a GUI for an Erlang application? Please one option per answer.
TITLE: What libraries can I use to build a GUI with Erlang? QUESTION: What libraries can I use to build a GUI for an Erlang application? Please one option per answer. ANSWER: Most people don't code the actual GUI in Erlang. A more common approach would be to write the GUI layer in Java or C# and then talk to your Erl...
[ "user-interface", "erlang" ]
46
18
25,191
8
0
2008-09-18T22:08:17.283000
2008-09-18T22:12:38.087000
97,513
97,635
How to load a python module into a fresh interactive shell in Komodo?
When using PyWin I can easily load a python file into a fresh interactive shell and I find this quite handy for prototyping and other exploratory tasks. I would like to use Komodo as my python editor, but I haven't found a replacement for PyWin's ability to restart the shell and reload the current module. How can I do ...
I use Komodo Edit, which might be a little less sophisticated than full Komodo. I create a "New Command" with %(python) -i %f as the text of the command. I have this run in a "New Console". I usually have the starting directory as %p, the top of the project directory. The -i option runs the file and drops into interact...
How to load a python module into a fresh interactive shell in Komodo? When using PyWin I can easily load a python file into a fresh interactive shell and I find this quite handy for prototyping and other exploratory tasks. I would like to use Komodo as my python editor, but I haven't found a replacement for PyWin's abi...
TITLE: How to load a python module into a fresh interactive shell in Komodo? QUESTION: When using PyWin I can easily load a python file into a fresh interactive shell and I find this quite handy for prototyping and other exploratory tasks. I would like to use Komodo as my python editor, but I haven't found a replaceme...
[ "python", "shell", "interpreter", "komodo" ]
2
5
2,138
1
0
2008-09-18T22:09:21.353000
2008-09-18T22:25:29.520000
97,522
206,409
What are all the valid self-closing elements in XHTML (as implemented by the major browsers)?
What are all the valid self-closing elements (e.g. ) in XHTML (as implemented by the major browsers)? I know that XHTML technically allows any element to be self-closed, but I'm looking for a list of those elements supported by all major browsers. See http://dusan.fora.si/blog/self-closing-tags for examples of some pro...
Every browser that supports XHTML (Firefox, Opera, Safari, IE9 ) supports self-closing syntax on every element.,, all should work just fine. If they don't, then you have HTML with inappropriately added XHTML DOCTYPE. DOCTYPE does not change how document is interpreted. Only MIME type does. W3C decision about ignoring D...
What are all the valid self-closing elements in XHTML (as implemented by the major browsers)? What are all the valid self-closing elements (e.g. ) in XHTML (as implemented by the major browsers)? I know that XHTML technically allows any element to be self-closed, but I'm looking for a list of those elements supported b...
TITLE: What are all the valid self-closing elements in XHTML (as implemented by the major browsers)? QUESTION: What are all the valid self-closing elements (e.g. ) in XHTML (as implemented by the major browsers)? I know that XHTML technically allows any element to be self-closed, but I'm looking for a list of those el...
[ "html", "browser", "xhtml", "cross-browser" ]
195
186
97,533
13
0
2008-09-18T22:10:44.207000
2008-10-15T20:48:52
97,532
97,667
What are the advantages and disadvantages of DTOs from a website performance perspective?
What are the advantages and disadvantages of DTOs from a website performance perspective? (I'm talking in the case where the database is accessed on a different app server to the web server - and the web server could access the database directly.)
DTO's aren't a performance concern. I think what you are asking about is the performance implications of tiering. In particular, using an application tier between your web tier (web server) and data tier (database server). Generally, the implications are that latency is increased (you have extra network roundtrips), bu...
What are the advantages and disadvantages of DTOs from a website performance perspective? What are the advantages and disadvantages of DTOs from a website performance perspective? (I'm talking in the case where the database is accessed on a different app server to the web server - and the web server could access the da...
TITLE: What are the advantages and disadvantages of DTOs from a website performance perspective? QUESTION: What are the advantages and disadvantages of DTOs from a website performance perspective? (I'm talking in the case where the database is accessed on a different app server to the web server - and the web server c...
[ "performance", "jakarta-ee", "ejb", "rpc", "dto-mapping" ]
2
4
3,655
1
0
2008-09-18T22:11:44.577000
2008-09-18T22:31:37.290000
97,557
97,731
how to estimate the TCO of open source implementations
I mean, this is Sakai, the open source project of a learning management system. But, really I'm clueless trying to estimate the hidden costs in one implementation project (on the technology side, not the pedagogy-stuff) in a small-medium scale institution. Deployment (1 engineer two or three months, with experience in ...
I work on support staff for a large uni that uses Blackboard. All the support people are students working part time, so salary can be pretty low per hour. You'll want to have someone on permanent staff as an administrator, who could also be the developer/deployment guy. Perhaps only part time if your institution is sma...
how to estimate the TCO of open source implementations I mean, this is Sakai, the open source project of a learning management system. But, really I'm clueless trying to estimate the hidden costs in one implementation project (on the technology side, not the pedagogy-stuff) in a small-medium scale institution. Deployme...
TITLE: how to estimate the TCO of open source implementations QUESTION: I mean, this is Sakai, the open source project of a learning management system. But, really I'm clueless trying to estimate the hidden costs in one implementation project (on the technology side, not the pedagogy-stuff) in a small-medium scale ins...
[ "open-source", "sakai" ]
3
2
291
3
0
2008-09-18T22:14:34.773000
2008-09-18T22:41:34.817000
97,565
97,788
C# 'generic' type problem
C# question (.net 3.5). I have a class, ImageData, that has a field ushort[,] pixels. I am dealing with proprietary image formats. The ImageData class takes a file location in the constructor, then switches on file extension to determine how to decode. In several of the image files, there is a "bit depth" field in the ...
To boil down your problem, you want to be able to have a class that has a ushort[,] pixels field (16-bits per pixel) sometimes and a uint32[,] pixels field (32-bits per pixel) some other times. There are a couple different ways to achieve this. You could create replacements for ushort / uint32 by making a Pixel class w...
C# 'generic' type problem C# question (.net 3.5). I have a class, ImageData, that has a field ushort[,] pixels. I am dealing with proprietary image formats. The ImageData class takes a file location in the constructor, then switches on file extension to determine how to decode. In several of the image files, there is a...
TITLE: C# 'generic' type problem QUESTION: C# question (.net 3.5). I have a class, ImageData, that has a field ushort[,] pixels. I am dealing with proprietary image formats. The ImageData class takes a file location in the constructor, then switches on file extension to determine how to decode. In several of the image...
[ "c#", "generics", "image" ]
2
2
525
3
0
2008-09-18T22:15:15.910000
2008-09-18T22:48:56.580000
97,578
97,804
How do I escape a string inside JavaScript code inside an onClick handler?
Maybe I'm just thinking about this too hard, but I'm having a problem figuring out what escaping to use on a string in some JavaScript code inside a link's onClick handler. Example: Select The <%itemid%> and <%itemname%> are where template substitution occurs. My problem is that the item name can contain any character,...
In JavaScript you can encode single quotes as "\x27" and double quotes as "\x22". Therefore, with this method you can, once you're inside the (double or single) quotes of a JavaScript string literal, use the \x27 \x22 with impunity without fear of any embedded quotes "breaking out" of your string. \xXX is for chars < 1...
How do I escape a string inside JavaScript code inside an onClick handler? Maybe I'm just thinking about this too hard, but I'm having a problem figuring out what escaping to use on a string in some JavaScript code inside a link's onClick handler. Example: Select The <%itemid%> and <%itemname%> are where template subst...
TITLE: How do I escape a string inside JavaScript code inside an onClick handler? QUESTION: Maybe I'm just thinking about this too hard, but I'm having a problem figuring out what escaping to use on a string in some JavaScript code inside a link's onClick handler. Example: Select The <%itemid%> and <%itemname%> are wh...
[ "javascript", "html", "string", "escaping" ]
69
80
127,422
13
0
2008-09-18T22:16:22.117000
2008-09-18T22:51:10.597000
97,586
112,268
Has anyone got an example of aerith style swing mixed with GUI maintainability of SWT editing?
My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maintain. To sell this, we'd like to use an aerith style L&F. Can anyone provide an example of an SW...
Like Heath Borders said, SWT doesn't support L&Fs, so you have to use Swing for that. Aerith however does not base on a look and feel, but on custom painting on the components with a lot of gradients. If you are looking for a Swing GUI Editor that is (nearly) as easy to use as VB, try the Matisse GUI Builder in NetBean...
Has anyone got an example of aerith style swing mixed with GUI maintainability of SWT editing? My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maint...
TITLE: Has anyone got an example of aerith style swing mixed with GUI maintainability of SWT editing? QUESTION: My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almos...
[ "java", "eclipse", "swing", "swt", "lf" ]
0
1
519
2
0
2008-09-18T22:17:47.667000
2008-09-21T21:47:19.750000
97,590
97,634
What's the best tool to track a process's memory usage over a long period of time in Windows?
What is the best available tool to monitor the memory usage of my C#/.Net windows service over a long period of time. As far as I know, tools like perfmon can monitor the memory usage over a short period of time, but not graphically over a long period of time. I need trend data over days, not seconds. To be clear, I wa...
Perfmon in my opinion is one of the best tools to do this but make sure you properly configure the sampling interval according to the time you wish to monitor. For example if you want to monitor a process: for 1 hour: I would use 1 second intervals (this will generate 60*60 samples) for 1 day: I would use 30 second int...
What's the best tool to track a process's memory usage over a long period of time in Windows? What is the best available tool to monitor the memory usage of my C#/.Net windows service over a long period of time. As far as I know, tools like perfmon can monitor the memory usage over a short period of time, but not graph...
TITLE: What's the best tool to track a process's memory usage over a long period of time in Windows? QUESTION: What is the best available tool to monitor the memory usage of my C#/.Net windows service over a long period of time. As far as I know, tools like perfmon can monitor the memory usage over a short period of t...
[ "c#", ".net", "performance", "memory" ]
1
5
8,464
7
0
2008-09-18T22:18:16.653000
2008-09-18T22:25:28.180000
97,594
97,595
Login failed for user 'username' - System.Data.SqlClient.SqlException with LINQ in external project / class library
This might seem obvious but I've had this error when trying to use LINQ to SQL with my business logic in a separate class library project. I've created the DBML in a class library, with all my business logic and custom controls in this project. I'd referenced the class library from my web project and attempted to use i...
The LINQ designer ads the connection string to the app.config of the class library, but the web site needed to see it in the web.config of the web project. Once copied across all was well.
Login failed for user 'username' - System.Data.SqlClient.SqlException with LINQ in external project / class library This might seem obvious but I've had this error when trying to use LINQ to SQL with my business logic in a separate class library project. I've created the DBML in a class library, with all my business lo...
TITLE: Login failed for user 'username' - System.Data.SqlClient.SqlException with LINQ in external project / class library QUESTION: This might seem obvious but I've had this error when trying to use LINQ to SQL with my business logic in a separate class library project. I've created the DBML in a class library, with ...
[ "linq-to-sql" ]
3
3
9,120
2
0
2008-09-18T22:18:59.473000
2008-09-18T22:19:07.023000
97,599
97,851
Static Analysis tool recommendation for Java?
Being vaguely familiar with the Java world I was googling for a static analysis tool that would also was intelligent enough to fix the issues it finds. I ran at CodePro tool but, again, I'm new to the Java community and don't know the vendors. What tool can you recommend based on the criteria above?
FindBugs, PMD and Checkstyle are all excellent choices especially if you integrate them into your build process. At my last company we also used Fortify to check for potential security problems. We were fortunate to have an enterprise license so I don't know the cost involved.
Static Analysis tool recommendation for Java? Being vaguely familiar with the Java world I was googling for a static analysis tool that would also was intelligent enough to fix the issues it finds. I ran at CodePro tool but, again, I'm new to the Java community and don't know the vendors. What tool can you recommend ba...
TITLE: Static Analysis tool recommendation for Java? QUESTION: Being vaguely familiar with the Java world I was googling for a static analysis tool that would also was intelligent enough to fix the issues it finds. I ran at CodePro tool but, again, I'm new to the Java community and don't know the vendors. What tool ca...
[ "java", "static-analysis" ]
57
38
53,412
9
0
2008-09-18T22:19:50.657000
2008-09-18T23:05:22.250000
97,614
97,629
What exactly is SQL Server 2005 User Mapping?
In the new login dialog of the SQL Server 2005 Management Studio Express, what is the User Mapping actually doing? Am I restricting access to those databases that are checked? What if I check none?
It's mapping user rights to specific databases. If you don't check any, that user won't have rights to any database unless it is in a server role that allows rights to individual databases.
What exactly is SQL Server 2005 User Mapping? In the new login dialog of the SQL Server 2005 Management Studio Express, what is the User Mapping actually doing? Am I restricting access to those databases that are checked? What if I check none?
TITLE: What exactly is SQL Server 2005 User Mapping? QUESTION: In the new login dialog of the SQL Server 2005 Management Studio Express, what is the User Mapping actually doing? Am I restricting access to those databases that are checked? What if I check none? ANSWER: It's mapping user rights to specific databases. I...
[ "sql-server", "security" ]
6
9
12,949
1
0
2008-09-18T22:22:02.447000
2008-09-18T22:24:20.380000
97,646
97,729
How do I determine darker or lighter color variant of a given color?
Given a source color of any hue by the system or user, I'd like a simple algorithm I can use to work out a lighter or darker variants of the selected color. Similar to effects used on Windows Live Messenger for styling the user interface. Language is C# with.net 3.5. Responding to comment: Color format is (Alpha)RGB. W...
Simply multiply the RGB values by the amount you want to modify the level by. If one of the colors is already at the max value, then you can't make it any brighter (using HSV math anyway.) This gives the exact same result with a lot less math as switching to HSV and then modifying V. This gives the same result as switc...
How do I determine darker or lighter color variant of a given color? Given a source color of any hue by the system or user, I'd like a simple algorithm I can use to work out a lighter or darker variants of the selected color. Similar to effects used on Windows Live Messenger for styling the user interface. Language is ...
TITLE: How do I determine darker or lighter color variant of a given color? QUESTION: Given a source color of any hue by the system or user, I'd like a simple algorithm I can use to work out a lighter or darker variants of the selected color. Similar to effects used on Windows Live Messenger for styling the user inter...
[ "c#", "colors" ]
44
28
46,915
13
0
2008-09-18T22:27:34.837000
2008-09-18T22:41:30.903000
97,663
97,802
How can I get word wrap to work in Eclipse PDT for PHP files?
Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc. However, one thing that drives me crazy is that I can't get my lines in PHP files to word wrap so on long lines I'm typing out indefinitely to the right. I click on Windows|Preferences and type in "wrap" and get: - J...
This has really been one of the most desired features in Eclipse. It's not just missing in PHP files-- it's missing in the IDE. Fortunately, from Google Summer of Code, we get this plug-in Eclipse Word-Wrap To install it, add the following update site in Eclipse: AhtiK Eclipse WordWrap 0.0.5 Update Site
How can I get word wrap to work in Eclipse PDT for PHP files? Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc. However, one thing that drives me crazy is that I can't get my lines in PHP files to word wrap so on long lines I'm typing out indefinitely to the right. ...
TITLE: How can I get word wrap to work in Eclipse PDT for PHP files? QUESTION: Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc. However, one thing that drives me crazy is that I can't get my lines in PHP files to word wrap so on long lines I'm typing out indefinit...
[ "php", "eclipse", "eclipse-pdt", "word-wrap" ]
52
66
31,411
4
0
2008-09-18T22:30:59.150000
2008-09-18T22:50:56.603000
97,666
97,686
Visual Studio 2005 says I don't have permission to debug?
I am new to visual studio/asp.net so please bear with me. Using vs 2005 and asp.net 3.5. I have vs installed on the production server. If I set the start option for the site to "use default web server" when I go to debug my website vs tries to open the site at http://localhost:4579/project and returns 404. If I set sta...
Do this...Instead of trying to debug by hitting F5 Go to Tools Attach to Process Click View Processes from all users Ensure you are selected only for Managed Code Select "W3WP.EXE". This is the ASP.NET Worker process. Click attach. You are now attached and debugging, go refresh the page in a browser and it should hit y...
Visual Studio 2005 says I don't have permission to debug? I am new to visual studio/asp.net so please bear with me. Using vs 2005 and asp.net 3.5. I have vs installed on the production server. If I set the start option for the site to "use default web server" when I go to debug my website vs tries to open the site at h...
TITLE: Visual Studio 2005 says I don't have permission to debug? QUESTION: I am new to visual studio/asp.net so please bear with me. Using vs 2005 and asp.net 3.5. I have vs installed on the production server. If I set the start option for the site to "use default web server" when I go to debug my website vs tries to ...
[ "asp.net", "visual-studio", "debugging" ]
1
4
2,327
4
0
2008-09-18T22:31:36.370000
2008-09-18T22:35:25.393000
97,683
97,747
Absolute position, can someone explain this
Here is a snippet of CSS that I need explained: #section { width: 860px; background: url(/blah.png); position: absolute; top: 0; left: 50%; margin-left: -445px; } Ok so it's absolute positioning of an image, obviously. top is like padding from the top, right? what does left 50% do? why is the left margin at -445px? Upd...
Top is the distance from the top of the html element or, if this is within another element with absolute position, from the top of that. & 3. It depends on the width of the image but it might be for centering the image horizontally (if the width of the image is 890px). There are other ways to center an image horizontal...
Absolute position, can someone explain this Here is a snippet of CSS that I need explained: #section { width: 860px; background: url(/blah.png); position: absolute; top: 0; left: 50%; margin-left: -445px; } Ok so it's absolute positioning of an image, obviously. top is like padding from the top, right? what does left 5...
TITLE: Absolute position, can someone explain this QUESTION: Here is a snippet of CSS that I need explained: #section { width: 860px; background: url(/blah.png); position: absolute; top: 0; left: 50%; margin-left: -445px; } Ok so it's absolute positioning of an image, obviously. top is like padding from the top, right...
[ "css", "css-position" ]
3
3
1,770
7
0
2008-09-18T22:35:04.053000
2008-09-18T22:43:37.433000
97,694
97,723
Auto-indent spaces with C in vim?
I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same indentation, and a...
These two commands should do it::set autoindent:set cindent For bonus points put them in a file named.vimrc located in your home directory on linux
Auto-indent spaces with C in vim? I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep...
TITLE: Auto-indent spaces with C in vim? QUESTION: I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? So after typing a { the next line will have 2 spaces indented in, and a return on t...
[ "c", "vim", "coding-style", "vi" ]
92
143
131,924
7
0
2008-09-18T22:36:57.810000
2008-09-18T22:41:16.690000
97,732
97,829
Using an ASP.NET SiteMap for a Page with multiple paths
I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this: < Page 1 > < MyPage / >... < /Page 1 > < Page 2 > < MyPage / >... < /Page 2 > < Page 3 > < MyPage / >... < /Page 3 > In ...
That's not really the intended purpose of the Web.sitemap file. From MSDN Docs of the SiteMap class, Fundamentally, the SiteMap is a container for a hierarchical collection of SiteMapNode objects. However, the SiteMap does not maintain the relationships between the nodes; rather, it delegates this to the site map provi...
Using an ASP.NET SiteMap for a Page with multiple paths I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this: < Page 1 > < MyPage / >... < /Page 1 > < Page 2 > < MyPage / >.....
TITLE: Using an ASP.NET SiteMap for a Page with multiple paths QUESTION: I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this: < Page 1 > < MyPage / >... < /Page 1 > < Page ...
[ "asp.net", "vb.net", ".net-2.0" ]
0
3
2,986
4
0
2008-09-18T22:41:52.773000
2008-09-18T22:58:17.367000
97,733
649,844
Using PostSharp to intercept calls to Silverlight objects?
I'm working with PostSharp to intercept method calls to objects I don't own, but my aspect code doesn't appear to be getting called. The documentation seems pretty lax in the Silverlight area, so I'd appreciate any help you guys can offer:) I have an attribute that looks like: public class LogAttribute: OnMethodInvocat...
This is not possible with the present version of PostSharp. PostSharp works by transforming assemblies prior to being loaded by the CLR. Right now, in order to do that, two things have to happen: The assembly must be about to be loaded into the CLR; you only get one shot, and you have to take it at this point. After th...
Using PostSharp to intercept calls to Silverlight objects? I'm working with PostSharp to intercept method calls to objects I don't own, but my aspect code doesn't appear to be getting called. The documentation seems pretty lax in the Silverlight area, so I'd appreciate any help you guys can offer:) I have an attribute ...
TITLE: Using PostSharp to intercept calls to Silverlight objects? QUESTION: I'm working with PostSharp to intercept method calls to objects I don't own, but my aspect code doesn't appear to be getting called. The documentation seems pretty lax in the Silverlight area, so I'd appreciate any help you guys can offer:) I ...
[ "c#", "postsharp" ]
3
2
1,543
4
0
2008-09-18T22:41:54.707000
2009-03-16T10:15:25.677000
97,741
97,930
OSCache vs. EHCache
Never used a cache like this before. The problem is that I want to load 500,000 + records out of a database and do some selecting/filtering wicked fast. I'm thinking about using a cache, and preliminarily found EHCache and OSCache, any opinions?
They're both pretty solid projects. If you have pretty basic caching needs, either one of them will probably work as well as the other. You may also wish to consider doing the filtering in a database query if it's feasible. Often, using a tuned query that returns a smaller result set will give you better performance th...
OSCache vs. EHCache Never used a cache like this before. The problem is that I want to load 500,000 + records out of a database and do some selecting/filtering wicked fast. I'm thinking about using a cache, and preliminarily found EHCache and OSCache, any opinions?
TITLE: OSCache vs. EHCache QUESTION: Never used a cache like this before. The problem is that I want to load 500,000 + records out of a database and do some selecting/filtering wicked fast. I'm thinking about using a cache, and preliminarily found EHCache and OSCache, any opinions? ANSWER: They're both pretty solid p...
[ "java", "caching", "ehcache", "oscache" ]
22
20
28,277
10
0
2008-09-18T22:43:12.083000
2008-09-18T23:16:16.217000
97,762
97,806
Algorithm for hit test in non-overlapping rectangles
I have a collection of non-overlapping rectangles that cover an enclosing rectangle. What is the best way to find the containing rectangle for a mouse click? The obvious answer is to have an array of rectangles and to search them in sequence, making the search O(n). Is there some way to order them by position so that t...
You can organize your rectangles in a quad or kd-tree. That gives you O(log n). That's the mainstream method. Another interesting data-structure for this problem are R-trees. These can be very efficient if you have to deal with lots of rectangles. http://en.wikipedia.org/wiki/R-tree And then there is the O(1) method of...
Algorithm for hit test in non-overlapping rectangles I have a collection of non-overlapping rectangles that cover an enclosing rectangle. What is the best way to find the containing rectangle for a mouse click? The obvious answer is to have an array of rectangles and to search them in sequence, making the search O(n). ...
TITLE: Algorithm for hit test in non-overlapping rectangles QUESTION: I have a collection of non-overlapping rectangles that cover an enclosing rectangle. What is the best way to find the containing rectangle for a mouse click? The obvious answer is to have an array of rectangles and to search them in sequence, making...
[ ".net", "geometry" ]
5
6
4,021
4
0
2008-09-18T22:46:18.347000
2008-09-18T22:51:31.003000
97,765
97,805
Forced Alpha-Numeric User IDs
I am a programmer at a financial institute. I have recently been told to enforce that all new user id's to have at least one alpha and one numeric. I immediately thought that this was a horrible idea and I would rather not implement it, as I believe this is an anti-feature and of poor user experience. The problem is th...
One argument against this is that many usernames / ids in other areas do not require numeric components. It's more likely that users will be better able to remember user ids that they have used elsewhere -- and that is more likely if they do not need to include numerics. Furthermore, depending on the system, the user i...
Forced Alpha-Numeric User IDs I am a programmer at a financial institute. I have recently been told to enforce that all new user id's to have at least one alpha and one numeric. I immediately thought that this was a horrible idea and I would rather not implement it, as I believe this is an anti-feature and of poor user...
TITLE: Forced Alpha-Numeric User IDs QUESTION: I am a programmer at a financial institute. I have recently been told to enforce that all new user id's to have at least one alpha and one numeric. I immediately thought that this was a horrible idea and I would rather not implement it, as I believe this is an anti-featur...
[ "security", "web-applications", "finance", "user-experience" ]
3
4
705
9
0
2008-09-18T22:46:45.617000
2008-09-18T22:51:10.753000