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
162,991
163,072
Selecting proper toolkit for a 2D simulation project in Java
I am looking for a toolkit that will allow me to design widgets containing 2D graphics for an elevator simulation in Java. Once created, those widgets will be integrated with SWT, Swing, or QtJambi framework. Background information: I am developing an Elevator Simulator for fun. My main goal is to increase my knowledge...
You can use an SWT canvas (or Swing canvas, or OpenGL canvas via JOGL,...), and set it up as an Observer of your simulation, and whenever the simulation state changes, you can redraw the new state.
Selecting proper toolkit for a 2D simulation project in Java I am looking for a toolkit that will allow me to design widgets containing 2D graphics for an elevator simulation in Java. Once created, those widgets will be integrated with SWT, Swing, or QtJambi framework. Background information: I am developing an Elevato...
TITLE: Selecting proper toolkit for a 2D simulation project in Java QUESTION: I am looking for a toolkit that will allow me to design widgets containing 2D graphics for an elevator simulation in Java. Once created, those widgets will be integrated with SWT, Swing, or QtJambi framework. Background information: I am dev...
[ "java", "graphics", "simulation" ]
2
1
1,265
3
0
2008-10-02T15:24:42.967000
2008-10-02T15:40:17.033000
162,993
164,690
The RunInstaller attribute in a WMI provider assembly
I am creating a decoupled WMI provider in a class library. Everything I have read points towards including something along these lines: [System.ComponentModel.RunInstaller(true)] public class MyApplicationManagementInstaller: DefaultManagementInstaller { } I gather the purpose of this installation is because the Window...
As I understand, DefaultManagementInstaller is ran by installutil.exe - if you don't include it, the class is not installed in WMI. Maybe it is possible to create a 'setup project' or 'installer project' that runs it, but I'm not sure because I don't use Visual Studio. [edit] for remote instalation, an option could be ...
The RunInstaller attribute in a WMI provider assembly I am creating a decoupled WMI provider in a class library. Everything I have read points towards including something along these lines: [System.ComponentModel.RunInstaller(true)] public class MyApplicationManagementInstaller: DefaultManagementInstaller { } I gather ...
TITLE: The RunInstaller attribute in a WMI provider assembly QUESTION: I am creating a decoupled WMI provider in a class library. Everything I have read points towards including something along these lines: [System.ComponentModel.RunInstaller(true)] public class MyApplicationManagementInstaller: DefaultManagementInsta...
[ "c#", "windows", "wmi" ]
1
2
1,818
3
0
2008-10-02T15:24:55.323000
2008-10-02T21:28:16.837000
163,004
163,087
MySQL Query: LIMITing a JOIN
Say I have two tables I want to join. Categories: id name ---------- 1 Cars 2 Games 3 Pencils And items: id categoryid itemname --------------------------- 1 1 Ford 2 1 BMW 3 1 VW 4 2 Tetris 5 2 Pong 6 3 Foobar Pencil Factory I want a query that returns the category and the first (and only the first) itemname: category...
Just done a quick test. This seems to work: mysql> select * from categories c, items i -> where i.categoryid = c.id -> group by c.id; +------+---------+------+------------+----------------+ | id | name | id | categoryid | name | +------+---------+------+------------+----------------+ | 1 | Cars | 1 | 1 | Ford | | 2 | G...
MySQL Query: LIMITing a JOIN Say I have two tables I want to join. Categories: id name ---------- 1 Cars 2 Games 3 Pencils And items: id categoryid itemname --------------------------- 1 1 Ford 2 1 BMW 3 1 VW 4 2 Tetris 5 2 Pong 6 3 Foobar Pencil Factory I want a query that returns the category and the first (and only ...
TITLE: MySQL Query: LIMITing a JOIN QUESTION: Say I have two tables I want to join. Categories: id name ---------- 1 Cars 2 Games 3 Pencils And items: id categoryid itemname --------------------------- 1 1 Ford 2 1 BMW 3 1 VW 4 2 Tetris 5 2 Pong 6 3 Foobar Pencil Factory I want a query that returns the category and th...
[ "mysql", "sql", "join", "greatest-n-per-group" ]
5
6
1,750
3
0
2008-10-02T15:25:58.817000
2008-10-02T15:42:24.673000
163,009
163,095
urllib2 file name
If I open a file using urllib2, like so: remotefile = urllib2.urlopen('http://example.com/somefile.zip') Is there an easy way to get the file name other then parsing the original URL? EDIT: changed openfile to urlopen... not sure how that happened. EDIT2: I ended up using: filename = url.split('/')[-1].split('#')[0].sp...
Did you mean urllib2.urlopen? You could potentially lift the intended filename if the server was sending a Content-Disposition header by checking remotefile.info()['Content-Disposition'], but as it is I think you'll just have to parse the url. You could use urlparse.urlsplit, but if you have any URLs like at the second...
urllib2 file name If I open a file using urllib2, like so: remotefile = urllib2.urlopen('http://example.com/somefile.zip') Is there an easy way to get the file name other then parsing the original URL? EDIT: changed openfile to urlopen... not sure how that happened. EDIT2: I ended up using: filename = url.split('/')[-1...
TITLE: urllib2 file name QUESTION: If I open a file using urllib2, like so: remotefile = urllib2.urlopen('http://example.com/somefile.zip') Is there an easy way to get the file name other then parsing the original URL? EDIT: changed openfile to urlopen... not sure how that happened. EDIT2: I ended up using: filename =...
[ "python", "url", "urllib2" ]
31
49
40,101
14
0
2008-10-02T15:27:04.553000
2008-10-02T15:43:12.970000
163,021
163,038
Where can I find free content hosting?
Is there any free hosting for Javascript? Recently google has been hosting jQuery,etc... and Yahoo hosts it's YUI, which is great, but it'd be even better if there was a service that could host user scripts and things like that. Any ideas?
You can turn Google AppEngine in to your own CDN. Which will definitely give you the effect you are looking for. http://www.coderjournal.com/2008/06/turn-google-app-engine-into-a-content-delivery-network-cdn/
Where can I find free content hosting? Is there any free hosting for Javascript? Recently google has been hosting jQuery,etc... and Yahoo hosts it's YUI, which is great, but it'd be even better if there was a service that could host user scripts and things like that. Any ideas?
TITLE: Where can I find free content hosting? QUESTION: Is there any free hosting for Javascript? Recently google has been hosting jQuery,etc... and Yahoo hosts it's YUI, which is great, but it'd be even better if there was a service that could host user scripts and things like that. Any ideas? ANSWER: You can turn G...
[ "javascript", "hosting", "cdn", "content-delivery-network" ]
5
4
1,187
2
0
2008-10-02T15:29:33.907000
2008-10-02T15:34:06.207000
163,022
163,096
High resolution timer in .NET
I'd like to do some basic profiling of my code, but found that the DateTime.Now in C# only have a resolution of about 16 ms. There must be better time keeping constructs that I haven't yet found.
Here is a sample bit of code to time an operation: Dim sw As New Stopwatch() sw.Start() //Insert Code To Time sw.Stop() Dim ms As Long = sw.ElapsedMilliseconds Console.WriteLine("Total Seconds Elapsed: " & ms / 1000) EDIT: And the neat thing is that it can resume as well. Stopwatch sw = new Stopwatch(); foreach(MyStuff...
High resolution timer in .NET I'd like to do some basic profiling of my code, but found that the DateTime.Now in C# only have a resolution of about 16 ms. There must be better time keeping constructs that I haven't yet found.
TITLE: High resolution timer in .NET QUESTION: I'd like to do some basic profiling of my code, but found that the DateTime.Now in C# only have a resolution of about 16 ms. There must be better time keeping constructs that I haven't yet found. ANSWER: Here is a sample bit of code to time an operation: Dim sw As New St...
[ ".net", "profiling", "timer" ]
35
56
21,588
4
0
2008-10-02T15:30:14.157000
2008-10-02T15:43:21.643000
163,058
551,215
How can I detect if I'm compiling for a 64bits architecture in C++
In a C++ function I need the compiler to choose a different block if it is compiling for a 64 bit architecture. I know a way to do it for MSVC++ and g++, so I'll post it as an answer. However I would like to know if there is a better way (more elegant that would work for all compilers/all 64 bits architectures). If the...
Why are you choosing one block over the other? If your decision is based on the size of a pointer, use sizeof(void*) == 8. If your decision is based on the size of an integer, use sizeof(int) == 8. My point is that the name of the architecture itself should rarely make any difference. You check only what you need to ch...
How can I detect if I'm compiling for a 64bits architecture in C++ In a C++ function I need the compiler to choose a different block if it is compiling for a 64 bit architecture. I know a way to do it for MSVC++ and g++, so I'll post it as an answer. However I would like to know if there is a better way (more elegant t...
TITLE: How can I detect if I'm compiling for a 64bits architecture in C++ QUESTION: In a C++ function I need the compiler to choose a different block if it is compiling for a 64 bit architecture. I know a way to do it for MSVC++ and g++, so I'll post it as an answer. However I would like to know if there is a better w...
[ "c++", "64-bit", "c-preprocessor" ]
28
7
22,941
8
0
2008-10-02T15:37:32.937000
2009-02-15T17:05:55.670000
163,071
165,821
Coupling, Cohesion and the Law of Demeter
The Law of Demeter indicates that you should only speak to objects that you know about directly. That is, do not perform method chaining to talk to other objects. When you do so, you are establishing improper linkages with the intermediary objects, inappropriately coupling your code to other code. That's bad. The solut...
Grady Booch in "Object Oriented Analysis and Design": "The idea of cohesion also comes from structured design. Simply stated, cohesion measures the degree of connectivity among the elements of a single module (and for object-oriented design, a single class or object). The least desirable form of cohesion is coincidenta...
Coupling, Cohesion and the Law of Demeter The Law of Demeter indicates that you should only speak to objects that you know about directly. That is, do not perform method chaining to talk to other objects. When you do so, you are establishing improper linkages with the intermediary objects, inappropriately coupling your...
TITLE: Coupling, Cohesion and the Law of Demeter QUESTION: The Law of Demeter indicates that you should only speak to objects that you know about directly. That is, do not perform method chaining to talk to other objects. When you do so, you are establishing improper linkages with the intermediary objects, inappropria...
[ "oop", "refactoring", "coupling", "law-of-demeter", "cohesion" ]
70
50
8,761
6
0
2008-10-02T15:40:11.417000
2008-10-03T05:47:55.263000
163,079
163,126
Exporting from SQLite to SQL Server
Is there a tool to migrate an SQLite database to SQL Server (both the structure and data)?
SQLite does have a.dump option to run at the command line. Though I prefer to use the SQLite Database Browser application for managing SQLite databases. You can export the structure and contents to a.sql file that can be read by just about anything. File > Export > Database to SQL file.
Exporting from SQLite to SQL Server Is there a tool to migrate an SQLite database to SQL Server (both the structure and data)?
TITLE: Exporting from SQLite to SQL Server QUESTION: Is there a tool to migrate an SQLite database to SQL Server (both the structure and data)? ANSWER: SQLite does have a.dump option to run at the command line. Though I prefer to use the SQLite Database Browser application for managing SQLite databases. You can expor...
[ "sql-server", "database", "sqlite", "data-migration" ]
39
49
105,342
6
0
2008-10-02T15:41:17.530000
2008-10-02T15:48:54.843000
163,098
163,218
How do I shrink the transaction log on MS SQL 2000 databases?
I have several databases where the transaction log (.LDF) is many times larger than the database file (.MDF). What can I do to automatically shrink these or keep them from getting so large?
That should do the job use master go dump transaction with no_log go use go DBCC SHRINKFILE (, 100) -- where 100 is the size you may want to shrink it to in MB, change it to your needs go -- then you can call to check that all went fine dbcc checkdb( ) A word of warning You would only really use it on a test/developmen...
How do I shrink the transaction log on MS SQL 2000 databases? I have several databases where the transaction log (.LDF) is many times larger than the database file (.MDF). What can I do to automatically shrink these or keep them from getting so large?
TITLE: How do I shrink the transaction log on MS SQL 2000 databases? QUESTION: I have several databases where the transaction log (.LDF) is many times larger than the database file (.MDF). What can I do to automatically shrink these or keep them from getting so large? ANSWER: That should do the job use master go dump...
[ "sql-server", "system-administration" ]
5
6
44,923
9
0
2008-10-02T15:44:10.940000
2008-10-02T16:08:50.600000
163,104
163,255
How do I grab events from sub-controls on a user-control in a WinForms App?
Is there any way for the main form to be able to intercept events firing on a subcontrol on a user control? I've got a custom user-control embedded in the main Form of my application. The control contains various subcontrols that manipulate data, which itself is displayed by other controls on the main form. What I'd li...
The best practice would be to expose events on the UserControl that bubble the events up to the parent form. I have gone ahead and put together an example for you. Here is a description of what this example provides. UserControl1 Create a UserControl with TextBox1 Register a public event on the UserControl called Contr...
How do I grab events from sub-controls on a user-control in a WinForms App? Is there any way for the main form to be able to intercept events firing on a subcontrol on a user control? I've got a custom user-control embedded in the main Form of my application. The control contains various subcontrols that manipulate dat...
TITLE: How do I grab events from sub-controls on a user-control in a WinForms App? QUESTION: Is there any way for the main form to be able to intercept events firing on a subcontrol on a user control? I've got a custom user-control embedded in the main Form of my application. The control contains various subcontrols t...
[ ".net", "winforms", "events", "user-controls" ]
11
15
8,777
5
0
2008-10-02T15:45:11.157000
2008-10-02T16:14:45.080000
163,133
163,652
Breakpoint not hooked up when debugging in VS.Net 2005
Been running into this problem lately... When debugging an app in VS.Net 2005, breakpoints are not connected. Error indicates that the compiled code is not the same as the running version and therefore there's a mismatch that causes the breakpoint to be disconnected. Cleaned solution of all bin file and re-compile does...
Maybe this suggestion might help: While debugging in Visual Studio, click on Debug > Windows > Modules. The IDE will dock a Modules window, showing all the modules that have been loaded for your project. Look for your project's DLL, and check the Symbol Status for it. If it says Symbols Loaded, then you're golden. If i...
Breakpoint not hooked up when debugging in VS.Net 2005 Been running into this problem lately... When debugging an app in VS.Net 2005, breakpoints are not connected. Error indicates that the compiled code is not the same as the running version and therefore there's a mismatch that causes the breakpoint to be disconnecte...
TITLE: Breakpoint not hooked up when debugging in VS.Net 2005 QUESTION: Been running into this problem lately... When debugging an app in VS.Net 2005, breakpoints are not connected. Error indicates that the compiled code is not the same as the running version and therefore there's a mismatch that causes the breakpoint...
[ "c#", "debugging", "visual-studio-2005", "breakpoints" ]
4
8
4,305
12
0
2008-10-02T15:50:42.220000
2008-10-02T17:48:32.513000
163,146
163,155
Where is the best place to re-learn graphics programming
Thinking in regards to Sliverlight, I would like to know where would be good places to go to get a refresher on 3d space, transforms, matrix manipulation, and all that good stuff.
Think I may have found it myself. Was looking at: http://msdn.microsoft.com/en-us/library/cc189037(VS.95).aspx and http://www.c-sharpcorner.com/UploadFile/mgold/TransformswithGDIplus09142005064919AM/TransformswithGDIplus.aspx
Where is the best place to re-learn graphics programming Thinking in regards to Sliverlight, I would like to know where would be good places to go to get a refresher on 3d space, transforms, matrix manipulation, and all that good stuff.
TITLE: Where is the best place to re-learn graphics programming QUESTION: Thinking in regards to Sliverlight, I would like to know where would be good places to go to get a refresher on 3d space, transforms, matrix manipulation, and all that good stuff. ANSWER: Think I may have found it myself. Was looking at: http:/...
[ "silverlight", "graphics" ]
9
1
1,044
7
0
2008-10-02T15:54:41.633000
2008-10-02T15:56:50.037000
163,162
163,220
Can you call Directory.GetFiles() with multiple filters?
I am trying to use the Directory.GetFiles() method to retrieve a list of files of multiple types, such as mp3 's and jpg 's. I have tried both of the following with no luck: Directory.GetFiles("C:\\path", "*.mp3|*.jpg", SearchOption.AllDirectories); Directory.GetFiles("C:\\path", "*.mp3;*.jpg", SearchOption.AllDirector...
For.NET 4.0 and later, var files = Directory.EnumerateFiles("C:\\path", "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".mp3") || s.EndsWith(".jpg")); For earlier versions of.NET, var files = Directory.GetFiles("C:\\path", "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".mp3") || s.EndsWith(".jpg"...
Can you call Directory.GetFiles() with multiple filters? I am trying to use the Directory.GetFiles() method to retrieve a list of files of multiple types, such as mp3 's and jpg 's. I have tried both of the following with no luck: Directory.GetFiles("C:\\path", "*.mp3|*.jpg", SearchOption.AllDirectories); Directory.Get...
TITLE: Can you call Directory.GetFiles() with multiple filters? QUESTION: I am trying to use the Directory.GetFiles() method to retrieve a list of files of multiple types, such as mp3 's and jpg 's. I have tried both of the following with no luck: Directory.GetFiles("C:\\path", "*.mp3|*.jpg", SearchOption.AllDirectori...
[ "c#", "filesystems", ".net" ]
418
623
520,635
28
0
2008-10-02T15:58:21.407000
2008-10-02T16:09:11.927000
163,183
163,261
LINQ to SQL Peculiarities
I'm encountering some peculiarities with LINQ to SQL. With a relatively simple query, I want to select some fields, but have the date fields formatted as strings, which I first achieved like this: var list = dataContext.MyLists.Single(x => x.ID == myId); var items = from i in list.MyItems select new { i.ID, i.Sector, ...
I'd do the SQL part without doing the formatting, then do the formatting on the client side: var items = list.MyItems.Select(item => new { item.ID, item.Sector, item.Description, item.CompleteDate, item.DueDate }).AsEnumerable() // Don't do the next bit in the DB.Select(item => new { item.ID, item.Sector, item.Descript...
LINQ to SQL Peculiarities I'm encountering some peculiarities with LINQ to SQL. With a relatively simple query, I want to select some fields, but have the date fields formatted as strings, which I first achieved like this: var list = dataContext.MyLists.Single(x => x.ID == myId); var items = from i in list.MyItems sel...
TITLE: LINQ to SQL Peculiarities QUESTION: I'm encountering some peculiarities with LINQ to SQL. With a relatively simple query, I want to select some fields, but have the date fields formatted as strings, which I first achieved like this: var list = dataContext.MyLists.Single(x => x.ID == myId); var items = from i i...
[ "c#", "linq", "linq-to-sql" ]
5
14
4,856
5
0
2008-10-02T16:01:31.007000
2008-10-02T16:14:57.277000
163,207
163,233
How do I use a String as a Stream in .Net?
I need to call a method that accepts a stream argument. The method loads text into the stream, which would normally be a file. I'd like to simply populate a string with the contents of the stream, instead of writing it to a file. How do I do this?
Use a MemoryStream with a StreamReader. Something like: using (MemoryStream ms = new MemoryStream()) using (StreamReader sr = new StreamReader(ms)) { // pass the memory stream to method ms.Seek(0, SeekOrigin.Begin); // added from itsmatt string s = sr.ReadToEnd(); }
How do I use a String as a Stream in .Net? I need to call a method that accepts a stream argument. The method loads text into the stream, which would normally be a file. I'd like to simply populate a string with the contents of the stream, instead of writing it to a file. How do I do this?
TITLE: How do I use a String as a Stream in .Net? QUESTION: I need to call a method that accepts a stream argument. The method loads text into the stream, which would normally be a file. I'd like to simply populate a string with the contents of the stream, instead of writing it to a file. How do I do this? ANSWER: Us...
[ ".net" ]
6
7
490
5
0
2008-10-02T16:07:07.467000
2008-10-02T16:11:17.117000
163,225
163,305
How do I test if a given BSP tree is optimal?
I have a polygon soup of triangles that I would like to construct a BSP tree for. My current program simply constructs a BSP tree by inserting a random triangle from the model one at a time until all the triangles are consumed, then it checks the depth and breadth of the tree and remembers the best score it achieved (l...
Construction of an optimal tree is an NP-complete problem. Determining if a given tree is optimal is essentially the same problem. From this BSP faq: The problem is one of splitting versus tree balancing. These are mutually exclusive requirements. You should choose your strategy for building a good tree based on how yo...
How do I test if a given BSP tree is optimal? I have a polygon soup of triangles that I would like to construct a BSP tree for. My current program simply constructs a BSP tree by inserting a random triangle from the model one at a time until all the triangles are consumed, then it checks the depth and breadth of the tr...
TITLE: How do I test if a given BSP tree is optimal? QUESTION: I have a polygon soup of triangles that I would like to construct a BSP tree for. My current program simply constructs a BSP tree by inserting a random triangle from the model one at a time until all the triangles are consumed, then it checks the depth and...
[ "algorithm", "3d", "bsp-tree" ]
4
3
1,684
3
0
2008-10-02T16:09:52
2008-10-02T16:24:09.720000
163,236
163,306
Where can I find a List of Standard HTTP Header Values?
I'm looking for all the current standard header values a web server would generally receive. An example would be things like "what will the header look like when coming from a Mac running OS X Leopard and Camino installed?" or "what will the header look like when coming from Fedora 9 running Firefox 3.0.1 versus SuSe r...
There is no set-in-stone list of user agent values. You can find lengthy lists (such as this one used by the JQuery browser plugin ). Regarding other HTTP Headers, this wikipedia article is a good place to start.
Where can I find a List of Standard HTTP Header Values? I'm looking for all the current standard header values a web server would generally receive. An example would be things like "what will the header look like when coming from a Mac running OS X Leopard and Camino installed?" or "what will the header look like when ...
TITLE: Where can I find a List of Standard HTTP Header Values? QUESTION: I'm looking for all the current standard header values a web server would generally receive. An example would be things like "what will the header look like when coming from a Mac running OS X Leopard and Camino installed?" or "what will the head...
[ "http", "http-headers", "web-standards" ]
6
4
7,409
7
0
2008-10-02T16:11:24.883000
2008-10-02T16:24:29.830000
163,246
5,184,901
SQL Server equivalent to Oracle's CREATE OR REPLACE VIEW
In Oracle, I can re-create a view with a single statement, as shown here: CREATE OR REPLACE VIEW MY_VIEW AS SELECT SOME_FIELD FROM SOME_TABLE WHERE SOME_CONDITIONS As the syntax implies, this will drop the old view and re-create it with whatever definition I've given. Is there an equivalent in MSSQL (SQL Server 2005 or...
The solutions above though they will get the job done do so at the risk of dropping user permissions. I prefer to do my create or replace views or stored procedures as follows. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vw_myView]')) EXEC sp_executesql N'CREATE VIEW [dbo].[vw_myView] AS...
SQL Server equivalent to Oracle's CREATE OR REPLACE VIEW In Oracle, I can re-create a view with a single statement, as shown here: CREATE OR REPLACE VIEW MY_VIEW AS SELECT SOME_FIELD FROM SOME_TABLE WHERE SOME_CONDITIONS As the syntax implies, this will drop the old view and re-create it with whatever definition I've g...
TITLE: SQL Server equivalent to Oracle's CREATE OR REPLACE VIEW QUESTION: In Oracle, I can re-create a view with a single statement, as shown here: CREATE OR REPLACE VIEW MY_VIEW AS SELECT SOME_FIELD FROM SOME_TABLE WHERE SOME_CONDITIONS As the syntax implies, this will drop the old view and re-create it with whatever...
[ "sql-server" ]
120
107
153,317
10
0
2008-10-02T16:13:08.483000
2011-03-03T18:28:20.357000
163,254
163,272
On 32-bit CPUs, is an 'integer' type more efficient than a 'short' type?
On a 32-bit CPU, an integer is 4 bytes and a short integer is 2 bytes. If I am writing a C/C++ application that uses many numeric values that will always fit within the provided range of a short integer, is it more efficient to use 4 byte integers or 2 byte integers? I have heard it suggested that 4 byte integers are m...
Yes, you should definitely use a 32 bit integer on a 32 bit CPU, otherwise it may end up masking off the unused bits (i.e., it will always do the maths in 32 bits, then convert the answer to 16 bits) It won't do two 16 bit operations at once for you, but if you write the code yourself and you're sure it won't overflow,...
On 32-bit CPUs, is an 'integer' type more efficient than a 'short' type? On a 32-bit CPU, an integer is 4 bytes and a short integer is 2 bytes. If I am writing a C/C++ application that uses many numeric values that will always fit within the provided range of a short integer, is it more efficient to use 4 byte integers...
TITLE: On 32-bit CPUs, is an 'integer' type more efficient than a 'short' type? QUESTION: On a 32-bit CPU, an integer is 4 bytes and a short integer is 2 bytes. If I am writing a C/C++ application that uses many numeric values that will always fit within the provided range of a short integer, is it more efficient to u...
[ "architecture", "integer", "cpu", "32-bit", "cpu-architecture" ]
15
15
10,724
8
0
2008-10-02T16:14:35.627000
2008-10-02T16:16:11.813000
163,275
163,414
What do you need to take into consideration when deciding between MySQL and Amazon's SimpleDB for a RoR app?
I am just beginning to do research into the feasibility of using Amazon's SimpleDB service as the datastore for RoR application I am planning to build. We will be using EC2 for the web server, and had planned to also use EC2 for the MySQL servers. But now the question is, why not use SimpleDB? The application will (if ...
The Ruby SimpleDB library is not as complete as ActiveRecord (the default Rails DB adapter), so many of the features you're used to will not be there. On the plus side it's schemaless, scalable and works well with ec2. If you're going to do things like full text search in your app then SimpleDB might not be the best ch...
What do you need to take into consideration when deciding between MySQL and Amazon's SimpleDB for a RoR app? I am just beginning to do research into the feasibility of using Amazon's SimpleDB service as the datastore for RoR application I am planning to build. We will be using EC2 for the web server, and had planned to...
TITLE: What do you need to take into consideration when deciding between MySQL and Amazon's SimpleDB for a RoR app? QUESTION: I am just beginning to do research into the feasibility of using Amazon's SimpleDB service as the datastore for RoR application I am planning to build. We will be using EC2 for the web server, ...
[ "mysql", "ruby-on-rails", "ruby", "amazon-web-services", "amazon-simpledb" ]
9
4
962
5
0
2008-10-02T16:16:50.643000
2008-10-02T16:54:15.310000
163,311
163,348
Best Way To Get All Dates Between DateA and DateB
I am using an asp:Calander and I have an object that has a beginning date and an ending date. I need to get all the dates between these two dates and place them in an array so i can then render corresponding dates on the calander with different CSS
I voted up AlbertEin because he gave a good answer, but do you really need a collection to hold all the dates? When you are rendering the day, couldn't you just check if the date is withing the specified range, and then render it differently, no need for a collection. Here's some code to demonstrate DateTime RangeStart...
Best Way To Get All Dates Between DateA and DateB I am using an asp:Calander and I have an object that has a beginning date and an ending date. I need to get all the dates between these two dates and place them in an array so i can then render corresponding dates on the calander with different CSS
TITLE: Best Way To Get All Dates Between DateA and DateB QUESTION: I am using an asp:Calander and I have an object that has a beginning date and an ending date. I need to get all the dates between these two dates and place them in an array so i can then render corresponding dates on the calander with different CSS AN...
[ "asp.net", "css", "date" ]
1
1
1,143
4
0
2008-10-02T16:26:29.467000
2008-10-02T16:37:25.383000
163,313
165,854
Weird results using P4COM
I'm using P4COM to communicate with our perforce server. I have written an little utility to simplify our QA of what files have changed from one release to another. I have been using the P4COM interface from Delphi. So far so good. I though it might be nice to allow users to view the diff between the two versions of th...
You're probably better of asking this to Perforce support itself, as this sounds like a bug in their software. As a sidenote: Why do you use p4v? (I hugely prefer p4win myself)
Weird results using P4COM I'm using P4COM to communicate with our perforce server. I have written an little utility to simplify our QA of what files have changed from one release to another. I have been using the P4COM interface from Delphi. So far so good. I though it might be nice to allow users to view the diff betw...
TITLE: Weird results using P4COM QUESTION: I'm using P4COM to communicate with our perforce server. I have written an little utility to simplify our QA of what files have changed from one release to another. I have been using the P4COM interface from Delphi. So far so good. I though it might be nice to allow users to ...
[ "delphi", "version-control", "perforce" ]
1
0
242
2
0
2008-10-02T16:26:50.650000
2008-10-03T06:01:43.577000
163,342
163,357
How do I read all feed items?
I want to read all items of a feed in C#. The solutions I've found are only for the latest items like just the last 10 days. Anybody has a good solution for this?
If you can tie into something like Google Reader, which archives old feed items (although I'm not sure it's a permanent archive or not), then perhaps you can accomplish this.
How do I read all feed items? I want to read all items of a feed in C#. The solutions I've found are only for the latest items like just the last 10 days. Anybody has a good solution for this?
TITLE: How do I read all feed items? QUESTION: I want to read all items of a feed in C#. The solutions I've found are only for the latest items like just the last 10 days. Anybody has a good solution for this? ANSWER: If you can tie into something like Google Reader, which archives old feed items (although I'm not su...
[ "c#" ]
1
1
260
5
0
2008-10-02T16:35:07.323000
2008-10-02T16:39:02.353000
163,355
163,377
Subquery in an IN() clause causing error
I'm on SQL Server 2005 and I am getting an error which I am pretty sure should not be getting. Msg 512, Level 16, State 1, Procedure spGetSavedSearchesByAdminUser, Line 8 Subquery returned more than 1 value. This is not permitted when the subquery follows =,!=, <, <=, >, >= or when the subquery is used as an expression...
Try rearranging the query so that the boolean expression occurs inside the subselect, e.g. ALTER PROCEDURE [dbo].[spGetSavedSearchesByAdminUser] @strUserName varchar(50),@bitQuickSearch bit = 0 AS BEGIN SELECT [intSearchID],strSearchTypeCode,[strSearchName] FROM [tblAdminSearches] WHERE strUserName = @strUserName AN...
Subquery in an IN() clause causing error I'm on SQL Server 2005 and I am getting an error which I am pretty sure should not be getting. Msg 512, Level 16, State 1, Procedure spGetSavedSearchesByAdminUser, Line 8 Subquery returned more than 1 value. This is not permitted when the subquery follows =,!=, <, <=, >, >= or w...
TITLE: Subquery in an IN() clause causing error QUESTION: I'm on SQL Server 2005 and I am getting an error which I am pretty sure should not be getting. Msg 512, Level 16, State 1, Procedure spGetSavedSearchesByAdminUser, Line 8 Subquery returned more than 1 value. This is not permitted when the subquery follows =,!=,...
[ "sql-server", "subquery", "in-clause" ]
0
4
5,586
3
0
2008-10-02T16:38:55.583000
2008-10-02T16:43:41.547000
163,360
163,398
Regular expression to match URLs in Java
I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java String flavor and pasted it into Java code, it does not work. The following class prints false: public class RegexFoo { pub...
Try the following regex string instead. Your test was probably done in a case-sensitive manner. I have added the lowercase alphas as well as a proper string beginning placeholder. String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"; This works too: String regex = "\\b(https?|ftp|fi...
Regular expression to match URLs in Java I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java String flavor and pasted it into Java code, it does not work. The following class p...
TITLE: Regular expression to match URLs in Java QUESTION: I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java String flavor and pasted it into Java code, it does not work. The...
[ "java", "regex", "regexbuddy" ]
100
116
257,518
11
0
2008-10-02T16:40:00.430000
2008-10-02T16:48:55.357000
163,363
163,411
How do I create an Excel chart that pulls data from multiple sheets?
I have monthly sales figures stored in separate sheets. I would like to create a plot of sales for multiple products per month. Each product would be represented in a different colored line on the same chart with each month running along the x axis. What is the best way to create a single line chart that pulls from the...
Use the Chart Wizard. On Step 2 of 4, there is a tab labeled "Series". There are 3 fields and a list box on this tab. The list box shows the different series you are already including on the chart. Each series has both a "Name" field and a "Values" field that is specific to that series. The final field is the "Category...
How do I create an Excel chart that pulls data from multiple sheets? I have monthly sales figures stored in separate sheets. I would like to create a plot of sales for multiple products per month. Each product would be represented in a different colored line on the same chart with each month running along the x axis. W...
TITLE: How do I create an Excel chart that pulls data from multiple sheets? QUESTION: I have monthly sales figures stored in separate sheets. I would like to create a plot of sales for multiple products per month. Each product would be represented in a different colored line on the same chart with each month running a...
[ "excel", "charts", "excel-2007" ]
7
7
159,534
3
0
2008-10-02T16:40:38.260000
2008-10-02T16:53:46.497000
163,365
163,417
How do I make a C++ macro behave like a function?
Let's say that for some reason you need to write a macro: MACRO(X,Y). (Let's assume there's a good reason you can't use an inline function.) You want this macro to emulate a call to a function with no return value. Example 1: This should work as expected. if (x > y) MACRO(x, y); do_something(); Example 2: This should n...
Macros should generally be avoided; prefer inline functions to them at all times. Any compiler worth its salt should be capable of inlining a small function as if it were a macro, and an inline function will respect namespaces and other scopes, as well as evaluating all the arguments once. If it must be a macro, a whil...
How do I make a C++ macro behave like a function? Let's say that for some reason you need to write a macro: MACRO(X,Y). (Let's assume there's a good reason you can't use an inline function.) You want this macro to emulate a call to a function with no return value. Example 1: This should work as expected. if (x > y) MAC...
TITLE: How do I make a C++ macro behave like a function? QUESTION: Let's say that for some reason you need to write a macro: MACRO(X,Y). (Let's assume there's a good reason you can't use an inline function.) You want this macro to emulate a call to a function with no return value. Example 1: This should work as expect...
[ "c++", "c-preprocessor" ]
65
51
158,977
9
0
2008-10-02T16:41:14.343000
2008-10-02T16:54:59.677000
163,367
163,422
Error Updating a record
I get a mysql error: #update (ActiveRecord::StatementInvalid) "Mysql::Error: #HY000Got error 139 from storage engine: When trying to update a text field on a record with a string of length 1429 characters, any ideas on how to track down the problem? Below is the stacktrace. from /var/www/releases/20081002155111/vendor/...
Maybe it's this bug: #1030 - Got error 139 from storage engine, but it would help if you'd post the query which should come directly after the error message.
Error Updating a record I get a mysql error: #update (ActiveRecord::StatementInvalid) "Mysql::Error: #HY000Got error 139 from storage engine: When trying to update a text field on a record with a string of length 1429 characters, any ideas on how to track down the problem? Below is the stacktrace. from /var/www/release...
TITLE: Error Updating a record QUESTION: I get a mysql error: #update (ActiveRecord::StatementInvalid) "Mysql::Error: #HY000Got error 139 from storage engine: When trying to update a text field on a record with a string of length 1429 characters, any ideas on how to track down the problem? Below is the stacktrace. fro...
[ "mysql", "ruby-on-rails", "ruby", "activerecord" ]
0
0
1,158
3
0
2008-10-02T16:41:42.550000
2008-10-02T16:55:49.520000
163,382
163,413
Type mismatch for Class Generics
I have the following code that won't compile and although there is a way to make it compile I want to understand why it isn't compiling. Can someone enlighten me as to specifically why I get the error message I will post at the end please? public class Test { public static void main(String args[]) { Test t = new Test()...
The reason is that Test.class is of the type Class. You cannot assign a reference of type Class to a variable of type Class as they are not the same thing. This, however, works: Class testType = type == null? Test.class: type; The wildcard allows both Class and Class references to be assigned to testType. There is a to...
Type mismatch for Class Generics I have the following code that won't compile and although there is a way to make it compile I want to understand why it isn't compiling. Can someone enlighten me as to specifically why I get the error message I will post at the end please? public class Test { public static void main(Str...
TITLE: Type mismatch for Class Generics QUESTION: I have the following code that won't compile and although there is a way to make it compile I want to understand why it isn't compiling. Can someone enlighten me as to specifically why I get the error message I will post at the end please? public class Test { public st...
[ "java", "generics" ]
22
24
44,573
3
0
2008-10-02T16:44:56.003000
2008-10-02T16:54:15.250000
163,389
163,483
Is there a way to get types/names of an unknown db query without executing it?
I have a web application where users enter arbitrary sql queries for later batch processing. We want to validate the syntax of the query without actually executing it. Some of the queries will take a long time, which is why we don't want to execute them. I'm using Oracle's dbms_sql.parse to do this. However, I now have...
You should be able to prepare a SQL query to validate the syntax and get result set metadata. Preparing a query should not execute it. import java.sql.*;... Connection conn;... PreparedStatement ps = conn.prepareStatement("SELECT * FROM foo"); ResultSetMetadata rsmd = ps.getMetaData(); int numberOfColumns = rsmd.getCol...
Is there a way to get types/names of an unknown db query without executing it? I have a web application where users enter arbitrary sql queries for later batch processing. We want to validate the syntax of the query without actually executing it. Some of the queries will take a long time, which is why we don't want to ...
TITLE: Is there a way to get types/names of an unknown db query without executing it? QUESTION: I have a web application where users enter arbitrary sql queries for later batch processing. We want to validate the syntax of the query without actually executing it. Some of the queries will take a long time, which is why...
[ "sql", "database", "oracle", "plsql" ]
4
7
1,063
2
0
2008-10-02T16:46:41.507000
2008-10-02T17:11:25.287000
163,392
163,683
Microsoft Access - SQL - Internal Foreign Key
Does MS Access 2007 support internal foreign keys within the same table?
Yes. Create the table with the hierarchy. id - autonumber - primary key parent_id - number value Go to the relationships screen. Add the hierarchy table twice. Connect the id and the parent_id fields. Enforce referential integrity.
Microsoft Access - SQL - Internal Foreign Key Does MS Access 2007 support internal foreign keys within the same table?
TITLE: Microsoft Access - SQL - Internal Foreign Key QUESTION: Does MS Access 2007 support internal foreign keys within the same table? ANSWER: Yes. Create the table with the hierarchy. id - autonumber - primary key parent_id - number value Go to the relationships screen. Add the hierarchy table twice. Connect the id...
[ "sql", "ms-access" ]
2
3
2,782
3
0
2008-10-02T16:47:24.953000
2008-10-02T17:53:23.237000
163,400
163,549
Database Design Issues with relationships
I'm working on an upgrade for an existing database that was designed without any of the code to implement the design being considered. Now I've hit a brick wall in terms of implementing the database design in code. I'm certain whether its a problem with the design of the database or if I'm simply not seeing the correct...
What you're looking for is relational division Not implemented directly in SQL, but it can be done. Search google for other examples.
Database Design Issues with relationships I'm working on an upgrade for an existing database that was designed without any of the code to implement the design being considered. Now I've hit a brick wall in terms of implementing the database design in code. I'm certain whether its a problem with the design of the databa...
TITLE: Database Design Issues with relationships QUESTION: I'm working on an upgrade for an existing database that was designed without any of the code to implement the design being considered. Now I've hit a brick wall in terms of implementing the database design in code. I'm certain whether its a problem with the de...
[ "php", "mysql", "database-design", "foreign-keys", "relational-database" ]
1
2
868
4
0
2008-10-02T16:49:39.597000
2008-10-02T17:26:28.790000
163,407
163,431
Enum inside a JSP
Is there a way to use Enum values inside a JSP without using scriptlets. e.g. package com.example; public enum Direction { ASC, DESC } so in the JSP I want to do something like this...
You could implement the web-friendly text for a direction within the enum as a field: <%@ page import="com.example.Direction" %>... Direction is <%=foo.direction.getFriendlyName()%> <% if (foo.direction == Direction.ASC) { %> That means you're going to heaven! <% } %> but that mixes the view and the model, although for...
Enum inside a JSP Is there a way to use Enum values inside a JSP without using scriptlets. e.g. package com.example; public enum Direction { ASC, DESC } so in the JSP I want to do something like this...
TITLE: Enum inside a JSP QUESTION: Is there a way to use Enum values inside a JSP without using scriptlets. e.g. package com.example; public enum Direction { ASC, DESC } so in the JSP I want to do something like this... ANSWER: You could implement the web-friendly text for a direction within the enum as a field: <%@...
[ "java", "jsp", "jstl" ]
18
22
48,108
3
0
2008-10-02T16:52:21.197000
2008-10-02T16:57:46.223000
163,420
188,947
Printing to a pdf printer programmatically
I am trying to print an existing file to PDF programmatically in Visual Basic 2008. Our current relevant assets are: Visual Studio 2008 Professional Adobe Acrobat Professional 8.0 I thought about getting a sdk like ITextSharp, but it seem like overkill for what I am trying to do especially since we have the full versio...
The big takeaway point here is that PDF IS HARD. If there is anything you can do to avoid creating or editing PDF documents directly, I strongly advise that you do so. It sounds like what you actually want is a batch SNP to PDF converter. You can probably do this with an off-the-shelf product, without even opening Visu...
Printing to a pdf printer programmatically I am trying to print an existing file to PDF programmatically in Visual Basic 2008. Our current relevant assets are: Visual Studio 2008 Professional Adobe Acrobat Professional 8.0 I thought about getting a sdk like ITextSharp, but it seem like overkill for what I am trying to ...
TITLE: Printing to a pdf printer programmatically QUESTION: I am trying to print an existing file to PDF programmatically in Visual Basic 2008. Our current relevant assets are: Visual Studio 2008 Professional Adobe Acrobat Professional 8.0 I thought about getting a sdk like ITextSharp, but it seem like overkill for wh...
[ "vb.net", "pdf" ]
4
3
41,429
10
0
2008-10-02T16:55:21.953000
2008-10-09T19:58:01.480000
163,472
225,061
Why doesn't my ListView display List or Details items?
Using C#.NET 2.0, I have an owner-drawn ListView where I'm overriding the OnDrawColumnHeader, OnDrawItem and OnDrawSubitem events. If I set the View property to Details at design-time, everything works beautifully and I can switch the View property and all view modes display as they should (I'm not using Tile view). Ho...
The WinForms ListView is mostly a layer of abstraction of the top of the actual Windows control, so there are aspect of its behaviour that are, well, counterintuitive is a polite way of putting things. I have a vague recollection, from back in my days as a Delphi developer, that when you are Owner drawing a ListView, t...
Why doesn't my ListView display List or Details items? Using C#.NET 2.0, I have an owner-drawn ListView where I'm overriding the OnDrawColumnHeader, OnDrawItem and OnDrawSubitem events. If I set the View property to Details at design-time, everything works beautifully and I can switch the View property and all view mod...
TITLE: Why doesn't my ListView display List or Details items? QUESTION: Using C#.NET 2.0, I have an owner-drawn ListView where I'm overriding the OnDrawColumnHeader, OnDrawItem and OnDrawSubitem events. If I set the View property to Details at design-time, everything works beautifully and I can switch the View propert...
[ "c#", ".net", "winforms", "listview" ]
2
2
5,949
4
0
2008-10-02T17:07:52.360000
2008-10-22T09:49:24.467000
163,484
163,561
Stop MSVC++ debug errors from blocking the current process?
Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from failing, instead waiting on user input indefinitely. Is there s a registry key o...
From MSDN about the ASSERT macro: In an MFC ISAPI application, an assertion in debug mode will bring up a modal dialog box (ASSERT dialog boxes are now modal by default); this will interrupt or hang the execution. To suppress modal assertion dialogs, add the following lines to your project source file (projectname.cpp)...
Stop MSVC++ debug errors from blocking the current process? Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from failing, instead wai...
TITLE: Stop MSVC++ debug errors from blocking the current process? QUESTION: Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from fa...
[ "windows", "unit-testing", "visual-c++", "continuous-integration", "automated-tests" ]
1
1
806
3
0
2008-10-02T17:11:28.280000
2008-10-02T17:29:35.600000
163,487
163,963
Generate a WSDL without a webserver
I would like to generate a WSDL file from a c++ atl webservice without using a web server. I would like to generate it as part of the visual studio build or as a post build event. I found a program ( CmdHelper ) that does this for.NET assemblies but it doesn't seem to work for what I need. Any ideas?
The Microsoft SOAP Toolkit comes with a WSDL generator, which will generate a WSDL file from a COM component. We use that where I work, and it seems to do the job. We haven't tried to integrate it into our build process - we've always run the tool by hand when we need to update the WSDL, and we check the generated WSDL...
Generate a WSDL without a webserver I would like to generate a WSDL file from a c++ atl webservice without using a web server. I would like to generate it as part of the visual studio build or as a post build event. I found a program ( CmdHelper ) that does this for.NET assemblies but it doesn't seem to work for what I...
TITLE: Generate a WSDL without a webserver QUESTION: I would like to generate a WSDL file from a c++ atl webservice without using a web server. I would like to generate it as part of the visual studio build or as a post build event. I found a program ( CmdHelper ) that does this for.NET assemblies but it doesn't seem ...
[ "c++", "visual-studio", "wsdl" ]
0
0
543
1
0
2008-10-02T17:12:06.500000
2008-10-02T18:51:34.267000
163,492
736,899
State and time transending logic and program flow?
Wondering if it would ever be useful to index every possible state of an application using some reference keys... Meaning, say we have a program that starts, has only so many possible outcomes, say 8. but if each outcome is attained through stepping through many more logic states, and in between each branch is consider...
Ryan, the answer is definitively YES. Contrary to the first answer, the halting problem does not prove anything. In fact, Ryan, what you're suggesting proves the halting problem wrong does not apply to real digital computers, and I've used this very example as a proof of it before. In a deterministic digital system (i....
State and time transending logic and program flow? Wondering if it would ever be useful to index every possible state of an application using some reference keys... Meaning, say we have a program that starts, has only so many possible outcomes, say 8. but if each outcome is attained through stepping through many more l...
TITLE: State and time transending logic and program flow? QUESTION: Wondering if it would ever be useful to index every possible state of an application using some reference keys... Meaning, say we have a program that starts, has only so many possible outcomes, say 8. but if each outcome is attained through stepping t...
[ "time", "logic", "state" ]
1
0
263
6
0
2008-10-02T17:13:39.260000
2009-04-10T06:44:13.187000
163,497
163,533
Running a Ruby Program as a Windows Service?
Is it possible to run a ruby application as a Windows Service? I see that there is a related question which discusses running a Java Application as a Windows Service, how can you do this with a Ruby application?
Check out the following library: Win32Utils. You can create a simple service that you can start/stop/restart at your leisure. I'm currently using it to manage a Mongrel instance for a Windows hosted Rails app and it works flawlessly.
Running a Ruby Program as a Windows Service? Is it possible to run a ruby application as a Windows Service? I see that there is a related question which discusses running a Java Application as a Windows Service, how can you do this with a Ruby application?
TITLE: Running a Ruby Program as a Windows Service? QUESTION: Is it possible to run a ruby application as a Windows Service? I see that there is a related question which discusses running a Java Application as a Windows Service, how can you do this with a Ruby application? ANSWER: Check out the following library: Win...
[ "ruby", "windows-services" ]
32
25
22,139
5
0
2008-10-02T17:14:43.610000
2008-10-02T17:23:55.053000
163,507
163,524
C#, ASP.NET - NullReferenceException - Object reference not set to an instance of an object
Definition of variables in use: Guid fldProId = (Guid)ffdPro.GetProperty("FieldId"); string fldProValue = (string)ffdPro.GetProperty("FieldValue"); FormFieldDef fmProFldDef = new FormFieldDef(); fmProFldDef.Key = fldProId; fmProFldDef.Retrieve(); string fldProName = (string)fmProFldDef.GetProperty("FieldName"); string ...
Are you sure that findControl is returning a value? Is hTxtBox.Text a property that does any computation on a set that could be throwing the NullReferenceException?
C#, ASP.NET - NullReferenceException - Object reference not set to an instance of an object Definition of variables in use: Guid fldProId = (Guid)ffdPro.GetProperty("FieldId"); string fldProValue = (string)ffdPro.GetProperty("FieldValue"); FormFieldDef fmProFldDef = new FormFieldDef(); fmProFldDef.Key = fldProId; fmPro...
TITLE: C#, ASP.NET - NullReferenceException - Object reference not set to an instance of an object QUESTION: Definition of variables in use: Guid fldProId = (Guid)ffdPro.GetProperty("FieldId"); string fldProValue = (string)ffdPro.GetProperty("FieldValue"); FormFieldDef fmProFldDef = new FormFieldDef(); fmProFldDef.Key...
[ "c#", "asp.net" ]
1
2
3,768
5
0
2008-10-02T17:18:08.593000
2008-10-02T17:21:40.160000
163,517
163,605
Accounting Software Design Patterns
Are there any good resources (books, authoritative guides, etc.) for design patterns or other best practices for software that includes financial accounting features? Specifically, where is good information about handling issues like the following: Internal representations of money quantities Internal representations o...
Martin Fowler's Analysis Patterns covers some of those topics.
Accounting Software Design Patterns Are there any good resources (books, authoritative guides, etc.) for design patterns or other best practices for software that includes financial accounting features? Specifically, where is good information about handling issues like the following: Internal representations of money q...
TITLE: Accounting Software Design Patterns QUESTION: Are there any good resources (books, authoritative guides, etc.) for design patterns or other best practices for software that includes financial accounting features? Specifically, where is good information about handling issues like the following: Internal represen...
[ "design-patterns", "accounting" ]
50
29
26,069
7
0
2008-10-02T17:20:47.387000
2008-10-02T17:41:18.490000
163,531
200,438
Set ASP.Net version using WiX
I am creating an installer for an ASP.Net website using WiX. How do you set the ASP.Net version in IIS using WiX?
We use this: First determine the.Net framework root directory from the registry: Then, inside the component that installs your website in IIS: For an x64 installer ( THIS IS IMPORTANT ) Add Win64='yes' to the registry search, because the 32 bits environment on a 64 bits machine has a different registry hive (and a diff...
Set ASP.Net version using WiX I am creating an installer for an ASP.Net website using WiX. How do you set the ASP.Net version in IIS using WiX?
TITLE: Set ASP.Net version using WiX QUESTION: I am creating an installer for an ASP.Net website using WiX. How do you set the ASP.Net version in IIS using WiX? ANSWER: We use this: First determine the.Net framework root directory from the registry: Then, inside the component that installs your website in IIS: For an...
[ "asp.net", "installation", "wix" ]
25
22
11,867
7
0
2008-10-02T17:22:50.203000
2008-10-14T08:57:18.240000
163,537
163,558
How do I write output to the console from a custom MSBuild task?
I'm trying to debug an MSBuild task, and I know there is some way to write to the MSBuild log from within a custom task but I forget how.
The base Task class has a Log property you can use: Log.LogMessage("My message");
How do I write output to the console from a custom MSBuild task? I'm trying to debug an MSBuild task, and I know there is some way to write to the MSBuild log from within a custom task but I forget how.
TITLE: How do I write output to the console from a custom MSBuild task? QUESTION: I'm trying to debug an MSBuild task, and I know there is some way to write to the MSBuild log from within a custom task but I forget how. ANSWER: The base Task class has a Log property you can use: Log.LogMessage("My message");
[ ".net", "msbuild" ]
5
9
3,215
2
0
2008-10-02T17:24:23.820000
2008-10-02T17:28:36.803000
163,538
163,543
C# - What does the Assert() method do? Is it still useful?
I am debugging with breakpoints and I realize the assert call? I thought it was only for unit tests. What does it do more than breakpoint? Since I can breakpoint, why should I use Assert?
In a debug compilation, Assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true. If you compile in Release, all Debug.Assert 's are automatically left out.
C# - What does the Assert() method do? Is it still useful? I am debugging with breakpoints and I realize the assert call? I thought it was only for unit tests. What does it do more than breakpoint? Since I can breakpoint, why should I use Assert?
TITLE: C# - What does the Assert() method do? Is it still useful? QUESTION: I am debugging with breakpoints and I realize the assert call? I thought it was only for unit tests. What does it do more than breakpoint? Since I can breakpoint, why should I use Assert? ANSWER: In a debug compilation, Assert takes in a Bool...
[ "c#", "assert" ]
193
241
212,382
9
0
2008-10-02T17:24:28.407000
2008-10-02T17:25:41.397000
163,542
165,662
How do I pass a string into subprocess.Popen (using the stdin argument)?
If I do the following: import subprocess from cStringIO import StringIO subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0] I get: Traceback (most recent call last): File " ", line 1, in? File "/build/toolchain/mac32/python-2.4.3/lib/python2.4/subp...
Popen.communicate() documentation: Note that if you want to send data to the process’s stdin, you need to create the Popen object with stdin=PIPE. Similarly, to get anything other than None in the result tuple, you need to give stdout=PIPE and/or stderr=PIPE too. Replacing os.popen* pipe = os.popen(cmd, 'w', bufsize) #...
How do I pass a string into subprocess.Popen (using the stdin argument)? If I do the following: import subprocess from cStringIO import StringIO subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0] I get: Traceback (most recent call last): File " ",...
TITLE: How do I pass a string into subprocess.Popen (using the stdin argument)? QUESTION: If I do the following: import subprocess from cStringIO import StringIO subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0] I get: Traceback (most recent cal...
[ "python", "subprocess", "stdin" ]
348
397
438,948
12
0
2008-10-02T17:25:23.303000
2008-10-03T04:11:07.493000
163,562
163,596
Wiki style text formatting
I'm looking for some kind of text-parser for ASP.NET that can make HTML from some style of text that uses a special format. Like in Wiki's there is some special syntax for headings and such. I have tried to look on google, but I did not found anything for.NET. Do someone know about a library for.NET that can parse the ...
how about the Markdown that StackOverflow uses? http://daringfireball.net/projects/markdown/ from their home page: Thus, “Markdown” is two things: (1) a plain text formatting syntax; and (2) a software tool, written in Perl, that converts the plain text formatting to HTML.
Wiki style text formatting I'm looking for some kind of text-parser for ASP.NET that can make HTML from some style of text that uses a special format. Like in Wiki's there is some special syntax for headings and such. I have tried to look on google, but I did not found anything for.NET. Do someone know about a library ...
TITLE: Wiki style text formatting QUESTION: I'm looking for some kind of text-parser for ASP.NET that can make HTML from some style of text that uses a special format. Like in Wiki's there is some special syntax for headings and such. I have tried to look on google, but I did not found anything for.NET. Do someone kno...
[ "asp.net", "html", ".net", "wiki", "text-formatting" ]
6
8
663
4
0
2008-10-02T17:29:49.343000
2008-10-02T17:37:54.550000
163,563
163,584
Javascript Date() constructor doesn't work
The javascript Date("mm-dd-yyyy") constructor doesn't work for FF. It works fine for IE. IE: new Date("04-02-2008") => "Wed Apr 2 00:00:00 EDT 2008" FF2: new Date("04-02-2008") => Invalid Date So let's try another constructor: Date("yyyy", "mm", "dd"). IE: new Date("2008", "04", "02"); => "Fri May 2 00:00:00 EDT 2008" ...
It is the definition of the Date object to use values 0-11 for the month field. I believe that the constructor using a String is system-dependent (not to mention locale/timezone dependent) so you are probably better off using the constructor where you specify year/month/day as separate parameters. BTW, in Firefox, new ...
Javascript Date() constructor doesn't work The javascript Date("mm-dd-yyyy") constructor doesn't work for FF. It works fine for IE. IE: new Date("04-02-2008") => "Wed Apr 2 00:00:00 EDT 2008" FF2: new Date("04-02-2008") => Invalid Date So let's try another constructor: Date("yyyy", "mm", "dd"). IE: new Date("2008", "04...
TITLE: Javascript Date() constructor doesn't work QUESTION: The javascript Date("mm-dd-yyyy") constructor doesn't work for FF. It works fine for IE. IE: new Date("04-02-2008") => "Wed Apr 2 00:00:00 EDT 2008" FF2: new Date("04-02-2008") => Invalid Date So let's try another constructor: Date("yyyy", "mm", "dd"). IE: ne...
[ "javascript", "date" ]
29
45
61,630
6
0
2008-10-02T17:29:53.183000
2008-10-02T17:34:11.860000
163,569
180,145
Is it possible to stop a ColdFusion Request?
I have a Flex application that calls a function which searches a large document collection. Depending on the search term, the user may want to stop the request from flex. I’d like to not only stop the flex application from expecting the request, but also stop the CFC request. Is this possible? What’s the best approach ...
To add onto Ben Doom's answer, I'm including some example code of a way this can be accomplished. There are multiple approaches and ways of names, organizing and calling the code below, but hopefully it is helpful. At some point during request start, store information about the process in shared scope and return an ID ...
Is it possible to stop a ColdFusion Request? I have a Flex application that calls a function which searches a large document collection. Depending on the search term, the user may want to stop the request from flex. I’d like to not only stop the flex application from expecting the request, but also stop the CFC request...
TITLE: Is it possible to stop a ColdFusion Request? QUESTION: I have a Flex application that calls a function which searches a large document collection. Depending on the search term, the user may want to stop the request from flex. I’d like to not only stop the flex application from expecting the request, but also st...
[ "apache-flex", "coldfusion" ]
4
2
2,892
4
0
2008-10-02T17:31:15.207000
2008-10-07T20:05:24.663000
163,581
163,793
Asp.net formatting lists of grouped data
I have a asp.net page where i query a list of url and the groups in the urls. In the code behind i loop through each group and create a group header and then list all of the links. something like this: Group 1 Link 1 Link 2 Link 3 Group 2 Link 1 Link 2 Link 3 Now that i have a lot of links, this create one long list on...
For ASP.NET 3.5 you could use ListView the control. A nice tutorial for grouping can be found here. If you are using ASP.NET 1.x or 2.0 you can try the DataList control (check the RepeatColumns and RepeatDirection properties). The ListView is more powerful.
Asp.net formatting lists of grouped data I have a asp.net page where i query a list of url and the groups in the urls. In the code behind i loop through each group and create a group header and then list all of the links. something like this: Group 1 Link 1 Link 2 Link 3 Group 2 Link 1 Link 2 Link 3 Now that i have a l...
TITLE: Asp.net formatting lists of grouped data QUESTION: I have a asp.net page where i query a list of url and the groups in the urls. In the code behind i loop through each group and create a group header and then list all of the links. something like this: Group 1 Link 1 Link 2 Link 3 Group 2 Link 1 Link 2 Link 3 N...
[ "asp.net", "layout" ]
1
1
478
1
0
2008-10-02T17:33:33.877000
2008-10-02T18:18:35.733000
163,603
164,769
Apache sockets not closing?
I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content. This all works just fine for small workloads. However,...
SetEnv proxy-nokeepalive 1 would probably tell you right away if the problem is keepalive between Apache and CP. See the mod_proxy docs for more info.
Apache sockets not closing? I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content. This all works just fine f...
TITLE: Apache sockets not closing? QUESTION: I have a web application written using CherryPy, which is run locally on 127.0.0.1:4321. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content. This all...
[ "python", "apache", "urllib2", "cherrypy", "mod-proxy" ]
6
6
6,096
2
0
2008-10-02T17:40:38.303000
2008-10-02T21:52:03.957000
163,604
163,843
What am I doing wrong when using RAND() in MS SQL Server 2005?
I'm trying to select a random 10% sampling from a small table. I thought I'd just use the RAND() function and select those rows where the random number is less than 0.10: SELECT * FROM SomeTable WHERE SomeColumn='SomeCondition' AND RAND() < 0.10 But I soon discovered that RAND() always returns the same number! Reminds ...
This type of approach (shown by ΤΖΩΤΖΙΟΥ) will not guarantee a 10% sampling. It will only give you all rows where Rand() is evaluated to <.10 which will not be consistent. Something like select top 10 percent * from MyTable order by NEWID() will do the trick. edit: there is not really a good way to make RAND behave. Th...
What am I doing wrong when using RAND() in MS SQL Server 2005? I'm trying to select a random 10% sampling from a small table. I thought I'd just use the RAND() function and select those rows where the random number is less than 0.10: SELECT * FROM SomeTable WHERE SomeColumn='SomeCondition' AND RAND() < 0.10 But I soon ...
TITLE: What am I doing wrong when using RAND() in MS SQL Server 2005? QUESTION: I'm trying to select a random 10% sampling from a small table. I thought I'd just use the RAND() function and select those rows where the random number is less than 0.10: SELECT * FROM SomeTable WHERE SomeColumn='SomeCondition' AND RAND() ...
[ "sql", "sql-server", "random" ]
4
6
3,709
5
0
2008-10-02T17:41:09.660000
2008-10-02T18:28:51.807000
163,610
163,718
AJAX and the Browser Back Button
I run a browser based game at www.darknovagames.com. Recently, I've been working on reformatting the site with CSS, trying to get all of its pages to verify according to the HTML standard. I've been toying with this idea of having the navigation menu on the left AJAX the pages in (rather than taking the user to a separ...
If you're going to enable AJAX, don't do it at the expense of having accessible URLs to every significant page on your site. This is the backbone of a navigable site that people can use. When you shovel all your functionality into AJAX calls and callbacks, you're basically forcing your users into a single path to acces...
AJAX and the Browser Back Button I run a browser based game at www.darknovagames.com. Recently, I've been working on reformatting the site with CSS, trying to get all of its pages to verify according to the HTML standard. I've been toying with this idea of having the navigation menu on the left AJAX the pages in (rathe...
TITLE: AJAX and the Browser Back Button QUESTION: I run a browser based game at www.darknovagames.com. Recently, I've been working on reformatting the site with CSS, trying to get all of its pages to verify according to the HTML standard. I've been toying with this idea of having the navigation menu on the left AJAX t...
[ "javascript", "html", "ajax", "navigation" ]
35
30
29,394
8
0
2008-10-02T17:42:40.810000
2008-10-02T18:01:41.467000
163,611
163,717
Changing the DefaultValue of a property on an inherited .net control
In.net, I have an inherited control: public CustomComboBox: ComboBox I simply want to change the default value of DropDownStyle property, to another value (ComboBoxStyle.DropDownList) besides the default one specified in the base class (ComboBoxStyle.DropDown). One might think that you can just add the constructor: pub...
This looks like it works: public class CustomComboBox: ComboBox { public CustomComboBox() { base.DropDownStyle = ComboBoxStyle.DropDownList; } [DefaultValue(ComboBoxStyle.DropDownList)] public new ComboBoxStyle DropDownStyle { set { base.DropDownStyle = value; Invalidate(); } get { return base.DropDownStyle;} } }
Changing the DefaultValue of a property on an inherited .net control In.net, I have an inherited control: public CustomComboBox: ComboBox I simply want to change the default value of DropDownStyle property, to another value (ComboBoxStyle.DropDownList) besides the default one specified in the base class (ComboBoxStyle....
TITLE: Changing the DefaultValue of a property on an inherited .net control QUESTION: In.net, I have an inherited control: public CustomComboBox: ComboBox I simply want to change the default value of DropDownStyle property, to another value (ComboBoxStyle.DropDownList) besides the default one specified in the base cla...
[ "c#", ".net", "controls", "properties", "default" ]
11
10
7,494
1
0
2008-10-02T17:42:54.663000
2008-10-02T18:01:22.937000
163,628
163,641
Making email addresses safe from bots on a webpage?
When placing email addresses on a webpage do you place them as text like this: joe.somebody@company.com or use a clever trick to try and fool the email address harvester bots? For example: HTML Escape Characters: joe.somebody@company.com Javascript Decrypter: function XOR_Crypt(EmailAddress) { Result = new String(); fo...
I generally don't bother. I used to be on a mailing list that got several thousand spams every day. Our spam filter (spamassassin) let maybe 1 or 2 a day through. With filters this good, why make it difficult for legitimate people to contact you?
Making email addresses safe from bots on a webpage? When placing email addresses on a webpage do you place them as text like this: joe.somebody@company.com or use a clever trick to try and fool the email address harvester bots? For example: HTML Escape Characters: joe.somebody@company.com Javascript Decrypter: function...
TITLE: Making email addresses safe from bots on a webpage? QUESTION: When placing email addresses on a webpage do you place them as text like this: joe.somebody@company.com or use a clever trick to try and fool the email address harvester bots? For example: HTML Escape Characters: joe.somebody@company.com Javascript D...
[ "email", "obfuscation" ]
47
45
39,017
51
0
2008-10-02T17:45:04.037000
2008-10-02T17:47:15.417000
163,632
163,660
Which SVG toolkit would you recommend to use in Java?
As a follow-up to another question, I was wondering what would be the best way to use SVG in a Java project.
The Apache Batik project is an open source SVG renderer written in Java. You can pass it an SVG file, or create a document programatically via a DOM-style API accesssible from Java code.
Which SVG toolkit would you recommend to use in Java? As a follow-up to another question, I was wondering what would be the best way to use SVG in a Java project.
TITLE: Which SVG toolkit would you recommend to use in Java? QUESTION: As a follow-up to another question, I was wondering what would be the best way to use SVG in a Java project. ANSWER: The Apache Batik project is an open source SVG renderer written in Java. You can pass it an SVG file, or create a document program...
[ "java", "svg" ]
4
4
1,767
2
0
2008-10-02T17:45:28.403000
2008-10-02T17:50:33.117000
163,646
940,254
How to get access to the Websphere 6.1 ant tasks from vanilla ant (not ws_ant)
I guess I need to know what I need in the classpath (what jar) in order to execute WebSphere 6.1 ant tasks. If someone can provide an example that would be perfect.
For Websphere 6.1, you can use the jar com.ibm.ws.runtime_6.1.0.jar to access the ant tasks. On Windows, the jar is located in the plugins directory (for me this is: C:\Program Files\IBM\WebSphere\AppServer\plugins).
How to get access to the Websphere 6.1 ant tasks from vanilla ant (not ws_ant) I guess I need to know what I need in the classpath (what jar) in order to execute WebSphere 6.1 ant tasks. If someone can provide an example that would be perfect.
TITLE: How to get access to the Websphere 6.1 ant tasks from vanilla ant (not ws_ant) QUESTION: I guess I need to know what I need in the classpath (what jar) in order to execute WebSphere 6.1 ant tasks. If someone can provide an example that would be perfect. ANSWER: For Websphere 6.1, you can use the jar com.ibm.ws...
[ "ant", "websphere", "task", "websphere-6.1" ]
3
4
2,837
3
0
2008-10-02T17:47:39.723000
2009-06-02T15:35:04.380000
163,647
4,950,346
Lightweight .NET debugger?
I frequently need to debug.NET binaries on test machines (by test-machine, I mean that the machine doesn't have Visual Studio installed on it, it's frequently re-imaged, It's not the same machine that I do my development on, etc). I love the Visual Studio debugger, but it's not practical for me to install visual studio...
I've finally found extensions for Windbg that do just what I wanted: Sosex.dll, lets me use windbg to debug managed applications with very minimal installation required. I've used it for more than a year now, and It's worked, without fault, for every debugging scenario I've encountered.
Lightweight .NET debugger? I frequently need to debug.NET binaries on test machines (by test-machine, I mean that the machine doesn't have Visual Studio installed on it, it's frequently re-imaged, It's not the same machine that I do my development on, etc). I love the Visual Studio debugger, but it's not practical for ...
TITLE: Lightweight .NET debugger? QUESTION: I frequently need to debug.NET binaries on test machines (by test-machine, I mean that the machine doesn't have Visual Studio installed on it, it's frequently re-imaged, It's not the same machine that I do my development on, etc). I love the Visual Studio debugger, but it's ...
[ ".net", "debugging" ]
29
6
22,364
8
0
2008-10-02T17:47:45.900000
2011-02-09T20:56:49.930000
163,662
163,689
Reading Comma Delimited File and Putting Data in ListView - C#
Alright, I'm trying to read a comma delimited file and then put that into a ListView (or any grid, really). I have the delimiting part of the job taken care of, with the fields of the file being put into a multidimensional string array. The problem is trying to get it into the ListView. It appears that there isn't a re...
Just loop through each of the arrays in that you've created and create a new ListViewItem object (there is a constructor that takes an array of strings, I believe). The pass the ListViewItem to the ListView.Items.Add() method.
Reading Comma Delimited File and Putting Data in ListView - C# Alright, I'm trying to read a comma delimited file and then put that into a ListView (or any grid, really). I have the delimiting part of the job taken care of, with the fields of the file being put into a multidimensional string array. The problem is tryin...
TITLE: Reading Comma Delimited File and Putting Data in ListView - C# QUESTION: Alright, I'm trying to read a comma delimited file and then put that into a ListView (or any grid, really). I have the delimiting part of the job taken care of, with the fields of the file being put into a multidimensional string array. Th...
[ "c#", "listview", "user-interface" ]
1
1
4,365
5
0
2008-10-02T17:50:50.527000
2008-10-02T17:54:06.447000
163,704
163,734
Ajax versus Frames
In light of how ajax is actually used by most sites today; why is ajax embraced while frames are still regarded as a bad idea?
AJAX, from where I'm sitting, is a sort of grand tradeoff. You are breaking things in the "document" model of the interwebs so that your site can behave more like an "application." If a site is using AJAx well, they will break the document model in subtle ways that add something of value to the application. The "vote" ...
Ajax versus Frames In light of how ajax is actually used by most sites today; why is ajax embraced while frames are still regarded as a bad idea?
TITLE: Ajax versus Frames QUESTION: In light of how ajax is actually used by most sites today; why is ajax embraced while frames are still regarded as a bad idea? ANSWER: AJAX, from where I'm sitting, is a sort of grand tradeoff. You are breaking things in the "document" model of the interwebs so that your site can b...
[ "html", "ajax", "frames" ]
1
7
4,422
6
0
2008-10-02T17:58:38.293000
2008-10-02T18:05:24.533000
163,707
163,726
Where is the Attic in Subversion (Tortoise)?
Whoops, I need some info from a file I deleted, a while ago. In CVS I would just go to the ATTIC to find it, how do I find a file in SVN without having to go back to a revision where it existed (especially annoying since I have no idea really when I deleted -- one week ago, two weeks ago...)
Browse the SVN Log of the directory it was in, find the revision where you deleted it. In the bottom pane, right click the file, and choose the option "Save Revision To..". To help you find which revision you deleted it in, look for the icon of a doc with an X in the lower left of it in the Actions column of Show Log.
Where is the Attic in Subversion (Tortoise)? Whoops, I need some info from a file I deleted, a while ago. In CVS I would just go to the ATTIC to find it, how do I find a file in SVN without having to go back to a revision where it existed (especially annoying since I have no idea really when I deleted -- one week ago, ...
TITLE: Where is the Attic in Subversion (Tortoise)? QUESTION: Whoops, I need some info from a file I deleted, a while ago. In CVS I would just go to the ATTIC to find it, how do I find a file in SVN without having to go back to a revision where it existed (especially annoying since I have no idea really when I deleted...
[ "svn", "tortoisesvn" ]
4
6
3,418
3
0
2008-10-02T17:58:52.503000
2008-10-02T18:03:06.923000
163,732
163,738
Recommended .NET Class for a collection of unique integers?
What would you recommend for class that needs to keep a list of unique integers? I'm going to want to Add() integers to the collection and also check for existence e.g. Contains(). Would be nice to also get them in a list as a string for display, ie. "1, 5, 10, 21".
HashSet: The HashSet class provides high-performance set operations. A set is a collection that contains no duplicate elements, and whose elements are in no particular order... The capacity of a HashSet object is the number of elements that the object can hold. A HashSet object's capacity automatically increases as ele...
Recommended .NET Class for a collection of unique integers? What would you recommend for class that needs to keep a list of unique integers? I'm going to want to Add() integers to the collection and also check for existence e.g. Contains(). Would be nice to also get them in a list as a string for display, ie. "1, 5, 10...
TITLE: Recommended .NET Class for a collection of unique integers? QUESTION: What would you recommend for class that needs to keep a list of unique integers? I'm going to want to Add() integers to the collection and also check for existence e.g. Contains(). Would be nice to also get them in a list as a string for disp...
[ "c#", ".net" ]
9
24
4,109
4
0
2008-10-02T18:04:53.240000
2008-10-02T18:06:28.337000
163,740
164,598
ASP.NET project size
Are there any known issues around how many "pages" are in an ASP.NET project? Does the size of the DLL created by the project matter at all? My existing project is about 150 pages and the DLL is only around 3MB but it has increased from about 50 pages and 0.5 MB recently
Scott Hanselman got on the subject two years ago. The absolute limit is your system memory. The bigger the project the more memory it will use. Surely you can stay in a [50-200] projects in a solution. If you find your Visual Studio taking more than memory than expected start thinking about breaking your projects up. I...
ASP.NET project size Are there any known issues around how many "pages" are in an ASP.NET project? Does the size of the DLL created by the project matter at all? My existing project is about 150 pages and the DLL is only around 3MB but it has increased from about 50 pages and 0.5 MB recently
TITLE: ASP.NET project size QUESTION: Are there any known issues around how many "pages" are in an ASP.NET project? Does the size of the DLL created by the project matter at all? My existing project is about 150 pages and the DLL is only around 3MB but it has increased from about 50 pages and 0.5 MB recently ANSWER: ...
[ "asp.net", "visual-studio" ]
4
2
585
5
0
2008-10-02T18:06:36.120000
2008-10-02T21:03:40.500000
163,747
164,030
Autoconf test for JNI include dir
I'm working on a configuration script for a JNI wrapper. One of the configuration parameters is the path to jni.h. What's a good quick-and-dirty Autoconf test for whether this parameter is set correctly for C++ compilation? You can assume you're running on Linux and g++ is available. Alternatively, is there a way to ge...
Checking for headers is easy; just use AC_CHECK_HEADER. If it's in a weird place (i.e., one the compiler doesn't know about), it's entirely reasonable to expect users to set CPPFLAGS. The hard part is actually locating libjvm. You typically don't want to link with this; but you may want to default to a location to dlop...
Autoconf test for JNI include dir I'm working on a configuration script for a JNI wrapper. One of the configuration parameters is the path to jni.h. What's a good quick-and-dirty Autoconf test for whether this parameter is set correctly for C++ compilation? You can assume you're running on Linux and g++ is available. A...
TITLE: Autoconf test for JNI include dir QUESTION: I'm working on a configuration script for a JNI wrapper. One of the configuration parameters is the path to jni.h. What's a good quick-and-dirty Autoconf test for whether this parameter is set correctly for C++ compilation? You can assume you're running on Linux and g...
[ "java", "java-native-interface", "autoconf" ]
5
5
2,356
3
0
2008-10-02T18:08:35.493000
2008-10-02T19:08:41.230000
163,757
703,105
How to use boost::bind in C++/CLI to bind a member of a managed class
I am using boost::signal in a native C++ class, and I now I am writing a.NET wrapper in C++/CLI, so that I can expose the native C++ callbacks as.NET events. When I try to use boost::bind to take the address of a member function of my managed class, I get compiler error 3374, saying I cannot take the address of a membe...
While your answer works, it exposes some of your implementation to the world (Managed::OnSomeEvent). If you don't want people to be able to raise the OnChange event willy-nilly by invoking OnSomeEvent(), you can update your Managed class as follows (based on this advice ): public delegate void ChangeHandler(void); type...
How to use boost::bind in C++/CLI to bind a member of a managed class I am using boost::signal in a native C++ class, and I now I am writing a.NET wrapper in C++/CLI, so that I can expose the native C++ callbacks as.NET events. When I try to use boost::bind to take the address of a member function of my managed class, ...
TITLE: How to use boost::bind in C++/CLI to bind a member of a managed class QUESTION: I am using boost::signal in a native C++ class, and I now I am writing a.NET wrapper in C++/CLI, so that I can expose the native C++ callbacks as.NET events. When I try to use boost::bind to take the address of a member function of ...
[ "delegates", "c++-cli", "boost-bind", "boost-signals" ]
11
10
5,864
2
0
2008-10-02T18:10:37.517000
2009-03-31T21:17:40.720000
163,760
175,658
Generic GDI+ Error
I have a Form being launched from another form on a different thread. Most of the time it works perfectly, but I get the below error from time to time. Can anyone help? at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap..ctor(Int32 width, Int32 height) at System.Drawi...
The user has to be able to see multiple open accounts simultaneously, right? So you need multiple instances of a form? Unless I'm misreading something, I don't think you need threads for this scenario, and I think you are just introducing yourself to a world of hurt (like these exceptions) as a result. Assuming your ac...
Generic GDI+ Error I have a Form being launched from another form on a different thread. Most of the time it works perfectly, but I get the below error from time to time. Can anyone help? at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap..ctor(Int32 width, Int32 heig...
TITLE: Generic GDI+ Error QUESTION: I have a Form being launched from another form on a different thread. Most of the time it works perfectly, but I get the below error from time to time. Can anyone help? at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap..ctor(Int32...
[ "winforms", "multithreading", ".net-3.5" ]
0
1
965
3
0
2008-10-02T18:11:35.780000
2008-10-06T18:46:00.237000
163,761
452,830
SetURL method of QuickTime object undefined?
I have a hidden embedded QuickTime object on my page that I'm trying to control via JavaScript, but it's not working. The object looks like this: There is nothing in the data parameter because at render time, I don't know the URL that's going to be loaded. I set it like this: var player = document.getElementById("myPla...
Try giving the object element some width and height (1px by 1px) and make it visible within the viewport when you attempt to communicate with the plugin via JavaScript. I've noticed that if the plugin area is not visible on screen it's unresponsive to JS commands. This might explain why this isn't working for you in IE...
SetURL method of QuickTime object undefined? I have a hidden embedded QuickTime object on my page that I'm trying to control via JavaScript, but it's not working. The object looks like this: There is nothing in the data parameter because at render time, I don't know the URL that's going to be loaded. I set it like this...
TITLE: SetURL method of QuickTime object undefined? QUESTION: I have a hidden embedded QuickTime object on my page that I'm trying to control via JavaScript, but it's not working. The object looks like this: There is nothing in the data parameter because at render time, I don't know the URL that's going to be loaded. ...
[ "javascript", "quicktime" ]
0
1
2,187
3
0
2008-10-02T18:11:45.890000
2009-01-17T05:26:00.780000
163,775
164,158
Is there a good iTunes coverflow-type control for WPF?
I am currently using Telerik's carousel control, but it is lacking many features and is buggy. Is there a good control out there that looks the the coverflow control in itunes?
ElementFlow control is inside the codeplex project called FluidKit - can be downloaded from here
Is there a good iTunes coverflow-type control for WPF? I am currently using Telerik's carousel control, but it is lacking many features and is buggy. Is there a good control out there that looks the the coverflow control in itunes?
TITLE: Is there a good iTunes coverflow-type control for WPF? QUESTION: I am currently using Telerik's carousel control, but it is lacking many features and is buggy. Is there a good control out there that looks the the coverflow control in itunes? ANSWER: ElementFlow control is inside the codeplex project called Flu...
[ "wpf" ]
6
9
12,204
5
0
2008-10-02T18:15:15.007000
2008-10-02T19:36:28.090000
163,778
163,850
Scrollable regions in ActionScript 3 Visualization
What is the best way to create several scrollable regions in an ActionScript 3 visualization that extends flash.display.Sprite and makes use of hierarchy of of low level DisplayObjects (Sprite'a, Shape's, TextField)? I have tried to use three mx.containers.Canvas objects added as children of the main Sprite and have al...
After adding the children to each Canvas you may need to call Canvas.invalidateSize() (on each one) to get them to recalculate their sizing. Needing to do this depends on which stage in the Component Lifecycle you're adding the children - i.e. when you're calling '_drawColumLabels'. I presume you're wanting a scollbar ...
Scrollable regions in ActionScript 3 Visualization What is the best way to create several scrollable regions in an ActionScript 3 visualization that extends flash.display.Sprite and makes use of hierarchy of of low level DisplayObjects (Sprite'a, Shape's, TextField)? I have tried to use three mx.containers.Canvas objec...
TITLE: Scrollable regions in ActionScript 3 Visualization QUESTION: What is the best way to create several scrollable regions in an ActionScript 3 visualization that extends flash.display.Sprite and makes use of hierarchy of of low level DisplayObjects (Sprite'a, Shape's, TextField)? I have tried to use three mx.conta...
[ "flash", "actionscript-3", "mxml", "scrollbars" ]
0
1
1,290
1
0
2008-10-02T18:15:33.323000
2008-10-02T18:29:54.410000
163,783
164,077
Fast Text Search Over Logs
Here's the problem I'm having, I've got a set of logs that can grow fairly quickly. They're split into individual files every day, and the files can easily grow up to a gig in size. To help keep the size down, entries older than 30 days or so are cleared out. The problem is when I want to search these files for a certa...
Check out the algorithms that Lucene uses to do its thing. They aren't likely to be very simple, though. I had to study some of these algorithms once upon a time, and some of them are very sophisticated. If you can identify the "words" in the text you want to index, just build a large hash table of the words which maps...
Fast Text Search Over Logs Here's the problem I'm having, I've got a set of logs that can grow fairly quickly. They're split into individual files every day, and the files can easily grow up to a gig in size. To help keep the size down, entries older than 30 days or so are cleared out. The problem is when I want to sea...
TITLE: Fast Text Search Over Logs QUESTION: Here's the problem I'm having, I've got a set of logs that can grow fairly quickly. They're split into individual files every day, and the files can easily grow up to a gig in size. To help keep the size down, entries older than 30 days or so are cleared out. The problem is ...
[ "algorithm", "search", "full-text-search", "scalability" ]
8
2
3,937
6
0
2008-10-02T18:16:34.193000
2008-10-02T19:19:51.297000
163,803
164,221
How do I select a .Net application configuration file from a command line parameter?
I would like to override the use of the standard app.config by passing a command line parameter. How do I change the default application configuration file so that when I access ConfigurationManager.AppSettings I am accessing the config file specified on the command line? Edit: It turns out that the correct way to load...
So here is the code that actually allows me to actually access the appSettings section in a config file other than the default one. ExeConfigurationFileMap configFile = new ExeConfigurationFileMap(); configFile.ExeConfigFilename = Path.Combine(Environment.CurrentDirectory, "Alternate.config"); Configuration config = Co...
How do I select a .Net application configuration file from a command line parameter? I would like to override the use of the standard app.config by passing a command line parameter. How do I change the default application configuration file so that when I access ConfigurationManager.AppSettings I am accessing the confi...
TITLE: How do I select a .Net application configuration file from a command line parameter? QUESTION: I would like to override the use of the standard app.config by passing a command line parameter. How do I change the default application configuration file so that when I access ConfigurationManager.AppSettings I am a...
[ ".net", "configuration", "configurationmanager" ]
16
14
13,121
5
0
2008-10-02T18:20:31.767000
2008-10-02T19:48:27.420000
163,809
163,825
Smart pagination algorithm
I'm looking for an example algorithm of smart pagination. By smart, what I mean is that I only want to show, for example, 2 adjacent pages to the current page, so instead of ending up with a ridiculously long page list, I truncate it. Here's a quick example to make it clearer... this is what I have now: Pages: 1 2 3 4 ...
Here is some code based on original code from this very old link. It uses markup compatible with Bootstrap's pagination component, and outputs page links like this: [1] 2 3 4 5 6... 100 1 [2] 3 4 5 6... 100... 1 2... 14 15 [16] 17 18... 100... 1 2... 97 [98] 99 100 query("SELECT * FROM mytable LIMIT $start, $limit") ->...
Smart pagination algorithm I'm looking for an example algorithm of smart pagination. By smart, what I mean is that I only want to show, for example, 2 adjacent pages to the current page, so instead of ending up with a ridiculously long page list, I truncate it. Here's a quick example to make it clearer... this is what ...
TITLE: Smart pagination algorithm QUESTION: I'm looking for an example algorithm of smart pagination. By smart, what I mean is that I only want to show, for example, 2 adjacent pages to the current page, so instead of ending up with a ridiculously long page list, I truncate it. Here's a quick example to make it cleare...
[ "php", "pagination" ]
37
33
49,733
8
0
2008-10-02T18:22:34.740000
2008-10-02T18:26:36.290000
163,823
164,631
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields?
I have a Person model that has a foreign key relationship to Book, which has a number of fields, but I'm most concerned about author (a standard CharField). With that being said, in my PersonAdmin model, I'd like to display book.author using list_display: class PersonAdmin(admin.ModelAdmin): list_display = ['book.autho...
As another option, you can do lookups like: #models.py class UserAdmin(admin.ModelAdmin): list_display = (..., 'get_author') def get_author(self, obj): return obj.book.author get_author.short_description = 'Author' get_author.admin_order_field = 'book__author' Since Django 3.2 you can use display() decorator: #models....
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? I have a Person model that has a foreign key relationship to Book, which has a number of fields, but I'm most concerned about author (a standard CharField). With that being said, in my PersonAdmin model, I'd like to display book.author u...
TITLE: Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields? QUESTION: I have a Person model that has a foreign key relationship to Book, which has a number of fields, but I'm most concerned about author (a standard CharField). With that being said, in my PersonAdmin model, I'd like to dis...
[ "python", "django", "django-models", "django-admin", "modeladmin" ]
420
661
252,749
15
0
2008-10-02T18:26:19.723000
2008-10-02T21:11:56.283000
163,835
163,912
Refactoring Nicely with Version Control
A co worker of mine asked me to review some of my code and he sent me a diff file. I'm not new to diffs or version control in general but the diff file was very difficult to read because of the changes he made. Specifically, he used the "extract method" feature and reordered some methods. Conceptually, very easy to und...
Eclipse can export refactoring history (see 3.2 release notes as well). You could then view the refactoring changes via preview in Eclipse.
Refactoring Nicely with Version Control A co worker of mine asked me to review some of my code and he sent me a diff file. I'm not new to diffs or version control in general but the diff file was very difficult to read because of the changes he made. Specifically, he used the "extract method" feature and reordered some...
TITLE: Refactoring Nicely with Version Control QUESTION: A co worker of mine asked me to review some of my code and he sent me a diff file. I'm not new to diffs or version control in general but the diff file was very difficult to read because of the changes he made. Specifically, he used the "extract method" feature ...
[ "java", "eclipse", "svn", "version-control" ]
7
4
495
4
0
2008-10-02T18:28:16.660000
2008-10-02T18:43:15.173000
163,837
163,895
Limiting impact of credit card processing scripts/bots
I'm involved in building a donation form for non-profits. We recently got hit by a fast round of low dollar submissions. Many were invalid cards, but a few went through. Obviously someone wrote a script to check a bunch of card numbers for validity, possibly so they can sell them later. Any ideas on how to prevent or l...
When a flood of invalid transactions from a single IP address or small range of addresses is detected, block that address / network. If a botnet is in use, this will not help. You can still detect floods of low dollar amount submissions and so deduce when you are under attack; during these times, stall low dollar amoun...
Limiting impact of credit card processing scripts/bots I'm involved in building a donation form for non-profits. We recently got hit by a fast round of low dollar submissions. Many were invalid cards, but a few went through. Obviously someone wrote a script to check a bunch of card numbers for validity, possibly so the...
TITLE: Limiting impact of credit card processing scripts/bots QUESTION: I'm involved in building a donation form for non-profits. We recently got hit by a fast round of low dollar submissions. Many were invalid cards, but a few went through. Obviously someone wrote a script to check a bunch of card numbers for validit...
[ "forms", "credit-card", "payment", "fraud-prevention" ]
10
5
622
4
0
2008-10-02T18:28:35.600000
2008-10-02T18:39:10.660000
163,881
163,905
WPF Alternative for python
Is there any alternative for WPF (windows presentation foundation) in python? http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF
Here is a list of Python GUI Toolkits. Also, you can use IronPython to work with WPF directly.
WPF Alternative for python Is there any alternative for WPF (windows presentation foundation) in python? http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF
TITLE: WPF Alternative for python QUESTION: Is there any alternative for WPF (windows presentation foundation) in python? http://msdn.microsoft.com/en-us/library/aa970268.aspx#Programming_with_WPF ANSWER: Here is a list of Python GUI Toolkits. Also, you can use IronPython to work with WPF directly.
[ "python", "user-interface" ]
7
7
24,811
4
0
2008-10-02T18:35:16.207000
2008-10-02T18:41:08.550000
163,887
163,907
SQL query: Simulating an "AND" over several rows instead of sub-querying
Suppose I have a "tags" table with two columns: tagid and contentid. Each row represents a tag assigned to a piece of content. I want a query that will give me the contentid of every piece of content which is tagged with tagids 334, 338, and 342. The "easy" way to do this would be ( pseudocode ): select contentid from ...
SELECT contentID FROM tags WHERE tagID in (334, 338, 342) GROUP BY contentID HAVING COUNT(DISTINCT tagID) = 3 --In general SELECT contentID FROM tags WHERE tagID in (...) --taglist GROUP BY contentID HAVING COUNT(DISTINCT tagID) =... --tagcount
SQL query: Simulating an "AND" over several rows instead of sub-querying Suppose I have a "tags" table with two columns: tagid and contentid. Each row represents a tag assigned to a piece of content. I want a query that will give me the contentid of every piece of content which is tagged with tagids 334, 338, and 342. ...
TITLE: SQL query: Simulating an "AND" over several rows instead of sub-querying QUESTION: Suppose I have a "tags" table with two columns: tagid and contentid. Each row represents a tag assigned to a piece of content. I want a query that will give me the contentid of every piece of content which is tagged with tagids 3...
[ "sql", "join" ]
11
25
2,458
5
0
2008-10-02T18:36:59.543000
2008-10-02T18:41:17.440000
163,898
231,552
Multiple H.264 video streams in one RTP session
I would like to dynamically switch the video source in a streaming video application. However, the different video sources have unique image dimensions. I can generate individual SDP files for each video source, but I would like to combine them into a single SDP file so that the viewing client could automatically resiz...
The parameters in your two sdp examples are very close - the stream name and the sprop-parameter-sets differ. I assume you don't care about the stream name. If you need separate sprop-parameter-sets and the clients support the standard well you can use separate dynamic payload types for each resolution and have a singl...
Multiple H.264 video streams in one RTP session I would like to dynamically switch the video source in a streaming video application. However, the different video sources have unique image dimensions. I can generate individual SDP files for each video source, but I would like to combine them into a single SDP file so t...
TITLE: Multiple H.264 video streams in one RTP session QUESTION: I would like to dynamically switch the video source in a streaming video application. However, the different video sources have unique image dimensions. I can generate individual SDP files for each video source, but I would like to combine them into a si...
[ "video", "streaming", "h.264", "rtp" ]
11
9
16,215
4
0
2008-10-02T18:39:32.593000
2008-10-23T21:12:12.027000
163,900
165,154
HTML/Javascript app that runs on the filesystem, security issue
I'm putting together a little tool that some business people can run on their local filesystems, since we don't want to setup a host for it. Basically, its just HTML + Javascript (using jQuery) to pull some reports using REST from a 3rd party. The problem is, FF3 and IE don't allow the ajax call, I get: Access to restr...
In a similar situation, my solution was to use Mark Of The Web, which is a special HTML comment that IE recognizes. It places the page in a different security zone. Reference: MSDN
HTML/Javascript app that runs on the filesystem, security issue I'm putting together a little tool that some business people can run on their local filesystems, since we don't want to setup a host for it. Basically, its just HTML + Javascript (using jQuery) to pull some reports using REST from a 3rd party. The problem ...
TITLE: HTML/Javascript app that runs on the filesystem, security issue QUESTION: I'm putting together a little tool that some business people can run on their local filesystems, since we don't want to setup a host for it. Basically, its just HTML + Javascript (using jQuery) to pull some reports using REST from a 3rd p...
[ "jquery", "ajax", "xss", "filesystems" ]
3
2
674
3
0
2008-10-02T18:40:03.013000
2008-10-03T00:06:05.447000
163,913
163,959
How do you decide if a project should be web-based or desktop-based?
I'm having trouble deciding if I want a project of mine to be web-based (as in a web-app), desktop-based (a desktop application), or a desktop application that can sync or connect to the cloud. I don't know if anyone else would have an interest in this application, and it's only going to be for me, so I'm leaning towar...
I generally ask a few questions: Can it even be done on the web? Something I did not too long ago involved an image editing component, and had to be a web app. It involved much pain to get this work, and a desktop app would have been a far better way to go. Will I need to access it from anywhere? Yeah you could load it...
How do you decide if a project should be web-based or desktop-based? I'm having trouble deciding if I want a project of mine to be web-based (as in a web-app), desktop-based (a desktop application), or a desktop application that can sync or connect to the cloud. I don't know if anyone else would have an interest in thi...
TITLE: How do you decide if a project should be web-based or desktop-based? QUESTION: I'm having trouble deciding if I want a project of mine to be web-based (as in a web-app), desktop-based (a desktop application), or a desktop application that can sync or connect to the cloud. I don't know if anyone else would have ...
[ "user-interface", "desktop-application", "web-applications" ]
14
17
1,933
10
0
2008-10-02T18:43:17.560000
2008-10-02T18:51:13.517000
163,919
163,987
Extracting Autocomplete Emails from Outlook 2007
I need to extract all the emails that show up as autocomplete entries in Outlook 2007. I mostly need to create a list of all the email addresses which I have sent emails to in the past and dump them into excel. Should I be connecting to Outlook through COM somehow? Thanks.
All of that information is in a file in the local settings with an extension NK2. c:\Documents and Settings\{USERNAME}\Application Data\Microsoft\Outlook\{USERNAME}.NK2 This utility can read/edit the contents. The file format itself is explained here: Google Code debunk2 explanation of NK2 file format
Extracting Autocomplete Emails from Outlook 2007 I need to extract all the emails that show up as autocomplete entries in Outlook 2007. I mostly need to create a list of all the email addresses which I have sent emails to in the past and dump them into excel. Should I be connecting to Outlook through COM somehow? Thank...
TITLE: Extracting Autocomplete Emails from Outlook 2007 QUESTION: I need to extract all the emails that show up as autocomplete entries in Outlook 2007. I mostly need to create a list of all the email addresses which I have sent emails to in the past and dump them into excel. Should I be connecting to Outlook through ...
[ "language-agnostic", "winapi", "outlook" ]
2
5
1,554
1
0
2008-10-02T18:44:15.890000
2008-10-02T18:58:17.137000
163,923
164,722
Methods for Geotagging or Geolabelling Text Content
What are some good algorithms for automatically labeling text with the city / region or origin? That is, if a blog is about New York, how can I tell programatically. Are there packages / papers that claim to do this with any degree of certainty? I have looked at some tfidf based approaches, proper noun intersections, b...
You're looking for a named entity recognition system, or short NER. There are several good toolkits available to help you out. LingPipe in particular has a very decent tutorial. CAGEclass seems to be oriented around NER on geographical place names, but I haven't used it yet. If you're going with Java, I'd recommend usi...
Methods for Geotagging or Geolabelling Text Content What are some good algorithms for automatically labeling text with the city / region or origin? That is, if a blog is about New York, how can I tell programatically. Are there packages / papers that claim to do this with any degree of certainty? I have looked at some ...
TITLE: Methods for Geotagging or Geolabelling Text Content QUESTION: What are some good algorithms for automatically labeling text with the city / region or origin? That is, if a blog is about New York, how can I tell programatically. Are there packages / papers that claim to do this with any degree of certainty? I ha...
[ "algorithm", "statistics", "nlp", "named-entity-recognition" ]
9
13
6,537
2
0
2008-10-02T18:44:32.677000
2008-10-02T21:38:52.570000
163,962
163,985
Switching from std::string to std::wstring for embedded applications?
Up until now I have been using std::string in my C++ applications for embedded system (routers, switches, telco gear, etc.). For the next project, I am considering to switch from std::string to std::wstring for Unicode support. This would, for example, allow end-users to use Chinese characters in the command line inter...
Note that many communications protocols require 8-bit characters (or 7-bit characters, or other varieties), so you will often need to translate between your internal wchar_t/wstring data and external encodings. UTF-8 encoding is useful when you need to have an 8-bit representation of Unicode characters. (See How Do You...
Switching from std::string to std::wstring for embedded applications? Up until now I have been using std::string in my C++ applications for embedded system (routers, switches, telco gear, etc.). For the next project, I am considering to switch from std::string to std::wstring for Unicode support. This would, for exampl...
TITLE: Switching from std::string to std::wstring for embedded applications? QUESTION: Up until now I have been using std::string in my C++ applications for embedded system (routers, switches, telco gear, etc.). For the next project, I am considering to switch from std::string to std::wstring for Unicode support. This...
[ "c++", "unicode", "stl", "embedded" ]
4
1
3,228
3
0
2008-10-02T18:51:33.860000
2008-10-02T18:57:06.017000
163,998
164,145
Classical set operations for java.util.Collection
Is there any built-in functionality for classical set operations on the java.util.Collection class? My specific implementation would be for ArrayList, but this sounds like something that should apply for all subclasses of Collection. I'm looking for something like: ArrayList setA... ArrayList setB... ArrayList setAinte...
Intersection is done with Collection.retainAll; subtraction with Collection.removeAll; union with Collection.addAll. In each case, as Set will act like a set and a List will act like a list. As mutable objects, they operate in place. You'll need to explicitly copy if you want to retain the original mutable object unmut...
Classical set operations for java.util.Collection Is there any built-in functionality for classical set operations on the java.util.Collection class? My specific implementation would be for ArrayList, but this sounds like something that should apply for all subclasses of Collection. I'm looking for something like: Arra...
TITLE: Classical set operations for java.util.Collection QUESTION: Is there any built-in functionality for classical set operations on the java.util.Collection class? My specific implementation would be for ArrayList, but this sounds like something that should apply for all subclasses of Collection. I'm looking for so...
[ "java", "collections", "set" ]
65
110
48,979
4
0
2008-10-02T19:01:31.933000
2008-10-02T19:33:21.387000
164,002
164,012
Why is fread reaching the EOF early?
I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the length of the file, and then use fread to read in the file. The loop runs once and then ends because the EOF is reached (no errors). At the end, byt...
perhaps it's a binary mode issue. Try opening the file with "r+b" as the mode. EDIT: as noted in a comment "rb" is likely a better match to your original intent since "r+b" will open it for read/write and "rb" is read-only.
Why is fread reaching the EOF early? I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the length of the file, and then use fread to read in the file. The loop runs once and then ends because the EOF is...
TITLE: Why is fread reaching the EOF early? QUESTION: I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the length of the file, and then use fread to read in the file. The loop runs once and then ends ...
[ "c++", "c", "file-io", "stdio", "feof" ]
30
56
16,402
3
0
2008-10-02T19:02:22.383000
2008-10-02T19:04:41.193000
164,008
164,021
Sql Server 2005 Connection Limit
Is there a connection limit on Sql Server 2005 Developers Edition. We have many threads grabbing connections, and I know ADO.NET does connection pooling, but I get OutOfMemory exceptions. We take out the db connections and it works fine.
This is the response to that question on Euan Garden's (a Program Manager for Visual Studio Team Edition) blog: There are no limits in terms of memory, db size or procs for DE, it is essentially Enterprise Edition. There is however a licensing restriction that prevents it from being used in production. Therefore, you p...
Sql Server 2005 Connection Limit Is there a connection limit on Sql Server 2005 Developers Edition. We have many threads grabbing connections, and I know ADO.NET does connection pooling, but I get OutOfMemory exceptions. We take out the db connections and it works fine.
TITLE: Sql Server 2005 Connection Limit QUESTION: Is there a connection limit on Sql Server 2005 Developers Edition. We have many threads grabbing connections, and I know ADO.NET does connection pooling, but I get OutOfMemory exceptions. We take out the db connections and it works fine. ANSWER: This is the response t...
[ "sql-server", "sql-server-2005" ]
1
4
6,341
4
0
2008-10-02T19:03:40.180000
2008-10-02T19:07:06.897000
164,022
164,092
Reading some integers then a line of text in C++
I'm reading input in a C++ program. First some integers, then a string. When I try reading the string with getline(cin,stringname);, it doesn't read the line that the user types: instead, I get an empty line, from when the user pressed Enter after typing the integers. cin>>track.day; //Int cin>>track.seriesday; //Int g...
I think that your cin of the ints is not reading the new line before the sentence. cin skips leading whitespace and stops reading a number when it encounters a non-digit, including whitespace. So: std::cin >> num1; std::cin >> num2; std::cin.ignore(INT_MAX, '\n'); // ignore the new line which follows num2 std::getline(...
Reading some integers then a line of text in C++ I'm reading input in a C++ program. First some integers, then a string. When I try reading the string with getline(cin,stringname);, it doesn't read the line that the user types: instead, I get an empty line, from when the user pressed Enter after typing the integers. ci...
TITLE: Reading some integers then a line of text in C++ QUESTION: I'm reading input in a C++ program. First some integers, then a string. When I try reading the string with getline(cin,stringname);, it doesn't read the line that the user types: instead, I get an empty line, from when the user pressed Enter after typin...
[ "c++", "string", "input", "newline", "iostream" ]
1
2
460
1
0
2008-10-02T19:07:17.020000
2008-10-02T19:22:49.197000
164,023
164,136
What guidelines are appropriate for determining when to implement a class member as a property versus a method?
The.NET coding standards PDF from SubMain that have started showing up in the "Sponsored By" area seems to indicate that properties are only appropriate for logical data members (see pages 34-35 of the document). Methods are deemed appropriate in the following cases: The operation is a conversion, such as Object.ToStri...
They seem sound, and basically in line with MSDN member design guidelines: http://msdn.microsoft.com/en-us/library/ms229059.aspx One point that people sometimes seem to forget (*) is that callers should be able to set properties in any order. Particularly important for classes that support designers, as you can't be su...
What guidelines are appropriate for determining when to implement a class member as a property versus a method? The.NET coding standards PDF from SubMain that have started showing up in the "Sponsored By" area seems to indicate that properties are only appropriate for logical data members (see pages 34-35 of the docume...
TITLE: What guidelines are appropriate for determining when to implement a class member as a property versus a method? QUESTION: The.NET coding standards PDF from SubMain that have started showing up in the "Sponsored By" area seems to indicate that properties are only appropriate for logical data members (see pages 3...
[ "c#", ".net" ]
5
3
241
5
0
2008-10-02T19:07:30.250000
2008-10-02T19:31:47.197000
164,026
164,035
On Win32 how do you move a thread to another CPU core?
I'd like to make sure that a thread is moved to a specific CPU core and can never be moved from it by the scheduler. There's a SetThreadAffinityMask() call but there's no GetThreadAffinityMask(). The reason I need this is because high resolution timers will get messed up if the scheduler moves that thread to another CP...
You should probably just use SetThreadAffinityMask and trust that it is working. MSDN
On Win32 how do you move a thread to another CPU core? I'd like to make sure that a thread is moved to a specific CPU core and can never be moved from it by the scheduler. There's a SetThreadAffinityMask() call but there's no GetThreadAffinityMask(). The reason I need this is because high resolution timers will get mes...
TITLE: On Win32 how do you move a thread to another CPU core? QUESTION: I'd like to make sure that a thread is moved to a specific CPU core and can never be moved from it by the scheduler. There's a SetThreadAffinityMask() call but there's no GetThreadAffinityMask(). The reason I need this is because high resolution t...
[ "c++", "c", "multithreading", "winapi", "multicore" ]
7
10
4,082
4
0
2008-10-02T19:07:51.170000
2008-10-02T19:09:35.533000
164,039
190,709
Docking a CControlBar derived window
How can I dock a CControlBar derived window to the middle of a splitter window (CSplitterWnd)? I would like the bar to be repositioned whenever the splitter is moved. To make it a little clearer as to what I'm after, imagine the vertical ruler in the Dialog Editor in Visual Studio (MFC only). It gets repositioned whene...
Alf, In case of VS, there's no splitter used: The resource view is a resizable ControlBar (It looks and feels like a splitter but it isn't a CSplitterWnd). The rest is a child frame (either tabbed or MDI. Go to Tools/Options/Environment/General and choose Multiple Documents to convince yourself). The ruler is part (con...
Docking a CControlBar derived window How can I dock a CControlBar derived window to the middle of a splitter window (CSplitterWnd)? I would like the bar to be repositioned whenever the splitter is moved. To make it a little clearer as to what I'm after, imagine the vertical ruler in the Dialog Editor in Visual Studio (...
TITLE: Docking a CControlBar derived window QUESTION: How can I dock a CControlBar derived window to the middle of a splitter window (CSplitterWnd)? I would like the bar to be repositioned whenever the splitter is moved. To make it a little clearer as to what I'm after, imagine the vertical ruler in the Dialog Editor ...
[ "c++", "visual-studio", "winapi", "visual-c++", "mfc" ]
0
1
1,286
2
0
2008-10-02T19:10:11.287000
2008-10-10T10:15:48.067000
164,048
164,079
Basic programming/algorithmic concepts
I'm about to start (with fellow programmers) a programming & algorithms club in my high school. The language of choice is C++ - sorry about that, I can't change this. We can assume students have little to no experience in the aforementioned topics. What do you think are the most basic concepts I should focus on? I know...
Make programming fun! Possible things to talk about would be Programming Competitions that either your club could hold itself or it could enter in locally. I compete in programming competitions at the University (ACM) level and I know for a fact that they have them at lower levels as well. Those kind of events can real...
Basic programming/algorithmic concepts I'm about to start (with fellow programmers) a programming & algorithms club in my high school. The language of choice is C++ - sorry about that, I can't change this. We can assume students have little to no experience in the aforementioned topics. What do you think are the most b...
TITLE: Basic programming/algorithmic concepts QUESTION: I'm about to start (with fellow programmers) a programming & algorithms club in my high school. The language of choice is C++ - sorry about that, I can't change this. We can assume students have little to no experience in the aforementioned topics. What do you th...
[ "algorithm", "language-agnostic", "theory" ]
17
12
5,161
23
0
2008-10-02T19:12:45.947000
2008-10-02T19:20:14.557000
164,053
164,058
Should log file streams be opened/closed on each write or kept open during a desktop application's lifetime?
Should log classes open/close a log file stream on each write to the log file or should it keep the log file stream open throughout the application's lifetime until all logging is complete? I'm asking in context of a desktop application. I have seen people do it both ways and was wondering which approach yields the bes...
If you have frequent read/writes it is more efficient to keep the file open for the lifetime with a single open/close. You might want to flush periodically or after each write though. If your application crashes you might not have all the data written to your file. Use fflush on Unix-based systems and FlushFileBuffers ...
Should log file streams be opened/closed on each write or kept open during a desktop application's lifetime? Should log classes open/close a log file stream on each write to the log file or should it keep the log file stream open throughout the application's lifetime until all logging is complete? I'm asking in context...
TITLE: Should log file streams be opened/closed on each write or kept open during a desktop application's lifetime? QUESTION: Should log classes open/close a log file stream on each write to the log file or should it keep the log file stream open throughout the application's lifetime until all logging is complete? I'm...
[ "logging" ]
42
20
18,247
13
0
2008-10-02T19:14:35.973000
2008-10-02T19:16:00.667000
164,073
164,351
Versioning a MySQL database when code base doesn't have a ORM
I've been thinking about this problem for a while and have yet to come up with any stable/elegant ideas. I know with MyISAM tables, you can get the table def update time but thats not so true with InnoDB and I've found its not even reliable to look at the.frm file for an idea of when the definition might have been modi...
This reminds me of this question: How do you manage database revisions on a medium sized project with branches? but maybe I'm being to general... http://odetocode.com/Blogs/scott/archive/2008/01/30/11702.aspx The codebase I'm currently working on does not have an ORM yet we still use the solution based on the blog abov...
Versioning a MySQL database when code base doesn't have a ORM I've been thinking about this problem for a while and have yet to come up with any stable/elegant ideas. I know with MyISAM tables, you can get the table def update time but thats not so true with InnoDB and I've found its not even reliable to look at the.fr...
TITLE: Versioning a MySQL database when code base doesn't have a ORM QUESTION: I've been thinking about this problem for a while and have yet to come up with any stable/elegant ideas. I know with MyISAM tables, you can get the table def update time but thats not so true with InnoDB and I've found its not even reliable...
[ "mysql", "project-management", "versioning" ]
3
1
1,088
3
0
2008-10-02T19:19:04.403000
2008-10-02T20:15:29.400000
164,088
164,180
Make your collections thread-safe?
When designing a collection class, is there any reason not to implement locking privately to make it thread safe? Or should I leave that responsibility up to the consumer of the collection?
is there any reason not to implement locking privately to make it thread safe? It depends. Is your goal to write a collection class which is accessed by multiple threads? If so, make it thread safe. If not, don't waste your time. This kind of thing is what people refer to when they talk about 'premature optimization' S...
Make your collections thread-safe? When designing a collection class, is there any reason not to implement locking privately to make it thread safe? Or should I leave that responsibility up to the consumer of the collection?
TITLE: Make your collections thread-safe? QUESTION: When designing a collection class, is there any reason not to implement locking privately to make it thread safe? Or should I leave that responsibility up to the consumer of the collection? ANSWER: is there any reason not to implement locking privately to make it th...
[ "c#", "java", "multithreading", "collections" ]
9
13
5,891
17
0
2008-10-02T19:22:26.687000
2008-10-02T19:42:01.587000
164,093
164,116
Serialization of a long array (in C)
in a C program I have an long* that I want to serialize (thus converting to chars). A long doesn't fit in a single char, and the size varies depending of the processor (can be 4 bytes or 8 bytes). Theres a good way to make the serialization and de-serialization?
long * longs; //... int numChars = numLongs * sizeof(long); char* longsAsChars = (char*) longs; char* chars = malloc(numChars); memcpy(chars, longsAsChars, numChars);
Serialization of a long array (in C) in a C program I have an long* that I want to serialize (thus converting to chars). A long doesn't fit in a single char, and the size varies depending of the processor (can be 4 bytes or 8 bytes). Theres a good way to make the serialization and de-serialization?
TITLE: Serialization of a long array (in C) QUESTION: in a C program I have an long* that I want to serialize (thus converting to chars). A long doesn't fit in a single char, and the size varies depending of the processor (can be 4 bytes or 8 bytes). Theres a good way to make the serialization and de-serialization? A...
[ "c", "arrays", "string", "serialization" ]
2
1
6,440
6
0
2008-10-02T19:22:53.830000
2008-10-02T19:26:44.367000
164,095
164,358
Need help improving a Ruby DSL for controlling an Arduino controlled drink dispenser (bar monkey)
I'm writing a DSL in Ruby to control an Arduino project I'm working on; Bardino. It's a bar monkey that will be software controlled to serve drinks. The Arduino takes commands via the serial port to tell the Arduino what pumps to turn on and for how long. It currently reads a recipe (see below) and prints it back out. ...
Without looking into implementation details (or your github links), I'd try write a DSL like this: (stealing from here: http://supercocktails.com/1310/Long-Island-Iced-Tea- ) describe "Long Island Iced Tea" do serve_in 'Highball Glass' ingredients do half.ounce.of:vodka half.ounce.of:tequila half.ounce.of:light_rum ha...
Need help improving a Ruby DSL for controlling an Arduino controlled drink dispenser (bar monkey) I'm writing a DSL in Ruby to control an Arduino project I'm working on; Bardino. It's a bar monkey that will be software controlled to serve drinks. The Arduino takes commands via the serial port to tell the Arduino what p...
TITLE: Need help improving a Ruby DSL for controlling an Arduino controlled drink dispenser (bar monkey) QUESTION: I'm writing a DSL in Ruby to control an Arduino project I'm working on; Bardino. It's a bar monkey that will be software controlled to serve drinks. The Arduino takes commands via the serial port to tell ...
[ "ruby", "language-design", "dsl", "arduino" ]
6
5
840
3
0
2008-10-02T19:23:12.613000
2008-10-02T20:16:28.553000
164,102
164,130
In c++, why does the compiler choose the non-const function when the const would work also?
For example, suppose I have a class: class Foo { public: std::string& Name() { m_maybe_modified = true; return m_name; } const std::string& Name() const { return m_name; } protected: std::string m_name; bool m_maybe_modified; }; And somewhere else in the code, I have something like this: Foo *a; // Do stuff... std::st...
Two answers spring to mind: The non-const version is a closer match. If it called the const overload for the non-const case, then under what circumstances would it ever call the non-const overload? You can get it to use the other overload by casting a to a const Foo *. Edit: From C++ Annotations Earlier, in section 2.5...
In c++, why does the compiler choose the non-const function when the const would work also? For example, suppose I have a class: class Foo { public: std::string& Name() { m_maybe_modified = true; return m_name; } const std::string& Name() const { return m_name; } protected: std::string m_name; bool m_maybe_modified; }...
TITLE: In c++, why does the compiler choose the non-const function when the const would work also? QUESTION: For example, suppose I have a class: class Foo { public: std::string& Name() { m_maybe_modified = true; return m_name; } const std::string& Name() const { return m_name; } protected: std::string m_name; bool m...
[ "c++", "constants", "overload-resolution", "const-reference", "function-qualifier" ]
21
20
4,176
4
0
2008-10-02T19:24:25.683000
2008-10-02T19:30:20.333000
164,105
164,664
Testing onbeforeunload events from Selenium
I'm trying to write a Selenium test for a web page that uses an onbeforeunload event to prompt the user before leaving. Selenium doesn't seem to recognize the confirmation dialog that comes up, or to provide a way to hit OK or Cancel. Is there any way to do this? I'm using the Java Selenium driver, if that's relevant.
You could write a user extension (or just some JavaScript in a storeEval etc) that tests that window.onbeforeunload is set, and then replaces it with null before continuing on from the page. Ugly, but ought to get you off the page.
Testing onbeforeunload events from Selenium I'm trying to write a Selenium test for a web page that uses an onbeforeunload event to prompt the user before leaving. Selenium doesn't seem to recognize the confirmation dialog that comes up, or to provide a way to hit OK or Cancel. Is there any way to do this? I'm using th...
TITLE: Testing onbeforeunload events from Selenium QUESTION: I'm trying to write a Selenium test for a web page that uses an onbeforeunload event to prompt the user before leaving. Selenium doesn't seem to recognize the confirmation dialog that comes up, or to provide a way to hit OK or Cancel. Is there any way to do ...
[ "java", "javascript", "html", "selenium", "onbeforeunload" ]
12
4
4,352
4
0
2008-10-02T19:24:47.353000
2008-10-02T21:19:35.813000
164,124
164,595
RSS Item updates
I'm working on an RSS feed for a custom tasking system we use, and I'm still wrapping my head around how things should work. What I want to have is a feed for each user that shows tasks assigned to them, and additionally a feed for each task that shows updates for the task. What I want to know right now concerns the us...
Changing the does indicate that the entry changed, but there is no requirement that a given RSS reader do anything about it. (Strictly speaking, there is no requirement than an RSS reader do anything, but let's remain reasonable.) Some reader do mark updated entries as changed. For example Bloglines.com can optionally ...
RSS Item updates I'm working on an RSS feed for a custom tasking system we use, and I'm still wrapping my head around how things should work. What I want to have is a feed for each user that shows tasks assigned to them, and additionally a feed for each task that shows updates for the task. What I want to know right no...
TITLE: RSS Item updates QUESTION: I'm working on an RSS feed for a custom tasking system we use, and I'm still wrapping my head around how things should work. What I want to have is a feed for each user that shows tasks assigned to them, and additionally a feed for each task that shows updates for the task. What I wan...
[ "rss", "syndication" ]
5
3
2,223
2
0
2008-10-02T19:29:44.690000
2008-10-02T21:02:56.807000
164,143
164,774
registers vs stacks
What exactly are the advantages and disadvantages to using a register-based virtual machine versus using a stack-based virtual machine? To me, it would seem as though a register based machine would be more straight-forward to program and more efficient. So why is it that the JVM, the CLR, and the Python VM are all stac...
This has already been answered, to a certain level, in the Parrot VM's FAQ and associated documents: A Parrot Overview The relevant text from that doc is this: the Parrot VM will have a register architecture, rather than a stack architecture. It will also have extremely low-level operations, more similar to Java's than...
registers vs stacks What exactly are the advantages and disadvantages to using a register-based virtual machine versus using a stack-based virtual machine? To me, it would seem as though a register based machine would be more straight-forward to program and more efficient. So why is it that the JVM, the CLR, and the Py...
TITLE: registers vs stacks QUESTION: What exactly are the advantages and disadvantages to using a register-based virtual machine versus using a stack-based virtual machine? To me, it would seem as though a register based machine would be more straight-forward to program and more efficient. So why is it that the JVM, t...
[ "language-agnostic", "vm-implementation", "stack-based" ]
83
45
36,732
7
0
2008-10-02T19:32:50.437000
2008-10-02T21:53:11.553000