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
59,418
59,440
Clean up Designer.vb file in Visual Studio 2008
I noticed that my Designer.vb file of one of my forms has a lot of controls that aren't even used or visible on my form. This is probably from copying controls from my other forms. Is there a way to clean up the Designer.vb file and get rid of all the unused controls? **UPDATE: This is for a Windows Form project.
The only real solution I see is to copy all the controls into a new form by selecting them in the designer. This way all the not created controls should not follow you to the next form.
Clean up Designer.vb file in Visual Studio 2008 I noticed that my Designer.vb file of one of my forms has a lot of controls that aren't even used or visible on my form. This is probably from copying controls from my other forms. Is there a way to clean up the Designer.vb file and get rid of all the unused controls? **U...
TITLE: Clean up Designer.vb file in Visual Studio 2008 QUESTION: I noticed that my Designer.vb file of one of my forms has a lot of controls that aren't even used or visible on my form. This is probably from copying controls from my other forms. Is there a way to clean up the Designer.vb file and get rid of all the un...
[ "vb.net", "visual-studio-2008" ]
2
3
1,742
1
0
2008-09-12T16:15:27.510000
2008-09-12T16:26:26.720000
59,422
59,430
Is a bool read/write atomic in C#
Is accessing a bool field atomic in C#? In particular, do I need to put a lock around: class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true; //... same for a read if (_bar) {... } }
Yes. Reads and writes of the following data types are atomic: bool, char, byte, sbyte, short, ushort, uint, int, float, and reference types. as found in C# Language Spec. Edit: It's probably also worthwhile understanding the volatile keyword.
Is a bool read/write atomic in C# Is accessing a bool field atomic in C#? In particular, do I need to put a lock around: class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true; //... same for a read if (_bar) {... } }
TITLE: Is a bool read/write atomic in C# QUESTION: Is accessing a bool field atomic in C#? In particular, do I need to put a lock around: class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true; //... same for a read if (_bar) {... } } ANSWER: Yes. Reads and writes of the f...
[ "c#", ".net", "concurrency", "locking", "boolean" ]
97
139
73,257
4
0
2008-09-12T16:19:28.657000
2008-09-12T16:24:02.717000
59,423
59,511
I have a link icon next to each link. How do I exclude the link icon from images?
I've got the following in my.css file creating a little image next to each link on my site: div.post.text a[href^="http:"] { background: url(../../pics/remote.gif) right top no-repeat; padding-right: 10px; white-space: nowrap; } How do I modify this snippet (or add something new) to exclude the link icon next to images...
If you set the background color and have a negative right margin on the image, the image will cover the external link image. Example: a[href^="http:"] { background: url(http://en.wikipedia.org/skins-1.5/monobook/external.png) right center no-repeat; padding-right: 14px; white-space: nowrap; } a[href^="http:"] img ...
I have a link icon next to each link. How do I exclude the link icon from images? I've got the following in my.css file creating a little image next to each link on my site: div.post.text a[href^="http:"] { background: url(../../pics/remote.gif) right top no-repeat; padding-right: 10px; white-space: nowrap; } How do I ...
TITLE: I have a link icon next to each link. How do I exclude the link icon from images? QUESTION: I've got the following in my.css file creating a little image next to each link on my site: div.post.text a[href^="http:"] { background: url(../../pics/remote.gif) right top no-repeat; padding-right: 10px; white-space: n...
[ "css" ]
1
4
950
4
0
2008-09-12T16:20:09.620000
2008-09-12T16:56:38.440000
59,424
59,460
Creating a mini-site in ASP.NET that works on Blackberry, Windows Mobile, and iPhone
I'm working on an ASP.NET website which targets desktop browsers. We want to enable an optional mobile view (e.g. http://m.sample.com ) which will offer a few simple pages which will be mostly text. There will be not need for AJAX or even Javascript, and there's no user input - it's really just tables of text with a fe...
I have done this in the past and the way I did it is by separating the pages by creating a directory for Desktop and creating a directory for Mobile. This gives you better separation of the views, since in reality they are a lot different. In ASP.NET Forms I used the Model View Presenter pattern a lot since it went wit...
Creating a mini-site in ASP.NET that works on Blackberry, Windows Mobile, and iPhone I'm working on an ASP.NET website which targets desktop browsers. We want to enable an optional mobile view (e.g. http://m.sample.com ) which will offer a few simple pages which will be mostly text. There will be not need for AJAX or e...
TITLE: Creating a mini-site in ASP.NET that works on Blackberry, Windows Mobile, and iPhone QUESTION: I'm working on an ASP.NET website which targets desktop browsers. We want to enable an optional mobile view (e.g. http://m.sample.com ) which will offer a few simple pages which will be mostly text. There will be not ...
[ "asp.net", "windows-mobile", "mobile" ]
14
7
3,895
5
0
2008-09-12T16:20:24.130000
2008-09-12T16:36:59.690000
59,425
59,437
How do I find records added to my database table in the past 24 hours?
I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record. INSERT INTO messages (typeId, messageTime, stationId, message) VALUES (?, NOW(),?,?)
SELECT * FROM messages WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= messageTime
How do I find records added to my database table in the past 24 hours? I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record. INSERT INTO messages (typeId, messageTime, stationId, message) VALUES (?, NOW(),?,?)
TITLE: How do I find records added to my database table in the past 24 hours? QUESTION: I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record. INSERT INTO messages (typeId, messageTime, stationId, message) VALUES (?, NOW()...
[ "sql" ]
4
4
739
6
0
2008-09-12T16:21:06.810000
2008-09-12T16:25:41.090000
59,428
59,434
Which environment, IDE or interpreter to put in practice Scheme?
I've been making my way through The Little Schemer and I was wondering what environment, IDE or interpreter would be best to use in order to test any of the Scheme code I jot down for myself.
Racket ( formerly Dr Scheme ) has a nice editor, several different Scheme dialects, an attempt at visual debugging, lots of libraries, and can run on most platforms. It even has some modes specifically geared around learning the language.
Which environment, IDE or interpreter to put in practice Scheme? I've been making my way through The Little Schemer and I was wondering what environment, IDE or interpreter would be best to use in order to test any of the Scheme code I jot down for myself.
TITLE: Which environment, IDE or interpreter to put in practice Scheme? QUESTION: I've been making my way through The Little Schemer and I was wondering what environment, IDE or interpreter would be best to use in order to test any of the Scheme code I jot down for myself. ANSWER: Racket ( formerly Dr Scheme ) has a ...
[ "ide", "scheme", "lisp", "the-little-schemer" ]
19
33
8,653
11
0
2008-09-12T16:23:12.517000
2008-09-12T16:25:23.197000
59,436
59,453
Is it feasible to support multiple applications of the same type that are all written in different languages?
As much as we would all like to say it is a benefit to programmers to be language agnostic, is it really feasible to support multiple enterprise Web applications of the same type all written in different languages? Think about how complicated a CMS or e-commerce system can be -- now imagine supporting three different C...
I think it all depends on who your clients are and what they expect. I think knowing about different technologies is good, but really when you're hired by someone, they expect you to know what you are doing. Personally, I would much rather be known that I do a really good job with a certain type of technology and when ...
Is it feasible to support multiple applications of the same type that are all written in different languages? As much as we would all like to say it is a benefit to programmers to be language agnostic, is it really feasible to support multiple enterprise Web applications of the same type all written in different langua...
TITLE: Is it feasible to support multiple applications of the same type that are all written in different languages? QUESTION: As much as we would all like to say it is a benefit to programmers to be language agnostic, is it really feasible to support multiple enterprise Web applications of the same type all written i...
[ "multilingual" ]
1
1
145
2
0
2008-09-12T16:25:34.600000
2008-09-12T16:31:17.957000
59,444
59,457
How do you check what version of SQL Server for a database using TSQL?
Is there a system stored procedure to get the version #?
Try SELECT @@VERSION or for SQL Server 2000 and above the following is easier to parse:) SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition') From: http://support.microsoft.com/kb/321185
How do you check what version of SQL Server for a database using TSQL? Is there a system stored procedure to get the version #?
TITLE: How do you check what version of SQL Server for a database using TSQL? QUESTION: Is there a system stored procedure to get the version #? ANSWER: Try SELECT @@VERSION or for SQL Server 2000 and above the following is easier to parse:) SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SER...
[ "sql-server", "database", "t-sql" ]
130
238
240,817
16
0
2008-09-12T16:29:19.507000
2008-09-12T16:33:27.890000
59,451
72,158
Creating a Silverlight DataTemplate in code
How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight. Edit: Here's the code I'm now using this for, based on the answer from Santiago below. public DataTemplate Create(Type type) { return (DataTemplate)XamlReader.Load( @" <" + type.Name + @" Text=""{Bind...
Although you cannot programatically create it, you can load it from a XAML string in code like this: public static DataTemplate Create(Type type) { return (DataTemplate) XamlReader.Load( @" <" + type.Name + @"/> " ); } The snippet above creates a data template containing a single control, which may be a user control wi...
Creating a Silverlight DataTemplate in code How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight. Edit: Here's the code I'm now using this for, based on the answer from Santiago below. public DataTemplate Create(Type type) { return (DataTemplate)XamlRead...
TITLE: Creating a Silverlight DataTemplate in code QUESTION: How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight. Edit: Here's the code I'm now using this for, based on the answer from Santiago below. public DataTemplate Create(Type type) { return (Dat...
[ "silverlight" ]
28
39
28,445
4
0
2008-09-12T16:31:06.130000
2008-09-16T13:28:40.483000
59,456
60,365
How do I make custom MenuHeaders in WPF with accelerators?
I'd like to make some custom MenuHeaders in WPF so I can have (for example), an icon and text in a menu item. Normally using MenuItems, if you populate the Header field with straight text, you can add an accelerator by using an underscore. eg, _File However, if I wanted to put in a UserControl, I believe this function ...
I think the Icon property fits your needs. However to answer the original question, it is possible to retain the Accelerator functionality when you compose the content of your menuitem. If you have nested content in a MenuItem you need to define the AccessText property explicitly like in the first one below. When you u...
How do I make custom MenuHeaders in WPF with accelerators? I'd like to make some custom MenuHeaders in WPF so I can have (for example), an icon and text in a menu item. Normally using MenuItems, if you populate the Header field with straight text, you can add an accelerator by using an underscore. eg, _File However, if...
TITLE: How do I make custom MenuHeaders in WPF with accelerators? QUESTION: I'd like to make some custom MenuHeaders in WPF so I can have (for example), an icon and text in a menu item. Normally using MenuItems, if you populate the Header field with straight text, you can add an accelerator by using an underscore. eg,...
[ "wpf", "xaml", "templates", "styles", "menu" ]
5
8
5,473
4
0
2008-09-12T16:32:28.577000
2008-09-13T06:34:48.413000
59,465
59,476
In Emacs, how can I add a website like 'Stackoverflow' to my webjump hotlist?
By default the webjump hotlist has the following which I use quite often: M-x webjump RET Google M-x webjump RET Wikipedia How can I add 'Stackoverflow' to my list?
Here's some example code in a webjump.el file on a site run by Apple:;; (require 'webjump);; (global-set-key "\C-cj" 'webjump);; (setq webjump-sites;; (append '(;; ("My Home Page". "www.someisp.net/users/joebobjr/");; ("Pop's Site". "www.joebob-and-son.com/");; );; webjump-sample-sites))
In Emacs, how can I add a website like 'Stackoverflow' to my webjump hotlist? By default the webjump hotlist has the following which I use quite often: M-x webjump RET Google M-x webjump RET Wikipedia How can I add 'Stackoverflow' to my list?
TITLE: In Emacs, how can I add a website like 'Stackoverflow' to my webjump hotlist? QUESTION: By default the webjump hotlist has the following which I use quite often: M-x webjump RET Google M-x webjump RET Wikipedia How can I add 'Stackoverflow' to my list? ANSWER: Here's some example code in a webjump.el file on a...
[ "emacs", "command" ]
0
1
683
3
0
2008-09-12T16:37:52.527000
2008-09-12T16:43:06.010000
59,472
59,513
Can VS be configured to automatically remove blank line(s) after text is cut?
Is there a way (or shortcut) to tell VS 2008 that it cuts a line like this: Before: Some Text here This gets cut Some Code there After: Some Text here Some Code there What I want: Some Text here Some Code there PS: I don't want to select the whole line or something like this... only the text I want to cut.
Unless I misunderstood you: Just place cursor on the line you want to cut (no selection) and press Ctrl + x. That cuts the line (leaving no blanks) and puts the text in the Clipboard. (tested in MS VC# 2008 Express with no additional settings I'm aware of) Is that what you want?
Can VS be configured to automatically remove blank line(s) after text is cut? Is there a way (or shortcut) to tell VS 2008 that it cuts a line like this: Before: Some Text here This gets cut Some Code there After: Some Text here Some Code there What I want: Some Text here Some Code there PS: I don't want to select the...
TITLE: Can VS be configured to automatically remove blank line(s) after text is cut? QUESTION: Is there a way (or shortcut) to tell VS 2008 that it cuts a line like this: Before: Some Text here This gets cut Some Code there After: Some Text here Some Code there What I want: Some Text here Some Code there PS: I don't ...
[ "visual-studio", "ide", "editor" ]
1
4
241
3
0
2008-09-12T16:41:10.240000
2008-09-12T16:58:20.903000
59,479
59,488
Optimize Windows Form Load Time
I have a Windows Form that takes quite a bit of time to load initially. However, each subsequent request to load the Form doesn't take as long. Is there a way to optimize a Form's load time?
You can use ngen. I also use this tip to reduce the Memory footprint on startup. The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native i...
Optimize Windows Form Load Time I have a Windows Form that takes quite a bit of time to load initially. However, each subsequent request to load the Form doesn't take as long. Is there a way to optimize a Form's load time?
TITLE: Optimize Windows Form Load Time QUESTION: I have a Windows Form that takes quite a bit of time to load initially. However, each subsequent request to load the Form doesn't take as long. Is there a way to optimize a Form's load time? ANSWER: You can use ngen. I also use this tip to reduce the Memory footprint o...
[ "c#", ".net", "vb.net", "winforms", "optimization" ]
5
10
4,163
2
0
2008-09-12T16:44:29.610000
2008-09-12T16:48:15.920000
59,482
59,522
What's the better database design: more tables or more columns?
A former coworker insisted that a database with more tables with fewer columns each is better than one with fewer tables with more columns each. For example rather than a customer table with name, address, city, state, zip, etc. columns, you would have a name table, an address table, a city table, etc. He argued this d...
I have a few fairly simple rules of thumb I follow when designing databases, which I think can be used to help make decisions like this.... Favor normalization. Denormalization is a form of optimization, with all the requisite tradeoffs, and as such it should be approached with a YAGNI attitude. Make sure that client c...
What's the better database design: more tables or more columns? A former coworker insisted that a database with more tables with fewer columns each is better than one with fewer tables with more columns each. For example rather than a customer table with name, address, city, state, zip, etc. columns, you would have a n...
TITLE: What's the better database design: more tables or more columns? QUESTION: A former coworker insisted that a database with more tables with fewer columns each is better than one with fewer tables with more columns each. For example rather than a customer table with name, address, city, state, zip, etc. columns, ...
[ "database", "database-design", "database-normalization" ]
100
74
69,048
18
0
2008-09-12T16:45:23.790000
2008-09-12T17:02:49.613000
59,483
59,517
Confused by gdb print ptr vs print "%s"
1167 ptr = (void*)getcwd(cwd, MAX_PATH_LENGTH-1); (gdb) n 1168 if (!ptr) { (gdb) print ptr $1 = 0xbff2d96c "/media/MMC-SD/partition1/aaaaaaaaaaa" (gdb) print &cwd $2 = (char (*)[3500]) 0xbff2d96c (gdb) print strlen(cwd) $3 = 36 (gdb) print "%s",cwd $4 = "/media/MMC-SD/partition1/aaaaaaaaaaa", '\0', "��O�001\000\000\000...
The reason that cwd is printed differently in gdb is because gdb knows that ptr is a char * (I guess) and that cwd is an array of length 3500 (as shown in your output). So when printing ptr it prints the pointer value (and as a service also the string it points to) and when printing cwd it prints the whole array. I don...
Confused by gdb print ptr vs print "%s" 1167 ptr = (void*)getcwd(cwd, MAX_PATH_LENGTH-1); (gdb) n 1168 if (!ptr) { (gdb) print ptr $1 = 0xbff2d96c "/media/MMC-SD/partition1/aaaaaaaaaaa" (gdb) print &cwd $2 = (char (*)[3500]) 0xbff2d96c (gdb) print strlen(cwd) $3 = 36 (gdb) print "%s",cwd $4 = "/media/MMC-SD/partition1/...
TITLE: Confused by gdb print ptr vs print "%s" QUESTION: 1167 ptr = (void*)getcwd(cwd, MAX_PATH_LENGTH-1); (gdb) n 1168 if (!ptr) { (gdb) print ptr $1 = 0xbff2d96c "/media/MMC-SD/partition1/aaaaaaaaaaa" (gdb) print &cwd $2 = (char (*)[3500]) 0xbff2d96c (gdb) print strlen(cwd) $3 = 36 (gdb) print "%s",cwd $4 = "/media/...
[ "c", "gdb", "buffer-overflow", "buffer-overrun" ]
1
2
7,835
4
0
2008-09-12T16:46:41.197000
2008-09-12T16:59:27.310000
59,515
59,551
Convert this delegate to an anonymous method or lambda
I am new to all the anonymous features and need some help. I have gotten the following to work: public void FakeSaveWithMessage(Transaction t) { t.Message = "I drink goats blood"; } public delegate void FakeSave(Transaction t); public void SampleTestFunction() { Expect.Call(delegate { _dao.Save(t); }).Do(new FakeSave...
That's a well known error message. Check the link below for a more detailed discussion. http://staceyw1.wordpress.com/2007/12/22/they-are-anonymous-methods-not-anonymous-delegates/ Basically you just need to put a cast in front of your anonymous delegate (your lambda expression). In case the link ever goes down, here i...
Convert this delegate to an anonymous method or lambda I am new to all the anonymous features and need some help. I have gotten the following to work: public void FakeSaveWithMessage(Transaction t) { t.Message = "I drink goats blood"; } public delegate void FakeSave(Transaction t); public void SampleTestFunction() { ...
TITLE: Convert this delegate to an anonymous method or lambda QUESTION: I am new to all the anonymous features and need some help. I have gotten the following to work: public void FakeSaveWithMessage(Transaction t) { t.Message = "I drink goats blood"; } public delegate void FakeSave(Transaction t); public void Sampl...
[ "c#", ".net-3.5", "delegates", "lambda", "anonymous-methods" ]
21
27
25,260
4
0
2008-09-12T16:58:32.603000
2008-09-12T17:20:21.537000
59,521
59,540
Synchronisation algorithms
Are there any good references for synchronisation algorithms? I'm interested in algorithms that synchronize the following kinds of data between multiple users: Calendars Documents Lists and outlines I'm not just looking for synchronization of contents of directories a la rsync; I am interested in merging the data withi...
SyncML is a standard for data synchronization of things normally associated with someone's personal organizer. Nokia and Motorola were both using it heavily a few years ago, but I don't know its current state. iCalendar is a calendar synchronization format specification, and CalDAV is an implementation of iCalendar ato...
Synchronisation algorithms Are there any good references for synchronisation algorithms? I'm interested in algorithms that synchronize the following kinds of data between multiple users: Calendars Documents Lists and outlines I'm not just looking for synchronization of contents of directories a la rsync; I am intereste...
TITLE: Synchronisation algorithms QUESTION: Are there any good references for synchronisation algorithms? I'm interested in algorithms that synchronize the following kinds of data between multiple users: Calendars Documents Lists and outlines I'm not just looking for synchronization of contents of directories a la rsy...
[ "algorithm", "calendar", "synchronization" ]
10
3
6,644
4
0
2008-09-12T17:02:02.983000
2008-09-12T17:14:03.767000
59,537
59,543
Service Oriented Architecture: How would you define it
Service Oriented Architecture seems to be more and more of a hot quote these days, but after asking around the office I have found that I seem to get many different definitions for it. How would you guys define SOA? What would you consider the official definition?
As Martin Fowler says, it means different things to different people. His article on the topic is pretty good although it isn't quite a definition. http://martinfowler.com/bliki/ServiceOrientedAmbiguity.html It may explain, the difficulty coming up with a concrete definition.
Service Oriented Architecture: How would you define it Service Oriented Architecture seems to be more and more of a hot quote these days, but after asking around the office I have found that I seem to get many different definitions for it. How would you guys define SOA? What would you consider the official definition?
TITLE: Service Oriented Architecture: How would you define it QUESTION: Service Oriented Architecture seems to be more and more of a hot quote these days, but after asking around the office I have found that I seem to get many different definitions for it. How would you guys define SOA? What would you consider the off...
[ "soa", "definition" ]
15
24
2,231
9
0
2008-09-12T17:10:36.503000
2008-09-12T17:15:14.403000
59,547
59,600
What tools exist to convert a Delphi 7 application to C# and the .Net framework?
I maintain an old PC-only application written in Delphi 7. Although Delphi has served me very well in the past I now only use it for this one application and find my skills with the language diminishing. Its syntax is too different from my 'day job' languages of Java/Ruby so it takes me longer to get into the groove of...
I am not aware of any automated tools for making that conversion. Personally I would suggest you stick with Delphi, maybe just upgrade to a new version. I have seen a couple code DOM's that attempt to convert from Delphi to C#, but that doesn't address the library issue. CodeGear (formally Borland) has a tool for going...
What tools exist to convert a Delphi 7 application to C# and the .Net framework? I maintain an old PC-only application written in Delphi 7. Although Delphi has served me very well in the past I now only use it for this one application and find my skills with the language diminishing. Its syntax is too different from my...
TITLE: What tools exist to convert a Delphi 7 application to C# and the .Net framework? QUESTION: I maintain an old PC-only application written in Delphi 7. Although Delphi has served me very well in the past I now only use it for this one application and find my skills with the language diminishing. Its syntax is too...
[ "c#", "delphi", "migration" ]
18
15
29,627
4
0
2008-09-12T17:16:27.880000
2008-09-12T17:42:12.340000
59,560
59,575
Most effective form of CAPTCHA?
Of all the forms of CAPTCHA available, which one is the "least crackable" while remaining fairly human readable?
I agree with Thomas. Captcha is on its way out. But if you must use it, reCAPTCHA is a pretty good provider with a simple API.
Most effective form of CAPTCHA? Of all the forms of CAPTCHA available, which one is the "least crackable" while remaining fairly human readable?
TITLE: Most effective form of CAPTCHA? QUESTION: Of all the forms of CAPTCHA available, which one is the "least crackable" while remaining fairly human readable? ANSWER: I agree with Thomas. Captcha is on its way out. But if you must use it, reCAPTCHA is a pretty good provider with a simple API.
[ "captcha" ]
17
16
7,747
15
0
2008-09-12T17:24:55.410000
2008-09-12T17:31:05.927000
59,590
59,616
lock keyword in C#
I understand the main function of the lock key word from MSDN lock Statement (C# Reference) The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock. When should the lock be used? For instance it makes se...
When should the lock be used? A lock should be used to protect shared resources in multithreaded code. Not for anything else. But is it necessary when the application does not spin off any other threads? Absolutely not. It's just a time waster. However do be sure that you're not implicitly using system threads. For exa...
lock keyword in C# I understand the main function of the lock key word from MSDN lock Statement (C# Reference) The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock. When should the lock be used? For i...
TITLE: lock keyword in C# QUESTION: I understand the main function of the lock key word from MSDN lock Statement (C# Reference) The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock. When should the l...
[ "c#", "multithreading", "design-patterns", "locking" ]
43
58
35,837
10
0
2008-09-12T17:38:49.930000
2008-09-12T17:49:43.557000
59,599
59,618
VBScript conditional short-circuiting workaround
I have a large classic ASP app that I have to maintain, and I repeatedly find myself thwarted by the lack of short-circuit evaluation capability. E.g., VBScript won't let you get away with: if not isNull(Rs("myField")) and Rs("myField") <> 0 then......because if Rs("myField") is null, you get an error in the second con...
Maybe not the best way, but it certainly works... Also, if you are in vb6 or.net, you can have different methods that cast to proper type too. if cint( getVal( rs("blah"), "" ) )<> 0 then 'do something end if function getVal( v, replacementVal ) if v is nothing then getVal = replacementVal else getVal = v end if end f...
VBScript conditional short-circuiting workaround I have a large classic ASP app that I have to maintain, and I repeatedly find myself thwarted by the lack of short-circuit evaluation capability. E.g., VBScript won't let you get away with: if not isNull(Rs("myField")) and Rs("myField") <> 0 then......because if Rs("myFi...
TITLE: VBScript conditional short-circuiting workaround QUESTION: I have a large classic ASP app that I have to maintain, and I repeatedly find myself thwarted by the lack of short-circuit evaluation capability. E.g., VBScript won't let you get away with: if not isNull(Rs("myField")) and Rs("myField") <> 0 then......b...
[ "asp-classic", "vbscript" ]
15
7
17,367
9
0
2008-09-12T17:42:05.417000
2008-09-12T17:50:44.553000
59,622
59,639
Detecting application hangs with ActiveX controls in .Net
I am working on upgrades to a screen scraping application. We are using an ActiveX control to scrape screens out of an IBM mainframe. The mainframe program often hangs and crashes the ActiveX control causing our application to crash. We don't have access to the mainframe or the ActiveX source code. We are not going to ...
You can start an executable with System.Diagnostics.Process.Start(). This returns a Process object with a Responding property that you can use to check periodically if the process is still active. You'll need two separate applications to do this though. And the application you're monitoring needs to have a main window ...
Detecting application hangs with ActiveX controls in .Net I am working on upgrades to a screen scraping application. We are using an ActiveX control to scrape screens out of an IBM mainframe. The mainframe program often hangs and crashes the ActiveX control causing our application to crash. We don't have access to the ...
TITLE: Detecting application hangs with ActiveX controls in .Net QUESTION: I am working on upgrades to a screen scraping application. We are using an ActiveX control to scrape screens out of an IBM mainframe. The mainframe program often hangs and crashes the ActiveX control causing our application to crash. We don't h...
[ ".net", "activex" ]
2
1
619
1
0
2008-09-12T17:53:07.433000
2008-09-12T18:01:22.623000
59,627
59,641
How do I find if my particular computer is going to have problems when I install linux?
The IT lady just gave me a laptop to keep! I've always wanted to have Linux install to play with so the first thing I did is search stackoverflow for Linux Distro suggestions and found it here. However they also mention that you should search around to see if anyone's had any problems with your drivers and that distro....
You can try Linux-On-Laptops. A quick search shows this Tecra A5. You can also download a LiveCD version, that will tell you if you can get most of your hardware working easily. If the LiveCD works, you're good. If it doesn't, you can just pop it out of the cd-rom drive. No harm done, and you can look at other options.
How do I find if my particular computer is going to have problems when I install linux? The IT lady just gave me a laptop to keep! I've always wanted to have Linux install to play with so the first thing I did is search stackoverflow for Linux Distro suggestions and found it here. However they also mention that you sho...
TITLE: How do I find if my particular computer is going to have problems when I install linux? QUESTION: The IT lady just gave me a laptop to keep! I've always wanted to have Linux install to play with so the first thing I did is search stackoverflow for Linux Distro suggestions and found it here. However they also me...
[ "linux", "installation", "drivers" ]
1
4
259
6
0
2008-09-12T17:57:10.073000
2008-09-12T18:01:29.113000
59,628
59,723
AJAX Partial Page Load?
I have a page results page (you get there after submitting your search query elsewhere) whit a whole bunch of gridviews for different type of data objects. Obviously, some of the queries take longer than the others. How can I make each gridview render as soon as it has the data it needs? This has been tricky for me bec...
@Gareth Jenkins The page will execute all of the queries before returning even the first update panel, so he won't save any time there. The trick to do this is to move each of your complex gridviews into a user control, in the user control, get rid of the Object DataSource crap, and do your binding in the code behind. ...
AJAX Partial Page Load? I have a page results page (you get there after submitting your search query elsewhere) whit a whole bunch of gridviews for different type of data objects. Obviously, some of the queries take longer than the others. How can I make each gridview render as soon as it has the data it needs? This ha...
TITLE: AJAX Partial Page Load? QUESTION: I have a page results page (you get there after submitting your search query elsewhere) whit a whole bunch of gridviews for different type of data objects. Obviously, some of the queries take longer than the others. How can I make each gridview render as soon as it has the data...
[ "asp.net", "ajax" ]
1
2
3,062
2
0
2008-09-12T17:57:51.790000
2008-09-12T18:38:10.990000
59,635
70,808
App does not run with VS 2008 SP1 DLLs, previous version works with RTM versions
Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using the MFC90.dll and msvc[pr]90.dlls along with the manifest files in a private side-by-side configuration so as to not worry about versions or installing them to the system. Pre-SP1, this was working fine (and still works fine on our developer ...
I have battled this problem myself last week and consider myself somewhat of an expert now;) I'm 99% sure that not all dlls and static libraries were recompiled with the SP1 version. You need to put #define _BIND_TO_CURRENT_MFC_VERSION 1 #define _BIND_TO_CURRENT_CRT_VERSION 1 into every project you're using. For every ...
App does not run with VS 2008 SP1 DLLs, previous version works with RTM versions Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using the MFC90.dll and msvc[pr]90.dlls along with the manifest files in a private side-by-side configuration so as to not worry about versions or installing them to t...
TITLE: App does not run with VS 2008 SP1 DLLs, previous version works with RTM versions QUESTION: Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using the MFC90.dll and msvc[pr]90.dlls along with the manifest files in a private side-by-side configuration so as to not worry about versions or in...
[ "c++", "visual-studio-2008", "mfc" ]
36
40
27,141
5
0
2008-09-12T17:59:53.767000
2008-09-16T09:47:15.053000
59,642
75,231
Determine Installed Compact Frameworks (and SP) Version
What's the best way to determine which version of the.NET Compact Frameworks (including Service Packs) is installed on a device through a.NET application.
Neil Cowburn maintains a fairly good list of all version numbers on his blog. As of right now the list looks like this: Version Release ---------- ------------------ 1.0.2268.0 1.0 RTM 1.0.3111.0 1.0 SP1 1.0.3226.0 1.0 SP2 (Recalled) 1.0.3227.0 1.0 SP2 Beta 1.0.3316.0 1.0 SP2 RTM 1.0.4177.0 1.0 SP3 Beta 1.0.4292.0 1.0 ...
Determine Installed Compact Frameworks (and SP) Version What's the best way to determine which version of the.NET Compact Frameworks (including Service Packs) is installed on a device through a.NET application.
TITLE: Determine Installed Compact Frameworks (and SP) Version QUESTION: What's the best way to determine which version of the.NET Compact Frameworks (including Service Packs) is installed on a device through a.NET application. ANSWER: Neil Cowburn maintains a fairly good list of all version numbers on his blog. As o...
[ "compact-framework" ]
2
1
590
2
0
2008-09-12T18:03:47.203000
2008-09-16T18:08:23.900000
59,648
59,778
Storing multiple arrays in Python
I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages to see if the average of the random...
Would something like this work? from random import randint mcworks = [] for n in xrange(NUM_ITERATIONS): mctest = [randint(0, 100) for i in xrange(5)] if sum(mctest[:3])/3 == mcavg[2]: mcworks.append(mctest) # mcavg is real data In the end, you are left with a list of valid mctest lists. What I changed: Used a list c...
Storing multiple arrays in Python I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages t...
TITLE: Storing multiple arrays in Python QUESTION: I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com I'm using a brute force method, where the computer generates some random daily polling data and then calculates th...
[ "python", "arrays" ]
3
3
18,067
6
0
2008-09-12T18:09:02.590000
2008-09-12T19:08:38.827000
59,651
59,688
Default integer type in ASP.NET from a stored procedure
I have a web page that I have hooked up to a stored procedure. In this SQL data source, I have a parameter that I'm passing back to the stored procedure of type int. ASP.NET seems to want to default to int32, but the number won't get higher than 6. Is it ok to override the ASP.NET default and put in 16 or will there be...
If you force it to be for example a byte and the number is over 255 you run the risk of a casting error (and an exception will be thrown). However if you know it not going to be higher than 6 it should not be a problem. If it was me, I would just use it as a normal int, I am not sure you save much if anything other tha...
Default integer type in ASP.NET from a stored procedure I have a web page that I have hooked up to a stored procedure. In this SQL data source, I have a parameter that I'm passing back to the stored procedure of type int. ASP.NET seems to want to default to int32, but the number won't get higher than 6. Is it ok to ove...
TITLE: Default integer type in ASP.NET from a stored procedure QUESTION: I have a web page that I have hooked up to a stored procedure. In this SQL data source, I have a parameter that I'm passing back to the stored procedure of type int. ASP.NET seems to want to default to int32, but the number won't get higher than ...
[ "asp.net", "sql-server", "stored-procedures", "parameters" ]
0
1
2,521
6
0
2008-09-12T18:10:16.470000
2008-09-12T18:23:10.463000
59,655
60,626
How to setup a Rails integration test for XML methods?
Given a controller method like: def show @model = Model.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render:xml => model } end end What's the best way to write an integration test that asserts that the return has the expected XML?
A combination of using the format and assert_select in an integration test works great: class ProductsTest < ActionController::IntegrationTest def test_contents_of_xml get '/index/1.xml' assert_select 'product name', /widget/ end end For more details check out assert_select in the Rails docs.
How to setup a Rails integration test for XML methods? Given a controller method like: def show @model = Model.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render:xml => model } end end What's the best way to write an integration test that asserts that the return has the expected X...
TITLE: How to setup a Rails integration test for XML methods? QUESTION: Given a controller method like: def show @model = Model.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render:xml => model } end end What's the best way to write an integration test that asserts that the return ...
[ "xml", "ruby", "integration-testing" ]
13
12
5,353
5
0
2008-09-12T18:11:42.817000
2008-09-13T15:43:54.037000
59,656
59,669
Why overwrite a file more than once to securely delete all traces of a file?
Erasing programs such as Eraser recommend overwriting data maybe 36 times. As I understand it all data is stored on a hard drive as 1s or 0s. If an overwrite of random 1s and 0s is carried out once over the whole file then why isn't that enough to remove all traces of the original file?
A hard drive bit which used to be a 0, and is then changed to a '1', has a slightly weaker magnetic field than one which used to be a 1 and was then written to 1 again. With sensitive equipment the previous contents of each bit can be discerned with a reasonable degree of accuracy, by measuring the slight variances in ...
Why overwrite a file more than once to securely delete all traces of a file? Erasing programs such as Eraser recommend overwriting data maybe 36 times. As I understand it all data is stored on a hard drive as 1s or 0s. If an overwrite of random 1s and 0s is carried out once over the whole file then why isn't that enoug...
TITLE: Why overwrite a file more than once to securely delete all traces of a file? QUESTION: Erasing programs such as Eraser recommend overwriting data maybe 36 times. As I understand it all data is stored on a hard drive as 1s or 0s. If an overwrite of random 1s and 0s is carried out once over the whole file then wh...
[ "security", "disk" ]
16
29
11,348
13
0
2008-09-12T18:11:51.910000
2008-09-12T18:15:45.553000
59,667
59,686
What are the use cases for selecting CHAR over VARCHAR in SQL?
I realize that CHAR is recommended if all my values are fixed-width. But, so what? Why not just pick VARCHAR for all text fields just to be safe.
The general rule is to pick CHAR if all rows will have close to the same length. Pick VARCHAR (or NVARCHAR ) when the length varies significantly. CHAR may also be a bit faster because all the rows are of the same length. It varies by DB implementation, but generally, VARCHAR (or NVARCHAR ) uses one or two more bytes o...
What are the use cases for selecting CHAR over VARCHAR in SQL? I realize that CHAR is recommended if all my values are fixed-width. But, so what? Why not just pick VARCHAR for all text fields just to be safe.
TITLE: What are the use cases for selecting CHAR over VARCHAR in SQL? QUESTION: I realize that CHAR is recommended if all my values are fixed-width. But, so what? Why not just pick VARCHAR for all text fields just to be safe. ANSWER: The general rule is to pick CHAR if all rows will have close to the same length. Pic...
[ "sql", "t-sql" ]
284
398
176,617
19
0
2008-09-12T18:15:28.097000
2008-09-12T18:22:06.927000
59,670
59,687
How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC
I'm working on an exceedingly large codebase, and recently upgraded to GCC 4.3, which now triggers this warning: warning: deprecated conversion from string constant to ‘char*’ Obviously, the correct way to fix this is to find every declaration like char *s = "constant string"; or function call like: void foo(char *s); ...
I believe passing -Wno-write-strings to GCC will suppress this warning.
How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC I'm working on an exceedingly large codebase, and recently upgraded to GCC 4.3, which now triggers this warning: warning: deprecated conversion from string constant to ‘char*’ Obviously, the correct way to fix this is to find ever...
TITLE: How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC QUESTION: I'm working on an exceedingly large codebase, and recently upgraded to GCC 4.3, which now triggers this warning: warning: deprecated conversion from string constant to ‘char*’ Obviously, the correct way to fix th...
[ "c++", "string", "gcc" ]
429
241
463,607
23
0
2008-09-12T18:15:55.320000
2008-09-12T18:22:10.030000
59,677
1,248,492
WSDualHttpBinding for duplex callbacks
Would using WSDualHttpBinding for duplex callbacks work in real-world scenarios? Say, I have a.NET application that uses a random port, would the service be able to resolve the client's base addresses and port for callbacks?
A complete answer to your question depends on the "real-world scenario" being either an Intranet or an Internet scenario. Although WSDualHttpBinding works in both scenarios there are specifics to be aware of: Intranet WSDualHttpBinding will work with your.NET application using a preconfigured custom port in an Intranet...
WSDualHttpBinding for duplex callbacks Would using WSDualHttpBinding for duplex callbacks work in real-world scenarios? Say, I have a.NET application that uses a random port, would the service be able to resolve the client's base addresses and port for callbacks?
TITLE: WSDualHttpBinding for duplex callbacks QUESTION: Would using WSDualHttpBinding for duplex callbacks work in real-world scenarios? Say, I have a.NET application that uses a random port, would the service be able to resolve the client's base addresses and port for callbacks? ANSWER: A complete answer to your que...
[ "wcf", "callback", "duplex" ]
10
35
16,866
2
0
2008-09-12T18:18:36.920000
2009-08-08T10:07:23.467000
59,719
59,730
How can I check for IsPostBack in JavaScript?
I need to run a JavaScript function onLoad(), but only do it if the page loaded the first time (i.e. is not the result of a postback). Basically, I need to check for IsPostBack in JavaScript. Thank you.
Server-side, write: if(IsPostBack) { // NOTE: the following uses an overload of RegisterClientScriptBlock() // that will surround our string with the needed script tags ClientScript.RegisterClientScriptBlock(GetType(), "IsPostBack", "var isPostBack = true;", true); } Then, in your script which runs for the onLoad, chec...
How can I check for IsPostBack in JavaScript? I need to run a JavaScript function onLoad(), but only do it if the page loaded the first time (i.e. is not the result of a postback). Basically, I need to check for IsPostBack in JavaScript. Thank you.
TITLE: How can I check for IsPostBack in JavaScript? QUESTION: I need to run a JavaScript function onLoad(), but only do it if the page loaded the first time (i.e. is not the result of a postback). Basically, I need to check for IsPostBack in JavaScript. Thank you. ANSWER: Server-side, write: if(IsPostBack) { // NOTE...
[ "asp.net", "javascript" ]
47
68
112,434
10
0
2008-09-12T18:35:25.957000
2008-09-12T18:42:39.153000
59,726
239,489
Finding network alias in .net
Is there a way in.net 2.0 to discover the network alias for the machine that my code is running on? Specifically, if my workgroup sees my machine as //jekkedev01, how do I retrieve that name programmatically?
Since you can have multiple network interfaces, each of which can have multiple IPs, and any single IP can have multiple names that can resolve to it, there may be more than one. If you want to know all the names by which your DNS server knows your machine, you can loop through them all like this: public ArrayList GetA...
Finding network alias in .net Is there a way in.net 2.0 to discover the network alias for the machine that my code is running on? Specifically, if my workgroup sees my machine as //jekkedev01, how do I retrieve that name programmatically?
TITLE: Finding network alias in .net QUESTION: Is there a way in.net 2.0 to discover the network alias for the machine that my code is running on? Specifically, if my workgroup sees my machine as //jekkedev01, how do I retrieve that name programmatically? ANSWER: Since you can have multiple network interfaces, each o...
[ "networking", ".net-2.0", "alias" ]
1
2
2,073
5
0
2008-09-12T18:40:05.463000
2008-10-27T10:14:46.683000
59,735
59,836
Recover corrupt zip or gzip files?
The most common method for corrupting compressed files is to inadvertently do an ASCII-mode FTP transfer, which causes a many-to-one trashing of CR and/or LF characters. Obviously, there is information loss, and the best way to fix this problem is to transfer again, in FTP binary mode. However, if the original is lost,...
From Bukys Software Approximately 1 in 256 bytes is known to be corrupted, and the corruption is known to occur only in bytes with the value '\012'. So the byte error rate is 1/256 (0.39% of input), and 2/256 bytes (0.78% of input) are suspect. But since only three bits per smashed byte are affected, the bit error rate...
Recover corrupt zip or gzip files? The most common method for corrupting compressed files is to inadvertently do an ASCII-mode FTP transfer, which causes a many-to-one trashing of CR and/or LF characters. Obviously, there is information loss, and the best way to fix this problem is to transfer again, in FTP binary mode...
TITLE: Recover corrupt zip or gzip files? QUESTION: The most common method for corrupting compressed files is to inadvertently do an ASCII-mode FTP transfer, which causes a many-to-one trashing of CR and/or LF characters. Obviously, there is information loss, and the best way to fix this problem is to transfer again, ...
[ "zip", "gzip", "recovery", "corrupt" ]
7
4
6,810
2
0
2008-09-12T18:44:47.403000
2008-09-12T20:05:05.633000
59,736
59,744
So, if CAPTCHA's on the way out, what comes next?
With text-recognition improving and CAPTCHA-breakers using Mechanical Turks to break otherwise unbreakable keys, what's the next technology to keep scripts from spam-botting a site that relies on user input?
I like the concept of an 'Invisible Captcha'. Phil Haack details one implementation here. This banks on the fact that bots, spiders, and crawlers don't implement javascript engines. This too could change in the near future.
So, if CAPTCHA's on the way out, what comes next? With text-recognition improving and CAPTCHA-breakers using Mechanical Turks to break otherwise unbreakable keys, what's the next technology to keep scripts from spam-botting a site that relies on user input?
TITLE: So, if CAPTCHA's on the way out, what comes next? QUESTION: With text-recognition improving and CAPTCHA-breakers using Mechanical Turks to break otherwise unbreakable keys, what's the next technology to keep scripts from spam-botting a site that relies on user input? ANSWER: I like the concept of an 'Invisible...
[ "captcha" ]
6
6
941
11
0
2008-09-12T18:45:57.837000
2008-09-12T18:51:40.223000
59,743
59,833
Number of possible combinations
How many possible combinations of the variables a,b,c,d,e are possible if I know that: a+b+c+d+e = 500 and that they are all integers and >= 0, so I know they are finite.
@Torlack, @Jason Cohen: Recursion is a bad idea here, because there are "overlapping subproblems." I.e., If you choose a as 1 and b as 2, then you have 3 variables left that should add up to 497; you arrive at the same subproblem by choosing a as 2 and b as 1. (The number of such coincidences explodes as the numbers gr...
Number of possible combinations How many possible combinations of the variables a,b,c,d,e are possible if I know that: a+b+c+d+e = 500 and that they are all integers and >= 0, so I know they are finite.
TITLE: Number of possible combinations QUESTION: How many possible combinations of the variables a,b,c,d,e are possible if I know that: a+b+c+d+e = 500 and that they are all integers and >= 0, so I know they are finite. ANSWER: @Torlack, @Jason Cohen: Recursion is a bad idea here, because there are "overlapping subpr...
[ "puzzle" ]
5
11
3,596
10
0
2008-09-12T18:50:34.020000
2008-09-12T20:04:30.877000
59,761
59,782
Disable Specific Keys in IE 6
I need to disable specific keys (Ctrl and Backspace) in Internet Explorer 6. Is there a registry hack to do this. It has to be IE6. Thanks. Long Edit: @apandit: Whoops. I need to more specific about the backspace thing. When I say disable backspace, I mean disable the ability for Backspace to mimic the Back browser but...
For what purpose do you need this? Because disabling the backspace would be hell for typing urls or emails, etc. We could recommend other workarounds if we knew the problem better. EDIT 1: This website seems to have some information as to how it's done. I can't verify it currently, but I'll look into it: http://www.ozz...
Disable Specific Keys in IE 6 I need to disable specific keys (Ctrl and Backspace) in Internet Explorer 6. Is there a registry hack to do this. It has to be IE6. Thanks. Long Edit: @apandit: Whoops. I need to more specific about the backspace thing. When I say disable backspace, I mean disable the ability for Backspace...
TITLE: Disable Specific Keys in IE 6 QUESTION: I need to disable specific keys (Ctrl and Backspace) in Internet Explorer 6. Is there a registry hack to do this. It has to be IE6. Thanks. Long Edit: @apandit: Whoops. I need to more specific about the backspace thing. When I say disable backspace, I mean disable the abi...
[ "internet-explorer-6", "kiosk" ]
0
0
1,803
3
0
2008-09-12T19:00:32.917000
2008-09-12T19:12:16.277000
59,766
59,770
How do you get JavaScript/jQuery Intellisense Working in Visual Studio 2008?
I thought jQuery Intellisense was supposed to be improved with SP1. I even downloaded an annotated version of jQuery 1.2.6, but intellisense will not work in a separate jscript file. I have the jQuery library referenced first on my web page in the tag. Am I doing anything wrong?
At the top of your external JavaScript file, add the following: /// Make sure the path is correct, relative to the file's position in the folder structure, etc. Also, any references need to be at the top of the file, before any other text, including comments - literally, the very first thing in the file. Hopefully futu...
How do you get JavaScript/jQuery Intellisense Working in Visual Studio 2008? I thought jQuery Intellisense was supposed to be improved with SP1. I even downloaded an annotated version of jQuery 1.2.6, but intellisense will not work in a separate jscript file. I have the jQuery library referenced first on my web page in...
TITLE: How do you get JavaScript/jQuery Intellisense Working in Visual Studio 2008? QUESTION: I thought jQuery Intellisense was supposed to be improved with SP1. I even downloaded an annotated version of jQuery 1.2.6, but intellisense will not work in a separate jscript file. I have the jQuery library referenced first...
[ "asp.net", "javascript", "jquery", "visual-studio", "intellisense" ]
93
88
10,156
9
0
2008-09-12T19:03:27.293000
2008-09-12T19:06:09.753000
59,768
153,474
Debugging with FF3 in VS2008
I am using Firefox 3 to debug my ASP.NET applications in Visual Studio 2008. How can I configure either FF3 or VS2008 so that when I 'x' out of Firefox I don't have to hit the stop debugging button in Visual Studio? (The behavior you get with IE)
My solution to this has been to manually attach the debugger to the relevant browser and the aspnet_wp process. When I'm finished, I simply detach all.
Debugging with FF3 in VS2008 I am using Firefox 3 to debug my ASP.NET applications in Visual Studio 2008. How can I configure either FF3 or VS2008 so that when I 'x' out of Firefox I don't have to hit the stop debugging button in Visual Studio? (The behavior you get with IE)
TITLE: Debugging with FF3 in VS2008 QUESTION: I am using Firefox 3 to debug my ASP.NET applications in Visual Studio 2008. How can I configure either FF3 or VS2008 so that when I 'x' out of Firefox I don't have to hit the stop debugging button in Visual Studio? (The behavior you get with IE) ANSWER: My solution to th...
[ "visual-studio-2008", "firefox", "ide" ]
5
1
299
3
0
2008-09-12T19:05:27.960000
2008-09-30T15:08:09.063000
59,787
60,021
How do you generate and analyze a thread dump from a running JBoss instance?
How do you generate and analyze a thread dump from a running JBoss instance?
There is a JBoss-specific method that is slightly more user-friendly: http://community.jboss.org/wiki/GenerateAThreadDumpWithTheJMXConsole This is especially useful when you don't have direct access to the host machine (which "kill" would require).
How do you generate and analyze a thread dump from a running JBoss instance? How do you generate and analyze a thread dump from a running JBoss instance?
TITLE: How do you generate and analyze a thread dump from a running JBoss instance? QUESTION: How do you generate and analyze a thread dump from a running JBoss instance? ANSWER: There is a JBoss-specific method that is slightly more user-friendly: http://community.jboss.org/wiki/GenerateAThreadDumpWithTheJMXConsole ...
[ "java", "multithreading", "dump" ]
8
6
23,689
7
0
2008-09-12T19:16:58.010000
2008-09-12T21:40:41.130000
59,809
63,610
MS Access ADP Autonumber
I am getting the following error in an MS Access ADP when trying to add a record on a form linked to a MS SQL Server 2000 table: Run-time error '31004': The value of an (AutoNumber) field cannot be retrived prior to being saved. Please save the record that contains the (AutoNumber) field prior to performing this action...
First of all, if you are going to look at experts-exchange - do it in FireFox, you'll see the unblocked answers at the bottom of the page. Second, do you have a subform on that form that's using the autonumber/key field on the master form? Do you require the data that's on that subform to be saved (i.e., having its own...
MS Access ADP Autonumber I am getting the following error in an MS Access ADP when trying to add a record on a form linked to a MS SQL Server 2000 table: Run-time error '31004': The value of an (AutoNumber) field cannot be retrived prior to being saved. Please save the record that contains the (AutoNumber) field prior ...
TITLE: MS Access ADP Autonumber QUESTION: I am getting the following error in an MS Access ADP when trying to add a record on a form linked to a MS SQL Server 2000 table: Run-time error '31004': The value of an (AutoNumber) field cannot be retrived prior to being saved. Please save the record that contains the (AutoNu...
[ "sql-server", "ms-access" ]
2
2
1,496
3
0
2008-09-12T19:36:43.423000
2008-09-15T14:53:17.747000
59,816
96,314
MapPoint 2009 Load Performance
I'm having some problems integrating MS MapPoint 2009 into my WinForms.Net 2.0 application in C#. I've added the ActiveX MapPoint control onto a form and have no problems getting it to display a maps and locations; my concern is the time it takes to load a map once it is created. The tests on my development machine hav...
According to these threads at mapforums.com the slowness of ActiveX startup is well known and unavoidable (though the question of threading to help with GUI responsiveness is still open. One thing suggested was to abandon the ActiveX version in favor of the MapPoint.Application object instead. Hope that helps.
MapPoint 2009 Load Performance I'm having some problems integrating MS MapPoint 2009 into my WinForms.Net 2.0 application in C#. I've added the ActiveX MapPoint control onto a form and have no problems getting it to display a maps and locations; my concern is the time it takes to load a map once it is created. The test...
TITLE: MapPoint 2009 Load Performance QUESTION: I'm having some problems integrating MS MapPoint 2009 into my WinForms.Net 2.0 application in C#. I've added the ActiveX MapPoint control onto a form and have no problems getting it to display a maps and locations; my concern is the time it takes to load a map once it is...
[ "c#", "winforms", "performance", "com", "mappoint" ]
2
3
1,153
2
0
2008-09-12T19:42:26.420000
2008-09-18T20:02:26.167000
59,819
66,693
How do I create a custom type in PowerShell for my scripts to use?
I would like to be able to define and use a custom type in some of my PowerShell scripts. For example, let's pretend I had a need for an object that had the following structure: Contact { string First string Last string Phone } How would I go about creating this so that I could use it in function like the following: fu...
Prior to PowerShell 3 PowerShell's Extensible Type System didn't originally let you create concrete types you can test against the way you did in your parameter. If you don't need that test, you're fine with any of the other methods mentioned above. If you want an actual type that you can cast to or type-check with, as...
How do I create a custom type in PowerShell for my scripts to use? I would like to be able to define and use a custom type in some of my PowerShell scripts. For example, let's pretend I had a need for an object that had the following structure: Contact { string First string Last string Phone } How would I go about crea...
TITLE: How do I create a custom type in PowerShell for my scripts to use? QUESTION: I would like to be able to define and use a custom type in some of my PowerShell scripts. For example, let's pretend I had a need for an object that had the following structure: Contact { string First string Last string Phone } How wou...
[ "powershell", "scripting" ]
112
171
110,907
8
0
2008-09-12T19:43:52.423000
2008-09-15T20:36:56.360000
59,825
59,841
How to retrieve an element from a set without removing it?
Suppose the following: >>> s = set([1, 2, 3]) How do I get a value (any value) out of s without doing s.pop()? I want to leave the item in the set until I am sure I can remove it - something I can only be sure of after an asynchronous call to another host. Quick and dirty: >>> elem = s.pop() >>> s.add(elem) But do you ...
Two options that don't require copying the whole set: for e in s: break # e is now an element from s Or... e = next(iter(s)) But in general, sets don't support indexing or slicing.
How to retrieve an element from a set without removing it? Suppose the following: >>> s = set([1, 2, 3]) How do I get a value (any value) out of s without doing s.pop()? I want to leave the item in the set until I am sure I can remove it - something I can only be sure of after an asynchronous call to another host. Quic...
TITLE: How to retrieve an element from a set without removing it? QUESTION: Suppose the following: >>> s = set([1, 2, 3]) How do I get a value (any value) out of s without doing s.pop()? I want to leave the item in the set until I am sure I can remove it - something I can only be sure of after an asynchronous call to ...
[ "python", "set" ]
679
837
894,820
15
0
2008-09-12T19:58:33.403000
2008-09-12T20:08:10.167000
59,832
59,960
getting java exception: java.net.MalformedURLException: no protocol
I am currently calling the following line of code: java.net.URL connection_url = new java.net.URL("http://: /path"); and I get the exception above when it executes. Any ideas as to why this is happening?
Your code works perfectly fine for me: public static void main(String[] args) { try { java.net.URL connection_url = new java.net.URL("http://:/path"); System.out.println("Instantiated new URL: " + connection_url); } catch (MalformedURLException e) { e.printStackTrace(); } } Instantiated new URL: http://:/path Sure you ...
getting java exception: java.net.MalformedURLException: no protocol I am currently calling the following line of code: java.net.URL connection_url = new java.net.URL("http://: /path"); and I get the exception above when it executes. Any ideas as to why this is happening?
TITLE: getting java exception: java.net.MalformedURLException: no protocol QUESTION: I am currently calling the following line of code: java.net.URL connection_url = new java.net.URL("http://: /path"); and I get the exception above when it executes. Any ideas as to why this is happening? ANSWER: Your code works perfe...
[ "java", "url", "io" ]
6
2
77,890
5
0
2008-09-12T20:03:43.657000
2008-09-12T21:06:22.990000
59,838
59,839
How do I check if a directory exists or not in a Bash shell script?
What command checks if a directory exists or not within a Bash shell script?
To check if a directory exists: if [ -d "$DIRECTORY" ]; then echo "$DIRECTORY does exist." fi To check if a directory does not exist: if [! -d "$DIRECTORY" ]; then echo "$DIRECTORY does not exist." fi However, as Jon Ericson points out, subsequent commands may not work as intended if you do not take into account that a...
How do I check if a directory exists or not in a Bash shell script? What command checks if a directory exists or not within a Bash shell script?
TITLE: How do I check if a directory exists or not in a Bash shell script? QUESTION: What command checks if a directory exists or not within a Bash shell script? ANSWER: To check if a directory exists: if [ -d "$DIRECTORY" ]; then echo "$DIRECTORY does exist." fi To check if a directory does not exist: if [! -d "$DIR...
[ "bash", "shell", "unix", "command", "posix" ]
4,448
5,975
3,253,951
35
0
2008-09-12T20:06:25.757000
2008-09-12T20:07:06.113000
59,840
59,854
bug in linq Contains statement - is there a fix or workaround?
I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround. If the querysource you do the contains with has more than 10 items in it, it does not pass the items correctly to the SQL query. It is hard...
The more I look at it, and after running more tests, I'm thinking the bug may be in the Sql Server Query Visualizer plugin for Visual Studio, not actually in Linq to SQL itself. So it is not nearly as bad a situation as I thought - the query will return the right results, but you can't trust what the Visualizer is show...
bug in linq Contains statement - is there a fix or workaround? I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround. If the querysource you do the contains with has more than 10 items in it, it...
TITLE: bug in linq Contains statement - is there a fix or workaround? QUESTION: I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround. If the querysource you do the contains with has more than ...
[ ".net", "linq" ]
2
1
732
2
0
2008-09-12T20:07:19.247000
2008-09-12T20:17:26.463000
59,880
59,932
Are Stored Procedures more efficient, in general, than inline statements on modern RDBMS's?
Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them ALL THE TIME. I am pretty sure this is grounded in some historical context where this was once the case. Now, I'm not advocating that Stored Procs are not needed, but I want to know in what cases stored proced...
NOTE that this is a general look at stored procedures not regulated to a specific DBMS. Some DBMS (and even, different versions of the same DBMS!) may operate contrary to this, so you'll want to double-check with your target DBMS before assuming all of this still holds. I've been a Sybase ASE, MySQL, and SQL Server DBA...
Are Stored Procedures more efficient, in general, than inline statements on modern RDBMS's? Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them ALL THE TIME. I am pretty sure this is grounded in some historical context where this was once the case. Now, I'm not...
TITLE: Are Stored Procedures more efficient, in general, than inline statements on modern RDBMS's? QUESTION: Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them ALL THE TIME. I am pretty sure this is grounded in some historical context where this was once the ...
[ "sql", "database", "stored-procedures" ]
124
278
82,389
20
0
2008-09-12T20:32:25.507000
2008-09-12T20:53:57.390000
59,893
60,054
Best method to obfuscate or secure .Net assemblies
I'm looking for a technique or tool which we can use to obfuscate or somehow secure our compiled c# code. The goal is not for user/data security but to hinder reverse engineering of some of the technology in our software. This is not for use on the web, but for a desktop application. So, do you know of any tools availa...
This is a pretty good list of obfuscators from Visual Studio Marketplace Obfuscators ArmDot Crypto Obfuscator Demeanor for.NET DeployLX CodeVeil Dotfuscator.NET Obfuscator Semantic Designs: C# Source Code Obfuscator Smartassembly Spices.Net Xenocode Postbuild 2006.NET Reactor I have not observed any performance issues ...
Best method to obfuscate or secure .Net assemblies I'm looking for a technique or tool which we can use to obfuscate or somehow secure our compiled c# code. The goal is not for user/data security but to hinder reverse engineering of some of the technology in our software. This is not for use on the web, but for a deskt...
TITLE: Best method to obfuscate or secure .Net assemblies QUESTION: I'm looking for a technique or tool which we can use to obfuscate or somehow secure our compiled c# code. The goal is not for user/data security but to hinder reverse engineering of some of the technology in our software. This is not for use on the we...
[ "c#", ".net", ".net-2.0" ]
33
37
57,471
4
0
2008-09-12T20:38:36.317000
2008-09-12T21:56:48.470000
59,895
246,128
How do I get the directory where a Bash script is located from within the script itself?
How do I get the path of the directory in which a Bash script is located, inside that script? I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash script is located, so I can operate on the files in that directory, like so: $./application
#!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) is a useful one-liner which will give you the full directory name of the script no matter where it is being called from. It will work as long as the last component of the path used to find the script is not a symlink (d...
How do I get the directory where a Bash script is located from within the script itself? How do I get the path of the directory in which a Bash script is located, inside that script? I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash scrip...
TITLE: How do I get the directory where a Bash script is located from within the script itself? QUESTION: How do I get the path of the directory in which a Bash script is located, inside that script? I want to use a Bash script as a launcher for another application. I want to change the working directory to the one wh...
[ "bash", "directory" ]
6,248
8,090
2,581,562
76
0
2008-09-12T20:39:56.860000
2008-10-29T08:36:45.740000
59,896
59,904
How do I stop an effect in jQuery
I have a page that uses $(id).show("highlight", {}, 2000); to highlight an element when I start a ajax request, that might fail so that I want to use something like $(id).show("highlight", {color: "#FF0000"}, 2000); in the error handler. The problem is that if the first highlight haven't finished, the second is placed ...
From the jQuery docs: http://docs.jquery.com/Effects/stop Stop the currently-running animation on the matched elements.... When.stop() is called on an element, the currently-running animation (if any) is immediately stopped. If, for instance, an element is being hidden with.slideUp() when.stop() is called, the element ...
How do I stop an effect in jQuery I have a page that uses $(id).show("highlight", {}, 2000); to highlight an element when I start a ajax request, that might fail so that I want to use something like $(id).show("highlight", {color: "#FF0000"}, 2000); in the error handler. The problem is that if the first highlight haven...
TITLE: How do I stop an effect in jQuery QUESTION: I have a page that uses $(id).show("highlight", {}, 2000); to highlight an element when I start a ajax request, that might fail so that I want to use something like $(id).show("highlight", {color: "#FF0000"}, 2000); in the error handler. The problem is that if the fir...
[ "javascript", "jquery" ]
15
11
6,381
4
0
2008-09-12T20:40:00.213000
2008-09-12T20:42:48.133000
59,926
60,104
SQL Server 2005 Encryption, asp.net and stored procedures
I need to write a web application using SQL Server 2005, asp.net, and ado.net. Much of the user data stored in this application must be encrypted (read HIPAA). In the past for projects that required encryption, I encrypted/decrypted in the application code. However, this was generally for encrypting passwords or credit...
1) Look into using TRY..CATCH in SQL 2005. Unfortunately there is no FINALLY, so you'll have to handle both the success and error cases individually. 2) Not necessary if (1) handles the cleanup. 3) There isn't really a difference between client and server transactions with SQL Server. Connection.BeginTransaction() more...
SQL Server 2005 Encryption, asp.net and stored procedures I need to write a web application using SQL Server 2005, asp.net, and ado.net. Much of the user data stored in this application must be encrypted (read HIPAA). In the past for projects that required encryption, I encrypted/decrypted in the application code. Howe...
TITLE: SQL Server 2005 Encryption, asp.net and stored procedures QUESTION: I need to write a web application using SQL Server 2005, asp.net, and ado.net. Much of the user data stored in this application must be encrypted (read HIPAA). In the past for projects that required encryption, I encrypted/decrypted in the appl...
[ "asp.net", "sql-server-2005", "encryption" ]
6
3
2,193
3
0
2008-09-12T20:51:38.860000
2008-09-12T22:41:47.177000
59,934
60,083
National holiday web service
Is there a public/government web service that I can call to find out what the national holidays are for a given year? (For the US and/or any country in the world.) Edit: Does anybody have a set of formulas to calculate US holidays? (C# would be my language of choice if there is a choice.)
There's a web service at http://www.holidaywebservice.com which will provide dates of holidays for the USA, Republic of Ireland, England and Scotland. They also sell a DLL and source code. As for details of algorithms, you could do worse than check out the excellent Calendrical Calculations book (third edition), which ...
National holiday web service Is there a public/government web service that I can call to find out what the national holidays are for a given year? (For the US and/or any country in the world.) Edit: Does anybody have a set of formulas to calculate US holidays? (C# would be my language of choice if there is a choice.)
TITLE: National holiday web service QUESTION: Is there a public/government web service that I can call to find out what the national holidays are for a given year? (For the US and/or any country in the world.) Edit: Does anybody have a set of formulas to calculate US holidays? (C# would be my language of choice if the...
[ "web-services", "egovernment" ]
19
8
20,773
8
0
2008-09-12T20:55:32.953000
2008-09-12T22:17:58.387000
59,936
59,977
Slowing down the playback of an audio file without changing its pitch?
I am working on an application for college music majors. A feature i am considering is slowing down music playback without changing its pitch. I have seen this done in commercial software, but cannot find any libraries or open source apps that do anything like this. Are there libraries out there? How could this be done...
Timestretching is quite hard. The more you slow down or speed up the sound the more artifacts you get. If you want to know what they sound like listen to "The Rockafeller Skank" by Fat Boy Slim. There are a lot of ways to do it that all have their own strengths and weaknesses. The math can get really complex. That's wh...
Slowing down the playback of an audio file without changing its pitch? I am working on an application for college music majors. A feature i am considering is slowing down music playback without changing its pitch. I have seen this done in commercial software, but cannot find any libraries or open source apps that do an...
TITLE: Slowing down the playback of an audio file without changing its pitch? QUESTION: I am working on an application for college music majors. A feature i am considering is slowing down music playback without changing its pitch. I have seen this done in commercial software, but cannot find any libraries or open sour...
[ "java", "audio", "media" ]
11
10
8,952
5
0
2008-09-12T20:56:53.700000
2008-09-12T21:12:42.443000
59,951
59,979
ASP Server variable not working on local IIS
I'm working on a simple ASP.Net page (handler, actually) where I check the value of the LOGON_USER server variable. This works using Visual Studio's built-in web server and it works in other sites deployed to the live intranet site. But it doesn't work on the IIS instance on my local XP machine. How can I fix it, or wh...
What authentication do you have enabled in IIS? Anonmyous, Basic, Digest, Integrated Windows? Sounds to me like anonymous access is enabled/allowed, and nothing else. This would means that LOGON_USER is not populated. When you access your local IIS, trying using http://127.0.0.1 in particular if you use IE. IE will rec...
ASP Server variable not working on local IIS I'm working on a simple ASP.Net page (handler, actually) where I check the value of the LOGON_USER server variable. This works using Visual Studio's built-in web server and it works in other sites deployed to the live intranet site. But it doesn't work on the IIS instance on...
TITLE: ASP Server variable not working on local IIS QUESTION: I'm working on a simple ASP.Net page (handler, actually) where I check the value of the LOGON_USER server variable. This works using Visual Studio's built-in web server and it works in other sites deployed to the live intranet site. But it doesn't work on t...
[ "asp.net", "iis", "server-variables" ]
0
2
2,392
2
0
2008-09-12T21:03:39.737000
2008-09-12T21:13:13.300000
59,958
60,430
WPF - Programmatic Binding on a BitmapEffect
I would like to be able to programmatically bind some data to the dependency properties on a BitmapEffect. With a FrameworkElement like TextBlock there is a SetBinding method where you can programmatically do these bindings like: myTextBlock.SetBinding(TextBlock.TextProperty, new Binding("SomeProperty")); And I know yo...
You can use BindingOperation.SetBinding: Binding newBinding = new Binding(); newBinding.ElementName = "SomeObject"; newBinding.Path = new PropertyPath(SomeObjectType.SomeProperty); BindingOperations.SetBinding(MyGlow, OuterGlowBitmapEffect.GlowSizeProperty, newBinding); I think that should do what you want.
WPF - Programmatic Binding on a BitmapEffect I would like to be able to programmatically bind some data to the dependency properties on a BitmapEffect. With a FrameworkElement like TextBlock there is a SetBinding method where you can programmatically do these bindings like: myTextBlock.SetBinding(TextBlock.TextProperty...
TITLE: WPF - Programmatic Binding on a BitmapEffect QUESTION: I would like to be able to programmatically bind some data to the dependency properties on a BitmapEffect. With a FrameworkElement like TextBlock there is a SetBinding method where you can programmatically do these bindings like: myTextBlock.SetBinding(Text...
[ "wpf", "data-binding", "bitmapeffect" ]
5
11
5,095
1
0
2008-09-12T21:05:46.253000
2008-09-13T09:16:15.607000
59,972
59,990
Old-school SQL DB access versus ORM (NHibernate, EF, et al). Who wins?
I've been successful with writing my own SQL access code with a combination of stored procedures and parameterized queries and a little wrapper library I've written to minimize the ADO.NET grunge. This has all worked very well for me in the past and I've been pretty productive with it. I'm heading into a new project--s...
A good question but a very controversial topic. This blog post from Frans Bouma from a few years back citing the pros of dynamic SQL (implying ORMs) over stored procedures sparked quite the fiery flame war.
Old-school SQL DB access versus ORM (NHibernate, EF, et al). Who wins? I've been successful with writing my own SQL access code with a combination of stored procedures and parameterized queries and a little wrapper library I've written to minimize the ADO.NET grunge. This has all worked very well for me in the past and...
TITLE: Old-school SQL DB access versus ORM (NHibernate, EF, et al). Who wins? QUESTION: I've been successful with writing my own SQL access code with a combination of stored procedures and parameterized queries and a little wrapper library I've written to minimize the ADO.NET grunge. This has all worked very well for ...
[ "orm", "ado.net" ]
4
1
976
3
0
2008-09-12T21:10:42.793000
2008-09-12T21:19:30.760000
59,974
60,006
Implementing large system changes
If you're familiar with the phrase "build one to throw away", well, we seem to have done that; we’re reaching the limits of version 1 of our online app. It's time to clean things up by: Re-organizing code and UI Unifying UI processes Adding more functionality Building for the future Modifying our database structure to ...
The answer, I'm afraid, is it depends. It depends on the kind of application and the kind of users you have. Without knowing what the system is and the scope of the changes in the version, it is difficult to offer an answer. That said, there are some rules of thumb. Firstly, avoid the big bang launch. Any launch of a s...
Implementing large system changes If you're familiar with the phrase "build one to throw away", well, we seem to have done that; we’re reaching the limits of version 1 of our online app. It's time to clean things up by: Re-organizing code and UI Unifying UI processes Adding more functionality Building for the future Mo...
TITLE: Implementing large system changes QUESTION: If you're familiar with the phrase "build one to throw away", well, we seem to have done that; we’re reaching the limits of version 1 of our online app. It's time to clean things up by: Re-organizing code and UI Unifying UI processes Adding more functionality Building...
[ "database-design", "testing", "architecture", "deployment" ]
3
2
322
4
0
2008-09-12T21:11:14.773000
2008-09-12T21:26:24.283000
59,986
60,043
XMLSerialization in C#
I have a simple type that explicitly implemets an Interface. public interface IMessageHeader { string FromAddress { get; set; } string ToAddress { get; set; } } [Serializable] public class MessageHeader:IMessageHeader { private string from; private string to; [XmlAttribute("From")] string IMessageHeade.FromAddress { ...
You cannot serialize IMessageHeader because you can't do Activator.CreateInstance(typeof(IMessageHeader)) which is what serialization is going to do under the covers. You need a concrete type. You can do typeof(MessageHeader) or you could say, have an instance of MessageHeader and do XmlSerializer serializer = new XmlS...
XMLSerialization in C# I have a simple type that explicitly implemets an Interface. public interface IMessageHeader { string FromAddress { get; set; } string ToAddress { get; set; } } [Serializable] public class MessageHeader:IMessageHeader { private string from; private string to; [XmlAttribute("From")] string IMess...
TITLE: XMLSerialization in C# QUESTION: I have a simple type that explicitly implemets an Interface. public interface IMessageHeader { string FromAddress { get; set; } string ToAddress { get; set; } } [Serializable] public class MessageHeader:IMessageHeader { private string from; private string to; [XmlAttribute("Fr...
[ "c#", ".net", "serialization", "interface" ]
2
3
3,765
5
0
2008-09-12T21:16:26.727000
2008-09-12T21:51:58.543000
60,000
2,688,631
C++ inheritance and member function pointers
In C++, can member function pointers be used to point to derived (or even base) class members? EDIT: Perhaps an example will help. Suppose we have a hierarchy of three classes X, Y, Z in order of inheritance. Y therefore has a base class X and a derived class Z. Now we can define a member function pointer p for class Y...
C++03 std, §4.11 2 Pointer to member conversions: An rvalue of type “pointer to member of B of type cv T,” where B is a class type, can be converted to an rvalue of type “pointer to member of D of type cv T,” where D is a derived class (clause 10) of B. If B is an inaccessible (clause 11), ambiguous (10.2) or virtual (...
C++ inheritance and member function pointers In C++, can member function pointers be used to point to derived (or even base) class members? EDIT: Perhaps an example will help. Suppose we have a hierarchy of three classes X, Y, Z in order of inheritance. Y therefore has a base class X and a derived class Z. Now we can d...
TITLE: C++ inheritance and member function pointers QUESTION: In C++, can member function pointers be used to point to derived (or even base) class members? EDIT: Perhaps an example will help. Suppose we have a hierarchy of three classes X, Y, Z in order of inheritance. Y therefore has a base class X and a derived cla...
[ "c++", "inheritance", "oop", "pointer-to-member" ]
54
32
28,490
8
0
2008-09-12T21:24:53.413000
2010-04-22T06:25:21.923000
60,030
60,209
How do you resize an IE browser window to 1024 x 768
In Firefox you can enter the following into the awesome bar and hit enter: javascript:self.resizeTo(1024,768); How do you do the same thing in IE?
javascript:resizeTo(1024,768); vbscript:resizeto(1024,768) Will work in IE7, But consider using something like javascript:moveTo(0,0);resizeTo(1024,768); because IE7 doesn't allow the window to "resize" beyond the screen borders. If you work on a 1024,768 desktop, this is what happens... Firefox: 1024x768 Window, going...
How do you resize an IE browser window to 1024 x 768 In Firefox you can enter the following into the awesome bar and hit enter: javascript:self.resizeTo(1024,768); How do you do the same thing in IE?
TITLE: How do you resize an IE browser window to 1024 x 768 QUESTION: In Firefox you can enter the following into the awesome bar and hit enter: javascript:self.resizeTo(1024,768); How do you do the same thing in IE? ANSWER: javascript:resizeTo(1024,768); vbscript:resizeto(1024,768) Will work in IE7, But consider usi...
[ "javascript", "internet-explorer" ]
9
12
30,174
5
0
2008-09-12T21:46:12.410000
2008-09-13T00:36:44.310000
60,032
60,089
Getting the array key in a 'foreach' loop
How do I get the key of the current element in a foreach loop in C#? For example: PHP foreach ($array as $key => $value) { echo("$value is assigned to key: $key"); } What I'm trying to do in C#: int[] values = { 5, 14, 29, 49, 99, 150, 999 }; foreach (int val in values) { if(search <= val &&!stop) { // Set key to a va...
Grauenwolf's way is the most straightforward and performant way of doing this with an array: Either use a for loop or create a temp variable that you increment on each pass. Which would of course look like this: int[] values = { 5, 14, 29, 49, 99, 150, 999 }; for (int key = 0; key < values.Length; ++key) if (search <=...
Getting the array key in a 'foreach' loop How do I get the key of the current element in a foreach loop in C#? For example: PHP foreach ($array as $key => $value) { echo("$value is assigned to key: $key"); } What I'm trying to do in C#: int[] values = { 5, 14, 29, 49, 99, 150, 999 }; foreach (int val in values) { if(s...
TITLE: Getting the array key in a 'foreach' loop QUESTION: How do I get the key of the current element in a foreach loop in C#? For example: PHP foreach ($array as $key => $value) { echo("$value is assigned to key: $key"); } What I'm trying to do in C#: int[] values = { 5, 14, 29, 49, 99, 150, 999 }; foreach (int val...
[ "c#", "arrays" ]
31
25
101,816
9
0
2008-09-12T21:47:17.323000
2008-09-12T22:34:50.860000
60,033
60,053
What is the easiest way to duplicate an activerecord record?
I want to make a copy of an ActiveRecord object, changing a single field in the process (in addition to the id ). What is the simplest way to accomplish this? I realize I could create a new record, and then iterate over each of the fields copying the data field-by-field - but I figured there must be an easier way to do...
To get a copy, use the dup (or clone for < rails 3.1+) method: #rails >= 3.1 new_record = old_record.dup # rails < 3.1 new_record = old_record.clone Then you can change whichever fields you want. ActiveRecord overrides the built-in Object#clone to give you a new (not saved to the DB) record with an unassigned ID. Note...
What is the easiest way to duplicate an activerecord record? I want to make a copy of an ActiveRecord object, changing a single field in the process (in addition to the id ). What is the simplest way to accomplish this? I realize I could create a new record, and then iterate over each of the fields copying the data fie...
TITLE: What is the easiest way to duplicate an activerecord record? QUESTION: I want to make a copy of an ActiveRecord object, changing a single field in the process (in addition to the id ). What is the simplest way to accomplish this? I realize I could create a new record, and then iterate over each of the fields co...
[ "ruby-on-rails", "ruby", "rails-activerecord" ]
474
707
240,374
12
0
2008-09-12T21:48:04.140000
2008-09-12T21:56:44.727000
60,039
63,753
C# NetCDF Library
I am currently working on (or at least planning) a couple of projects that work with large amounts of repetitive data. The kind of data that works well in a spreadsheet or database, but is nasty in XML.:) NetCDF seems like a great option for a file format. However, my work is in C# and there is no "official" NetCDF imp...
First, are you sure that NetCDF is the right choice? If you want to interact with other programs that need to read in large amounts of data and they already support NetCDF, then it's probably a great choice. There aren't that many standard and well-supported file formats that support large multidimensional arrays. But ...
C# NetCDF Library I am currently working on (or at least planning) a couple of projects that work with large amounts of repetitive data. The kind of data that works well in a spreadsheet or database, but is nasty in XML.:) NetCDF seems like a great option for a file format. However, my work is in C# and there is no "of...
TITLE: C# NetCDF Library QUESTION: I am currently working on (or at least planning) a couple of projects that work with large amounts of repetitive data. The kind of data that works well in a spreadsheet or database, but is nasty in XML.:) NetCDF seems like a great option for a file format. However, my work is in C# a...
[ ".net", "file", "file-format" ]
8
7
14,377
4
0
2008-09-12T21:49:59.500000
2008-09-15T15:09:08.283000
60,049
60,961
Java sound recording and mixer settings
I'm using the javax.sound.sampled package in a radio data mode decoding program. To use the program the user feeds audio from their radio receiver into their PC's line input. The user is also required to use their mixer program to select the line in as the recording input. The trouble is some users don't know how to do...
To answer your first question, you can check if the Line.Info object for your recording input matches Port.Info.LINE_IN like this: public static boolean isLineIn(Line.Info lineInfo) { Line.Info[] detected = AudioSystem.getSourceLineInfo(Port.Info.LINE_IN); for (Line.Info lineIn: detected) { if (lineIn.matches(lineInfo)...
Java sound recording and mixer settings I'm using the javax.sound.sampled package in a radio data mode decoding program. To use the program the user feeds audio from their radio receiver into their PC's line input. The user is also required to use their mixer program to select the line in as the recording input. The tr...
TITLE: Java sound recording and mixer settings QUESTION: I'm using the javax.sound.sampled package in a radio data mode decoding program. To use the program the user feeds audio from their radio receiver into their PC's line input. The user is also required to use their mixer program to select the line in as the recor...
[ "java", "javasound" ]
5
3
1,401
1
0
2008-09-12T21:54:42.860000
2008-09-13T22:43:22.860000
60,051
60,411
Referencing back to the parent from a child object
My question is pertaining to the best practice for accessing a child object's parent. So let's say a class instantiates another class, that class instance is now referenced with an object. From that child object, what is the best way to reference back to the parent object? Currently I know of a couple ways that I use o...
It's generally good to have the class as it's own instance and reduce tight coupling to something else (as in this case, it's parent). If you do something like parent.doSomething() it's not possible to use that class in container that doesn't have the doSometing() method. I think it's definitely better to pass in whate...
Referencing back to the parent from a child object My question is pertaining to the best practice for accessing a child object's parent. So let's say a class instantiates another class, that class instance is now referenced with an object. From that child object, what is the best way to reference back to the parent obj...
TITLE: Referencing back to the parent from a child object QUESTION: My question is pertaining to the best practice for accessing a child object's parent. So let's say a class instantiates another class, that class instance is now referenced with an object. From that child object, what is the best way to reference back...
[ "flash", "actionscript-3" ]
2
3
10,002
6
0
2008-09-12T21:55:24.137000
2008-09-13T08:27:47.580000
60,070
60,077
Is there a child's PID?
I am currently in an operating systems class and my teacher spent half of the class period talking about PIDs. She mentioned, as many know, that processes know their parent's ID. My question is this: Does a process's PCB know its child's ID? If so, what is the way to go about it obtaining it?
As far as I know a process doesn't have an explicit list of its children's PIDs, but it can easily be built, since a process should know which child processes it spawns. For example the UNIX fork() call returns the child PID in the parent process and 0 in the child process, CreateProcess() on Windows returns (IIRC) the...
Is there a child's PID? I am currently in an operating systems class and my teacher spent half of the class period talking about PIDs. She mentioned, as many know, that processes know their parent's ID. My question is this: Does a process's PCB know its child's ID? If so, what is the way to go about it obtaining it?
TITLE: Is there a child's PID? QUESTION: I am currently in an operating systems class and my teacher spent half of the class period talking about PIDs. She mentioned, as many know, that processes know their parent's ID. My question is this: Does a process's PCB know its child's ID? If so, what is the way to go about i...
[ "operating-system" ]
2
5
987
4
0
2008-09-12T22:08:42.623000
2008-09-12T22:13:34.437000
60,076
60,225
SQL Error OLE.INTEROP
I'm getting an error whenever I load Management Studio or open a folder in the server explorer, etc. Additionally, If I try to create a new database it constantly is updating and does not finish. I have attached a screenshot of the error. Please let me know what I can do to fix this because it's really aggravating. Err...
From MSDN forum http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=120476&SiteID=1
SQL Error OLE.INTEROP I'm getting an error whenever I load Management Studio or open a folder in the server explorer, etc. Additionally, If I try to create a new database it constantly is updating and does not finish. I have attached a screenshot of the error. Please let me know what I can do to fix this because it's r...
TITLE: SQL Error OLE.INTEROP QUESTION: I'm getting an error whenever I load Management Studio or open a folder in the server explorer, etc. Additionally, If I try to create a new database it constantly is updating and does not finish. I have attached a screenshot of the error. Please let me know what I can do to fix t...
[ "sql-server" ]
1
1
115
3
0
2008-09-12T22:12:43.847000
2008-09-13T00:55:48.510000
60,098
201,092
"Could not load type" in web service converted to VB.NET
I wrote a simple web service in C# using SharpDevelop (which I just got and I love). The client wanted it in VB, and fortunately there's a Convert To VB.NET feature. It's great. Translated all the code, and it builds. (I've been a "Notepad" guy for a long time, so I may seem a little old-fashioned.) But I get this erro...
In VB.NET, namespace declarations are relative to the default namespace of the project. So if the default namespace for the project is set to X.Y, everithyng between Namespace Z and End Namespace will be in the X.Y.Z namespace. In C# you have to provide the full namespace name, regardless of the default namespace of th...
"Could not load type" in web service converted to VB.NET I wrote a simple web service in C# using SharpDevelop (which I just got and I love). The client wanted it in VB, and fortunately there's a Convert To VB.NET feature. It's great. Translated all the code, and it builds. (I've been a "Notepad" guy for a long time, s...
TITLE: "Could not load type" in web service converted to VB.NET QUESTION: I wrote a simple web service in C# using SharpDevelop (which I just got and I love). The client wanted it in VB, and fortunately there's a Convert To VB.NET feature. It's great. Translated all the code, and it builds. (I've been a "Notepad" guy ...
[ "c#", "vb.net", "web-services", "translation", "sharpdevelop" ]
1
1
1,878
3
0
2008-09-12T22:38:38.027000
2008-10-14T13:11:31.630000
60,099
61,161
How do I get a particular labeled version of a folder in Borland StarTeam?
I'm about to perform a bunch of folder moving operations in StarTeam (including some new nesting levels) and I would like to set a label so that I can roll back in case of issues. I figured out how to set a label on a folder and all its children, but I couldn't figure out how to get the version of that folder correspon...
I've switched to Subversion and FogBugz so I am rusty on StarTeam. I think you need a View Label. From View menu, select Labels... to open the Labels dialog. On the View tab, click New... button to open View Label dialog. Type in label name as "Release 1.2.3.4", check Frozen, and hit OK. To get back to the state, From ...
How do I get a particular labeled version of a folder in Borland StarTeam? I'm about to perform a bunch of folder moving operations in StarTeam (including some new nesting levels) and I would like to set a label so that I can roll back in case of issues. I figured out how to set a label on a folder and all its children...
TITLE: How do I get a particular labeled version of a folder in Borland StarTeam? QUESTION: I'm about to perform a bunch of folder moving operations in StarTeam (including some new nesting levels) and I would like to set a label so that I can roll back in case of issues. I figured out how to set a label on a folder an...
[ "version-control", "starteam" ]
1
4
1,016
1
0
2008-09-12T22:38:56.717000
2008-09-14T06:27:26.567000
60,109
857,012
Good challenges/tasks/exercises for learning or improving object oriented programming (OOP) skills
What is a good challenge to improve your skills in object oriented programming? The idea behind this poll is to provide an idea of which exercises are useful for learning OOP. The challenge should be as language agnostic as possible, requiring either little or no use of specific libraries, or only the most common of li...
Building Skills in Object-Oriented Design is a free book that might be of use. The description is as follows: "The intent of this book is to help the beginning designer by giving them a sequence of interesting and moderately complex exercises in OO design. This book can also help managers develop a level of comfort wit...
Good challenges/tasks/exercises for learning or improving object oriented programming (OOP) skills What is a good challenge to improve your skills in object oriented programming? The idea behind this poll is to provide an idea of which exercises are useful for learning OOP. The challenge should be as language agnostic ...
TITLE: Good challenges/tasks/exercises for learning or improving object oriented programming (OOP) skills QUESTION: What is a good challenge to improve your skills in object oriented programming? The idea behind this poll is to provide an idea of which exercises are useful for learning OOP. The challenge should be as ...
[ "oop" ]
88
49
81,836
8
0
2008-09-12T22:45:09.633000
2009-05-13T09:38:29.780000
60,121
376,143
Silverlight Install Base - How big is it?
Silverlight v2.0 is getting closer and closer to RTM but I have yet to hear any stats as to how many browsers are running Silverlight. If I ask Adobe (by googling "Flash install base") they're only too happy to tell me that 97.7% of browsers are running Flash player 9 or better. Not that I believe everything I read, bu...
Quick Answer: www.riastats.com This site compares the different RIA plugins using graphical charts and graphs. It gets its data from small snippets of javascripts running on sites accross the web (approx 400,000 last time I looked) At the time of this post, Silverlight 2 was sitting at close to 11%. I would not take th...
Silverlight Install Base - How big is it? Silverlight v2.0 is getting closer and closer to RTM but I have yet to hear any stats as to how many browsers are running Silverlight. If I ask Adobe (by googling "Flash install base") they're only too happy to tell me that 97.7% of browsers are running Flash player 9 or better...
TITLE: Silverlight Install Base - How big is it? QUESTION: Silverlight v2.0 is getting closer and closer to RTM but I have yet to hear any stats as to how many browsers are running Silverlight. If I ask Adobe (by googling "Flash install base") they're only too happy to tell me that 97.7% of browsers are running Flash ...
[ "apache-flex", "silverlight", "installation" ]
14
20
6,766
16
0
2008-09-12T22:58:20.600000
2008-12-17T21:46:44.933000
60,122
60,146
Select rows in dataset table based on other dataset table
I have a dataset that has two tables in it. I want to do the following (or something like it) is it possible and is how I have it correct? dsTabData.Tables("FilingTabs").Select("fs_ID not in (select fsp_fsid from ParentTabs)") how do you reference data from other table in the same dataset?
ok ok before y'all flame me!;) I did some more looking around online and found what looks like the stuff I need, now off to read some more from here: Navigating a Relationship Between Tables
Select rows in dataset table based on other dataset table I have a dataset that has two tables in it. I want to do the following (or something like it) is it possible and is how I have it correct? dsTabData.Tables("FilingTabs").Select("fs_ID not in (select fsp_fsid from ParentTabs)") how do you reference data from othe...
TITLE: Select rows in dataset table based on other dataset table QUESTION: I have a dataset that has two tables in it. I want to do the following (or something like it) is it possible and is how I have it correct? dsTabData.Tables("FilingTabs").Select("fs_ID not in (select fsp_fsid from ParentTabs)") how do you refere...
[ ".net", "vb.net", "select", "dataset" ]
2
1
7,740
1
0
2008-09-12T22:58:20.880000
2008-09-12T23:25:14.513000
60,137
60,155
Technical issues when switching to an unmanaged Virtual Private Server (VPS) hosting provider?
I'm considering moving a number of small client sites to an unmanaged VPS hosting provider. I haven't decided which one yet, but my understanding is that they'll give me a base OS install (I'd prefer Debian or Ubuntu), an IP address, a root account, SSH, and that's about it. Ideally, I would like to create a complete V...
Slicehost ( referral link, if you so choose) offers reverse DNS, multiple IPs ($2/month/IP), Ubuntu/Debian (along with others). The only criteria it doesn't support is the ship-a-VM one, but it does let you clone VMs you've set up in their system via snapshots. You could thus set it up once, then copy that VM as many t...
Technical issues when switching to an unmanaged Virtual Private Server (VPS) hosting provider? I'm considering moving a number of small client sites to an unmanaged VPS hosting provider. I haven't decided which one yet, but my understanding is that they'll give me a base OS install (I'd prefer Debian or Ubuntu), an IP ...
TITLE: Technical issues when switching to an unmanaged Virtual Private Server (VPS) hosting provider? QUESTION: I'm considering moving a number of small client sites to an unmanaged VPS hosting provider. I haven't decided which one yet, but my understanding is that they'll give me a base OS install (I'd prefer Debian ...
[ "hosting", "virtualization", "vps", "reverse-dns" ]
2
1
476
2
0
2008-09-12T23:13:52.887000
2008-09-12T23:33:13.433000
60,142
60,154
Best way to determine the number of servers needed
How much traffic can one web server handle? What's the best way to see if we're beyond that? I have an ASP.Net application that has a couple hundred users. Aspects of it are fairly processor intensive, but thus far we have done fine with only one server to run both SqlServer and the site. It's running Windows Server 20...
What you need is some info on Capacity Planning.. Capacity planning is the process of planning for growth and forecasting peak usage periods in order to meet system and application capacity requirements. It involves extensive performance testing to establish the application's resource utilization and transaction throug...
Best way to determine the number of servers needed How much traffic can one web server handle? What's the best way to see if we're beyond that? I have an ASP.Net application that has a couple hundred users. Aspects of it are fairly processor intensive, but thus far we have done fine with only one server to run both Sql...
TITLE: Best way to determine the number of servers needed QUESTION: How much traffic can one web server handle? What's the best way to see if we're beyond that? I have an ASP.Net application that has a couple hundred users. Aspects of it are fairly processor intensive, but thus far we have done fine with only one serv...
[ "asp.net", "webserver", "capacity-planning" ]
8
7
6,884
4
0
2008-09-12T23:17:43.253000
2008-09-12T23:31:14.640000
60,143
60,166
Is it possible to embed and use a portable executable in a .net DLL?
The easiest way to think of my question is to think of a single, simple unix command (albeit, this is for windows) and I need progmatic access to run it. I have a single command-line based executable that performs some unit of work. I want to call that executable with the.net process library, as I can do with any other...
No, you can't execute it directly. You could probably unpack it to a temporary directory and execute it from there.
Is it possible to embed and use a portable executable in a .net DLL? The easiest way to think of my question is to think of a single, simple unix command (albeit, this is for windows) and I need progmatic access to run it. I have a single command-line based executable that performs some unit of work. I want to call tha...
TITLE: Is it possible to embed and use a portable executable in a .net DLL? QUESTION: The easiest way to think of my question is to think of a single, simple unix command (albeit, this is for windows) and I need progmatic access to run it. I have a single command-line based executable that performs some unit of work. ...
[ ".net", "dll", "command-line", "resources" ]
4
1
291
3
0
2008-09-12T23:21:04.243000
2008-09-12T23:43:50.333000
60,151
60,184
Whats the best way to do throbber in C#?
Specifically what I am looking to do is make the icons for the Nodes in my System.Windows.Forms.TreeView control to throb while a long loading operation is taking place.
If you load each frame into an ImageList, you can use a loop to update to each frame. Example: bool runThrobber = true; private void AnimateThrobber(TreeNode animatedNode) { BackgroundWorker bg = new BackgroundWorker(); bg.DoWork += new DoWorkEventHandler(delegate { while (runThrobber) { this.Invoke((MethodInvoker)dele...
Whats the best way to do throbber in C#? Specifically what I am looking to do is make the icons for the Nodes in my System.Windows.Forms.TreeView control to throb while a long loading operation is taking place.
TITLE: Whats the best way to do throbber in C#? QUESTION: Specifically what I am looking to do is make the icons for the Nodes in my System.Windows.Forms.TreeView control to throb while a long loading operation is taking place. ANSWER: If you load each frame into an ImageList, you can use a loop to update to each fra...
[ "c#", "treeview" ]
3
4
1,778
1
0
2008-09-12T23:27:39.173000
2008-09-13T00:08:10.137000
60,152
69,867
Automate firefox with python?
Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?
The PyXPCOM extension is one possibility. But looking at what firewatir provides, I have to 2nd the suggestion for twill. It's based on mechanize, which might also be useful in this context.
Automate firefox with python? Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?
TITLE: Automate firefox with python? QUESTION: Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions? ANSWER: The PyXPCOM extension is one possibility. But looking at what firewatir provides, I have to 2nd the suggestion for twill. It's based on me...
[ "python", "linux", "firefox", "ubuntu", "automation" ]
12
4
22,697
8
0
2008-09-12T23:28:16.830000
2008-09-16T06:41:51.757000
60,168
78,024
In what order are ON DELETE CASCADE constraints processed?
Here is an example of what I've got going on: CREATE TABLE Parent (id BIGINT NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB; CREATE TABLE Child (id BIGINT NOT NULL, parentid BIGINT NOT NULL, PRIMARY KEY (id), KEY (parentid), CONSTRAINT fk_parent FOREIGN KEY (parentid) REFERENCES Parent (id) ON DELETE CASCADE) ENGINE=InnoDB...
The parent deletion is triggering the child deletion as you stated and I don't know why it goes to the child table before the uncle table. I imagine you would have to look at the dbms code to know for sure, but im sure there is an algorithm that picks which tables to cascade to first. The system does not really 'figure...
In what order are ON DELETE CASCADE constraints processed? Here is an example of what I've got going on: CREATE TABLE Parent (id BIGINT NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB; CREATE TABLE Child (id BIGINT NOT NULL, parentid BIGINT NOT NULL, PRIMARY KEY (id), KEY (parentid), CONSTRAINT fk_parent FOREIGN KEY (parent...
TITLE: In what order are ON DELETE CASCADE constraints processed? QUESTION: Here is an example of what I've got going on: CREATE TABLE Parent (id BIGINT NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB; CREATE TABLE Child (id BIGINT NOT NULL, parentid BIGINT NOT NULL, PRIMARY KEY (id), KEY (parentid), CONSTRAINT fk_parent F...
[ "mysql", "database-design", "mysql-error-1451" ]
14
3
11,828
4
0
2008-09-12T23:46:52.777000
2008-09-16T22:38:24.373000
60,174
60,496
How can I prevent SQL injection in PHP?
If user input is inserted without modification into an SQL query, then the application becomes vulnerable to SQL injection, like in the following example: $unsafe_variable = $_POST['user_input']; mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')"); That's because the user can input something like...
The correct way to avoid SQL injection attacks, no matter which database you use, is to separate the data from SQL, so that data stays data and will never be interpreted as commands by the SQL parser. It is possible to create an SQL statement with correctly formatted data parts, but if you don't fully understand the de...
How can I prevent SQL injection in PHP? If user input is inserted without modification into an SQL query, then the application becomes vulnerable to SQL injection, like in the following example: $unsafe_variable = $_POST['user_input']; mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')"); That's b...
TITLE: How can I prevent SQL injection in PHP? QUESTION: If user input is inserted without modification into an SQL query, then the application becomes vulnerable to SQL injection, like in the following example: $unsafe_variable = $_POST['user_input']; mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_vari...
[ "php", "mysql", "sql", "security", "sql-injection" ]
2,773
9,660
2,183,595
27
0
2008-09-12T23:55:00.900000
2008-09-13T12:30:26.950000
60,204
60,228
Multiple permission types (roles) stored in database as single decimal
I was going to ask a question here about whether or not my design for some users/roles database tables was acceptable, but after some research I came across this question: What is the best way to handle multiple permission types? It sounds like an innovative approach, so instead of a many-to-many relationship users_to_...
You use bitwise operations. The pseudo-code would be something like: bool HasPermission(User user, Permission permission) { return (user.Permission & permission)!= 0; } void SetPermission(User user, Permission permission) { user.Permission |= permission; } void ClearPermission(User user, Permission permission) { user...
Multiple permission types (roles) stored in database as single decimal I was going to ask a question here about whether or not my design for some users/roles database tables was acceptable, but after some research I came across this question: What is the best way to handle multiple permission types? It sounds like an i...
TITLE: Multiple permission types (roles) stored in database as single decimal QUESTION: I was going to ask a question here about whether or not my design for some users/roles database tables was acceptable, but after some research I came across this question: What is the best way to handle multiple permission types? I...
[ "database", "permissions", "roles" ]
9
7
4,631
2
0
2008-09-13T00:25:58.253000
2008-09-13T00:58:29.343000
60,208
60,211
Replacements for switch statement in Python?
I want to write a function in Python that returns different fixed values based on the value of an input index. In other languages I would use a switch or case statement, but Python does not appear to have a switch statement. What are the recommended Python solutions in this scenario?
Python 3.10 (2021) introduced the match - case statement, which provides a first-class implementation of a "switch" for Python. For example: def f(x): match x: case 'a': return 1 case 'b': return 2 case _: return 0 # 0 is the default case if x is not found The match - case statement is considerably more powerful than t...
Replacements for switch statement in Python? I want to write a function in Python that returns different fixed values based on the value of an input index. In other languages I would use a switch or case statement, but Python does not appear to have a switch statement. What are the recommended Python solutions in this ...
TITLE: Replacements for switch statement in Python? QUESTION: I want to write a function in Python that returns different fixed values based on the value of an input index. In other languages I would use a switch or case statement, but Python does not appear to have a switch statement. What are the recommended Python ...
[ "python", "switch-statement" ]
1,717
2,183
2,280,405
44
0
2008-09-13T00:36:30.847000
2008-09-13T00:38:24.353000
60,213
60,217
Why won't my local Apache open html pages?
so, I'm running Apache on my laptop. If I go to "localhost", I get the page that says, If you can see this, it means that the installation of the Apache web server software on this system was successful. You may now add content to this directory and replace this page. except, I can't add content and replace that page. ...
"By default, your pages should be placed in the "C:\Program Files\Apache Group\Apache2\htdocs" folder for Apache 2.0 and the "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" folder for Apache 2.2. When your site is ready, simply delete the existing files in the folder and replace them with those you want ...
Why won't my local Apache open html pages? so, I'm running Apache on my laptop. If I go to "localhost", I get the page that says, If you can see this, it means that the installation of the Apache web server software on this system was successful. You may now add content to this directory and replace this page. except, ...
TITLE: Why won't my local Apache open html pages? QUESTION: so, I'm running Apache on my laptop. If I go to "localhost", I get the page that says, If you can see this, it means that the installation of the Apache web server software on this system was successful. You may now add content to this directory and replace t...
[ "apache" ]
4
4
14,272
3
0
2008-09-13T00:38:31.403000
2008-09-13T00:44:25.820000
60,221
60,226
How to animate the command line?
I have always wondered how people update a previous line in a command line. a great example of this is when using the wget command in linux. It creates an ASCII loading bar of sorts that looks like this: [======> ] 37% and of course the loading bar moves and the percent changes, But it doesn't make a new line. I cannot...
There are two ways I know of to do this: Use the backspace escape character ('\b') to erase your line Use the curses package, if your programming language of choice has bindings for it. And a Google revealed ANSI Escape Codes, which appear to be a good way. For reference, here is a function in C++ to do this: void Draw...
How to animate the command line? I have always wondered how people update a previous line in a command line. a great example of this is when using the wget command in linux. It creates an ASCII loading bar of sorts that looks like this: [======> ] 37% and of course the loading bar moves and the percent changes, But it ...
TITLE: How to animate the command line? QUESTION: I have always wondered how people update a previous line in a command line. a great example of this is when using the wget command in linux. It creates an ASCII loading bar of sorts that looks like this: [======> ] 37% and of course the loading bar moves and the percen...
[ "command-line" ]
81
46
42,922
8
0
2008-09-13T00:53:10.997000
2008-09-13T00:56:00.240000
60,244
60,254
Is there replacement for cat on Windows
I need to join two binary files with a *.bat script on Windows. How can I achieve that?
Windows type command works similarly to UNIX cat. Example 1: type file1 file2 > file3 is equivalent of: cat file1 file2 > file3 Example 2: type *.vcf > all_in_one.vcf This command will merge all the vcards into one.
Is there replacement for cat on Windows I need to join two binary files with a *.bat script on Windows. How can I achieve that?
TITLE: Is there replacement for cat on Windows QUESTION: I need to join two binary files with a *.bat script on Windows. How can I achieve that? ANSWER: Windows type command works similarly to UNIX cat. Example 1: type file1 file2 > file3 is equivalent of: cat file1 file2 > file3 Example 2: type *.vcf > all_in_one.vc...
[ "windows", "command-line", "scripting" ]
349
503
532,036
11
0
2008-09-13T01:28:06.043000
2008-09-13T01:53:10.320000
60,256
60,258
How do you balance fun feature creep with time constraints?
I enjoy programming, usually. Tedious stuff is easy to get done as quickly and correctly as possible so I can get through it and not have to see it again. But a lot of my coding is fun and when I get in the 'zone' I just really enjoy myself. Which is where I make the mistake of spending too much time, perhaps adding fe...
Keep a detailed prioritized feature list/bug list. review it often then balance the fun work with bugs/features that need to get done.
How do you balance fun feature creep with time constraints? I enjoy programming, usually. Tedious stuff is easy to get done as quickly and correctly as possible so I can get through it and not have to see it again. But a lot of my coding is fun and when I get in the 'zone' I just really enjoy myself. Which is where I m...
TITLE: How do you balance fun feature creep with time constraints? QUESTION: I enjoy programming, usually. Tedious stuff is easy to get done as quickly and correctly as possible so I can get through it and not have to see it again. But a lot of my coding is fun and when I get in the 'zone' I just really enjoy myself. ...
[ "project-management" ]
3
6
298
5
0
2008-09-13T01:57:34.553000
2008-09-13T02:01:36.290000
60,259
395,358
How to load an xml string in the code behind to databound UI controls that bind to the XPath of the XML?
Every sample that I have seen uses static XML in the xmldataprovider source, which is then used to databind UI controls using XPath binding. Idea is to edit a dynamic XML (structure known to the developer during coding), using the WPF UI. Has anyone found a way to load a dynamic xml string (for example load it from a f...
Here is some code I used to load a XML file from disk and bind it to a TreeView. I removed some of the normal tests for conciseness. The XML in the example is an OPML file. XmlDataProvider provider = new XmlDataProvider(); if (provider!= null) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(fileN...
How to load an xml string in the code behind to databound UI controls that bind to the XPath of the XML? Every sample that I have seen uses static XML in the xmldataprovider source, which is then used to databind UI controls using XPath binding. Idea is to edit a dynamic XML (structure known to the developer during cod...
TITLE: How to load an xml string in the code behind to databound UI controls that bind to the XPath of the XML? QUESTION: Every sample that I have seen uses static XML in the xmldataprovider source, which is then used to databind UI controls using XPath binding. Idea is to edit a dynamic XML (structure known to the de...
[ "wpf", "xml", "data-binding", "xpath", "xmldataprovider" ]
3
2
5,492
2
0
2008-09-13T02:02:00.033000
2008-12-27T20:15:38.287000
60,260
60,267
My first Lisp macro; is it leaky?
I've been working through Practical Common Lisp and as an exercise decided to write a macro to determine if a number is a multiple of another number: (defmacro multp (value factor) `(= (rem,value,factor) 0)) so that: (multp 40 10) evaluates to true whilst (multp 40 13) does not The question is does this macro leak in s...
Siebel gives an extensive rundown (for simple cases anyway) of possible sources of leaks, and there aren't any of those here. Both value and factor are evaluated only once and in order, and rem doesn't have any side effects. This is not good Lisp though, because there's no reason to use a macro in this case. A function...
My first Lisp macro; is it leaky? I've been working through Practical Common Lisp and as an exercise decided to write a macro to determine if a number is a multiple of another number: (defmacro multp (value factor) `(= (rem,value,factor) 0)) so that: (multp 40 10) evaluates to true whilst (multp 40 13) does not The que...
TITLE: My first Lisp macro; is it leaky? QUESTION: I've been working through Practical Common Lisp and as an exercise decided to write a macro to determine if a number is a multiple of another number: (defmacro multp (value factor) `(= (rem,value,factor) 0)) so that: (multp 40 10) evaluates to true whilst (multp 40 13...
[ "macros", "lisp" ]
5
11
737
4
0
2008-09-13T02:04:20.153000
2008-09-13T02:21:26.400000
60,269
61,982
How to implement draggable tab using Java Swing?
How do I implement a draggable tab using Java Swing? Instead of the static JTabbedPane I would like to drag-and-drop a tab to different position to rearrange the tabs. EDIT: The Java Tutorials - Drag and Drop and Data Transfer.
I liked Terai Atsuhiro san's DnDTabbedPane, but I wanted more from it. The original Terai implementation transfered tabs within the TabbedPane, but it would be nicer if I could drag from one TabbedPane to another. Inspired by @ Tom 's effort, I decided to modify the code myself. There are some details I added. For exam...
How to implement draggable tab using Java Swing? How do I implement a draggable tab using Java Swing? Instead of the static JTabbedPane I would like to drag-and-drop a tab to different position to rearrange the tabs. EDIT: The Java Tutorials - Drag and Drop and Data Transfer.
TITLE: How to implement draggable tab using Java Swing? QUESTION: How do I implement a draggable tab using Java Swing? Instead of the static JTabbedPane I would like to drag-and-drop a tab to different position to rearrange the tabs. EDIT: The Java Tutorials - Drag and Drop and Data Transfer. ANSWER: I liked Terai At...
[ "java", "user-interface", "swing", "tabs" ]
37
14
19,017
5
0
2008-09-13T02:25:54.563000
2008-09-15T07:41:08.797000
60,271
2,997,758
Best way to write a Safari 4 Extension
What is the best way to write a Safari extension? I've written a couple XUL extensions for Firefox, and now I'd like to write versions of them for Safari. Is there a way that would allow you to add buttons or forms to the browser UI, since this is not possible with an Input manager or Service menu?
With the release of Safari 5.0, Apple released a new extension framework for developers to use. In features it looks similar to Firefox extension framework allowing to customize buttons, toolbars, context menus, injections using javascript and html 5 More at this link https://developer.apple.com/documentation/safariext...
Best way to write a Safari 4 Extension What is the best way to write a Safari extension? I've written a couple XUL extensions for Firefox, and now I'd like to write versions of them for Safari. Is there a way that would allow you to add buttons or forms to the browser UI, since this is not possible with an Input manage...
TITLE: Best way to write a Safari 4 Extension QUESTION: What is the best way to write a Safari extension? I've written a couple XUL extensions for Firefox, and now I'd like to write versions of them for Safari. Is there a way that would allow you to add buttons or forms to the browser UI, since this is not possible wi...
[ "plugins", "safari" ]
14
8
11,557
8
0
2008-09-13T02:30:32.493000
2010-06-08T13:38:34.923000
60,274
60,275
What are some good rigid body dynamics references?
I'm not a math guy in the least but I'm interested in learning about rigid body physics (for the purpose of implementing a basic 3d physics engine). In school I only took Maths through Algebra II, but I've done 3d dev for years so I have a fairly decent understanding of vectors, quaternions, matrices, etc. My real prob...
Physics for Game Programmers I think is better than Physics for Game Developers. If you want something thick in your bookshelf (like I do), Eberly's 3D Game Engine Design and Erleben's Physics-Based Animation can accompany the above.
What are some good rigid body dynamics references? I'm not a math guy in the least but I'm interested in learning about rigid body physics (for the purpose of implementing a basic 3d physics engine). In school I only took Maths through Algebra II, but I've done 3d dev for years so I have a fairly decent understanding o...
TITLE: What are some good rigid body dynamics references? QUESTION: I'm not a math guy in the least but I'm interested in learning about rigid body physics (for the purpose of implementing a basic 3d physics engine). In school I only took Maths through Algebra II, but I've done 3d dev for years so I have a fairly dece...
[ "math", "physics" ]
7
4
1,998
5
0
2008-09-13T02:37:13.383000
2008-09-13T02:40:58.100000
60,285
60,358
If possible how can one embed PostgreSQL?
If it's possible, I'm interested in being able to embed a PostgreSQL database, similar to sqllite. I've read that it's not possible. I'm no database expert though, so I want to hear from you. Essentially I want PostgreSQL without all the configuration and installation. If it's possible, tell me how.
Unless you do a major rewrite of code, it is not possible to run Postgres "embedded". Either run it as a separate process or use something else. SQLite is an excellent choice. But there are others. MySQL has an embedded version. See it at http://mysql.com/oem/. Also several java choices, and Mac has Core Data you can w...
If possible how can one embed PostgreSQL? If it's possible, I'm interested in being able to embed a PostgreSQL database, similar to sqllite. I've read that it's not possible. I'm no database expert though, so I want to hear from you. Essentially I want PostgreSQL without all the configuration and installation. If it's ...
TITLE: If possible how can one embed PostgreSQL? QUESTION: If it's possible, I'm interested in being able to embed a PostgreSQL database, similar to sqllite. I've read that it's not possible. I'm no database expert though, so I want to hear from you. Essentially I want PostgreSQL without all the configuration and inst...
[ "database", "postgresql", "embedded-database" ]
39
10
24,871
8
0
2008-09-13T02:59:22.657000
2008-09-13T06:06:24.800000
60,290
60,295
Can I change the appearance of an html image during hover without a second image?
Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)?
Here's some good information about image opacity and transparency with CSS. So to make an image with opacity 50%, you'd do this: The opacity: part is how Firefox does it, and it's a value between 0.0 and 1.0. filter: is how IE does it, and it's a value from 0 to 100.
Can I change the appearance of an html image during hover without a second image? Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)?
TITLE: Can I change the appearance of an html image during hover without a second image? QUESTION: Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)? ANSWER: Here's some goo...
[ "html", "css", "image" ]
4
9
5,192
4
0
2008-09-13T03:10:18.403000
2008-09-13T03:17:12.647000
60,293
60,339
Listview background drawing problem C# Winform
I have a little problem with a Listview. I can load it with listview items fine, but when I set the background color it doesn't draw the color all the way to the left side of the row [The listViewItems are loaded with ListViewSubItems to make a grid view, only the first column shows the error]. There is a a narrow stri...
Ah! I see now:} You want hacky? I present unto you the following:... lv.OwnerDraw = true; lv.DrawItem += new DrawListViewItemEventHandler( lv_DrawItem );... void lv_DrawItem( object sender, DrawListViewItemEventArgs e ) { Rectangle foo = e.Bounds; foo.Offset( -10, 0 ); e.Graphics.FillRectangle( new SolidBrush( e.Item....
Listview background drawing problem C# Winform I have a little problem with a Listview. I can load it with listview items fine, but when I set the background color it doesn't draw the color all the way to the left side of the row [The listViewItems are loaded with ListViewSubItems to make a grid view, only the first co...
TITLE: Listview background drawing problem C# Winform QUESTION: I have a little problem with a Listview. I can load it with listview items fine, but when I set the background color it doesn't draw the color all the way to the left side of the row [The listViewItems are loaded with ListViewSubItems to make a grid view,...
[ "c#", "winforms", "listview" ]
3
5
8,180
4
0
2008-09-13T03:12:48.290000
2008-09-13T05:10:44.073000
60,302
60,578
Starting a process with inherited stdin/stdout/stderr in Java 6
If I start a process via Java's ProcessBuilder class, I have full access to that process's standard in, standard out, and standard error streams as Java InputStreams and OutputStreams. However, I can't find a way to seamlessly connect those streams to System.in, System.out, and System.err. It's possible to use redirect...
You will need to copy the Process out, err, and input streams to the System versions. The easiest way to do that is using the IOUtils class from the Commons IO package. The copy method looks to be what you need. The copy method invocations will need to be in separate threads. Here is the basic code: // Assume you alrea...
Starting a process with inherited stdin/stdout/stderr in Java 6 If I start a process via Java's ProcessBuilder class, I have full access to that process's standard in, standard out, and standard error streams as Java InputStreams and OutputStreams. However, I can't find a way to seamlessly connect those streams to Syst...
TITLE: Starting a process with inherited stdin/stdout/stderr in Java 6 QUESTION: If I start a process via Java's ProcessBuilder class, I have full access to that process's standard in, standard out, and standard error streams as Java InputStreams and OutputStreams. However, I can't find a way to seamlessly connect tho...
[ "java", "io", "process", "pipe" ]
28
16
13,565
3
0
2008-09-13T03:27:59.720000
2008-09-13T14:51:41.387000
60,330
60,334
What function does a tag cloud serve?
I see them all the time and always ignore them. Can someone explain to me why they have become so prevalent? If I'm using a site that allows me to explore it via tags (e.g., this one, del.icio.us, etc.) that's what I will do. Why would I need a "cloud" of tags upon which to click? I can just type that tag(s) into a sea...
It's more of a browse assist than a search assist. If you see a large or bold tag in a tag cloud that interests you it my lead to some knowledge discovery that wouldn't have otherwise been sought out with a deliberate search. When I am browsing del.ico.us or stackoverflow I appreciate the tags as they sometimes lead me...
What function does a tag cloud serve? I see them all the time and always ignore them. Can someone explain to me why they have become so prevalent? If I'm using a site that allows me to explore it via tags (e.g., this one, del.icio.us, etc.) that's what I will do. Why would I need a "cloud" of tags upon which to click? ...
TITLE: What function does a tag cloud serve? QUESTION: I see them all the time and always ignore them. Can someone explain to me why they have become so prevalent? If I'm using a site that allows me to explore it via tags (e.g., this one, del.icio.us, etc.) that's what I will do. Why would I need a "cloud" of tags upo...
[ "tags" ]
5
15
2,478
7
0
2008-09-13T04:37:18.023000
2008-09-13T04:46:01.187000
60,352
60,506
Can distutils create empty __init__.py files?
If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation?
Is there a reason you want to avoid putting empty __init__.py files in version control? If you do this you won't be able to import your packages from the source directory wihout first running distutils. If you really want to, I suppose you can create __init__.py in setup.py. It has to be before running distutils.setup,...
Can distutils create empty __init__.py files? If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation?
TITLE: Can distutils create empty __init__.py files? QUESTION: If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation? ANSWER: Is there a reason you want to avoid putting empty __init__.py files in ...
[ "python", "version-control", "distutils" ]
0
4
1,628
2
0
2008-09-13T05:51:17.097000
2008-09-13T12:46:50.657000