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
159,914
159,989
CSS/JavaScript Use Div to grey out section of page
Does anybody know a way with JavaScript or CSS to basically grey out a certain part of a form/div in HTML? I have a ' User Profile ' form where I want to disable part of it for a ' Non-Premium ' member, but want the user to see what is behind the form and place a ' Call to Action ' on top of it. Does anybody know an ea...
You might try the jQuery BlockUI plugin. It's quite flexible and is very easy to use, if you don't mind the dependency on jQuery. It supports element-level blocking as well an overlay message, which seems to be what you need. The code to use it is as simple as: $('div.profileform').block({ message: ' Premium Users only...
CSS/JavaScript Use Div to grey out section of page Does anybody know a way with JavaScript or CSS to basically grey out a certain part of a form/div in HTML? I have a ' User Profile ' form where I want to disable part of it for a ' Non-Premium ' member, but want the user to see what is behind the form and place a ' Cal...
TITLE: CSS/JavaScript Use Div to grey out section of page QUESTION: Does anybody know a way with JavaScript or CSS to basically grey out a certain part of a form/div in HTML? I have a ' User Profile ' form where I want to disable part of it for a ' Non-Premium ' member, but want the user to see what is behind the form...
[ "javascript", "css" ]
46
41
81,363
5
0
2008-10-01T21:49:42.567000
2008-10-01T22:09:15.890000
159,916
159,953
Confused on count(*) and self joins
I want to return all application dates for the current month and for the current year. This must be simple, however I can not figure it out. I know I have 2 dates for the current month and 90 dates for the current year. Right, Left, Outer, Inner I have tried them all, just throwing code at the wall trying to see what w...
You don't need any joins at all. You want to count the loanID column from tblEventDates, and you want to do it conditionally based on the date matching the current month or the current year. SO: SELECT SUM( CASE WHEN Month(a.evdtApplication) = MONTH(GEtDate() THEN 1 END) as monthTotal, count(*) FROM tblEventDates a WHE...
Confused on count(*) and self joins I want to return all application dates for the current month and for the current year. This must be simple, however I can not figure it out. I know I have 2 dates for the current month and 90 dates for the current year. Right, Left, Outer, Inner I have tried them all, just throwing c...
TITLE: Confused on count(*) and self joins QUESTION: I want to return all application dates for the current month and for the current year. This must be simple, however I can not figure it out. I know I have 2 dates for the current month and 90 dates for the current year. Right, Left, Outer, Inner I have tried them al...
[ "sql", "join", "self-join" ]
0
6
969
1
0
2008-10-01T21:49:57.653000
2008-10-01T21:59:02.607000
159,924
160,365
How do I loop through a MySQL query via PDO in PHP?
I'm slowly moving all of my LAMP websites from mysql_ functions to PDO functions and I've hit my first brick wall. I don't know how to loop through results with a parameter. I am fine with the following: foreach ($database->query("SELECT * FROM widgets") as $results) { echo $results["widget_name"]; } However if I want ...
Here is an example for using PDO to connect to a DB, to tell it to throw Exceptions instead of php errors (will help with your debugging), and using parameterised statements instead of substituting dynamic values into the query yourself (highly recommended): // connect to PDO $pdo = new PDO("mysql:host=localhost;dbname...
How do I loop through a MySQL query via PDO in PHP? I'm slowly moving all of my LAMP websites from mysql_ functions to PDO functions and I've hit my first brick wall. I don't know how to loop through results with a parameter. I am fine with the following: foreach ($database->query("SELECT * FROM widgets") as $results) ...
TITLE: How do I loop through a MySQL query via PDO in PHP? QUESTION: I'm slowly moving all of my LAMP websites from mysql_ functions to PDO functions and I've hit my first brick wall. I don't know how to loop through results with a parameter. I am fine with the following: foreach ($database->query("SELECT * FROM widge...
[ "php", "mysql", "pdo" ]
32
77
60,786
3
0
2008-10-01T21:52:17.880000
2008-10-02T00:24:56.530000
159,925
160,081
How do I make a ListView row draggable in .NET?
I am not the most experienced GUI programmer, so bear with me here. I have a custom list view. I would like to be able to drag a row from the ListView to another control on a form. I know how to catch events that are fired when an object is dragged to a control, but I am not sure how to make a row itself draggable. I c...
http://www.c-sharpcorner.com/UploadFile/skulkarni/ImlementingDragandDropinListViewControls11252005035642AM/ImlementingDragandDropinListViewControls.aspx
How do I make a ListView row draggable in .NET? I am not the most experienced GUI programmer, so bear with me here. I have a custom list view. I would like to be able to drag a row from the ListView to another control on a form. I know how to catch events that are fired when an object is dragged to a control, but I am ...
TITLE: How do I make a ListView row draggable in .NET? QUESTION: I am not the most experienced GUI programmer, so bear with me here. I have a custom list view. I would like to be able to drag a row from the ListView to another control on a form. I know how to catch events that are fired when an object is dragged to a ...
[ ".net", "winforms", "controls" ]
0
0
148
1
0
2008-10-01T21:52:19.393000
2008-10-01T22:37:56.350000
159,926
160,067
Is there any reasonable way to migrate from subversion to cvs?
My company unwittingly switched from cvs to subversion and now we're all wishing we had cvs back. I know there's tools to migrate history and changes from cvs to svn and there's no equivalent to do the reverse. Any suggestions or ideas on how to do this?
I originally added this as a comment to someone else's answer, but then realized that it was an answer, of sorts. I have done these sorts of transitions before, where there was no existing way to convert from one SCM system to another. It's not rocket science to write a script that takes the list of commits from your S...
Is there any reasonable way to migrate from subversion to cvs? My company unwittingly switched from cvs to subversion and now we're all wishing we had cvs back. I know there's tools to migrate history and changes from cvs to svn and there's no equivalent to do the reverse. Any suggestions or ideas on how to do this?
TITLE: Is there any reasonable way to migrate from subversion to cvs? QUESTION: My company unwittingly switched from cvs to subversion and now we're all wishing we had cvs back. I know there's tools to migrate history and changes from cvs to svn and there's no equivalent to do the reverse. Any suggestions or ideas on ...
[ "svn", "migration", "cvs" ]
5
25
3,681
13
0
2008-10-01T21:52:36.320000
2008-10-01T22:35:13.347000
159,928
163,154
Animating a custom Button ControlTemplate Foreground
I want to change/animate the Foreground property of a custom button control template depending on the control's state. Pre-RC0, I set the Foreground of the ContentPresenter, gave it an x:Name, and referenced it in the VisualStateManager transitions. Now, ContentPresenter no longer has a Foreground, since it doesn't inh...
There is a post from Jesse Liberty dealing with this issue. In a few words, the idea is that you can't, because you would be forcing any content in the button to have a specific foreground colour, and that decision should be left to the content itself. Anyway, perhaps you may want to take a look at the concept of hijac...
Animating a custom Button ControlTemplate Foreground I want to change/animate the Foreground property of a custom button control template depending on the control's state. Pre-RC0, I set the Foreground of the ContentPresenter, gave it an x:Name, and referenced it in the VisualStateManager transitions. Now, ContentPrese...
TITLE: Animating a custom Button ControlTemplate Foreground QUESTION: I want to change/animate the Foreground property of a custom button control template depending on the control's state. Pre-RC0, I set the Foreground of the ContentPresenter, gave it an x:Name, and referenced it in the VisualStateManager transitions....
[ ".net", "silverlight", "silverlight-2-rc0" ]
2
2
1,354
4
0
2008-10-01T21:53:15.163000
2008-10-02T15:56:32.347000
159,934
159,968
One To Many To Itself
How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I'm working on an app to track animal breeding. Each animal has an ID; it's also got a sire ID and a dame ID. So it's possible to have a one to many from the sire or dame to its offspring. I would be inclined...
Well, this is a "normal" one-to-many relationship and the method you suggest is the classical one for solving it. Note that two tables are denormalized (I can't point out exactly where the superkey-is-not-well-should-be-subset-of-other-key-fsck-I-forgot part is, but I'm pretty sure it's there somewhere); the intuitive ...
One To Many To Itself How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I'm working on an app to track animal breeding. Each animal has an ID; it's also got a sire ID and a dame ID. So it's possible to have a one to many from the sire or dame to its offsprin...
TITLE: One To Many To Itself QUESTION: How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I'm working on an app to track animal breeding. Each animal has an ID; it's also got a sire ID and a dame ID. So it's possible to have a one to many from the sire or da...
[ "database-design", "data-modeling", "table-structure" ]
5
6
8,184
9
0
2008-10-01T21:54:29.187000
2008-10-01T22:04:42.937000
159,961
160,955
Subsonic and sp_help_job
Is it possible for subsonic to access dbo.sp_help_job?
SubSonic is an ORM tool that also wraps SP's but does not generate code for system SP's and the project is open source so you can edit the code to your need
Subsonic and sp_help_job Is it possible for subsonic to access dbo.sp_help_job?
TITLE: Subsonic and sp_help_job QUESTION: Is it possible for subsonic to access dbo.sp_help_job? ANSWER: SubSonic is an ORM tool that also wraps SP's but does not generate code for system SP's and the project is open source so you can edit the code to your need
[ "subsonic" ]
0
2
140
1
0
2008-10-01T22:01:57.967000
2008-10-02T05:06:47.837000
159,978
159,993
C# - Keyword usage virtual+override vs. new
What are differences between declaring a method in a base type " virtual " and then overriding it in a child type using the " override " keyword as opposed to simply using the " new " keyword when declaring the matching method in the child type?
The "new" keyword doesn't override, it signifies a new method that has nothing to do with the base class method. public class Foo { public bool DoSomething() { return false; } } public class Bar: Foo { public new bool DoSomething() { return true; } } public class Test { public static void Main () { Foo test = new Bar...
C# - Keyword usage virtual+override vs. new What are differences between declaring a method in a base type " virtual " and then overriding it in a child type using the " override " keyword as opposed to simply using the " new " keyword when declaring the matching method in the child type?
TITLE: C# - Keyword usage virtual+override vs. new QUESTION: What are differences between declaring a method in a base type " virtual " and then overriding it in a child type using the " override " keyword as opposed to simply using the " new " keyword when declaring the matching method in the child type? ANSWER: The...
[ "c#", "syntax", "overriding", "method-hiding", "member-hiding" ]
228
202
74,153
11
0
2008-10-01T22:06:52.400000
2008-10-01T22:10:01.223000
159,983
160,003
How can I create a temporary file for writing in C++ on a Linux platform?
In C++, on Linux, how can I write a function to return a temporary filename that I can then open for writing? The filename should be as unique as possible, so that another process using the same function won't get the same name.
Use one of the standard library "mktemp" functions: mktemp/mkstemp/mkstemps/mkdtemp. Edit: plain mktemp can be insecure - mkstemp is preferred.
How can I create a temporary file for writing in C++ on a Linux platform? In C++, on Linux, how can I write a function to return a temporary filename that I can then open for writing? The filename should be as unique as possible, so that another process using the same function won't get the same name.
TITLE: How can I create a temporary file for writing in C++ on a Linux platform? QUESTION: In C++, on Linux, how can I write a function to return a temporary filename that I can then open for writing? The filename should be as unique as possible, so that another process using the same function won't get the same name....
[ "c++", "linux", "temporary-files" ]
11
18
9,047
7
0
2008-10-01T22:08:08.700000
2008-10-01T22:13:18.673000
159,990
160,227
What is the difference between Ruby and Python versions of"self"?
I've done some Python but have just now starting to use Ruby I could use a good explanation of the difference between "self" in these two languages. Obvious on first glance: Self is not a keyword in Python, but there is a "self-like" value no matter what you call it. Python methods receive self as an explicit argument,...
Python is designed to support more than just object-oriented programming. Preserving the same interface between methods and functions lets the two styles interoperate more cleanly. Ruby was built from the ground up to be object-oriented. Even the literals are objects (evaluate 1.class and you get Fixnum). The language ...
What is the difference between Ruby and Python versions of"self"? I've done some Python but have just now starting to use Ruby I could use a good explanation of the difference between "self" in these two languages. Obvious on first glance: Self is not a keyword in Python, but there is a "self-like" value no matter what...
TITLE: What is the difference between Ruby and Python versions of"self"? QUESTION: I've done some Python but have just now starting to use Ruby I could use a good explanation of the difference between "self" in these two languages. Obvious on first glance: Self is not a keyword in Python, but there is a "self-like" va...
[ "python", "ruby", "language-features" ]
6
8
1,572
4
0
2008-10-01T22:09:16.013000
2008-10-01T23:32:01.760000
160,022
162,013
Determine if a resource exists in ResourceManager
Is there anyway to determine if a ResourceManager contains a named resource? Currently I am catching the MissingManifestResourceException but I hate having to use Exceptions for non-exceptional situations. There must be some way to enumerate the name value pairs of a ResourceManager through reflection, or something? ED...
You can use the ResourceSet to do that, only it loads all the data into memory if you enumerate it. Here y'go: // At startup. ResourceManager mgr = Resources.ResourceManager; List keys = new List (); ResourceSet set = mgr.GetResourceSet(CultureInfo.CurrentCulture, true, true); foreach (DictionaryEntry o in set) { keys...
Determine if a resource exists in ResourceManager Is there anyway to determine if a ResourceManager contains a named resource? Currently I am catching the MissingManifestResourceException but I hate having to use Exceptions for non-exceptional situations. There must be some way to enumerate the name value pairs of a Re...
TITLE: Determine if a resource exists in ResourceManager QUESTION: Is there anyway to determine if a ResourceManager contains a named resource? Currently I am catching the MissingManifestResourceException but I hate having to use Exceptions for non-exceptional situations. There must be some way to enumerate the name v...
[ "c#", "resources" ]
19
24
21,667
2
0
2008-10-01T22:18:49.330000
2008-10-02T12:28:01.427000
160,032
160,061
Does dependency injection break the Law of Demeter
I have been adding dependency injection to my code because it makes by code much easier to Unit test through mocking. However I am requiring objects higher up my call chain to have knowledge of objects further down the call chain. Does this break the Law of Demeter? If so does it matter? for example: a class A has a de...
Dependency Injection CAN break the Law of Demeter. If you force consumers to do the injection of the dependencies. This can be avoided through static factory methods, and DI frameworks. You can have both by designing your objects in such a way that they require the dependencies be passed in, and at the same time having...
Does dependency injection break the Law of Demeter I have been adding dependency injection to my code because it makes by code much easier to Unit test through mocking. However I am requiring objects higher up my call chain to have knowledge of objects further down the call chain. Does this break the Law of Demeter? If...
TITLE: Does dependency injection break the Law of Demeter QUESTION: I have been adding dependency injection to my code because it makes by code much easier to Unit test through mocking. However I am requiring objects higher up my call chain to have knowledge of objects further down the call chain. Does this break the ...
[ "oop" ]
16
13
3,074
8
0
2008-10-01T22:22:10.197000
2008-10-01T22:34:26.500000
160,040
162,093
Finding the time taken to send messages with WCF net.tcp
I’m writing a prototype WCF enabled distributed app, to try and find out any issues I’ll have upgrading my existing “sending xml over tcp to communicate” apps I’ve got. I’m using Callback Contracts to register clients with a server (Singleton in ServiceHost) and so far all the communications between client and server w...
David is right about the problems with clock synchronization. However, adding the timestamp information outside of the service/client implementation is not hard at all on WCF. You're right it doesn't support SoapExtensions, though, in fact, it has a much richer set of extensibility point. In your specific case, I think...
Finding the time taken to send messages with WCF net.tcp I’m writing a prototype WCF enabled distributed app, to try and find out any issues I’ll have upgrading my existing “sending xml over tcp to communicate” apps I’ve got. I’m using Callback Contracts to register clients with a server (Singleton in ServiceHost) and ...
TITLE: Finding the time taken to send messages with WCF net.tcp QUESTION: I’m writing a prototype WCF enabled distributed app, to try and find out any issues I’ll have upgrading my existing “sending xml over tcp to communicate” apps I’ve got. I’m using Callback Contracts to register clients with a server (Singleton in...
[ "c#", ".net", "wcf", "distributed-apps" ]
2
1
1,155
2
0
2008-10-01T22:25:53.963000
2008-10-02T12:50:27.643000
160,045
160,074
Break when a value changes using the Visual Studio debugger
Is there a way to place a watch on variable and only have Visual Studio break when that value changes? It would make it so much easier to find tricky state issues. Can this be done? Breakpoint conditions still need a breakpoint set, and I'd rather set a watch and let Visual Studio set the breakpoints at state changes.
In the Visual Studio 2005 menu: Debug -> New Breakpoint -> New Data Breakpoint Enter: &myVariable
Break when a value changes using the Visual Studio debugger Is there a way to place a watch on variable and only have Visual Studio break when that value changes? It would make it so much easier to find tricky state issues. Can this be done? Breakpoint conditions still need a breakpoint set, and I'd rather set a watch ...
TITLE: Break when a value changes using the Visual Studio debugger QUESTION: Is there a way to place a watch on variable and only have Visual Studio break when that value changes? It would make it so much easier to find tricky state issues. Can this be done? Breakpoint conditions still need a breakpoint set, and I'd r...
[ "visual-studio", "debugging", "breakpoints", "conditional-breakpoint" ]
237
150
172,038
14
0
2008-10-01T22:26:50.963000
2008-10-01T22:36:30.443000
160,046
162,555
Is there a way to keep Visual Studio from modifying the solution file after every test run?
Visual Studio seems to be modifying a list of.vsmdi files in my.sln every time sometimes when I run a unit test. This is annoying because my source control client thinks the.sln file needs to be checked in even though I don't want to check it in. Is there any way to keep Visual Studio from munging the.sln file after a ...
I don't believe a solution exists. A good Connect case, that does a better job of documenting the issue and a repro case, is this one. At the very bottom of the page a commenter proposes a workaround, which I've reproduced here. I haven't actually tested this workaround for myself yet, I guess I've gotten numb to disca...
Is there a way to keep Visual Studio from modifying the solution file after every test run? Visual Studio seems to be modifying a list of.vsmdi files in my.sln every time sometimes when I run a unit test. This is annoying because my source control client thinks the.sln file needs to be checked in even though I don't wa...
TITLE: Is there a way to keep Visual Studio from modifying the solution file after every test run? QUESTION: Visual Studio seems to be modifying a list of.vsmdi files in my.sln every time sometimes when I run a unit test. This is annoying because my source control client thinks the.sln file needs to be checked in even...
[ "visual-studio" ]
6
3
519
3
0
2008-10-01T22:27:41.587000
2008-10-02T14:23:41.693000
160,051
160,129
Many-to-Many with "Primary"
I'm working on a database that needs to represent computers and their users. Each computer can have multiple users and each user can be associated with multiple computers, so it's a classic many-to-many relationship. However, there also needs to be a concept of a "primary" user. I have to be able to join against the pr...
Option 3, though it may feel strange, is the closest to what you want to model. You'd do something like: User { UserId PRIMARY KEY (UserId) } Computer { ComputerId, PrimaryUserId PRIMARY KEY (UserId) FOREIGN KEY (ComputerId, PrimaryUserId) REFERENCES Computer_User (ComputerId, UserId) } Computer_User { ComputerId, Us...
Many-to-Many with "Primary" I'm working on a database that needs to represent computers and their users. Each computer can have multiple users and each user can be associated with multiple computers, so it's a classic many-to-many relationship. However, there also needs to be a concept of a "primary" user. I have to be...
TITLE: Many-to-Many with "Primary" QUESTION: I'm working on a database that needs to represent computers and their users. Each computer can have multiple users and each user can be associated with multiple computers, so it's a classic many-to-many relationship. However, there also needs to be a concept of a "primary" ...
[ "sql-server", "database-design" ]
6
7
331
7
0
2008-10-01T22:28:49.727000
2008-10-01T22:51:09.657000
160,077
160,361
How do you decide which API function documentations to read and how seriously?
Suppose that you are writing or maintaining a piece of code that uses some API that you are not 100% familiar with. How do you decide whether to read the documentation of a certain call target, and how much time to spend reading it? How do you decide not to read it? (Let's assume you can read it by opening the HTML doc...
Ideally you should read all of it, but we know that's a pain in the... you know. What I normally do on those cases (and I did that a lot while I worked as a freelancer) is weight some factors and depending on the result, I read the docs. Factors that tell me I shouldn't read the docs: What the function does is easy to ...
How do you decide which API function documentations to read and how seriously? Suppose that you are writing or maintaining a piece of code that uses some API that you are not 100% familiar with. How do you decide whether to read the documentation of a certain call target, and how much time to spend reading it? How do y...
TITLE: How do you decide which API function documentations to read and how seriously? QUESTION: Suppose that you are writing or maintaining a piece of code that uses some API that you are not 100% familiar with. How do you decide whether to read the documentation of a certain call target, and how much time to spend re...
[ "documentation" ]
1
2
123
1
0
2008-10-01T22:37:11.750000
2008-10-02T00:21:14.793000
160,097
160,117
What's the difference between <%# %> and <%= %>?
Pardon my ASP ignorance, but what's the difference?
These are somewhat informally referred to as "bee stings". There are 4 types: <%# %> is invoked during the DataBinding phase. <%= %> is used to get values from code to the UI layer. Meant for backward compatibility with ASP applications. Shouldn't use in.NET. <%@ %> represents directives and allow behaviors to be set w...
What's the difference between <%# %> and <%= %>? Pardon my ASP ignorance, but what's the difference?
TITLE: What's the difference between <%# %> and <%= %>? QUESTION: Pardon my ASP ignorance, but what's the difference? ANSWER: These are somewhat informally referred to as "bee stings". There are 4 types: <%# %> is invoked during the DataBinding phase. <%= %> is used to get values from code to the UI layer. Meant for ...
[ ".net", "asp.net" ]
12
20
1,508
5
0
2008-10-01T22:41:32.957000
2008-10-01T22:48:09.087000
160,105
160,176
How can you bring a control to front in mfc
How do you change controls' Z-order in MFC at design time - i.e. I can't use SetWindowPos or do this at runtime - I want to see the changed z-order in the designer (even if I have to resort to direct-editing the.rc code). I have an MFC dialog to which I am adding controls. If there is overlap between the edges of the c...
I think the control in front will be the last control that occurs in the rc file. In other words, the dialog editor will draw each control as it is encountered from top to bottom in the rc file, overlapping them when necessary. You can edit the rc file to reorder them, or you can change the tab order in the editor, whi...
How can you bring a control to front in mfc How do you change controls' Z-order in MFC at design time - i.e. I can't use SetWindowPos or do this at runtime - I want to see the changed z-order in the designer (even if I have to resort to direct-editing the.rc code). I have an MFC dialog to which I am adding controls. If...
TITLE: How can you bring a control to front in mfc QUESTION: How do you change controls' Z-order in MFC at design time - i.e. I can't use SetWindowPos or do this at runtime - I want to see the changed z-order in the designer (even if I have to resort to direct-editing the.rc code). I have an MFC dialog to which I am a...
[ "visual-studio", "visual-c++", "mfc" ]
18
19
35,652
7
0
2008-10-01T22:45:17.380000
2008-10-01T23:08:04.767000
160,118
160,143
Static and Instance methods with the same name?
I have a class with both a static and a non-static interface in C#. Is it possible to have a static and a non-static method in a class with the same name and signature? I get a compiler error when I try to do this, but for some reason I thought there was a way to do this. Am I wrong or is there no way to have both stat...
No you can't. The reason for the limitation is that static methods can also be called from non-static contexts without needing to prepend the class name (so MyStaticMethod() instead of MyClass.MyStaticMethod()). The compiler can't tell which you're looking for if you have both. You can have static and non-static method...
Static and Instance methods with the same name? I have a class with both a static and a non-static interface in C#. Is it possible to have a static and a non-static method in a class with the same name and signature? I get a compiler error when I try to do this, but for some reason I thought there was a way to do this....
TITLE: Static and Instance methods with the same name? QUESTION: I have a class with both a static and a non-static interface in C#. Is it possible to have a static and a non-static method in a class with the same name and signature? I get a compiler error when I try to do this, but for some reason I thought there was...
[ "c#", ".net", "oop" ]
70
69
34,403
7
0
2008-10-01T22:48:45.250000
2008-10-01T22:55:52.813000
160,128
216,683
SQL split/merge of table partitions: What is the best approach to implement?
Microsoft in its MSDN entry about altering SQL 2005 partitions, listed a few possible approaches: Create a new partitioned table with the desired partition function, and then insert the data from the old table into the new table by using an INSERT INTO...SELECT FROM statement. Create a partitioned clustered index on a ...
I'd recommend the first approach - creating a new partitioned table and inserting into it - because it gives you the luxury of comparing your old and new tables. You can test query plans against both styles of tables and see if your queries are indeed faster before cutting over to the new table design. You may find the...
SQL split/merge of table partitions: What is the best approach to implement? Microsoft in its MSDN entry about altering SQL 2005 partitions, listed a few possible approaches: Create a new partitioned table with the desired partition function, and then insert the data from the old table into the new table by using an IN...
TITLE: SQL split/merge of table partitions: What is the best approach to implement? QUESTION: Microsoft in its MSDN entry about altering SQL 2005 partitions, listed a few possible approaches: Create a new partitioned table with the desired partition function, and then insert the data from the old table into the new ta...
[ "sql-server", "partitioning" ]
1
3
5,047
1
0
2008-10-01T22:51:00.640000
2008-10-19T17:12:12.733000
160,147
160,164
Catching exceptions from a constructor's initializer list
Here's a curious one. I have a class A. It has an item of class B, which I want to initialize in the constructor of A using an initializer list, like so: class A { public: A(const B& b): mB(b) { }; private: B mB; }; Is there a way to catch exceptions that might be thrown by mB's copy-constructor while still using the ...
Have a read of http://weseetips.wordpress.com/tag/exception-from-constructor-initializer-list/ ) Edit: After more digging, these are called "Function try blocks". I confess I didn't know this either until I went looking. You learn something every day! I don't know if this is an indictment of how little I get to use C++...
Catching exceptions from a constructor's initializer list Here's a curious one. I have a class A. It has an item of class B, which I want to initialize in the constructor of A using an initializer list, like so: class A { public: A(const B& b): mB(b) { }; private: B mB; }; Is there a way to catch exceptions that might...
TITLE: Catching exceptions from a constructor's initializer list QUESTION: Here's a curious one. I have a class A. It has an item of class B, which I want to initialize in the constructor of A using an initializer list, like so: class A { public: A(const B& b): mB(b) { }; private: B mB; }; Is there a way to catch exc...
[ "c++", "exception" ]
66
111
30,706
5
0
2008-10-01T22:57:13.373000
2008-10-01T23:03:23.577000
160,162
163,310
"Authorization failed" with SVN 1.5.2 on OS X (PowerPC G4)
I'm trying to commit to an SVN server hosted on my school's network. I have installed SVN 1.5.2 with binaries downloaded from CollabNet here. The error reported is: svn: Commit failed (details follow): svn: MKACTIVITY of '/opensvn/cs598r/!svn/act/defe271c-f33b-4851-a706-b2906301fed0': authorization failed (http://dna.c...
Since you can commit from other machines, and your team members can commit but not from your machine, I'd say it's probably an issue with your subversion client. I'd suggest you uninstall the client you have, then install the version that's being run on the server just to be safe.
"Authorization failed" with SVN 1.5.2 on OS X (PowerPC G4) I'm trying to commit to an SVN server hosted on my school's network. I have installed SVN 1.5.2 with binaries downloaded from CollabNet here. The error reported is: svn: Commit failed (details follow): svn: MKACTIVITY of '/opensvn/cs598r/!svn/act/defe271c-f33b-...
TITLE: "Authorization failed" with SVN 1.5.2 on OS X (PowerPC G4) QUESTION: I'm trying to commit to an SVN server hosted on my school's network. I have installed SVN 1.5.2 with binaries downloaded from CollabNet here. The error reported is: svn: Commit failed (details follow): svn: MKACTIVITY of '/opensvn/cs598r/!svn/...
[ "svn", "macos", "collabnet" ]
2
1
2,475
5
0
2008-10-01T23:02:23.483000
2008-10-02T16:26:06.410000
160,175
160,321
Traversing a multi-dimensional hash in Perl
If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have $f->{$x}{$y}, I want something like foreach ($x, $y) (deep_keys %{$f}) { } instead of foreach $x (keys %f) { foreach $y (keys %{$f->{$x}) { } }
Here's an option. This works for arbitrarily deep hashes: sub deep_keys_foreach { my ($hashref, $code, $args) = @_; while (my ($k, $v) = each(%$hashref)) { my @newargs = defined($args)? @$args: (); push(@newargs, $k); if (ref($v) eq 'HASH') { deep_keys_foreach($v, $code, \@newargs); } else { $code->(@newargs); } } } ...
Traversing a multi-dimensional hash in Perl If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have $f->{$x}{$y}, I want something like foreach ($x, $y) (deep_keys %{$f}) { } instead of foreach $x (keys ...
TITLE: Traversing a multi-dimensional hash in Perl QUESTION: If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have $f->{$x}{$y}, I want something like foreach ($x, $y) (deep_keys %{$f}) { } instead of...
[ "perl", "scripting", "multidimensional-array" ]
5
11
31,569
8
0
2008-10-01T23:07:33.113000
2008-10-02T00:07:11.783000
160,179
240,958
Visual Studio 2005, how to get where project are used in a solution?
I have a solution with other 70 projects into it. My question is: How can I know where the project is used? I do not want to open all those 70 projects to verify the References one by one. How can I see which project use one project in particular? Edit I do not want to do 1 by 1 search in XML or in the Reference in VS....
Visual Ndepend is a tool that I am trying at this moment and look promising with my original question.
Visual Studio 2005, how to get where project are used in a solution? I have a solution with other 70 projects into it. My question is: How can I know where the project is used? I do not want to open all those 70 projects to verify the References one by one. How can I see which project use one project in particular? Edi...
TITLE: Visual Studio 2005, how to get where project are used in a solution? QUESTION: I have a solution with other 70 projects into it. My question is: How can I know where the project is used? I do not want to open all those 70 projects to verify the References one by one. How can I see which project use one project ...
[ ".net", "visual-studio-2005", "project-reference" ]
3
0
6,448
5
0
2008-10-01T23:08:49.727000
2008-10-27T18:27:43.583000
160,204
160,268
How to use ditto on OS X to work like cp -a on Linux
I'm a Linux guy and I'm used to copying directory trees with cp -a. OS X doesn't have -a option on cp... but it does have the ditto command. I'm reading the man on ditto now, but is there anything I should specifically be looking out for?
According to the cp man page cp -a is the same as cp -dpR which is -p = preserve mode,ownership,timestamps -R = recursive -d = no dereference and preserve links The OS X equivalent would be cp -pPR -p = preserve -R = recursive -P = no symbolic links are followed -- can be added but this is the default behavior The only...
How to use ditto on OS X to work like cp -a on Linux I'm a Linux guy and I'm used to copying directory trees with cp -a. OS X doesn't have -a option on cp... but it does have the ditto command. I'm reading the man on ditto now, but is there anything I should specifically be looking out for?
TITLE: How to use ditto on OS X to work like cp -a on Linux QUESTION: I'm a Linux guy and I'm used to copying directory trees with cp -a. OS X doesn't have -a option on cp... but it does have the ditto command. I'm reading the man on ditto now, but is there anything I should specifically be looking out for? ANSWER: A...
[ "macos" ]
7
10
11,924
6
0
2008-10-01T23:20:33.287000
2008-10-01T23:43:47.800000
160,212
164,057
VisualSVN and class libraries not in the working copy root
We're making the switch from SourceGear Vault to TortoiseSVN with VisualSVN for Visual Studio integration - absolutely love it. However, there are multiple class libraries that we reference in multiple different applications that aren't a part of the working copy root in any of the applications. What's the best way to ...
Found the best answers here: Referenced Projects Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different subdirectories to come from different locations in a repository, or perhaps from different repositories altogether. If you want eve...
VisualSVN and class libraries not in the working copy root We're making the switch from SourceGear Vault to TortoiseSVN with VisualSVN for Visual Studio integration - absolutely love it. However, there are multiple class libraries that we reference in multiple different applications that aren't a part of the working co...
TITLE: VisualSVN and class libraries not in the working copy root QUESTION: We're making the switch from SourceGear Vault to TortoiseSVN with VisualSVN for Visual Studio integration - absolutely love it. However, there are multiple class libraries that we reference in multiple different applications that aren't a part...
[ "visual-studio", "svn", "version-control", "tortoisesvn", "visualsvn" ]
7
4
1,450
2
0
2008-10-01T23:24:46.333000
2008-10-02T19:15:00.217000
160,214
160,344
What does a ListViewSubtemCollection use for its keys?
I am trying to get the value of some ListViewSubItems, but I have no idea what values it uses for its keys. I have some simple code: protected override void OnItemDrag(ItemDragEventArgs e) { base.OnItemDrag(e); ListViewItem item = e.Item as ListViewItem; string val = item.SubItems[???].ToString(); } The??? part is wher...
The key of the ListViewSubItem is the Name property as described here. Setting the Name equal to the column name, would allow you to index into the SubItems by the name of the column. And some code as an example ListViewItem myListViewItem = new ListViewItem(); ListViewItem.ListViewSubItem myListViewSubItem = new ListV...
What does a ListViewSubtemCollection use for its keys? I am trying to get the value of some ListViewSubItems, but I have no idea what values it uses for its keys. I have some simple code: protected override void OnItemDrag(ItemDragEventArgs e) { base.OnItemDrag(e); ListViewItem item = e.Item as ListViewItem; string val...
TITLE: What does a ListViewSubtemCollection use for its keys? QUESTION: I am trying to get the value of some ListViewSubItems, but I have no idea what values it uses for its keys. I have some simple code: protected override void OnItemDrag(ItemDragEventArgs e) { base.OnItemDrag(e); ListViewItem item = e.Item as ListVi...
[ ".net", "listview" ]
1
1
314
3
0
2008-10-01T23:25:26.940000
2008-10-02T00:15:52.030000
160,215
160,301
C# How to replace system tray clock
How do I replace the standard system tray clock in the taskbar? Thanks!
I found an example here in C++: C++ Open Source Project I hope you are able to find something in C# as well.
C# How to replace system tray clock How do I replace the standard system tray clock in the taskbar? Thanks!
TITLE: C# How to replace system tray clock QUESTION: How do I replace the standard system tray clock in the taskbar? Thanks! ANSWER: I found an example here in C++: C++ Open Source Project I hope you are able to find something in C# as well.
[ "c#", "windows", "windows-xp" ]
5
2
2,386
1
0
2008-10-01T23:25:33.990000
2008-10-02T00:01:49.177000
160,216
4,700,704
ForEach loop in Mathematica
I'd like something like this: each[i_, {1,2,3}, Print[i] ] Or, more generally, to destructure arbitrary stuff in the list you're looping over, like: each[{i_, j_}, {{1,10}, {2,20}, {3,30}}, Print[i*j] ] Usually you want to use Map or other purely functional constructs and eschew a non-functional programming style where...
Thanks to Pillsy and Leonid Shifrin, here's what I'm now using: SetAttributes[each, HoldAll]; (* each[pattern, list, body] *) each[pat_, lst_List, bod_]:= (* converts pattern to body for *) (Cases[Unevaluated@lst, pat:>bod]; Null); (* each element of list. *) each[p_, l_, b_]:= (Cases[l, p:>b]; Null); (* (Break/Continu...
ForEach loop in Mathematica I'd like something like this: each[i_, {1,2,3}, Print[i] ] Or, more generally, to destructure arbitrary stuff in the list you're looping over, like: each[{i_, j_}, {{1,10}, {2,20}, {3,30}}, Print[i*j] ] Usually you want to use Map or other purely functional constructs and eschew a non-functi...
TITLE: ForEach loop in Mathematica QUESTION: I'd like something like this: each[i_, {1,2,3}, Print[i] ] Or, more generally, to destructure arbitrary stuff in the list you're looping over, like: each[{i_, j_}, {{1,10}, {2,20}, {3,30}}, Print[i*j] ] Usually you want to use Map or other purely functional constructs and e...
[ "loops", "language-features", "wolfram-mathematica" ]
22
1
21,263
7
0
2008-10-01T23:25:43.460000
2011-01-15T16:30:38.153000
160,218
160,295
To ternary or not to ternary?
I'm personally an advocate of the ternary operator: ()?: I do realize that it has its place, but I have come across many programmers that are completely against ever using it, and some that use it too often. What are your feelings on it? What interesting code have you seen using it?
Use it for simple expressions only: int a = (b > 10)? c: d; Don't chain or nest ternary operators as it hard to read and confusing: int a = b > 10? c < 20? 50: 80: e == 2? 4: 8; Moreover, when using ternary operator, consider formatting the code in a way that improves readability: int a = (b > 10)? some_value: another_...
To ternary or not to ternary? I'm personally an advocate of the ternary operator: ()?: I do realize that it has its place, but I have come across many programmers that are completely against ever using it, and some that use it too often. What are your feelings on it? What interesting code have you seen using it?
TITLE: To ternary or not to ternary? QUESTION: I'm personally an advocate of the ternary operator: ()?: I do realize that it has its place, but I have come across many programmers that are completely against ever using it, and some that use it too often. What are your feelings on it? What interesting code have you see...
[ "conditional-operator" ]
205
269
61,451
54
0
2008-10-01T23:27:46.433000
2008-10-01T23:58:49.823000
160,222
160,241
ASP.net Web App undo support
I have a simple web form that has a several fields and a gridview on it. I also have a save and cancel button. I would like a way to undo what was done to the data on the form when the user presses cancel. This is simple enough with the fields however since changes to the gridview happen in real time against the databa...
Keep all the data in a session object and write that to the database when you are ready. If you abstract your data layer you can use the ObjectDataSource that interacts with the session objects. I'm currently using this method on a checkout system for an e-commerce site. I store the data in custom objects that mimic th...
ASP.net Web App undo support I have a simple web form that has a several fields and a gridview on it. I also have a save and cancel button. I would like a way to undo what was done to the data on the form when the user presses cancel. This is simple enough with the fields however since changes to the gridview happen in...
TITLE: ASP.net Web App undo support QUESTION: I have a simple web form that has a several fields and a gridview on it. I also have a save and cancel button. I would like a way to undo what was done to the data on the form when the user presses cancel. This is simple enough with the fields however since changes to the ...
[ "c#", "asp.net", "web-applications", "undo" ]
4
2
1,448
4
0
2008-10-01T23:29:39.520000
2008-10-01T23:36:05.027000
160,233
5,615,783
What does mysql error 1025 (HY000): Error on rename of './foo' (errorno: 150) mean?
I tried this in mysql: mysql> alter table region drop column country_id; And got this: ERROR 1025 (HY000): Error on rename of './product/#sql-14ae_81' to './product/region' (errno: 150) Any ideas? Foreign key stuff?
You usually get this error if your tables use the InnoDB engine. In that case you would have to drop the foreign key, and then do the alter table and drop the column. But the tricky part is that you can't drop the foreign key using the column name, but instead you would have to find the name used to index it. To find t...
What does mysql error 1025 (HY000): Error on rename of './foo' (errorno: 150) mean? I tried this in mysql: mysql> alter table region drop column country_id; And got this: ERROR 1025 (HY000): Error on rename of './product/#sql-14ae_81' to './product/region' (errno: 150) Any ideas? Foreign key stuff?
TITLE: What does mysql error 1025 (HY000): Error on rename of './foo' (errorno: 150) mean? QUESTION: I tried this in mysql: mysql> alter table region drop column country_id; And got this: ERROR 1025 (HY000): Error on rename of './product/#sql-14ae_81' to './product/region' (errno: 150) Any ideas? Foreign key stuff? A...
[ "mysql", "mysql-error-1025" ]
163
242
139,907
14
0
2008-10-01T23:33:21.787000
2011-04-11T00:45:46.720000
160,245
160,375
Which is the best way to get a list of running processes in unix with python?
I'm trying: import commands print commands.getoutput("ps -u 0") But it doesn't work on os x. os instead of commands gives the same output: USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND nothing more
This works on Mac OS X 10.5.5. Note the capital -U option. Perhaps that's been your problem. import subprocess ps = subprocess.Popen("ps -U 0", shell=True, stdout=subprocess.PIPE) print ps.stdout.read() ps.stdout.close() ps.wait() Here's the Python version Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Ap...
Which is the best way to get a list of running processes in unix with python? I'm trying: import commands print commands.getoutput("ps -u 0") But it doesn't work on os x. os instead of commands gives the same output: USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND nothing more
TITLE: Which is the best way to get a list of running processes in unix with python? QUESTION: I'm trying: import commands print commands.getoutput("ps -u 0") But it doesn't work on os x. os instead of commands gives the same output: USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND nothing more ANSWER: This wo...
[ "python" ]
2
8
8,230
6
0
2008-10-01T23:37:06.257000
2008-10-02T00:29:39.483000
160,250
160,952
Flex: Modify an embedded icon and use it in a button?
Just that, if you embed an icon: [Embed(source='icons/checkmark.png')] private static var CheckMark:Class; You end up with a dynamic class. You can pretty easily assign the icon to a button at runtime by calling the setStyle method: var btn:Button = new Button(); btn.setStyle("icon", CheckMark); But what if you wanted ...
This is the only answer I could find that seemed close: Dynamic Icons (example with View Source) His solution involves a custom "DynamicIcon" class which is used in the button's icon setting, and a custom Button class which adds one method to the Button class to draw dynamic icons. The end result is that you are able t...
Flex: Modify an embedded icon and use it in a button? Just that, if you embed an icon: [Embed(source='icons/checkmark.png')] private static var CheckMark:Class; You end up with a dynamic class. You can pretty easily assign the icon to a button at runtime by calling the setStyle method: var btn:Button = new Button(); bt...
TITLE: Flex: Modify an embedded icon and use it in a button? QUESTION: Just that, if you embed an icon: [Embed(source='icons/checkmark.png')] private static var CheckMark:Class; You end up with a dynamic class. You can pretty easily assign the icon to a button at runtime by calling the setStyle method: var btn:Button ...
[ "apache-flex", "flash", "image", "icons" ]
1
2
10,328
3
0
2008-10-01T23:38:17.300000
2008-10-02T05:05:50.163000
160,267
162,197
Compile error in VS.NET 2008 (VB.NET) that I can't get rid of!
I can't shake this error when compiling my Visual Studio.NET 2008 solution. The project that's generating the error is a VB.NET Web Application in a 12 project solution (mixed types and languages). I've tried all the tricks I can find on google, and the obvious of removing the directoy and folder manually. I'm running ...
After thinking about this and not finding any solutions from answers or via the Internet, I went ahead and moved my entire solution to my C:\ drive vs. my G:\ drive (both are local). Doing this fixed my compile problem for some reason.
Compile error in VS.NET 2008 (VB.NET) that I can't get rid of! I can't shake this error when compiling my Visual Studio.NET 2008 solution. The project that's generating the error is a VB.NET Web Application in a 12 project solution (mixed types and languages). I've tried all the tricks I can find on google, and the obv...
TITLE: Compile error in VS.NET 2008 (VB.NET) that I can't get rid of! QUESTION: I can't shake this error when compiling my Visual Studio.NET 2008 solution. The project that's generating the error is a VB.NET Web Application in a 12 project solution (mixed types and languages). I've tried all the tricks I can find on g...
[ "vb.net", "visual-studio-2008", "debugging", "compiler-construction", "windows-vista" ]
7
0
5,999
8
0
2008-10-01T23:43:34.027000
2008-10-02T13:14:43.203000
160,288
164,477
How to update object with no data contexts
Entity framework provides great flexibility to update data in the same datacontext Dim personA = (from p in datacontext.Person where p.PersonID = 1 select p) personA.name = txtName.value datacontext.savechanges() If I have to move this Update function to Service layer which only takes "Person" in the request, what woul...
You need to attach your entity object to a data context. You also need to extend your data context partial class with the AttachUpdeted method. As when you attach a object to a data context it does not know that updates have been made. The code below will tell the data context every property has been updated and needs ...
How to update object with no data contexts Entity framework provides great flexibility to update data in the same datacontext Dim personA = (from p in datacontext.Person where p.PersonID = 1 select p) personA.name = txtName.value datacontext.savechanges() If I have to move this Update function to Service layer which on...
TITLE: How to update object with no data contexts QUESTION: Entity framework provides great flexibility to update data in the same datacontext Dim personA = (from p in datacontext.Person where p.PersonID = 1 select p) personA.name = txtName.value datacontext.savechanges() If I have to move this Update function to Serv...
[ ".net", "vb.net", "entity-framework" ]
9
12
4,937
1
0
2008-10-01T23:55:27.290000
2008-10-02T20:39:46.813000
160,290
160,306
should I free pointer returned by getpwuid() in Linux?
After I call getpwuid(uid), I have a reference to a pointer. Should I free that pointer when I don't use it anymore? Reading the man pages, it says that it makes reference to some static area, that may be overwritten by subsequent calls to the same functions, so I'm not sure if I should touch that memory area. Thanks.
No. You do not need to free the result. You can only call free(3) on pointers allocated on the heap with malloc(3), calloc(3) or realloc(3). Static data is part of a program's data or bss segments and will persist until the process exits (or is overwritten by exec(2)).
should I free pointer returned by getpwuid() in Linux? After I call getpwuid(uid), I have a reference to a pointer. Should I free that pointer when I don't use it anymore? Reading the man pages, it says that it makes reference to some static area, that may be overwritten by subsequent calls to the same functions, so I'...
TITLE: should I free pointer returned by getpwuid() in Linux? QUESTION: After I call getpwuid(uid), I have a reference to a pointer. Should I free that pointer when I don't use it anymore? Reading the man pages, it says that it makes reference to some static area, that may be overwritten by subsequent calls to the sam...
[ "c", "linux", "getpwuid" ]
9
12
2,882
3
0
2008-10-01T23:56:41.450000
2008-10-02T00:04:07.627000
160,296
175,069
Localization in OpenSocial gadget app
I'm trying to add multi-language support to an OpenSocial application. I see that I can link to my own message bundles in the gadget XML markup:... But how do I actually extract values from them?
To extract the values you should use the getMsg method var prefs = new gadgets.Prefs(); var msg = prefs.getMsg('hello_world');
Localization in OpenSocial gadget app I'm trying to add multi-language support to an OpenSocial application. I see that I can link to my own message bundles in the gadget XML markup:... But how do I actually extract values from them?
TITLE: Localization in OpenSocial gadget app QUESTION: I'm trying to add multi-language support to an OpenSocial application. I see that I can link to my own message bundles in the gadget XML markup:... But how do I actually extract values from them? ANSWER: To extract the values you should use the getMsg method var ...
[ "javascript", "localization", "internationalization", "opensocial" ]
2
5
585
1
0
2008-10-01T23:58:55.813000
2008-10-06T16:34:45.370000
160,298
161,082
Django/Python - Grouping objects by common set from a many-to-many relationships
This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that. In Python, it's worth mentioning that the problem is somewhat related to how-do-i-use-pythons-itertoolsgroupby. Suppose you're given two Django Model-deri...
Have you tried sorting the list first? The algorithm you proposed should work, albeit with lots of database hits. import itertools cars = [ {'car': 'X2', 'mods': [1,2]}, {'car': 'Y2', 'mods': [2]}, {'car': 'W2', 'mods': [1]}, {'car': 'X1', 'mods': [1,2]}, {'car': 'W1', 'mods': [1]}, {'car': 'Y1', 'mods': [2]}, {'car':...
Django/Python - Grouping objects by common set from a many-to-many relationships This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that. In Python, it's worth mentioning that the problem is somewhat related to ...
TITLE: Django/Python - Grouping objects by common set from a many-to-many relationships QUESTION: This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that. In Python, it's worth mentioning that the problem is so...
[ "python", "django", "algorithm", "puzzle" ]
8
4
3,134
5
0
2008-10-01T23:59:52.723000
2008-10-02T06:20:53.227000
160,315
160,861
How to check for key being held down on startup in Java
I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holding down the alt key at startup. Unfortunately, there is no obvious way to ...
public class LockingKeyDemo { static Toolkit kit = Toolkit.getDefaultToolkit(); public static void main(String[] args) { System.out.println("caps lock2 = " + kit.getLockingKeyState(KeyEvent.VK_CAPS_LOCK)); } }
How to check for key being held down on startup in Java I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holding down the alt ke...
TITLE: How to check for key being held down on startup in Java QUESTION: I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holdi...
[ "java", "swing", "keyboard", "key", "awt" ]
8
1
7,282
6
0
2008-10-02T00:06:38.667000
2008-10-02T04:14:56.167000
160,318
160,356
Considerations about a simulation game
The kind of simulation game that I have in mind is the kind where you have things to build in various locations and workers/transporters that connect such locations. Something more like the Settlers series. Let's assume I don't want any graphics at the moment, that I think I can manage. So my doubts are the following: ...
The normal approach does not use threading at all, but rather implements entities as state-machines. Then your mainloop looks like this: while( 1 ) { foreach( entity in entlist ) { entity->update(); } render(); }
Considerations about a simulation game The kind of simulation game that I have in mind is the kind where you have things to build in various locations and workers/transporters that connect such locations. Something more like the Settlers series. Let's assume I don't want any graphics at the moment, that I think I can m...
TITLE: Considerations about a simulation game QUESTION: The kind of simulation game that I have in mind is the kind where you have things to build in various locations and workers/transporters that connect such locations. Something more like the Settlers series. Let's assume I don't want any graphics at the moment, th...
[ "simulation" ]
4
14
1,048
6
0
2008-10-02T00:06:50.087000
2008-10-02T00:19:45.327000
160,335
160,454
How do you localize a database driven website
I've been playing with the.NET built in localization features and they seem to all rely on putting data in resx files. But most systems can't rely on this because they are database driven. So how do you solve this issue? Is there a built in.NET way, or do you create a translations table in SQL and do it all manually? A...
In my opinion, localizing dynamic content (e.g., your FAQ) should be done by you in your database. Depending on how your questions are stored, I would probably create a "locale" column and use that when selecting the FAQ questions from the database. I'm not sure if this would scale very well when you started localizing...
How do you localize a database driven website I've been playing with the.NET built in localization features and they seem to all rely on putting data in resx files. But most systems can't rely on this because they are database driven. So how do you solve this issue? Is there a built in.NET way, or do you create a trans...
TITLE: How do you localize a database driven website QUESTION: I've been playing with the.NET built in localization features and they seem to all rely on putting data in resx files. But most systems can't rely on this because they are database driven. So how do you solve this issue? Is there a built in.NET way, or do ...
[ "c#", ".net", "asp.net", "localization" ]
18
17
12,486
5
0
2008-10-02T00:11:56.187000
2008-10-02T01:09:54.660000
160,373
160,443
String problem with SQL Reader?
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = "connect timeout=9999999;" & _ "data source=" & DefaultIserver & ";" & _ "initial catalog=" & DefaultIdBase & "; " & _ "user id=userid;" & _ "password=userpass;" & _ "persist security info=True; " & _ "packet size=4096" SQL...
NEVER store actual passwords in the db. Now it looks like your passwords might not quite be plain text because of the convert/cast operations, but you still have a problem. At very least any encryption used is easily reversible, and if your sql server ever ends up on a different machine from the application then passwo...
String problem with SQL Reader? Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = "connect timeout=9999999;" & _ "data source=" & DefaultIserver & ";" & _ "initial catalog=" & DefaultIdBase & "; " & _ "user id=userid;" & _ "password=userpass;" & _ "persist security info=Tr...
TITLE: String problem with SQL Reader? QUESTION: Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = "connect timeout=9999999;" & _ "data source=" & DefaultIserver & ";" & _ "initial catalog=" & DefaultIdBase & "; " & _ "user id=userid;" & _ "password=userpass;" & _ "persis...
[ "vb.net" ]
0
2
373
3
0
2008-10-02T00:29:14.540000
2008-10-02T01:01:47.863000
160,374
160,801
TSQL: How do I do a self-join in XML to get a nested document?
I have a SQL Server 2005 table like this: create table Taxonomy( CategoryId integer primary key, ParentCategoryId integer references Taxonomy(CategoryId), CategoryDescription varchar(50) ) with data looking like CategoryIdParentCategoryIdCategoryDescription 123nullfoo345123bar I'd like to query it into an xml document ...
It is possible but the main limitation is that the levels of the hierarchy must be hard coded. The SQL Server Books Online has a description of how to represent hierarchies in XML at this link. Below is a sample query that produces the XML you requested: SELECT [CategoryId] as "@CategoryID",[CategoryDescription] as "@C...
TSQL: How do I do a self-join in XML to get a nested document? I have a SQL Server 2005 table like this: create table Taxonomy( CategoryId integer primary key, ParentCategoryId integer references Taxonomy(CategoryId), CategoryDescription varchar(50) ) with data looking like CategoryIdParentCategoryIdCategoryDescription...
TITLE: TSQL: How do I do a self-join in XML to get a nested document? QUESTION: I have a SQL Server 2005 table like this: create table Taxonomy( CategoryId integer primary key, ParentCategoryId integer references Taxonomy(CategoryId), CategoryDescription varchar(50) ) with data looking like CategoryIdParentCategoryIdC...
[ "sql-server", "t-sql", "sqlxml", "for-xml" ]
3
3
2,541
1
0
2008-10-02T00:29:28.423000
2008-10-02T03:38:30.840000
160,376
160,538
Why move your Javascript files to a different main domain that you also own?
I've noticed that just in the last year or so, many major websites have made the same change to the way their pages are structured. Each has moved their Javascript files from being hosted on the same domain as the page itself (or a subdomain of that), to being hosted on a differently named domain. It's not simply paral...
Your follow-up question is essentially: Assuming a popular website is using a CDN, why would they use their own TLD like imwx.com instead of a subdomain (static.weather.com) or the CDN's domain? Well, the reason for using a domain they control versus the CDN's domain is that they retain control -- they could potentiall...
Why move your Javascript files to a different main domain that you also own? I've noticed that just in the last year or so, many major websites have made the same change to the way their pages are structured. Each has moved their Javascript files from being hosted on the same domain as the page itself (or a subdomain o...
TITLE: Why move your Javascript files to a different main domain that you also own? QUESTION: I've noticed that just in the last year or so, many major websites have made the same change to the way their pages are structured. Each has moved their Javascript files from being hosted on the same domain as the page itself...
[ "javascript", "webserver", "cdn", "provisioning", "whitelist" ]
29
42
7,301
10
0
2008-10-02T00:30:38.513000
2008-10-02T01:53:33.447000
160,379
160,397
Improving the quality of code?
So, in reading this site, it seems that the shop in which I work does a lot of things wrong and some things right. How can I improve the code that I work with from my colleagues? The only thing I can think of is to lead by example - start using Boost, etc. Any other thoughts?
You probably have to look more closely at what it is your shop does wrong and what they do right. What can you actually change there? What can you change about your own practices that will improve your skills or that of your team? It can be difficult to realize change in an entrenched shop. Try proposing code reviews (...
Improving the quality of code? So, in reading this site, it seems that the shop in which I work does a lot of things wrong and some things right. How can I improve the code that I work with from my colleagues? The only thing I can think of is to lead by example - start using Boost, etc. Any other thoughts?
TITLE: Improving the quality of code? QUESTION: So, in reading this site, it seems that the shop in which I work does a lot of things wrong and some things right. How can I improve the code that I work with from my colleagues? The only thing I can think of is to lead by example - start using Boost, etc. Any other thou...
[ "c++" ]
10
3
1,104
12
0
2008-10-02T00:32:21.427000
2008-10-02T00:38:19.260000
160,382
161,145
Extract all string from a java project
I have a rather big number of source files that I need parse and extract all string literals and put them in a file as play old java constant. For exemple: Label l = new Label("Cat"); Would become: Label l = new Label(Constants.CAT); And in Constants.java I would have: public final static String CAT = "Cat"; I do not w...
To complete Peter Kelley answer, you might consider for eclipse IDE the AST solution. You might then write an AST program which parse your source code and does what you want. A full example is available in this eclipse corner article, also more details in the eclipse help. And you can find some examples in Listing 5 of...
Extract all string from a java project I have a rather big number of source files that I need parse and extract all string literals and put them in a file as play old java constant. For exemple: Label l = new Label("Cat"); Would become: Label l = new Label(Constants.CAT); And in Constants.java I would have: public fina...
TITLE: Extract all string from a java project QUESTION: I have a rather big number of source files that I need parse and extract all string literals and put them in a file as play old java constant. For exemple: Label l = new Label("Cat"); Would become: Label l = new Label(Constants.CAT); And in Constants.java I would...
[ "java", "eclipse", "string", "gwt", "plugins" ]
12
9
9,574
5
0
2008-10-02T00:33:52.267000
2008-10-02T06:50:55.153000
160,384
160,388
Apache mod_rewrite to catch XML requests
How do I create a apache RewriteRule that catches any request URL ending in.xml, strips off the.xml and passes it to a specific script? http://www.example.com/document.xml, becomes http://www.example.com/document passed to script.php
This should do the trick, I believe. RewriteRule ^(.+)\.xml$ script.php?path=$1
Apache mod_rewrite to catch XML requests How do I create a apache RewriteRule that catches any request URL ending in.xml, strips off the.xml and passes it to a specific script? http://www.example.com/document.xml, becomes http://www.example.com/document passed to script.php
TITLE: Apache mod_rewrite to catch XML requests QUESTION: How do I create a apache RewriteRule that catches any request URL ending in.xml, strips off the.xml and passes it to a specific script? http://www.example.com/document.xml, becomes http://www.example.com/document passed to script.php ANSWER: This should do the...
[ "apache", "mod-rewrite" ]
1
2
716
1
0
2008-10-02T00:34:44.980000
2008-10-02T00:36:03.713000
160,418
160,434
Programmatically Sort Start Menu
I'm looking to sort the start menu alphabetically using C#. I've read about deleting the registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder but when I tried it on my machine it doesn't appear to do much of anything. Does anyone have any other ideas as to what must be done in order to sort th...
Apparently, you can't, and it's on purpose. From Raymond Chen's blog (good read for Windows developers): Because the power would be used for evil far more than it would be used for good. Full entry here.
Programmatically Sort Start Menu I'm looking to sort the start menu alphabetically using C#. I've read about deleting the registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder but when I tried it on my machine it doesn't appear to do much of anything. Does anyone have any other ideas as to what...
TITLE: Programmatically Sort Start Menu QUESTION: I'm looking to sort the start menu alphabetically using C#. I've read about deleting the registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder but when I tried it on my machine it doesn't appear to do much of anything. Does anyone have any othe...
[ "c#", "windows", "sorting" ]
2
3
711
1
0
2008-10-02T00:46:25.810000
2008-10-02T00:57:54.720000
160,467
160,785
How do I create a Jet ODBC link to a SQL Server view with periods in the field names?
I need to create an ODBC link from an Access 2003 (Jet) database to a SQL Server hosted view which contains aliased field names containing periods such as: Seq.Group In the SQL source behind the view, the field names are encased in square brackets... SELECT Table._Group AS [Seq.Group]...so SQL Server doesn't complain a...
Although I didn't technically end up escaping the dot, your suggestion actually did make me realize another alternative. While wondering how I would "pass" the escape code to the "SQL" server, it dawned on me: Why not use a "SQL Pass-Through Query" instead of an ODBC linked table? Since I only need read access to the S...
How do I create a Jet ODBC link to a SQL Server view with periods in the field names? I need to create an ODBC link from an Access 2003 (Jet) database to a SQL Server hosted view which contains aliased field names containing periods such as: Seq.Group In the SQL source behind the view, the field names are encased in sq...
TITLE: How do I create a Jet ODBC link to a SQL Server view with periods in the field names? QUESTION: I need to create an ODBC link from an Access 2003 (Jet) database to a SQL Server hosted view which contains aliased field names containing periods such as: Seq.Group In the SQL source behind the view, the field names...
[ "sql-server", "ms-access", "odbc", "jet" ]
2
4
1,985
3
0
2008-10-02T01:20:29.503000
2008-10-02T03:33:41.837000
160,473
160,481
How to check if there is any read/write activity for a specific harddrive with C#?
I'm curious how to assess if there is any read- or write-activity for a specific harddrive at a given moment with.NET / C#. Second it would be interesting to assess the actual speed of access. Any ideas?
Look into the Windows Management Instrumentation (WMI) APIs which are supported in the.NET Framework via the System.Management and System.Management.Instrumentation namespaces.
How to check if there is any read/write activity for a specific harddrive with C#? I'm curious how to assess if there is any read- or write-activity for a specific harddrive at a given moment with.NET / C#. Second it would be interesting to assess the actual speed of access. Any ideas?
TITLE: How to check if there is any read/write activity for a specific harddrive with C#? QUESTION: I'm curious how to assess if there is any read- or write-activity for a specific harddrive at a given moment with.NET / C#. Second it would be interesting to assess the actual speed of access. Any ideas? ANSWER: Look i...
[ "c#", ".net", "file-io" ]
1
2
224
1
0
2008-10-02T01:24:08.357000
2008-10-02T01:27:52.747000
160,475
160,723
ASP.NET Deployment
For the last couple of months I have been writing an intranet site for my college with lots of reports for staff about students. It is all going well but once a week (ish) I am having to go to IT get them to log into IIS stop the application pool, clear out the website folder, clear out the temporary asp.NET cache and ...
Why are you stopping the app pool and clearing the temp files? It works just fine of you overwrite the files in the website itself. The only thing I do is go into the bin directory and clear out all the randomly named.dll files. Visual Studio also has it's own deployment option, which you can just give a UNC path and i...
ASP.NET Deployment For the last couple of months I have been writing an intranet site for my college with lots of reports for staff about students. It is all going well but once a week (ish) I am having to go to IT get them to log into IIS stop the application pool, clear out the website folder, clear out the temporary...
TITLE: ASP.NET Deployment QUESTION: For the last couple of months I have been writing an intranet site for my college with lots of reports for staff about students. It is all going well but once a week (ish) I am having to go to IT get them to log into IIS stop the application pool, clear out the website folder, clear...
[ "asp.net", "iis" ]
4
2
642
7
0
2008-10-02T01:24:49.023000
2008-10-02T03:05:27.037000
160,482
160,500
Java development in a Perl shop: How to select the right tool?
My group is a Perl shop in an organization that is very heterogenous. Although we support the odd Java, PHP, or Python installation, we're using Perl for nearly all of our web applications and systems/data marshalling tasks. All of our boxes are Linux, although we interface with IIS systems as well. We're coming under ...
Is there a specific technical reason for switching to Java? Is there something you can do in Java but not Perl? Is there a performance difference? Is some other group/person all about Java and doesn't want to learn Perl? My experience has been that you should stick with what you know. Your group knows Perl really well....
Java development in a Perl shop: How to select the right tool? My group is a Perl shop in an organization that is very heterogenous. Although we support the odd Java, PHP, or Python installation, we're using Perl for nearly all of our web applications and systems/data marshalling tasks. All of our boxes are Linux, alth...
TITLE: Java development in a Perl shop: How to select the right tool? QUESTION: My group is a Perl shop in an organization that is very heterogenous. Although we support the odd Java, PHP, or Python installation, we're using Perl for nearly all of our web applications and systems/data marshalling tasks. All of our box...
[ "java", "perl" ]
5
8
344
8
0
2008-10-02T01:28:18.593000
2008-10-02T01:37:53.673000
160,488
1,483,366
ASP.NET WSAT (Website Administration Tool) and Custom Membership Providers
I'm building an ASP.NET MVC applicaiton that will have custom role and membership providers. I have been looking into adminstration tools to save us some time, WSAT has crossed my path. It looks good at a glance, it's all open source and very simple if it doesn't work I can fix it myself. First question is have any of ...
MVC WSAT appears to be the tool of choice for providing Web site Administration functionality to ASP.NET MVC web sites. Also, although the ASPNetWSAT tool is no longer available on Codeplex, it is still available in places. See this thread: ASP.Net WSAT (Web Site Administration) Starter Kit. What happened? and check th...
ASP.NET WSAT (Website Administration Tool) and Custom Membership Providers I'm building an ASP.NET MVC applicaiton that will have custom role and membership providers. I have been looking into adminstration tools to save us some time, WSAT has crossed my path. It looks good at a glance, it's all open source and very si...
TITLE: ASP.NET WSAT (Website Administration Tool) and Custom Membership Providers QUESTION: I'm building an ASP.NET MVC applicaiton that will have custom role and membership providers. I have been looking into adminstration tools to save us some time, WSAT has crossed my path. It looks good at a glance, it's all open ...
[ "asp.net", "asp.net-membership", "wsat" ]
7
7
10,300
1
0
2008-10-02T01:31:31.753000
2009-09-27T11:16:02.323000
160,494
160,570
Generic method call
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericCount { class Program { static int Count1 (T a) where T: IEnumerable { return a.Count(); } static void Main(string[] args) { List mystring = new List () { "rob","tx" }; int count = Count1 >(mystring);****** Console...
You want this static int Count1 (IEnumerable a) { return a.Count(); }
Generic method call using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericCount { class Program { static int Count1 (T a) where T: IEnumerable { return a.Count(); } static void Main(string[] args) { List mystring = new List () { "rob","tx" }; int count = Count1 >(myst...
TITLE: Generic method call QUESTION: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericCount { class Program { static int Count1 (T a) where T: IEnumerable { return a.Count(); } static void Main(string[] args) { List mystring = new List () { "rob","tx" }; int cou...
[ "c#", "generics" ]
1
4
258
4
0
2008-10-02T01:34:45.663000
2008-10-02T02:04:54.950000
160,497
160,505
Removing .svn folders from project for deployment
I'm using subversion (TortoiseSVN) and I want to remove the.svn folders from my project for deployment, is there an automated way of doing this using subversion or do I have to create a custom script for this?
TortoiseSVN has an export function. This will create the entire SVN tree elsewhere without the.svn folders. Also, a lot of FTP clients have filtering, which you can add.svn to just in case you forget one day.
Removing .svn folders from project for deployment I'm using subversion (TortoiseSVN) and I want to remove the.svn folders from my project for deployment, is there an automated way of doing this using subversion or do I have to create a custom script for this?
TITLE: Removing .svn folders from project for deployment QUESTION: I'm using subversion (TortoiseSVN) and I want to remove the.svn folders from my project for deployment, is there an automated way of doing this using subversion or do I have to create a custom script for this? ANSWER: TortoiseSVN has an export functio...
[ "svn", "deployment", "tortoisesvn" ]
15
24
9,161
9
0
2008-10-02T01:36:51.147000
2008-10-02T01:39:36.307000
160,509
160,512
How do I use Google Analytics in ASP.NET?
I have a web page in which people go to register for my site. I use server side validation to authenticate them. I need to call some Javascript to tell GA that user was or was not registered. Later I need stats on success in registration. How can I call the GA function on my server side C# code?
I don't think Google Analytics is set up to do what you are trying to do. You should just be pasting the code into your master page. From there, you should be able to get a good idea of how many people have registered based on how many visited the landing page after they register.
How do I use Google Analytics in ASP.NET? I have a web page in which people go to register for my site. I use server side validation to authenticate them. I need to call some Javascript to tell GA that user was or was not registered. Later I need stats on success in registration. How can I call the GA function on my se...
TITLE: How do I use Google Analytics in ASP.NET? QUESTION: I have a web page in which people go to register for my site. I use server side validation to authenticate them. I need to call some Javascript to tell GA that user was or was not registered. Later I need stats on success in registration. How can I call the GA...
[ "c#", "asp.net", "google-analytics" ]
2
0
5,288
5
0
2008-10-02T01:42:04.473000
2008-10-02T01:43:11.150000
160,514
160,530
Partial Classes in C#
Are there are good uses of Partial Classes outside the webforms/winforms generated code scenarios? Or is this feature basically to support that?
It is in part to support scenarios (WebForms, WinForms, LINQ-to-SQL, etc) mixing generated code with programmer code. There are more reasons to use it. For example, if you have big classes in large, unwieldy files, but the classes have groups of logically related methods, partial classes may be an option to make your f...
Partial Classes in C# Are there are good uses of Partial Classes outside the webforms/winforms generated code scenarios? Or is this feature basically to support that?
TITLE: Partial Classes in C# QUESTION: Are there are good uses of Partial Classes outside the webforms/winforms generated code scenarios? Or is this feature basically to support that? ANSWER: It is in part to support scenarios (WebForms, WinForms, LINQ-to-SQL, etc) mixing generated code with programmer code. There ar...
[ "c#", "partial-classes" ]
15
12
6,399
20
0
2008-10-02T01:44:13.610000
2008-10-02T01:49:05.423000
160,519
160,582
linqtosql, timespan, aggregates ... can it be done?
Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP BY City
using System.Data.Linq.SqlClient; db.Incidents.GroupBy(i => i.City).Select(g => new { City = g.Key, DownTime = g.Sum(i => SqlMethods.DateDiffMinute(i.StartDate, i.Completed)) });
linqtosql, timespan, aggregates ... can it be done? Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP BY City
TITLE: linqtosql, timespan, aggregates ... can it be done? QUESTION: Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP BY City ANSWER: using System.Data.Linq.SqlClient; db.Incidents.GroupBy(i => i.City).Select(g => new { City = g.Key, DownTime = g.S...
[ "linq" ]
1
1
374
2
0
2008-10-02T01:45:27.273000
2008-10-02T02:10:54.157000
160,532
172,881
Exporting MSAccess Tables as Unicode with Tilde delimiter
I want to export the contents of several tables from MSAccess2003. The tables contain unicode Japanese characters. I want to store them as tilde delimited text files. I can do this manually using File/Export and, in the 'Advanced' dialog selecting tilde as Field Delimiter and the Unicode as the Code Page. I can store t...
I have eventually solved this. (I am now using Access 2007 but had the same problems as with Access 2003.) First, what didn't work: TransferText would only make the Header Row unicode and tilde delimited, even with a correctly formatted schema.ini. (No, I didn't put it all on one line, that was just a formatting issue ...
Exporting MSAccess Tables as Unicode with Tilde delimiter I want to export the contents of several tables from MSAccess2003. The tables contain unicode Japanese characters. I want to store them as tilde delimited text files. I can do this manually using File/Export and, in the 'Advanced' dialog selecting tilde as Field...
TITLE: Exporting MSAccess Tables as Unicode with Tilde delimiter QUESTION: I want to export the contents of several tables from MSAccess2003. The tables contain unicode Japanese characters. I want to store them as tilde delimited text files. I can do this manually using File/Export and, in the 'Advanced' dialog select...
[ "ms-access", "unicode", "utf-8", "csv", "export" ]
2
4
5,946
4
0
2008-10-02T01:50:21.520000
2008-10-06T00:07:35.813000
160,534
160,547
How do I get the "td" in a table element with jquery?
I need to get the "td" element of a table. I do not have the ability to add a mouseover or onclick event to the "td" element, so I need to add them with JQUERY. I need JQUERY to add the mouseover and onclick event to the all "td" elements in the table. Thats what I need, maybe someone can help me out?
$(function() { $("table#mytable td").mouseover(function() { //The onmouseover code }).click(function() { //The onclick code }); });
How do I get the "td" in a table element with jquery? I need to get the "td" element of a table. I do not have the ability to add a mouseover or onclick event to the "td" element, so I need to add them with JQUERY. I need JQUERY to add the mouseover and onclick event to the all "td" elements in the table. Thats what I ...
TITLE: How do I get the "td" in a table element with jquery? QUESTION: I need to get the "td" element of a table. I do not have the ability to add a mouseover or onclick event to the "td" element, so I need to add them with JQUERY. I need JQUERY to add the mouseover and onclick event to the all "td" elements in the ta...
[ "jquery" ]
11
24
29,668
2
0
2008-10-02T01:51:55.887000
2008-10-02T01:57:09.243000
160,550
160,583
ZIP Code (US Postal Code) validation
I thought people would be working on little code projects together, but I don't see them, so here's an easy one: Code that validates a valid US Zip Code. I know there are ZIP code databases out there, but there are still uses, like web pages, quick validation, and also the fact that zip codes keep getting issued, so yo...
Javascript Regex Literal: US Zip Codes: /(^\d{5}$)|(^\d{5}-\d{4}$)/ var isValidZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/.test("90210"); Some countries use Postal Codes, which would fail this pattern.
ZIP Code (US Postal Code) validation I thought people would be working on little code projects together, but I don't see them, so here's an easy one: Code that validates a valid US Zip Code. I know there are ZIP code databases out there, but there are still uses, like web pages, quick validation, and also the fact that...
TITLE: ZIP Code (US Postal Code) validation QUESTION: I thought people would be working on little code projects together, but I don't see them, so here's an easy one: Code that validates a valid US Zip Code. I know there are ZIP code databases out there, but there are still uses, like web pages, quick validation, and ...
[ "javascript", "validation" ]
39
54
265,867
13
0
2008-10-02T01:57:52.207000
2008-10-02T02:11:07.027000
160,555
163,609
My form doesn't properly display when it is launched from another thread
Here's the situation: I'm developing a simple application with the following structure: FormMain (startup point) FormNotification CompleFunctions Right? Well, in FormMain I have the following function: private void DoItInNewThread(ParameterizedThreadStart pParameterizedThreadStart, object pParameters, ThreadPriority pT...
Almost every GUI library is designed to only allow calls that change the GUI to be made in a single thread designated for that purpose (called the UI thread). If you are in another thread, you are required to arrange for the call to change the GUI to be made in the UI thread. In.NET, the way to do that is to call Invok...
My form doesn't properly display when it is launched from another thread Here's the situation: I'm developing a simple application with the following structure: FormMain (startup point) FormNotification CompleFunctions Right? Well, in FormMain I have the following function: private void DoItInNewThread(ParameterizedThr...
TITLE: My form doesn't properly display when it is launched from another thread QUESTION: Here's the situation: I'm developing a simple application with the following structure: FormMain (startup point) FormNotification CompleFunctions Right? Well, in FormMain I have the following function: private void DoItInNewThrea...
[ "c#", "winforms", "multithreading" ]
4
5
3,996
5
0
2008-10-02T01:59:14.870000
2008-10-02T17:42:31.420000
160,557
160,655
Defining custom actions in Selenium
I have a Selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day). select validity_Y label=2008 select validity_M label=08 select validity_D label=08 This part gets repeated a lot throughout the test case. I'd like to reduce it by defining my custom action "selectValid...
I take it you're coding your tests in Selenese. If so, have you considered using one of the client drivers in any one of many languages? They've got java,.net, perl, ruby, javascript, php, and python. Each and every one of them have subroutines. Supposedly, the IDE can translate your existing Selenese tests into most o...
Defining custom actions in Selenium I have a Selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day). select validity_Y label=2008 select validity_M label=08 select validity_D label=08 This part gets repeated a lot throughout the test case. I'd like to reduce it by de...
TITLE: Defining custom actions in Selenium QUESTION: I have a Selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day). select validity_Y label=2008 select validity_M label=08 select validity_D label=08 This part gets repeated a lot throughout the test case. I'd like ...
[ "unit-testing", "selenium" ]
3
3
943
2
0
2008-10-02T02:00:00.233000
2008-10-02T02:40:24.520000
160,587
718,505
No output to console from a WPF application?
I'm using Console.WriteLine() from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what might be going on here? I can reproduce it by creating a WPF application in VS 2008, and simply adding Console.WriteLine...
You'll have to create a Console window manually before you actually call any Console.Write methods. That will init the Console to work properly without changing the project type (which for WPF application won't work). Here's a complete source code example, of how a ConsoleManager class might look like, and how it can b...
No output to console from a WPF application? I'm using Console.WriteLine() from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what might be going on here? I can reproduce it by creating a WPF application in...
TITLE: No output to console from a WPF application? QUESTION: I'm using Console.WriteLine() from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what might be going on here? I can reproduce it by creating a ...
[ "c#", ".net", "wpf", "console" ]
170
102
183,339
10
0
2008-10-02T02:12:03.980000
2009-04-05T07:14:31.997000
160,589
160,676
Experience with CSLA in a WPF/WCF application
Has anyone used CSLA in an application that has a WPF front end and a WCF wire for entities? If so, which "entity framework" did you use? (nHibernate, Linq, etc...) What were the hang-ups? What did it help you with? I am concerned with implementing this for an application, not knowing how data-binding, validation with ...
I don't know much about CSLA, but I have built application with WPF + LINQ + WCF, This combination works well for one way databinding to WPF, but we need to have an intermediate object class(ViewModel for WPF) to get the TwoWay working. This classes might be an exact copy of WCF classes(in most of the cases) but it wou...
Experience with CSLA in a WPF/WCF application Has anyone used CSLA in an application that has a WPF front end and a WCF wire for entities? If so, which "entity framework" did you use? (nHibernate, Linq, etc...) What were the hang-ups? What did it help you with? I am concerned with implementing this for an application, ...
TITLE: Experience with CSLA in a WPF/WCF application QUESTION: Has anyone used CSLA in an application that has a WPF front end and a WCF wire for entities? If so, which "entity framework" did you use? (nHibernate, Linq, etc...) What were the hang-ups? What did it help you with? I am concerned with implementing this fo...
[ "wpf", "wcf", "csla" ]
1
2
1,535
1
0
2008-10-02T02:13:00.267000
2008-10-02T02:50:06.650000
160,604
160,661
Combine multiple LINQ expressions from an array
I'm trying to combine a list of functions like so. I have this: Func [] criteria = new Func [3]; criteria[0] = i => i % 2 == 0; criteria[1] = i => i % 3 == 0; criteria[2] = i => i % 5 == 0; And I want this: Func [] predicates = new Func [3]; predicates[0] = i => i % 2 == 0; predicates[1] = i => i % 2 == 0 && i % 3 == 0...
This was a guess, as I know little about this stuff, but this seems to fix it: Func [] criteria = new Func [3]; criteria[0] = i => i % 2 == 0; criteria[1] = i => i % 3 == 0; criteria[2] = i => i % 5 == 0; Expression >[] results = new Expression >[criteria.Length]; for (int i = 0; i < criteria.Length; i++) { results[i] ...
Combine multiple LINQ expressions from an array I'm trying to combine a list of functions like so. I have this: Func [] criteria = new Func [3]; criteria[0] = i => i % 2 == 0; criteria[1] = i => i % 3 == 0; criteria[2] = i => i % 5 == 0; And I want this: Func [] predicates = new Func [3]; predicates[0] = i => i % 2 == ...
TITLE: Combine multiple LINQ expressions from an array QUESTION: I'm trying to combine a list of functions like so. I have this: Func [] criteria = new Func [3]; criteria[0] = i => i % 2 == 0; criteria[1] = i => i % 3 == 0; criteria[2] = i => i % 5 == 0; And I want this: Func [] predicates = new Func [3]; predicates[0...
[ "c#", ".net", "linq", "expression" ]
2
4
5,649
2
0
2008-10-02T02:19:22.717000
2008-10-02T02:42:45.390000
160,608
163,769
Do a "git export" (like "svn export")?
I've been wondering whether there is a good "git export" solution that creates a copy of a tree without the.git repository directory. There are at least three methods I know of: git clone followed by removing the.git repository directory. git checkout-index alludes to this functionality but starts with "Just read the d...
Probably the simplest way to achieve this is with git archive. If you really need just the expanded tree you can do something like this. git archive master | tar -x -C /somewhere/else Most of the time that I need to 'export' something from git, I want a compressed archive in any case so I do something like this. git ar...
Do a "git export" (like "svn export")? I've been wondering whether there is a good "git export" solution that creates a copy of a tree without the.git repository directory. There are at least three methods I know of: git clone followed by removing the.git repository directory. git checkout-index alludes to this functio...
TITLE: Do a "git export" (like "svn export")? QUESTION: I've been wondering whether there is a good "git export" solution that creates a copy of a tree without the.git repository directory. There are at least three methods I know of: git clone followed by removing the.git repository directory. git checkout-index allud...
[ "git", "export", "git-archive", "svn-export" ]
2,563
2,579
756,186
31
0
2008-10-02T02:21:33.897000
2008-10-02T18:13:14.263000
160,614
601,048
Using ASP.NET Dynamic Data site on Windows XP IIS?
I have a Dynamic Data website built in Visual Studio 2008 using.NET 3.5 SP1. The site works OK on my Vista machine, but I get the following error when running it on a Windows XP machine: Server Error in '/FlixManagerWeb' Application. -------------------------------------------------------------------------------- The r...
IIS 7 handles requests differently than IIS 5/6, and "default" routes are not handled by MVC in the classic mode. While IIS 5/6 will work if you specify a specific page, it will not work out-of-the-box for typical MVC URLs ( http://somesite/controller/action/parm ). It will only work if a) you include an extension in e...
Using ASP.NET Dynamic Data site on Windows XP IIS? I have a Dynamic Data website built in Visual Studio 2008 using.NET 3.5 SP1. The site works OK on my Vista machine, but I get the following error when running it on a Windows XP machine: Server Error in '/FlixManagerWeb' Application. -----------------------------------...
TITLE: Using ASP.NET Dynamic Data site on Windows XP IIS? QUESTION: I have a Dynamic Data website built in Visual Studio 2008 using.NET 3.5 SP1. The site works OK on my Vista machine, but I get the following error when running it on a Windows XP machine: Server Error in '/FlixManagerWeb' Application. -----------------...
[ ".net", "asp.net", "asp.net-mvc", "windows-xp", "dynamic-data" ]
0
1
733
2
0
2008-10-02T02:24:42.313000
2009-03-02T01:58:21.903000
160,633
160,646
Why do we still program with flat files?
Why are flat text files the state of the art for representing source code? Sure - the preprocessor and compiler need to see a flat file representation of the file, but that's easily created. It seems to me that some form of XML or binary data could represent lots of ideas that are very difficult to track, otherwise. Fo...
you can diff them you can merge them anyone can edit them they are simple and easy to deal with they are universally accessible to thousands of tools
Why do we still program with flat files? Why are flat text files the state of the art for representing source code? Sure - the preprocessor and compiler need to see a flat file representation of the file, but that's easily created. It seems to me that some form of XML or binary data could represent lots of ideas that a...
TITLE: Why do we still program with flat files? QUESTION: Why are flat text files the state of the art for representing source code? Sure - the preprocessor and compiler need to see a flat file representation of the file, but that's easily created. It seems to me that some form of XML or binary data could represent lo...
[ "flat-file" ]
49
141
7,688
34
0
2008-10-02T02:32:37.457000
2008-10-02T02:36:26.403000
160,635
160,864
FitNesse Wiki Per Project or Company?
For a company with many development projects, should you create multiple FitNesse wikis (one for each project/product) or contain them all within a large wiki for everything? Advantages of one large wiki is the ability to easily link to other products in the company and that it is a one-stop location for all the FitNes...
It seems it all boils down to an administration problem: How many servers are available out there and who manages them? One central server mean a server able to take the load, both in term of requests (all developers from all projects can make many queries on a fairly regular base), and in term of "on-server" FitNesse-...
FitNesse Wiki Per Project or Company? For a company with many development projects, should you create multiple FitNesse wikis (one for each project/product) or contain them all within a large wiki for everything? Advantages of one large wiki is the ability to easily link to other products in the company and that it is ...
TITLE: FitNesse Wiki Per Project or Company? QUESTION: For a company with many development projects, should you create multiple FitNesse wikis (one for each project/product) or contain them all within a large wiki for everything? Advantages of one large wiki is the ability to easily link to other products in the compa...
[ "fitnesse" ]
3
1
588
1
0
2008-10-02T02:33:14.540000
2008-10-02T04:17:30.153000
160,650
160,860
Run custom Javascript whenever a client-side ASP.NET validator is triggered?
Is there a way to run some custom Javascript whenever a client-side ASP.NET validator ( RequiredFieldValidator, RangeValidator, etc) is triggered? Basically, I have a complicated layout that requires I run a custom script whenever a DOM element is shown or hidden. I'm looking for a way to automatically run this script ...
See this comment for how I managed to extend the ASP.Net client side validation. Others have managed to extend it using server side techniques.
Run custom Javascript whenever a client-side ASP.NET validator is triggered? Is there a way to run some custom Javascript whenever a client-side ASP.NET validator ( RequiredFieldValidator, RangeValidator, etc) is triggered? Basically, I have a complicated layout that requires I run a custom script whenever a DOM elemen...
TITLE: Run custom Javascript whenever a client-side ASP.NET validator is triggered? QUESTION: Is there a way to run some custom Javascript whenever a client-side ASP.NET validator ( RequiredFieldValidator, RangeValidator, etc) is triggered? Basically, I have a complicated layout that requires I run a custom script whe...
[ "asp.net", "javascript" ]
3
2
2,564
3
0
2008-10-02T02:38:06.570000
2008-10-02T04:14:50.817000
160,651
162,457
HTTPHandler to Retrieve Download File from another server?
I would like to provide downloadable files to website users, but want to hide the URL of the files from the user... I'm thinking an HTTPHandler could do the trick, but is it possible to retrieve a file from an external server and stream it to the user? Perhaps somebody can give me a hint at how to accomplish this, or p...
With your clarification of wanting the bandwidth to come from the external server and not yours, it changes the question quite a bit. In order to accomplish that, the external server would have to have a website on it you could send the user to. You cannot stream the file through your site but not get hit with the band...
HTTPHandler to Retrieve Download File from another server? I would like to provide downloadable files to website users, but want to hide the URL of the files from the user... I'm thinking an HTTPHandler could do the trick, but is it possible to retrieve a file from an external server and stream it to the user? Perhaps ...
TITLE: HTTPHandler to Retrieve Download File from another server? QUESTION: I would like to provide downloadable files to website users, but want to hide the URL of the files from the user... I'm thinking an HTTPHandler could do the trick, but is it possible to retrieve a file from an external server and stream it to ...
[ "asp.net", "download", "httphandler" ]
1
1
7,795
5
0
2008-10-02T02:38:10.970000
2008-10-02T14:08:13.057000
160,666
160,717
HTML - display an image as large as possible while preserving aspect ratio
I'd like to have an HTML page which displays a single PNG or JPEG image. I want the image to take up the whole screen but when I do this: It just stretches the image and messes up the aspect ratio. How do I solve this so the image has the correct aspect ratio while scaling to the maximum size possible? The solution pos...
Here's a quick function that will adjust the height or width to 100% depending on which is bigger. Tested in FF3, IE7 & Chrome
HTML - display an image as large as possible while preserving aspect ratio I'd like to have an HTML page which displays a single PNG or JPEG image. I want the image to take up the whole screen but when I do this: It just stretches the image and messes up the aspect ratio. How do I solve this so the image has the correc...
TITLE: HTML - display an image as large as possible while preserving aspect ratio QUESTION: I'd like to have an HTML page which displays a single PNG or JPEG image. I want the image to take up the whole screen but when I do this: It just stretches the image and messes up the aspect ratio. How do I solve this so the im...
[ "html" ]
22
15
39,582
8
0
2008-10-02T02:44:59.253000
2008-10-02T03:03:19.473000
160,742
160,747
How do you put { and } in a format string
I'm trying to generate some code at runtime where I put in some boiler-plate stuff and the user is allowed to enter the actual working code. My boiler-plate code looks something like this: using System; public class ClassName { public double TheFunction(double input) { // user entered code here } } Ideally, I think I ...
Escape them by doubling them up: string s = String.Format("{{ hello to all }}"); Console.WriteLine(s); //prints '{ hello to all }' From http://msdn.microsoft.com/en-us/netframework/aa569608.aspx#Question1
How do you put { and } in a format string I'm trying to generate some code at runtime where I put in some boiler-plate stuff and the user is allowed to enter the actual working code. My boiler-plate code looks something like this: using System; public class ClassName { public double TheFunction(double input) { // user...
TITLE: How do you put { and } in a format string QUESTION: I'm trying to generate some code at runtime where I put in some boiler-plate stuff and the user is allowed to enter the actual working code. My boiler-plate code looks something like this: using System; public class ClassName { public double TheFunction(doubl...
[ "c#", ".net", "string", "formatting" ]
23
40
4,843
5
0
2008-10-02T03:12:04.290000
2008-10-02T03:14:14.237000
160,776
160,782
How would you compare IP address?
For my server app, I need to check if an ip address is in our blacklist. What is the most efficient way of comparing ip addresses? Would converting the IP address to integer and comparing them efficient?
Depends what language you're using, but an IP address is usually stored as a 32-bit unsigned integer, at least at the network layer, making comparisons quite fast. Even if it's not, unless you're designing a high performance packet switching application it's not likely to be a performance bottleneck. Avoid premature op...
How would you compare IP address? For my server app, I need to check if an ip address is in our blacklist. What is the most efficient way of comparing ip addresses? Would converting the IP address to integer and comparing them efficient?
TITLE: How would you compare IP address? QUESTION: For my server app, I need to check if an ip address is in our blacklist. What is the most efficient way of comparing ip addresses? Would converting the IP address to integer and comparing them efficient? ANSWER: Depends what language you're using, but an IP address i...
[ "ip-address" ]
13
30
21,048
12
0
2008-10-02T03:28:37.230000
2008-10-02T03:31:44.663000
160,791
194,073
Sticky mouse when dragging controls in VS2005
Maybe this is a dumb question, but I have the following behavior in Visual Studio 2005 while designing forms: 1 - Drop a control onto the form (suppose it's a Label, just for discussion) 2 - Drag that label to a specific location (aligning w/other controls, whatever) 3 - Release the mouse button 4 - The control is stil...
This problem spread to other applications within my VM, so I reinstalled Parallels tools and it went away.
Sticky mouse when dragging controls in VS2005 Maybe this is a dumb question, but I have the following behavior in Visual Studio 2005 while designing forms: 1 - Drop a control onto the form (suppose it's a Label, just for discussion) 2 - Drag that label to a specific location (aligning w/other controls, whatever) 3 - Re...
TITLE: Sticky mouse when dragging controls in VS2005 QUESTION: Maybe this is a dumb question, but I have the following behavior in Visual Studio 2005 while designing forms: 1 - Drop a control onto the form (suppose it's a Label, just for discussion) 2 - Drag that label to a specific location (aligning w/other controls...
[ "visual-studio-2005" ]
0
0
189
2
0
2008-10-02T03:35:18.650000
2008-10-11T13:32:09.217000
160,793
161,120
Is there build farm for checking open source apps against different OS'es?
I have an Open Source app and I have it working on Windows, Linux and Macintosh ( it's in C++ and built with gcc ). I've only tested it on a few different flavors of Linux so I don't know if it compiles and runs on all different Linux versions. Is there a place where I can upload my code and have it tested across a bun...
There are a few options but there don't appear to be many (any?) free services like this, which isn't surprising considering the amount of effort and resources it requires. Sourceforge used to operate a compile farm like what you describe but it shut down a year or so ago. You might look into some of the following. If ...
Is there build farm for checking open source apps against different OS'es? I have an Open Source app and I have it working on Windows, Linux and Macintosh ( it's in C++ and built with gcc ). I've only tested it on a few different flavors of Linux so I don't know if it compiles and runs on all different Linux versions. ...
TITLE: Is there build farm for checking open source apps against different OS'es? QUESTION: I have an Open Source app and I have it working on Windows, Linux and Macintosh ( it's in C++ and built with gcc ). I've only tested it on a few different flavors of Linux so I don't know if it compiles and runs on all differen...
[ "c++", "build", "operating-system" ]
19
11
2,819
4
0
2008-10-02T03:35:32.453000
2008-10-02T06:42:06.827000
160,800
160,852
Run Sparc binaries without Sparc hardware
I've been curious in the past few months in trying my hand at doing some assembly for the SPARC processor (either V8 or V9). My question is this, I have no access to a SPARC machine, is there a way I can run SPARC binaries on my x86 machine? I've looked at QEMU but I am not too sure how to set it up.
SimICS emulates a Sparc platform. Academic and personal licenses are free. Edit: I didn't do SimICS justice in my initial response, it is a very useful tool for Sparc-based development. You can instrument, profile, and explore the behavior or code in both user space and kernel space. I first became aware of it about 10...
Run Sparc binaries without Sparc hardware I've been curious in the past few months in trying my hand at doing some assembly for the SPARC processor (either V8 or V9). My question is this, I have no access to a SPARC machine, is there a way I can run SPARC binaries on my x86 machine? I've looked at QEMU but I am not too...
TITLE: Run Sparc binaries without Sparc hardware QUESTION: I've been curious in the past few months in trying my hand at doing some assembly for the SPARC processor (either V8 or V9). My question is this, I have no access to a SPARC machine, is there a way I can run SPARC binaries on my x86 machine? I've looked at QEM...
[ "assembly", "emulation", "sparc" ]
12
6
13,030
10
0
2008-10-02T03:38:05.757000
2008-10-02T04:07:57.103000
160,813
160,832
Define a .NET extension method with solution scope
I have a few 'helper' style extension methods I use quite regularly now (they are mostly quite simple, intuitive, and work for good not evil, so please don't have this descend into a discussion around whether or not I should use them). They are largely extending core.NET CLR classes. Currently, I have to copy the 'Exte...
If you don't want to create a whole project just for the extension methods, you can link the same file into separate projects without copying the file: In Solution Explorer, select the target project. Select the Project menu. Select Add Existing Item. In the Add Existing Item dialog box, select the item you want to lin...
Define a .NET extension method with solution scope I have a few 'helper' style extension methods I use quite regularly now (they are mostly quite simple, intuitive, and work for good not evil, so please don't have this descend into a discussion around whether or not I should use them). They are largely extending core.N...
TITLE: Define a .NET extension method with solution scope QUESTION: I have a few 'helper' style extension methods I use quite regularly now (they are mostly quite simple, intuitive, and work for good not evil, so please don't have this descend into a discussion around whether or not I should use them). They are largel...
[ ".net", "extension-methods" ]
6
9
1,427
5
0
2008-10-02T03:44:53.947000
2008-10-02T03:54:15.780000
160,824
161,652
How do I pass data between activities in Windows Workflow?
I'm not completely sure I understand the workflow way of doing things, but if it's a pipeline n filter style model I should be able to pass data (even strings) from one activity to another. Does anyone know how to do this? Bonus points for a video! I hope this is possible. If WF were the same as my idea of it then it w...
Method 1 (Design- and run-time): Activity databinding You can bind the dependency properties of an activity to the properties of another activity. See Activity Binding in Windows Workflow Foundation. Enabling Activity Data Binding Method 2 (Run-time): Find an activity from the activity tree See Paragraph "Workflow Deve...
How do I pass data between activities in Windows Workflow? I'm not completely sure I understand the workflow way of doing things, but if it's a pipeline n filter style model I should be able to pass data (even strings) from one activity to another. Does anyone know how to do this? Bonus points for a video! I hope this ...
TITLE: How do I pass data between activities in Windows Workflow? QUESTION: I'm not completely sure I understand the workflow way of doing things, but if it's a pipeline n filter style model I should be able to pass data (even strings) from one activity to another. Does anyone know how to do this? Bonus points for a v...
[ ".net", "data-binding", "workflow", "workflow-foundation", "workflow-activity" ]
2
5
5,006
1
0
2008-10-02T03:51:02.667000
2008-10-02T10:18:19.880000
160,848
160,850
.NET multiplication optimization
Does the compiler optimize out any multiplications by 1? That is, consider: int a = 1; int b = 5 * a; Will the expression 5 * a be optimized into just 5? If not, will it if a is defined as: const int a = 1;
It will pre-calculate any constant expressions when it compiles, including string concatenation. Without the const it will be left alone. Your first example compiles to this IL:.maxstack 2.locals init ([0] int32, [1] int32) ldc.i4.1 //load 1 stloc.0 //store in 1st local variable ldc.i4.5 //load 5 ldloc.0 //load 1st va...
.NET multiplication optimization Does the compiler optimize out any multiplications by 1? That is, consider: int a = 1; int b = 5 * a; Will the expression 5 * a be optimized into just 5? If not, will it if a is defined as: const int a = 1;
TITLE: .NET multiplication optimization QUESTION: Does the compiler optimize out any multiplications by 1? That is, consider: int a = 1; int b = 5 * a; Will the expression 5 * a be optimized into just 5? If not, will it if a is defined as: const int a = 1; ANSWER: It will pre-calculate any constant expressions when i...
[ "c#", ".net", "optimization", "compiler-construction", "multiplication" ]
7
14
1,934
4
0
2008-10-02T04:06:23.783000
2008-10-02T04:07:41.113000
160,859
160,898
What is "lambda binding" in Python?
I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs. A link to read about it would be great. A trivial explained example would be even better. Thank you.
First, a general definition: When a program or function statement is executed, the current values of formal parameters are saved (on the stack) and within the scope of the statement, they are bound to the values of the actual arguments made in the call. When the statement is exited, the original values of those formal ...
What is "lambda binding" in Python? I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs. A link to read about it would be great. A trivial explained example would be even better. Thank you.
TITLE: What is "lambda binding" in Python? QUESTION: I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs. A link to read about it would be great. A trivial explained example would be even better. Thank you. ANSWER: First, a general de...
[ "python", "binding", "lambda" ]
10
14
6,298
3
0
2008-10-02T04:14:01.100000
2008-10-02T04:38:59.680000
160,876
160,964
How does a Perl socket resolve hostnames under Linux?
I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails: $s = new IO::Socket::INET( PeerAddr => 'stackoverflow.com', PeerPort => 80, Proto => 'tcp', ); die "Error: $!\n" unless $s; I ve...
From a quick look, the following code from IO::Socket::INET sub _get_addr { my($sock,$addr_str, $multi) = @_; my @addr; if ($multi && $addr_str!~ /^\d+(?:\.\d+){3}$/) { (undef, undef, undef, undef, @addr) = gethostbyname($addr_str); } else { my $h = inet_aton($addr_str); push(@addr, $h) if defined $h; } @addr; } sugges...
How does a Perl socket resolve hostnames under Linux? I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails: $s = new IO::Socket::INET( PeerAddr => 'stackoverflow.com', PeerPort => 80,...
TITLE: How does a Perl socket resolve hostnames under Linux? QUESTION: I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails: $s = new IO::Socket::INET( PeerAddr => 'stackoverflow.com...
[ "linux", "perl", "sockets", "dns" ]
3
7
4,047
3
0
2008-10-02T04:25:29.650000
2008-10-02T05:11:35.577000
160,881
169,241
VB6 Integration with MSBuild
So this is a question for anyone who has had to integrate the building/compilation of legacy projects/code in a Team Build/MSBuild environment - specifically, Visual Basic 6 applications/projects. Outside of writing a custom build Task (which I am not against) does anyone have any suggestions on how best to integrate c...
The VB6 task will be back on Monday. With regards to versioning, there is no explicit vb versioning task in the pack, however you could make use of the TfsVersion (TaskAction="GetVersion") and the File (TaskAction="Replace") tasks. If you think there is value in creating a new task to encapsulate / provide other functi...
VB6 Integration with MSBuild So this is a question for anyone who has had to integrate the building/compilation of legacy projects/code in a Team Build/MSBuild environment - specifically, Visual Basic 6 applications/projects. Outside of writing a custom build Task (which I am not against) does anyone have any suggestio...
TITLE: VB6 Integration with MSBuild QUESTION: So this is a question for anyone who has had to integrate the building/compilation of legacy projects/code in a Team Build/MSBuild environment - specifically, Visual Basic 6 applications/projects. Outside of writing a custom build Task (which I am not against) does anyone ...
[ "vb6", "tfs", "msbuild", "build-automation" ]
6
2
3,409
2
0
2008-10-02T04:29:59.907000
2008-10-03T23:07:05.313000
160,889
161,146
Emulation of lex like functionality in Perl or Python
Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes? One example: I have to get all href tags, their corresponding text and some other text based on a different regex. So I have 3 expressions and would like to tokenize the line and extract tokens of text matching every expressi...
If you're specifically after parsing links out of web-pages, then Perl's WWW::Mechanize module will figure things out for you in a very elegant fashion. Here's a sample program that grabs the first page of Stack Overflow and parses out all the links, printing their text and corresponding URLs: #!/usr/bin/perl use stric...
Emulation of lex like functionality in Perl or Python Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes? One example: I have to get all href tags, their corresponding text and some other text based on a different regex. So I have 3 expressions and would like to tokenize the l...
TITLE: Emulation of lex like functionality in Perl or Python QUESTION: Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes? One example: I have to get all href tags, their corresponding text and some other text based on a different regex. So I have 3 expressions and would like...
[ "python", "perl", "parsing", "lex" ]
4
7
1,545
8
0
2008-10-02T04:34:06.213000
2008-10-02T06:52:06.337000
160,890
163,178
Generating random numbers in Objective-C
I'm a Java head mainly, and I want a way to generate a pseudo-random number between 0 and 74. In Java I would use the method: Random.nextInt(74) I'm not interested in a discussion about seeds or true randomness, just how you accomplish the same task in Objective-C. I've scoured Google, and there just seems to be lots o...
You should use the arc4random_uniform() function. It uses a superior algorithm to rand. You don't even need to set a seed. #include //... //... int r = arc4random_uniform(74); The arc4random man page: NAME arc4random, arc4random_stir, arc4random_addrandom -- arc4 random number generator LIBRARY Standard C Library (lib...
Generating random numbers in Objective-C I'm a Java head mainly, and I want a way to generate a pseudo-random number between 0 and 74. In Java I would use the method: Random.nextInt(74) I'm not interested in a discussion about seeds or true randomness, just how you accomplish the same task in Objective-C. I've scoured ...
TITLE: Generating random numbers in Objective-C QUESTION: I'm a Java head mainly, and I want a way to generate a pseudo-random number between 0 and 74. In Java I would use the method: Random.nextInt(74) I'm not interested in a discussion about seeds or true randomness, just how you accomplish the same task in Objectiv...
[ "objective-c", "random" ]
754
1,037
468,559
13
0
2008-10-02T04:35:21.967000
2008-10-02T16:00:17.797000
160,904
160,933
Oracle considers empty strings to be NULL while SQL Server does not - how is this best handled?
I have to write a component that re-creates SQL Server tables (structure and data) in an Oracle database. This component also has to take new data entered into the Oracle database and copy it back into SQL Server. Translating the data types from SQL Server to Oracle is not a problem. However, a critical difference betw...
I don't see an easy solution for this. Maybe you can store your values as one or more blanks -> ' ', which aren't NULLS in Oracle, or keep track of this special case through extra fields/tables, and an adapter layer.
Oracle considers empty strings to be NULL while SQL Server does not - how is this best handled? I have to write a component that re-creates SQL Server tables (structure and data) in an Oracle database. This component also has to take new data entered into the Oracle database and copy it back into SQL Server. Translatin...
TITLE: Oracle considers empty strings to be NULL while SQL Server does not - how is this best handled? QUESTION: I have to write a component that re-creates SQL Server tables (structure and data) in an Oracle database. This component also has to take new data entered into the Oracle database and copy it back into SQL ...
[ "sql-server", "oracle" ]
21
10
32,599
11
0
2008-10-02T04:43:19.717000
2008-10-02T05:00:48.473000
160,905
160,916
Django admin site not displaying ManyToManyField relationship
I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields. Here's my models.py: class Tech(models.Model): name = models.CharField(max_length = 30) class Project(models.Model): title = models.CharField(max_length = 50) techs = models.ManyTo...
I've tried adding the TechInline class to the inlines list, but that causes a 'TechInLine' not defined Is that a straight copy-paste? It looks like you just made a typo -- try TechInline instead of TechInLine. If your syncdb didn't create the proper table, you can do it manually. Execute this command: python manage.py ...
Django admin site not displaying ManyToManyField relationship I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields. Here's my models.py: class Tech(models.Model): name = models.CharField(max_length = 30) class Project(models.Model): t...
TITLE: Django admin site not displaying ManyToManyField relationship QUESTION: I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields. Here's my models.py: class Tech(models.Model): name = models.CharField(max_length = 30) class Projec...
[ "python", "django" ]
4
3
5,737
3
0
2008-10-02T04:43:28.923000
2008-10-02T04:48:29.987000
160,908
696,240
OpenJDK7: What essential ADTs are not Implemented in OpenJDK7?
What Abstract Datatypes should be added to OpenJDK7?
If you look at these two links you will see what some people feel is missing: http://commons.apache.org/collections/ http://code.google.com/p/google-collections/ My favourite missing one is Bag... it is easy to implement, but annoying to have to implement it. Mulimaps would also nice to have in the standard packages.
OpenJDK7: What essential ADTs are not Implemented in OpenJDK7? What Abstract Datatypes should be added to OpenJDK7?
TITLE: OpenJDK7: What essential ADTs are not Implemented in OpenJDK7? QUESTION: What Abstract Datatypes should be added to OpenJDK7? ANSWER: If you look at these two links you will see what some people feel is missing: http://commons.apache.org/collections/ http://code.google.com/p/google-collections/ My favourite mi...
[ "java", "specifications", "adts" ]
0
3
203
2
0
2008-10-02T04:45:15.687000
2009-03-30T06:57:50.360000
160,923
160,993
How to simulate a Delphi breakpoint in code?
I am pretty sure I have seen this before, but I haven't found out / remembered how to do it. I want to have a line of code that when executed from the Delphi debugger I want the debugger to pop-up like there was a break point on that line. Something like: FooBar:= Foo(Bar); SimulateBreakPoint; // Cause break point to o...
To trigger the debugger from code (supposedly, I don't have a copy of delphi handy to try): asm int 3 end; See this page: http://17slon.com/blogs/gabr/2008/03/debugging-with-lazy-breakpoints.html
How to simulate a Delphi breakpoint in code? I am pretty sure I have seen this before, but I haven't found out / remembered how to do it. I want to have a line of code that when executed from the Delphi debugger I want the debugger to pop-up like there was a break point on that line. Something like: FooBar:= Foo(Bar); ...
TITLE: How to simulate a Delphi breakpoint in code? QUESTION: I am pretty sure I have seen this before, but I haven't found out / remembered how to do it. I want to have a line of code that when executed from the Delphi debugger I want the debugger to pop-up like there was a break point on that line. Something like: F...
[ "delphi", "debugging", "ide", "breakpoints" ]
27
39
5,634
2
0
2008-10-02T04:54:24.653000
2008-10-02T05:25:13.503000
160,924
160,926
How can I kill a process by name instead of PID, on Linux?
Sometimes when I try to start Firefox it says "a Firefox process is already running". So I have to do this: jeremy@jeremy-desktop:~$ ps aux | grep firefox jeremy 7451 25.0 27.4 170536 65680? Sl 22:39 1:18 /usr/lib/firefox-3.0.1/firefox jeremy 7578 0.0 0.3 3004 768 pts/0 S+ 22:44 0:00 grep firefox jeremy@jeremy-desktop:...
pkill firefox More information: http://linux.about.com/library/cmd/blcmdl1_pkill.htm
How can I kill a process by name instead of PID, on Linux? Sometimes when I try to start Firefox it says "a Firefox process is already running". So I have to do this: jeremy@jeremy-desktop:~$ ps aux | grep firefox jeremy 7451 25.0 27.4 170536 65680? Sl 22:39 1:18 /usr/lib/firefox-3.0.1/firefox jeremy 7578 0.0 0.3 3004 ...
TITLE: How can I kill a process by name instead of PID, on Linux? QUESTION: Sometimes when I try to start Firefox it says "a Firefox process is already running". So I have to do this: jeremy@jeremy-desktop:~$ ps aux | grep firefox jeremy 7451 25.0 27.4 170536 65680? Sl 22:39 1:18 /usr/lib/firefox-3.0.1/firefox jeremy ...
[ "linux", "bash", "shell", "kill" ]
528
734
792,162
18
0
2008-10-02T04:57:20.387000
2008-10-02T04:58:24.173000
160,930
160,935
How do I check if an integer is even or odd?
How can I check if a given number is even or odd in C?
Use the modulo (%) operator to check if there's a remainder when dividing by 2: if (x % 2) { /* x is odd */ } A few people have criticized my answer above stating that using x & 1 is "faster" or "more efficient". I do not believe this to be the case. Out of curiosity, I created two trivial test case programs: /* modulo...
How do I check if an integer is even or odd? How can I check if a given number is even or odd in C?
TITLE: How do I check if an integer is even or odd? QUESTION: How can I check if a given number is even or odd in C? ANSWER: Use the modulo (%) operator to check if there's a remainder when dividing by 2: if (x % 2) { /* x is odd */ } A few people have criticized my answer above stating that using x & 1 is "faster" o...
[ "c", "integer" ]
193
448
503,098
30
0
2008-10-02T05:00:08.617000
2008-10-02T05:01:03.887000
160,938
160,957
Fatal Error C1083: Cannot Open Include file: 'tiffio.h': No such file or directory VC++ 2008
I got this error when I tried to compile an application that includes the tiffio.h header. For the record, the tiffio.h is located at: C:\Program Files\GnuWin32\include I have set that directory to be included in the 'Projects' and 'Solution' Visual C++ directories, as shown in the image located here. What am I missing...
In the Options dialog you have in the image - change the "Show directories for" from "Executable Files" to "Include files" and then add the include path there.
Fatal Error C1083: Cannot Open Include file: 'tiffio.h': No such file or directory VC++ 2008 I got this error when I tried to compile an application that includes the tiffio.h header. For the record, the tiffio.h is located at: C:\Program Files\GnuWin32\include I have set that directory to be included in the 'Projects'...
TITLE: Fatal Error C1083: Cannot Open Include file: 'tiffio.h': No such file or directory VC++ 2008 QUESTION: I got this error when I tried to compile an application that includes the tiffio.h header. For the record, the tiffio.h is located at: C:\Program Files\GnuWin32\include I have set that directory to be included...
[ "visual-c++" ]
2
3
9,100
1
0
2008-10-02T05:01:16.103000
2008-10-02T05:07:23.077000
160,948
160,953
How can I tell if SP1 has been installed on VS2008?
How can I tell if SP1 has been installed on VS2008? e.g. If I'm working on a co-worker's machine - how can I tell if he/she has installed SP1 for VS2008?
In Help->About, you can view the installed products. You should see something similar to Microsoft Visual Studio Team System 2008 Team Suite - ENU Service Pack 1 (KB945140) KB945140 in the list of entries.
How can I tell if SP1 has been installed on VS2008? How can I tell if SP1 has been installed on VS2008? e.g. If I'm working on a co-worker's machine - how can I tell if he/she has installed SP1 for VS2008?
TITLE: How can I tell if SP1 has been installed on VS2008? QUESTION: How can I tell if SP1 has been installed on VS2008? e.g. If I'm working on a co-worker's machine - how can I tell if he/she has installed SP1 for VS2008? ANSWER: In Help->About, you can view the installed products. You should see something similar t...
[ "visual-studio-2008", "installation" ]
22
28
17,021
4
0
2008-10-02T05:02:50.980000
2008-10-02T05:05:54.093000
160,954
160,989
Rails Console Doesn't Automatically Load Models For 2nd DB
I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database. database.yml looks like development: adapter: postgresql database: blah blah... oracle_db: adapter: oracle database: blah blah My models which descend from data on ...
I believe this might have to do with your model name, rather than your connection. The Rails convention is that model class names are CamelCase, while the files they reside in are lowercase+underscore. The "LegacyModel" class should therefore be in models/legacy_model.rb. Your statement about "require 'LegacyDataClass'...
Rails Console Doesn't Automatically Load Models For 2nd DB I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database. database.yml looks like development: adapter: postgresql database: blah blah... oracle_db: adapter: oracl...
TITLE: Rails Console Doesn't Automatically Load Models For 2nd DB QUESTION: I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database. database.yml looks like development: adapter: postgresql database: blah blah... oracle_...
[ "ruby-on-rails", "ruby", "console", "require" ]
1
3
1,889
2
0
2008-10-02T05:06:06.730000
2008-10-02T05:24:56.700000
160,960
160,969
Error: initializer element is not computable at load time
I have a function that takes a struct, and I'm trying to store its variables in array: int detect_prm(Param prm) { int prm_arr[] = {prm.field1, prm.field2, prm.field3}; return 0; } But with gcc -Wall -ansi -pedantic-errors -Werror I get the following error: initializer element is not computable at load time It looks f...
This is illegal in C. Initializer lists must be constant compile time expressions. Do the following instead: int prm_arr[3]; prm_arr[0] = prm.field1; prm_arr[1] = prm.field2; prm_arr[2] = prm.field3;
Error: initializer element is not computable at load time I have a function that takes a struct, and I'm trying to store its variables in array: int detect_prm(Param prm) { int prm_arr[] = {prm.field1, prm.field2, prm.field3}; return 0; } But with gcc -Wall -ansi -pedantic-errors -Werror I get the following error: ini...
TITLE: Error: initializer element is not computable at load time QUESTION: I have a function that takes a struct, and I'm trying to store its variables in array: int detect_prm(Param prm) { int prm_arr[] = {prm.field1, prm.field2, prm.field3}; return 0; } But with gcc -Wall -ansi -pedantic-errors -Werror I get the fo...
[ "c", "gcc", "ansi-c", "gcc-pedantic" ]
15
18
36,796
2
0
2008-10-02T05:08:39.063000
2008-10-02T05:13:50.690000
160,968
161,016
How do you balance the conflicting needs of backwards compatibility and innovation?
I work on an application that has a both a GUI (graphical) and API (scripting) interface. Our product has a very large installed base. Many customers have invested a lot of time and effort into writing scripts that use our product. In all of our designs and implementation, we (understandably) have a very strict require...
As far is my programming experience is concerned, if I'm going to fundamentally change something that will prevent past incoming data to be used correctly, I need to create an abstraction layer for the old data where it can be converted for use in the new format. Basically I set the "improved" way as default and make s...
How do you balance the conflicting needs of backwards compatibility and innovation? I work on an application that has a both a GUI (graphical) and API (scripting) interface. Our product has a very large installed base. Many customers have invested a lot of time and effort into writing scripts that use our product. In a...
TITLE: How do you balance the conflicting needs of backwards compatibility and innovation? QUESTION: I work on an application that has a both a GUI (graphical) and API (scripting) interface. Our product has a very large installed base. Many customers have invested a lot of time and effort into writing scripts that use...
[ "backwards-compatibility" ]
10
5
629
4
0
2008-10-02T05:13:13.360000
2008-10-02T05:37:21.337000