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
178,070
327,288
DDD and Asynchronous Repositories
We're working on a rich client (written in Flex) that is connected to a Java backend, using both RMI and JMS. I was thinking about implementing the client in a DDD fashion so that it has Repositories for the CRUD operations on the domain objects. The problem is however that all backend communication happens asynchronou...
Flex and Flash Remoting is inherently asynchronous so fighting against that paradigm is going to give you a ton of trouble. Our service delegates return AsyncToken from every method and we've never had a problem with it. If you want to ensure that the application doesn't render a new view or perform some other logic un...
DDD and Asynchronous Repositories We're working on a rich client (written in Flex) that is connected to a Java backend, using both RMI and JMS. I was thinking about implementing the client in a DDD fashion so that it has Repositories for the CRUD operations on the domain objects. The problem is however that all backend...
TITLE: DDD and Asynchronous Repositories QUESTION: We're working on a rich client (written in Flex) that is connected to a Java backend, using both RMI and JMS. I was thinking about implementing the client in a DDD fashion so that it has Repositories for the CRUD operations on the domain objects. The problem is howeve...
[ "apache-flex", "asynchronous", "domain-driven-design", "ddd-repositories" ]
3
4
3,462
3
0
2008-10-07T11:41:01.017000
2008-11-29T07:01:56.990000
178,128
178,146
Functions vs Stored Procedures
Let's say I have to implement a piece of T-SQL code that must return a table as result. I can implement a table-valued function or else a stored procedure that returns a set of rows. What should I use? In short, what I want to know is: Which are the main differences between functions and stored procedures? What conside...
If you're likely to want to combine the result of this piece of code with other tables, then obviously a table-valued function will allow you to compose the results in a single SELECT statement. Generally, there's a hierarchy (View < TV Function < Stored Proc). You can do more in each one, but the ability to compose th...
Functions vs Stored Procedures Let's say I have to implement a piece of T-SQL code that must return a table as result. I can implement a table-valued function or else a stored procedure that returns a set of rows. What should I use? In short, what I want to know is: Which are the main differences between functions and ...
TITLE: Functions vs Stored Procedures QUESTION: Let's say I have to implement a piece of T-SQL code that must return a table as result. I can implement a table-valued function or else a stored procedure that returns a set of rows. What should I use? In short, what I want to know is: Which are the main differences betw...
[ "sql", "sql-server", "database", "function", "stored-procedures" ]
95
54
44,253
12
0
2008-10-07T11:59:49.277000
2008-10-07T12:05:49.483000
178,138
178,174
How to Pass an Object Method as a Parameter in Delphi, and then Call It?
I fear this is probably a bit of a dummy question, but it has me pretty stumped. I'm looking for the simplest way possible to pass a method of an object into a procedure, so that the procedure can call the object's method (e.g. after a timeout, or maybe in a different thread). So basically I want to: Capture a referenc...
Just remove the Pointer stuff. Delphi will do it for you: procedure TCallbackObject.SetupCallback; begin CallbackTheCallback(CallbackMethodImpl); end;
How to Pass an Object Method as a Parameter in Delphi, and then Call It? I fear this is probably a bit of a dummy question, but it has me pretty stumped. I'm looking for the simplest way possible to pass a method of an object into a procedure, so that the procedure can call the object's method (e.g. after a timeout, or...
TITLE: How to Pass an Object Method as a Parameter in Delphi, and then Call It? QUESTION: I fear this is probably a bit of a dummy question, but it has me pretty stumped. I'm looking for the simplest way possible to pass a method of an object into a procedure, so that the procedure can call the object's method (e.g. a...
[ "delphi", "pointers", "callback" ]
17
20
13,943
2
0
2008-10-07T12:04:18.380000
2008-10-07T12:15:50.807000
178,144
179,753
How to create an automatically managed "last update" field with Microsoft Access
Originally I thought to ask if there would be an easy way to provide an automatically managed last update field with MS Access. After some googling I found following approach: Private Sub Form_Dirty(Cancel As Integer) Me.Last_Update = Date() End Sub Which seems to do the job. I thought I'd share it with others too (a...
You could also put that same code into a BeforeUpdate. The difference being that the OnDirty will tag the record when you first started to edit the record; while the BeforeUpdate will tag the record just before it gets committed to the database. The latter may be preferable if you have a user who starts editing a recor...
How to create an automatically managed "last update" field with Microsoft Access Originally I thought to ask if there would be an easy way to provide an automatically managed last update field with MS Access. After some googling I found following approach: Private Sub Form_Dirty(Cancel As Integer) Me.Last_Update = Dat...
TITLE: How to create an automatically managed "last update" field with Microsoft Access QUESTION: Originally I thought to ask if there would be an easy way to provide an automatically managed last update field with MS Access. After some googling I found following approach: Private Sub Form_Dirty(Cancel As Integer) Me...
[ "ms-access" ]
5
3
12,270
4
0
2008-10-07T12:05:12.310000
2008-10-07T18:31:15.617000
178,147
178,162
How can I verify if a Windows Service is running
I have an application in C# (2.0 running on XP embedded) that is communicating with a 'watchdog' that is implemented as a Windows Service. When the device boots, this service typically takes some time to start. I'd like to check, from my code, if the service is running. How can I accomplish this?
I guess something like this would work: Add System.ServiceProcess to your project references (It's on the.NET tab). using System.ServiceProcess; ServiceController sc = new ServiceController(SERVICENAME); switch (sc.Status) { case ServiceControllerStatus.Running: return "Running"; case ServiceControllerStatus.Stopped:...
How can I verify if a Windows Service is running I have an application in C# (2.0 running on XP embedded) that is communicating with a 'watchdog' that is implemented as a Windows Service. When the device boots, this service typically takes some time to start. I'd like to check, from my code, if the service is running. ...
TITLE: How can I verify if a Windows Service is running QUESTION: I have an application in C# (2.0 running on XP embedded) that is communicating with a 'watchdog' that is implemented as a Windows Service. When the device boots, this service typically takes some time to start. I'd like to check, from my code, if the se...
[ "c#", "windows-services", "watchdog" ]
206
415
213,436
2
0
2008-10-07T12:05:59.717000
2008-10-07T12:10:39.240000
178,173
181,012
Reading the Exchange server time via MAPI
I'd like to calculate the age of the messages in an Exchange mailbox to make sure they sit there for at least a minute before our program (C++, MAPI) processes them. This way the spam filter we use should have enough time to do its job. Because the time on the PC where our program runs might be different from the time ...
I presume you are getting a MAPI event notification when the message arrives in the Exchange mailbox. I would suggest pushing these messages into a queue and waiting n seconds (e.g. 60s) before processing the message. Since the time is relative to the notification event there will be no issue with respect to clock drif...
Reading the Exchange server time via MAPI I'd like to calculate the age of the messages in an Exchange mailbox to make sure they sit there for at least a minute before our program (C++, MAPI) processes them. This way the spam filter we use should have enough time to do its job. Because the time on the PC where our prog...
TITLE: Reading the Exchange server time via MAPI QUESTION: I'd like to calculate the age of the messages in an Exchange mailbox to make sure they sit there for at least a minute before our program (C++, MAPI) processes them. This way the spam filter we use should have enough time to do its job. Because the time on the...
[ "c++", "exchange-server", "mapi" ]
2
1
850
2
0
2008-10-07T12:15:37.873000
2008-10-08T01:01:32.600000
178,187
178,504
OO Design: Multiple persistance design for a ruby class
I am designing a class for log entries of my mail server. I have parsed the log entries and created the class hierarchy. Now I need to save the in memory representation to the disk. I need to save it to multiple destinations like mysql and disk files. I am at a loss to find out the proper way to design the persistence ...
Personally I'd break things out a bit - the object representing a log entry really shouldn't be worrying about how it should save it, so I'd probably create a MySQLObjectStore, and FileObjectStore, which you can configure separately, and gets passed the object to save. You could give your Object class a class variable ...
OO Design: Multiple persistance design for a ruby class I am designing a class for log entries of my mail server. I have parsed the log entries and created the class hierarchy. Now I need to save the in memory representation to the disk. I need to save it to multiple destinations like mysql and disk files. I am at a lo...
TITLE: OO Design: Multiple persistance design for a ruby class QUESTION: I am designing a class for log entries of my mail server. I have parsed the log entries and created the class hierarchy. Now I need to save the in memory representation to the disk. I need to save it to multiple destinations like mysql and disk f...
[ "ruby", "oop" ]
1
2
267
3
0
2008-10-07T12:19:37.693000
2008-10-07T13:45:28.050000
178,188
178,197
Bitfields in C#
So, bitfields. Specifically, large bitfields. I understand how to manipulate individual values in a bitfield, but how would I go about doing this on a large set, such as say: uint[] bitfield = new uint[4] { 0x0080000, 0x00FA3020, 0x00C8000, 0x0FF00D0 }; The specific problem I'm having is doing left and right shifts tha...
What makes you think that BitArray uses bools internally? It uses Boolean values to represent the bits in terms of the API, but under the hood I believe it uses an int[].
Bitfields in C# So, bitfields. Specifically, large bitfields. I understand how to manipulate individual values in a bitfield, but how would I go about doing this on a large set, such as say: uint[] bitfield = new uint[4] { 0x0080000, 0x00FA3020, 0x00C8000, 0x0FF00D0 }; The specific problem I'm having is doing left and ...
TITLE: Bitfields in C# QUESTION: So, bitfields. Specifically, large bitfields. I understand how to manipulate individual values in a bitfield, but how would I go about doing this on a large set, such as say: uint[] bitfield = new uint[4] { 0x0080000, 0x00FA3020, 0x00C8000, 0x0FF00D0 }; The specific problem I'm having ...
[ "c#", "data-structures", "bit-manipulation", "bit-fields" ]
4
2
3,019
4
0
2008-10-07T12:19:56.787000
2008-10-07T12:25:03.657000
178,194
178,417
In ASP.NET MVC I encounter an incorrect type error when rendering a page with the correct typed object
I am developing an application using MVC Preview 5. I have used typed views. After setting debug="false", I have found that I am receiving errors of the form: "The model item passed into the dictionary is of type 'blah.Models.UserAdmin.IndexData' but this dictionary requires a model item of type 'blah.Models.Organisati...
Yes, the bug has been reported. Best leave debug on for now, or modify the offending code (sorry cant recall where).
In ASP.NET MVC I encounter an incorrect type error when rendering a page with the correct typed object I am developing an application using MVC Preview 5. I have used typed views. After setting debug="false", I have found that I am receiving errors of the form: "The model item passed into the dictionary is of type 'bla...
TITLE: In ASP.NET MVC I encounter an incorrect type error when rendering a page with the correct typed object QUESTION: I am developing an application using MVC Preview 5. I have used typed views. After setting debug="false", I have found that I am receiving errors of the form: "The model item passed into the dictiona...
[ "asp.net-mvc" ]
6
1
4,024
3
0
2008-10-07T12:23:21.493000
2008-10-07T13:23:42.743000
178,199
178,213
Python: can I have a list with named indices?
In PHP I can name my array indices so that I may have something like: $shows = Array(0 => Array('id' => 1, 'name' => 'Sesame Street'), 1 => Array('id' => 2, 'name' => 'Dora The Explorer')); Is this possible in Python?
This sounds like the PHP array using named indices is very similar to a python dict: shows = [ {"id": 1, "name": "Sesaeme Street"}, {"id": 2, "name": "Dora The Explorer"}, ] See http://docs.python.org/tutorial/datastructures.html#dictionaries for more on this.
Python: can I have a list with named indices? In PHP I can name my array indices so that I may have something like: $shows = Array(0 => Array('id' => 1, 'name' => 'Sesame Street'), 1 => Array('id' => 2, 'name' => 'Dora The Explorer')); Is this possible in Python?
TITLE: Python: can I have a list with named indices? QUESTION: In PHP I can name my array indices so that I may have something like: $shows = Array(0 => Array('id' => 1, 'name' => 'Sesame Street'), 1 => Array('id' => 2, 'name' => 'Dora The Explorer')); Is this possible in Python? ANSWER: This sounds like the PHP arra...
[ "python", "arrays" ]
50
67
133,182
8
0
2008-10-07T12:25:25.170000
2008-10-07T12:29:57.673000
178,210
178,295
User configurable security in multi-tenant ASP.NET website
We are building a multi-tenant website in ASP.NET, and we must let each customer configure their own security model. They must be able to define their own roles, and put users in those roles. What is the best way to do this? There are tons of simple examples of page_load events that have code like: if (!user.InGroup("A...
Perhaps put the configurable roles in a DB table, where you store the roles and tenant, and then the PagePermissions in another table, for example: Table "Role" RoleId, TenantId, Role Table "PagePermissions" PageId, RoleId Table "UserRoles" UserId, RoleId Then in the page load check whether the User is in a RoleId th...
User configurable security in multi-tenant ASP.NET website We are building a multi-tenant website in ASP.NET, and we must let each customer configure their own security model. They must be able to define their own roles, and put users in those roles. What is the best way to do this? There are tons of simple examples of...
TITLE: User configurable security in multi-tenant ASP.NET website QUESTION: We are building a multi-tenant website in ASP.NET, and we must let each customer configure their own security model. They must be able to define their own roles, and put users in those roles. What is the best way to do this? There are tons of ...
[ "asp.net", "security", "multi-tenant" ]
3
4
1,235
2
0
2008-10-07T12:29:19.483000
2008-10-07T12:54:51.430000
178,216
185,890
Casting in Informix
In Informix, how can I cast a char(8) type into a money type, so that I can compare it to another money type? Using " tblAid.amt::money as aid_amt " did not work. Using " (tblAid.amt * 1) AS aid_amt " did not work.
try this --> select (disb_amt::NUMERIC) disb_amt from tmp_kygrants; You may be able to compare the amounts as numeric.
Casting in Informix In Informix, how can I cast a char(8) type into a money type, so that I can compare it to another money type? Using " tblAid.amt::money as aid_amt " did not work. Using " (tblAid.amt * 1) AS aid_amt " did not work.
TITLE: Casting in Informix QUESTION: In Informix, how can I cast a char(8) type into a money type, so that I can compare it to another money type? Using " tblAid.amt::money as aid_amt " did not work. Using " (tblAid.amt * 1) AS aid_amt " did not work. ANSWER: try this --> select (disb_amt::NUMERIC) disb_amt from tmp_...
[ "casting", "informix" ]
3
5
33,620
3
0
2008-10-07T12:30:58.387000
2008-10-09T04:01:45.187000
178,228
178,242
Best Practices : Where to place required files
I'm working with a number of 'helper' classes, which affectively have a bunch of static functions which allow the controllers and actions have access to chunks of shared functionality. Problem is that these files have been used as a dumping ground for any functionality which is required across the modules/application a...
Take a look at the autoloading feature. this will reduce all your includes down to only what is required, when it is required.
Best Practices : Where to place required files I'm working with a number of 'helper' classes, which affectively have a bunch of static functions which allow the controllers and actions have access to chunks of shared functionality. Problem is that these files have been used as a dumping ground for any functionality whi...
TITLE: Best Practices : Where to place required files QUESTION: I'm working with a number of 'helper' classes, which affectively have a bunch of static functions which allow the controllers and actions have access to chunks of shared functionality. Problem is that these files have been used as a dumping ground for any...
[ "php", "coding-style" ]
2
9
417
2
0
2008-10-07T12:34:39.987000
2008-10-07T12:38:09.730000
178,247
178,269
Best Practice: include( or <script src="
I have minified my javascript and my css. Now, Which is better? OR Same question for CSS. If the answer is 'sometimes because browsers fetch files simultaneously?' Which browsers, and what are examples of the times in either scenario.
...is better, as the user's browser can cache the file. Adding a parameter to the src such as the file's last modified timestamp is even better, as the user's browser will cache the file but will always retrieve the most up to date version when the file is modified.
Best Practice: include( or <script src=" I have minified my javascript and my css. Now, Which is better? OR Same question for CSS. If the answer is 'sometimes because browsers fetch files simultaneously?' Which browsers, and what are examples of the times in either scenario.
TITLE: Best Practice: include( or <script src=" QUESTION: I have minified my javascript and my css. Now, Which is better? OR Same question for CSS. If the answer is 'sometimes because browsers fetch files simultaneously?' Which browsers, and what are examples of the times in either scenario. ANSWER: ...is better, as ...
[ "php", "javascript", "css", "include" ]
11
22
8,740
3
0
2008-10-07T12:40:20.770000
2008-10-07T12:46:41.867000
178,251
178,272
How to implement Querystring authentication
I’m developing a website of a client and they are sending out newsletters to their customers (through the website administration interface) The newsletters are personal to each of the subscribed recipients/customers. Each recipient/ customer is also a user with a username/password that enables them to sign in on the we...
You will have to compromise your security somewhat, if you want people to be able to login without entering password. Note that even if you had access to the password (as in your example), you would have to embed it in a mail massage which would be transmitted in plaintext. You can create a Guid associated with each us...
How to implement Querystring authentication I’m developing a website of a client and they are sending out newsletters to their customers (through the website administration interface) The newsletters are personal to each of the subscribed recipients/customers. Each recipient/ customer is also a user with a username/pas...
TITLE: How to implement Querystring authentication QUESTION: I’m developing a website of a client and they are sending out newsletters to their customers (through the website administration interface) The newsletters are personal to each of the subscribed recipients/customers. Each recipient/ customer is also a user w...
[ "authentication" ]
3
6
2,451
3
0
2008-10-07T12:40:57.480000
2008-10-07T12:47:36.327000
178,257
559,052
How to avoid syntax-highlighting for large files in vim?
Huge files take forever to load and work with in vim, due to syntax-highlighting. I'm looking for a way to limit size of highlighted files, such that files larger than (say) 10MB will be colorless.
Adding the following line to _vimrc does the trick, with a bonus: it handles gzipped files, too (which is a common case with huge files): autocmd BufWinEnter * if line2byte(line("$") + 1) > 1000000 | syntax clear | endif
How to avoid syntax-highlighting for large files in vim? Huge files take forever to load and work with in vim, due to syntax-highlighting. I'm looking for a way to limit size of highlighted files, such that files larger than (say) 10MB will be colorless.
TITLE: How to avoid syntax-highlighting for large files in vim? QUESTION: Huge files take forever to load and work with in vim, due to syntax-highlighting. I'm looking for a way to limit size of highlighted files, such that files larger than (say) 10MB will be colorless. ANSWER: Adding the following line to _vimrc do...
[ "vim", "colors", "vim-syntax-highlighting" ]
20
23
4,293
5
0
2008-10-07T12:43:28.347000
2009-02-17T22:39:14.727000
178,262
178,296
What should be OO and what shouldn't?
I've read a lot of people saying that some things shouldn't be written in an object orientated style - as a person learning the OO style coming from a C background, what do they mean by this? What shouldn't be OO, why do some things fit this design better, and how do we know when it's best to do what?
The real world is full of objects. It's helpful to make the software world match the real world. "What about 'system utilities'? They just deal with abstractions like sockets and processes and file systems." They sound like things to me. They have attributes and behaviors, they have associations. If you're looking for ...
What should be OO and what shouldn't? I've read a lot of people saying that some things shouldn't be written in an object orientated style - as a person learning the OO style coming from a C background, what do they mean by this? What shouldn't be OO, why do some things fit this design better, and how do we know when i...
TITLE: What should be OO and what shouldn't? QUESTION: I've read a lot of people saying that some things shouldn't be written in an object orientated style - as a person learning the OO style coming from a C background, what do they mean by this? What shouldn't be OO, why do some things fit this design better, and how...
[ "oop" ]
5
5
626
7
0
2008-10-07T12:45:36.360000
2008-10-07T12:55:02.707000
178,263
179,535
JavaScript bookmarklet to delete all cookies within a given domain
I am testing a web app that writes cookies to subdomain.thisdomain.com and several subfolders within that. I'm looking for JavaScript that I can put into a bookmarklet that will delete all cookies under that subdomain, regardless of the folder in which they exist. Any ideas?
Derived from my answer here: javascript:new function(){var c=document.cookie.split(";");for(var i=0;i -1?c[i].substr(0,e):c[i];document.cookie=n+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT";}}(); return void(0); Due to browser security issues, this will only work when executed while on a page that has access to all the co...
JavaScript bookmarklet to delete all cookies within a given domain I am testing a web app that writes cookies to subdomain.thisdomain.com and several subfolders within that. I'm looking for JavaScript that I can put into a bookmarklet that will delete all cookies under that subdomain, regardless of the folder in which ...
TITLE: JavaScript bookmarklet to delete all cookies within a given domain QUESTION: I am testing a web app that writes cookies to subdomain.thisdomain.com and several subfolders within that. I'm looking for JavaScript that I can put into a bookmarklet that will delete all cookies under that subdomain, regardless of th...
[ "javascript", "cookies", "bookmarklet" ]
19
25
21,034
2
0
2008-10-07T12:45:37.127000
2008-10-07T17:31:57.610000
178,264
178,406
Sqlite on an embedded system
I have a database file that is generated on a PC using Sqlite. This file is then transferred to an ARM7 based embedded system without an operating system. The embedded system must access this database, but does not need to update it. I have been trying to get sqlite3 small enough for the embedded system, but so far I c...
The smallest sqlite3 I came up with was 327 KBytes (for PowerPC), which was sufficient for the system so I stopped trying to make it smaller. This was the full sqlite3 CLI binary, the C APIs alone would have been somewhat smaller. I had set SQLITE_OMIT_AUTHORIZATION, SQLITE_OMIT_EXPLAIN, SQLITE_OMIT_PROGRESS_CALLBACK, ...
Sqlite on an embedded system I have a database file that is generated on a PC using Sqlite. This file is then transferred to an ARM7 based embedded system without an operating system. The embedded system must access this database, but does not need to update it. I have been trying to get sqlite3 small enough for the em...
TITLE: Sqlite on an embedded system QUESTION: I have a database file that is generated on a PC using Sqlite. This file is then transferred to an ARM7 based embedded system without an operating system. The embedded system must access this database, but does not need to update it. I have been trying to get sqlite3 small...
[ "database", "sqlite", "embedded" ]
10
4
10,633
5
0
2008-10-07T12:45:40.730000
2008-10-07T13:21:01.780000
178,265
179,225
What is the most hard to understand piece of C++ code you know?
Today at work we came across the following code (some of you might recognize it): #define GET_VAL( val, type ) \ { \ ASSERT( ( pIP + sizeof(type) ) <= pMethodEnd ); \ val = ( *((type *&)(pIP))++ ); \ } Basically we have a byte array and a pointer. The macro returns a reference to a variable of type and advance the poin...
The inverse square root implementation in Quake 3: float InvSqrt (float x){ float xhalf = 0.5f*x; int i = *(int*)&x i = 0x5f3759df - (i>>1); x = *(float*)&i x = x*(1.5f - xhalf*x*x); return x; } Update: How this works (thanks ryan_s)
What is the most hard to understand piece of C++ code you know? Today at work we came across the following code (some of you might recognize it): #define GET_VAL( val, type ) \ { \ ASSERT( ( pIP + sizeof(type) ) <= pMethodEnd ); \ val = ( *((type *&)(pIP))++ ); \ } Basically we have a byte array and a pointer. The macr...
TITLE: What is the most hard to understand piece of C++ code you know? QUESTION: Today at work we came across the following code (some of you might recognize it): #define GET_VAL( val, type ) \ { \ ASSERT( ( pIP + sizeof(type) ) <= pMethodEnd ); \ val = ( *((type *&)(pIP))++ ); \ } Basically we have a byte array and a...
[ "c++" ]
23
45
43,046
11
0
2008-10-07T12:45:57.577000
2008-10-07T16:11:21.860000
178,307
178,321
SQL Server Storage of Data: 4 gb Raw, how much in SQL Server?
I have a SQL Server 2005 database and I have 4 GB of text files that I need to import into it. The question is, if these 4 GB of text files are 1.2 GB when they are zipped, how big would the database be if they are imported? Does SQL Server shrink data by default, or how would I set this (think create a database as a d...
SQL Server will not shrink data by default. In fact, there will be a small overhead per column and row, so it would require more space. If you really must store those files in the DB (it is recommended that you don't), take a look at this article I blogged a while back. In SQL Server 2008, they have introduced the FILE...
SQL Server Storage of Data: 4 gb Raw, how much in SQL Server? I have a SQL Server 2005 database and I have 4 GB of text files that I need to import into it. The question is, if these 4 GB of text files are 1.2 GB when they are zipped, how big would the database be if they are imported? Does SQL Server shrink data by de...
TITLE: SQL Server Storage of Data: 4 gb Raw, how much in SQL Server? QUESTION: I have a SQL Server 2005 database and I have 4 GB of text files that I need to import into it. The question is, if these 4 GB of text files are 1.2 GB when they are zipped, how big would the database be if they are imported? Does SQL Server...
[ "sql", "sql-server" ]
1
4
418
3
0
2008-10-07T12:58:07.617000
2008-10-07T13:01:38.200000
178,320
178,322
Do you validate your URL variables?
When you're passing variables through your site using GET requests, do you validate (regular expressions, filters, etc.) them before you use them? Say you have the URL http://www.example.com/i=45&p=custform. You know that "i" will always be an integer and "p" will always contain only letters and/or numbers. Is it worth...
Yes. Without a doubt. Never trust user input. To improve the user experience, input fields can (and IMHO should) be validated on the client. This can pre-empt a round trip to the server that only leads to the same form and an error message. However, input must always be validated on the server side since the user can j...
Do you validate your URL variables? When you're passing variables through your site using GET requests, do you validate (regular expressions, filters, etc.) them before you use them? Say you have the URL http://www.example.com/i=45&p=custform. You know that "i" will always be an integer and "p" will always contain only...
TITLE: Do you validate your URL variables? QUESTION: When you're passing variables through your site using GET requests, do you validate (regular expressions, filters, etc.) them before you use them? Say you have the URL http://www.example.com/i=45&p=custform. You know that "i" will always be an integer and "p" will a...
[ "validation", "url", "server-side" ]
9
41
863
7
0
2008-10-07T13:01:13.723000
2008-10-07T13:02:41.040000
178,325
178,450
How do I check if an element is hidden in jQuery?
How do I toggle the visibility of an element using.hide(),.show(), or.toggle()? How do I test if an element is visible or hidden?
Since the question refers to a single element, this code might be more suitable: // Checks CSS content for display:[none|block], ignores visibility:[true|false] $(element).is(":visible"); // The same works with hidden $(element).is(":hidden"); It is the same as twernt's suggestion, but applied to a single element; and...
How do I check if an element is hidden in jQuery? How do I toggle the visibility of an element using.hide(),.show(), or.toggle()? How do I test if an element is visible or hidden?
TITLE: How do I check if an element is hidden in jQuery? QUESTION: How do I toggle the visibility of an element using.hide(),.show(), or.toggle()? How do I test if an element is visible or hidden? ANSWER: Since the question refers to a single element, this code might be more suitable: // Checks CSS content for displa...
[ "javascript", "jquery", "dom", "visibility", "display" ]
8,676
10,248
3,189,323
66
0
2008-10-07T13:03:18.057000
2008-10-07T13:30:22.217000
178,326
178,443
Sizing an MFC Window
I have an MFC app which I have been working on for a few weeks now, I want to manually set the dimensions of the main frame when it is loaded, can someone give me a hand with this, specifically where to put the code as well? Thanks!
You can also set the size (with SetWindowPos() ) from within CMainFrame::OnCreate(), or in the CWinApp -derived class' InitInstance. Look for the line that says pMainFrame->ShowWindow(), and call pMainFrame->SetWindowPos() before that line. That's where I always do it.
Sizing an MFC Window I have an MFC app which I have been working on for a few weeks now, I want to manually set the dimensions of the main frame when it is loaded, can someone give me a hand with this, specifically where to put the code as well? Thanks!
TITLE: Sizing an MFC Window QUESTION: I have an MFC app which I have been working on for a few weeks now, I want to manually set the dimensions of the main frame when it is loaded, can someone give me a hand with this, specifically where to put the code as well? Thanks! ANSWER: You can also set the size (with SetWind...
[ "c++", "mfc" ]
9
12
29,101
5
0
2008-10-07T13:03:52.220000
2008-10-07T13:28:44.747000
178,328
178,375
In PHP (>= 5.0), is passing by reference faster?
In PHP, function parameters can be passed by reference by prepending an ampersand to the parameter in the function declaration, like so: function foo(&$bar) { //... } Now, I am aware that this is not designed to improve performance, but to allow functions to change variables that are normally out of their scope. Instea...
The Zend Engine uses copy-on-write, and when you use a reference yourself, it incurs a little extra overhead. Can only find this mention at time of writing though, and comments in the manual contain other links. (EDIT) The manual page on Objects and references contains a little more info on how object variables differ ...
In PHP (>= 5.0), is passing by reference faster? In PHP, function parameters can be passed by reference by prepending an ampersand to the parameter in the function declaration, like so: function foo(&$bar) { //... } Now, I am aware that this is not designed to improve performance, but to allow functions to change varia...
TITLE: In PHP (>= 5.0), is passing by reference faster? QUESTION: In PHP, function parameters can be passed by reference by prepending an ampersand to the parameter in the function declaration, like so: function foo(&$bar) { //... } Now, I am aware that this is not designed to improve performance, but to allow functio...
[ "php", "performance", "pass-by-reference" ]
77
39
37,134
9
0
2008-10-07T13:04:40.800000
2008-10-07T13:14:43.090000
178,333
1,695,631
Multiple Inheritance in C#
Since multiple inheritance is bad (it makes the source more complicated) C# does not provide such a pattern directly. But sometimes it would be helpful to have this ability. For instance I'm able to implement the missing multiple inheritance pattern using interfaces and three classes like that: public interface IFirst ...
Since multiple inheritance is bad (it makes the source more complicated) C# does not provide such a pattern directly. But sometimes it would be helpful to have this ability. C# and the.net CLR have not implemented MI because they have not concluded how it would inter-operate between C#, VB.net and the other languages y...
Multiple Inheritance in C# Since multiple inheritance is bad (it makes the source more complicated) C# does not provide such a pattern directly. But sometimes it would be helpful to have this ability. For instance I'm able to implement the missing multiple inheritance pattern using interfaces and three classes like tha...
TITLE: Multiple Inheritance in C# QUESTION: Since multiple inheritance is bad (it makes the source more complicated) C# does not provide such a pattern directly. But sometimes it would be helpful to have this ability. For instance I'm able to implement the missing multiple inheritance pattern using interfaces and thre...
[ "c#", "interface", "multiple-inheritance" ]
254
153
496,903
13
0
2008-10-07T13:05:23.077000
2009-11-08T07:09:29.780000
178,341
178,442
Why is distributed source control considered harder?
It seems rather common (around here, at least) for people to recommend SVN to newcomers to source control because it's "easier" than one of the distributed options. As a very casual user of SVN before switching to Git for many of my projects, I found this to be not the case at all. It is conceptually easier to set up a...
A distributed versioning system is A Very Good Thing (tm), but I find the primary barrier to adoption being educating users on the new possibilities a new SCM gives. This coupled with an often lack-luster amount of UI tools (half-finished tortoise implementations etc), brings a blank stare to the eye of many co-workers...
Why is distributed source control considered harder? It seems rather common (around here, at least) for people to recommend SVN to newcomers to source control because it's "easier" than one of the distributed options. As a very casual user of SVN before switching to Git for many of my projects, I found this to be not t...
TITLE: Why is distributed source control considered harder? QUESTION: It seems rather common (around here, at least) for people to recommend SVN to newcomers to source control because it's "easier" than one of the distributed options. As a very casual user of SVN before switching to Git for many of my projects, I foun...
[ "version-control" ]
12
7
550
9
0
2008-10-07T13:08:24.897000
2008-10-07T13:28:44.450000
178,342
178,364
What happens when I edit web.config?
I need to edit the web.config file on a live Sharepoint environment, but I'm unsure what will happen if I do (I want to output custom errors). Will this cause the IIS6 worker process to recycle? Will active users lose their session state because of this? Or can I safely edit the file?
The application pool will restart and session state will be lost. Imagine each ASP.NET application (as defined in IIS) is a program on the desktop. Saving web.config will do something similar to closing the program and reopening it.
What happens when I edit web.config? I need to edit the web.config file on a live Sharepoint environment, but I'm unsure what will happen if I do (I want to output custom errors). Will this cause the IIS6 worker process to recycle? Will active users lose their session state because of this? Or can I safely edit the fil...
TITLE: What happens when I edit web.config? QUESTION: I need to edit the web.config file on a live Sharepoint environment, but I'm unsure what will happen if I do (I want to output custom errors). Will this cause the IIS6 worker process to recycle? Will active users lose their session state because of this? Or can I s...
[ "asp.net", "sharepoint", "iis-6" ]
88
83
63,301
5
0
2008-10-07T13:08:50.497000
2008-10-07T13:13:05.183000
178,351
886,247
Unable to start debug in Visual Studio 2005
My "Start debugging" button and element menu are greyed out... but only on one of my projects (an ASP.NET website). I have no idea what I have done to disable it. I already checked everything in the Property page of both the solution and project. I even compared it to another project, but nothing seems to do the trick....
It sounds like your startup projects are all set to "start without debugging", since that would cause the button and element to grey out. This can be fixed from Solution -> Set StartUp Projects.
Unable to start debug in Visual Studio 2005 My "Start debugging" button and element menu are greyed out... but only on one of my projects (an ASP.NET website). I have no idea what I have done to disable it. I already checked everything in the Property page of both the solution and project. I even compared it to another...
TITLE: Unable to start debug in Visual Studio 2005 QUESTION: My "Start debugging" button and element menu are greyed out... but only on one of my projects (an ASP.NET website). I have no idea what I have done to disable it. I already checked everything in the Property page of both the solution and project. I even comp...
[ "visual-studio" ]
3
5
7,055
5
0
2008-10-07T13:10:18.293000
2009-05-20T05:15:46.537000
178,396
240,608
Form Elements in ASP.NET Master Pages and Content Pages
OK, another road bump in my current project. I have never had form elements in both my master and content pages, I tend to have all the forms in the content where relevant. In the current project however, we have a page where they want both. A login form at the top right, and a questions form in the content. Having tri...
Thought I would review some of my outstanding questions and see if I can close some of them off. This one was an interesting one. I outright refused to believe you can only have one form on an ASP.NET page. This to me made no sense. I have seen plenty of webpages that have more than one form on a web page, why should a...
Form Elements in ASP.NET Master Pages and Content Pages OK, another road bump in my current project. I have never had form elements in both my master and content pages, I tend to have all the forms in the content where relevant. In the current project however, we have a page where they want both. A login form at the to...
TITLE: Form Elements in ASP.NET Master Pages and Content Pages QUESTION: OK, another road bump in my current project. I have never had form elements in both my master and content pages, I tend to have all the forms in the content where relevant. In the current project however, we have a page where they want both. A lo...
[ "asp.net", "forms", "webforms", "master-pages" ]
24
19
57,531
12
0
2008-10-07T13:19:39.147000
2008-10-27T16:54:59.310000
178,398
178,431
Under an MVC framework, which directory structure would be expected by other developers?
Generally, MVC frameeworks have a structure that looks something like: /models /views /controllers /utils However, in a web application suite, I've decided that clumping all models, views, and controllers together probably wouldn't be the best for clarity, unless I treated the system as one application instead of an ap...
It seems like 2) would be your best option, assuming you want some separation of applications. You could also have a "/common" folder at the "/app#" level for shared resources across all applications... like a shared utility class or whatever.
Under an MVC framework, which directory structure would be expected by other developers? Generally, MVC frameeworks have a structure that looks something like: /models /views /controllers /utils However, in a web application suite, I've decided that clumping all models, views, and controllers together probably wouldn't...
TITLE: Under an MVC framework, which directory structure would be expected by other developers? QUESTION: Generally, MVC frameeworks have a structure that looks something like: /models /views /controllers /utils However, in a web application suite, I've decided that clumping all models, views, and controllers together...
[ "model-view-controller", "frameworks" ]
5
5
2,935
4
0
2008-10-07T13:19:54.780000
2008-10-07T13:26:42.800000
178,401
179,046
Can MySql 5.0 have a view of a table located on another server
Can MySql 5.0 views use tables that are located on another server? What is the syntax for creating such a view?
Federated Tables: http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html This allows a table to be remotely accessed as if the remote table was a local table. It has its limitations but seems to meet my needs.
Can MySql 5.0 have a view of a table located on another server Can MySql 5.0 views use tables that are located on another server? What is the syntax for creating such a view?
TITLE: Can MySql 5.0 have a view of a table located on another server QUESTION: Can MySql 5.0 views use tables that are located on another server? What is the syntax for creating such a view? ANSWER: Federated Tables: http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html This allows a table to be remot...
[ "mysql", "view" ]
3
7
10,213
2
0
2008-10-07T13:20:10.300000
2008-10-07T15:28:47.857000
178,407
178,425
Select all child elements except the first
Say I have the following: First item Second item Third item How would I select all the child elements after the first one using jQuery? So I can achieve something like: First item Second item Third item
You should be able to use the "not" and "first child" selectors. $("li:not(:first-child)").addClass("something"); http://docs.jquery.com/Selectors/not http://docs.jquery.com/Selectors/firstChild
Select all child elements except the first Say I have the following: First item Second item Third item How would I select all the child elements after the first one using jQuery? So I can achieve something like: First item Second item Third item
TITLE: Select all child elements except the first QUESTION: Say I have the following: First item Second item Third item How would I select all the child elements after the first one using jQuery? So I can achieve something like: First item Second item Third item ANSWER: You should be able to use the "not" and "first ...
[ "javascript", "jquery" ]
86
146
74,500
8
0
2008-10-07T13:21:20.610000
2008-10-07T13:25:15.860000
178,434
181,394
What is the best way to solve an Objective-C namespace collision?
Objective-C has no namespaces; it's much like C, everything is within one global namespace. Common practice is to prefix classes with initials, e.g. if you are working at IBM, you could prefix them with "IBM"; if you work for Microsoft, you could use "MS"; and so on. Sometimes the initials refer to the project, e.g. Ad...
If you do not need to use classes from both frameworks at the same time, and you are targeting platforms which support NSBundle unloading (OS X 10.4 or later, no GNUStep support), and performance really isn't an issue for you, I believe that you could load one framework every time you need to use a class from it, and t...
What is the best way to solve an Objective-C namespace collision? Objective-C has no namespaces; it's much like C, everything is within one global namespace. Common practice is to prefix classes with initials, e.g. if you are working at IBM, you could prefix them with "IBM"; if you work for Microsoft, you could use "MS...
TITLE: What is the best way to solve an Objective-C namespace collision? QUESTION: Objective-C has no namespaces; it's much like C, everything is within one global namespace. Common practice is to prefix classes with initials, e.g. if you are working at IBM, you could prefix them with "IBM"; if you work for Microsoft,...
[ "objective-c", "cocoa", "macos", "namespaces" ]
178
48
43,190
13
0
2008-10-07T13:27:41.377000
2008-10-08T04:51:59.030000
178,444
181,546
Properly using file Designer Files in ASP.NET Web Sites
I need to get existing web pages into an existing ASP.NET web site project in Visual Studio 2008. I simply tried to drag and drop the whole file folder content into the Visual Studio Solution Explorer or even to copy them into the web site folder. Both ways, Visual Studio seems unable to map the.designer.cs files to th...
It sounds like you are trying to bring web application files into a web site. IIf that is the case, The designer files are not even needed. Just dont include them. They are generated and compiled in at runtime when the website runs.
Properly using file Designer Files in ASP.NET Web Sites I need to get existing web pages into an existing ASP.NET web site project in Visual Studio 2008. I simply tried to drag and drop the whole file folder content into the Visual Studio Solution Explorer or even to copy them into the web site folder. Both ways, Visua...
TITLE: Properly using file Designer Files in ASP.NET Web Sites QUESTION: I need to get existing web pages into an existing ASP.NET web site project in Visual Studio 2008. I simply tried to drag and drop the whole file folder content into the Visual Studio Solution Explorer or even to copy them into the web site folder...
[ "c#", ".net", "asp.net", "visual-studio", "designer" ]
2
3
1,365
3
0
2008-10-07T13:28:56.353000
2008-10-08T06:28:12.240000
178,449
178,515
Getting selected members from multiselect list view ctrl
I have a list view control which at the moment only allows one item to be selected. I then read this via the following code: void CApp::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult) { int nSelected = (m_List.GetSelectionMark());... However, now I want to make this list able to multiselect, GetSelectionMark() always r...
Use GetFirstSelectedItemPosition() to find first selected item, then GetNextSelectedItem() for the rest and you're done.:)
Getting selected members from multiselect list view ctrl I have a list view control which at the moment only allows one item to be selected. I then read this via the following code: void CApp::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult) { int nSelected = (m_List.GetSelectionMark());... However, now I want to make t...
TITLE: Getting selected members from multiselect list view ctrl QUESTION: I have a list view control which at the moment only allows one item to be selected. I then read this via the following code: void CApp::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult) { int nSelected = (m_List.GetSelectionMark());... However, no...
[ "c++", "mfc", "controls" ]
0
4
2,028
1
0
2008-10-07T13:30:20.187000
2008-10-07T13:47:29.870000
178,456
178,464
What is the proper way to rethrow an exception in C#?
Is it better to do this: try {... } catch (Exception ex) {... throw; } Or this: try {... } catch (Exception ex) {... throw ex; } Do they do the same thing? Is one better than the other?
You should always use the following syntax to rethrow an exception. Else you'll stomp the stack trace: throw; If you print the trace resulting from throw ex, you'll see that it ends on that statement and not at the real source of the exception. Basically, it should be deemed a criminal offense to use throw ex. If there...
What is the proper way to rethrow an exception in C#? Is it better to do this: try {... } catch (Exception ex) {... throw; } Or this: try {... } catch (Exception ex) {... throw ex; } Do they do the same thing? Is one better than the other?
TITLE: What is the proper way to rethrow an exception in C#? QUESTION: Is it better to do this: try {... } catch (Exception ex) {... throw; } Or this: try {... } catch (Exception ex) {... throw ex; } Do they do the same thing? Is one better than the other? ANSWER: You should always use the following syntax to rethrow...
[ "c#", ".net", "exception" ]
548
912
238,738
9
0
2008-10-07T13:33:55.080000
2008-10-07T13:36:44.713000
178,458
179,531
Python, unit-testing and mocking imports
I am in a project where we are starting refactoring some massive code base. One problem that immediately sprang up is that each file imports a lot of other files. How do I in an elegant way mock this in my unit test without having to alter the actual code so I can start to write unit-tests? As an example: The file with...
If you want to import a module while at the same time ensuring that it doesn't import anything, you can replace the __import__ builtin function. For example, use this class: class ImportWrapper(object): def __init__(self, real_import): self.real_import = real_import def wrapper(self, wantedModules): def inner(moduleNa...
Python, unit-testing and mocking imports I am in a project where we are starting refactoring some massive code base. One problem that immediately sprang up is that each file imports a lot of other files. How do I in an elegant way mock this in my unit test without having to alter the actual code so I can start to write...
TITLE: Python, unit-testing and mocking imports QUESTION: I am in a project where we are starting refactoring some massive code base. One problem that immediately sprang up is that each file imports a lot of other files. How do I in an elegant way mock this in my unit test without having to alter the actual code so I ...
[ "python", "unit-testing", "refactoring", "python-import" ]
15
8
5,338
5
0
2008-10-07T13:34:42.690000
2008-10-07T17:30:27.597000
178,462
178,487
Setting up local server with PHP
I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I'm using Windows vista business 32bit. I tried to install everything manually (one thing at a time, apache, postgresql and php (all the latest stable releases)) and after I get everything up and running. Whenever I try to run a script on my mac...
You should have something like this in your httpd.conf file: LoadModule php5_module "c:/php/php5apache2_2.dll" AddType application/x-httpd-php.php PHPIniDir "c:/php" Make sure that's in place, and don't forget to restart apache! In Windows, the default location for your conf file is C:\Program Files\Apache Group\Apache...
Setting up local server with PHP I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I'm using Windows vista business 32bit. I tried to install everything manually (one thing at a time, apache, postgresql and php (all the latest stable releases)) and after I get everything up and running. Wheneve...
TITLE: Setting up local server with PHP QUESTION: I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I'm using Windows vista business 32bit. I tried to install everything manually (one thing at a time, apache, postgresql and php (all the latest stable releases)) and after I get everything up an...
[ "php", "apache", "localhost" ]
0
4
502
6
0
2008-10-07T13:36:12.780000
2008-10-07T13:43:40.097000
178,470
178,497
How do I create a keyboard hook with a different thread in C#?
I'm creating a low level keyboard hook in c# using SetWindowsHookEx, question is how can I make the on keyboard event function run on a thread other from the main thread? Also I currently don't have a thread other then the main thread, so how can I create one that will halt until a keyboard hook event will occur?
Here is the code for the C# Keyboard hook. You just need to call Hook.CreateHook(METHODNAMEHERE); in a new Thread (see the Thread class).
How do I create a keyboard hook with a different thread in C#? I'm creating a low level keyboard hook in c# using SetWindowsHookEx, question is how can I make the on keyboard event function run on a thread other from the main thread? Also I currently don't have a thread other then the main thread, so how can I create o...
TITLE: How do I create a keyboard hook with a different thread in C#? QUESTION: I'm creating a low level keyboard hook in c# using SetWindowsHookEx, question is how can I make the on keyboard event function run on a thread other from the main thread? Also I currently don't have a thread other then the main thread, so ...
[ "c#", "keyboard-hook" ]
1
2
2,892
2
0
2008-10-07T13:38:32.480000
2008-10-07T13:45:00.470000
178,473
178,518
LINQ query to WebControl.Controls
I have three TextBox controls on the page and an event handler protected void TextBox_TextChanged(object sender, EventArgs e) { WebControl changed_control = (WebControl)sender; var next_controls = from WebControl control in changed_control.Parent.Controls where control.TabIndex > changed_control.TabIndex orderby contr...
OfType from control in changed_control.Parent.Controls.OfType ()
LINQ query to WebControl.Controls I have three TextBox controls on the page and an event handler protected void TextBox_TextChanged(object sender, EventArgs e) { WebControl changed_control = (WebControl)sender; var next_controls = from WebControl control in changed_control.Parent.Controls where control.TabIndex > chan...
TITLE: LINQ query to WebControl.Controls QUESTION: I have three TextBox controls on the page and an event handler protected void TextBox_TextChanged(object sender, EventArgs e) { WebControl changed_control = (WebControl)sender; var next_controls = from WebControl control in changed_control.Parent.Controls where contr...
[ "asp.net", "linq", "web-controls" ]
1
5
3,861
3
0
2008-10-07T13:39:44.847000
2008-10-07T13:48:01.743000
178,479
189,399
PreparedStatement IN clause alternatives?
What are the best workarounds for using a SQL IN clause with instances of java.sql.PreparedStatement, which is not supported for multiple values due to SQL injection attack security issues: One? placeholder represents one value, rather than a list of values. Consider the following SQL statement: SELECT my_column FROM m...
An analysis of the various options available, and the pros and cons of each is available in Jeanne Boyarsky's Batching Select Statements in JDBC entry on JavaRanch Journal. The suggested options are: Prepare SELECT my_column FROM my_table WHERE search_column =?, execute it for each value and UNION the results client-si...
PreparedStatement IN clause alternatives? What are the best workarounds for using a SQL IN clause with instances of java.sql.PreparedStatement, which is not supported for multiple values due to SQL injection attack security issues: One? placeholder represents one value, rather than a list of values. Consider the follow...
TITLE: PreparedStatement IN clause alternatives? QUESTION: What are the best workarounds for using a SQL IN clause with instances of java.sql.PreparedStatement, which is not supported for multiple values due to SQL injection attack security issues: One? placeholder represents one value, rather than a list of values. C...
[ "java", "security", "jdbc", "prepared-statement", "in-clause" ]
391
224
383,183
33
0
2008-10-07T13:41:36.310000
2008-10-09T22:13:14
178,482
178,540
Pathing in a non-geographic environment
For a school project, I need to create a way to create personnalized queries based on end-user choices. Since the user can choose basically any fields from any combination of tables, I need to find a way to map the tables in order to make a join and not have extraneous data (This may lead to incoherent reports, but we'...
You might be able to try some form of an A* algorithm. Basically this looks at each of the possible next options to choose and applies a heuristic to it, a function that determines roughly how far it is between this node and your goal. It then chooses the one that is closer and repeats. The hardest part of implementing...
Pathing in a non-geographic environment For a school project, I need to create a way to create personnalized queries based on end-user choices. Since the user can choose basically any fields from any combination of tables, I need to find a way to map the tables in order to make a join and not have extraneous data (This...
TITLE: Pathing in a non-geographic environment QUESTION: For a school project, I need to create a way to create personnalized queries based on end-user choices. Since the user can choose basically any fields from any combination of tables, I need to find a way to map the tables in order to make a join and not have ext...
[ "mysql", "algorithm" ]
1
0
107
2
0
2008-10-07T13:42:11.800000
2008-10-07T13:52:37.647000
178,519
178,534
Where should assets go in a CodeIgniter project?
I'm just starting with CodeIgniter, and I am not sure where things such as css, js, and images should go. Outside the whole system folder seems ok, but that means everything is seperate. Inside means the filepaths are longer, and I'm worried that it might mess things up. What's the best practice on this issue?
I usually put separate folders at the root level, so I end up with a directory structure like this: /system /css /js /img Seems to work for me - when you use site_url(url), the URL it generates is from the root, so you can use site_url('css/file.css') to generate URLs to your stylesheets etc.
Where should assets go in a CodeIgniter project? I'm just starting with CodeIgniter, and I am not sure where things such as css, js, and images should go. Outside the whole system folder seems ok, but that means everything is seperate. Inside means the filepaths are longer, and I'm worried that it might mess things up....
TITLE: Where should assets go in a CodeIgniter project? QUESTION: I'm just starting with CodeIgniter, and I am not sure where things such as css, js, and images should go. Outside the whole system folder seems ok, but that means everything is seperate. Inside means the filepaths are longer, and I'm worried that it mig...
[ "php", "codeigniter" ]
18
15
11,507
6
0
2008-10-07T13:48:09.933000
2008-10-07T13:51:25.713000
178,530
197,395
PHP/PDO and SQL Server connection and i18n issues
In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts. Database collation is Cyrillic_General_CI_AS, table collation is Cyrillic_General_CI_AS, column type is NVARCHAR(MAX). We tried connecting to a database using two following schemes, both causing different problems. PD...
Try executing SET NAMES "charset" after you connect. I don't know what the charset to match Cyrillic_General_CI_AS is, but try "Cyrillic"?
PHP/PDO and SQL Server connection and i18n issues In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts. Database collation is Cyrillic_General_CI_AS, table collation is Cyrillic_General_CI_AS, column type is NVARCHAR(MAX). We tried connecting to a database using two foll...
TITLE: PHP/PDO and SQL Server connection and i18n issues QUESTION: In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts. Database collation is Cyrillic_General_CI_AS, table collation is Cyrillic_General_CI_AS, column type is NVARCHAR(MAX). We tried connecting to a datab...
[ "php", "sql-server", "sql-server-2005" ]
5
2
4,867
5
0
2008-10-07T13:50:32.813000
2008-10-13T12:25:52.080000
178,537
178,557
Why does my Delphi 7 Debugger randomly decide to stop accepting certain keyboard input
Maybe this is an overarching question as I've seen similar bugs in Firefox and I'd like to know how to avoid coding them. For no apparent reason, the function keys, arrow keys (de-numlocked numpad as well), the 6 keys over the arrows, and backspace stop working. Every other key seems to work leading me to think it's so...
I doubt that it's Delphi's fault. I'm using Delphi 7 and never had this problem. I suggest you look for another culprit.
Why does my Delphi 7 Debugger randomly decide to stop accepting certain keyboard input Maybe this is an overarching question as I've seen similar bugs in Firefox and I'd like to know how to avoid coding them. For no apparent reason, the function keys, arrow keys (de-numlocked numpad as well), the 6 keys over the arrows...
TITLE: Why does my Delphi 7 Debugger randomly decide to stop accepting certain keyboard input QUESTION: Maybe this is an overarching question as I've seen similar bugs in Firefox and I'd like to know how to avoid coding them. For no apparent reason, the function keys, arrow keys (de-numlocked numpad as well), the 6 ke...
[ "delphi", "keyboard", "madexcept" ]
1
5
799
4
0
2008-10-07T13:52:00.847000
2008-10-07T13:55:28.390000
178,539
178,551
How do you round a floating point number in Perl?
How can I round a decimal number (floating point) to the nearest integer? e.g. 1.2 = 1 1.7 = 2
Output of perldoc -q round Does Perl have a round() function? What about ceil() and floor()? Trig functions? Remember that int() merely truncates toward 0. For rounding to a certain number of digits, sprintf() or printf() is usually the easiest route. printf("%.3f", 3.1415926535); # prints 3.142 The POSIX module (part ...
How do you round a floating point number in Perl? How can I round a decimal number (floating point) to the nearest integer? e.g. 1.2 = 1 1.7 = 2
TITLE: How do you round a floating point number in Perl? QUESTION: How can I round a decimal number (floating point) to the nearest integer? e.g. 1.2 = 1 1.7 = 2 ANSWER: Output of perldoc -q round Does Perl have a round() function? What about ceil() and floor()? Trig functions? Remember that int() merely truncates to...
[ "perl", "floating-point", "rounding" ]
196
217
387,229
14
0
2008-10-07T13:52:27.710000
2008-10-07T13:54:12.120000
178,554
178,593
Is it possible to include/embed one Java EE application(war file) inside another?
I have an application which is a portal application and I want to allow other users add their applications to it. In order to do this I need some way to be able to access their applications in mine. Is this possible?
You cannot put WARs inside of other WARs. You need an EAR file to contain WARs, EJBs, etc. One way to implement inter-WAR communication is to package that logic directly in the EAR. It all depends on what you're trying to do.
Is it possible to include/embed one Java EE application(war file) inside another? I have an application which is a portal application and I want to allow other users add their applications to it. In order to do this I need some way to be able to access their applications in mine. Is this possible?
TITLE: Is it possible to include/embed one Java EE application(war file) inside another? QUESTION: I have an application which is a portal application and I want to allow other users add their applications to it. In order to do this I need some way to be able to access their applications in mine. Is this possible? AN...
[ "java", "jakarta-ee", "war" ]
3
4
1,179
4
0
2008-10-07T13:54:43.133000
2008-10-07T14:01:43.197000
178,561
178,677
How to convert VB.net interface with enum to C#
I have the following VB.net interface that I need to port to C#. C# does not allow enumerations in interfaces. How can I port this without changing code that uses this interface? Public Interface MyInterface Enum MyEnum Yes = 0 No = 1 Maybe = 2 End Enum ReadOnly Property Number() As MyEnum End Interface
In short, you can't change that interface without breaking code, because C# can't nest types in interfaces. When you implement the VB.NET versions's interface, you are specifying that Number will return a type of MyInterface.MyEnum: class TestClass3: TestInterfaces.MyInterface { TestInterfaces.MyInterface.MyEnum TestI...
How to convert VB.net interface with enum to C# I have the following VB.net interface that I need to port to C#. C# does not allow enumerations in interfaces. How can I port this without changing code that uses this interface? Public Interface MyInterface Enum MyEnum Yes = 0 No = 1 Maybe = 2 End Enum ReadOnly Propert...
TITLE: How to convert VB.net interface with enum to C# QUESTION: I have the following VB.net interface that I need to port to C#. C# does not allow enumerations in interfaces. How can I port this without changing code that uses this interface? Public Interface MyInterface Enum MyEnum Yes = 0 No = 1 Maybe = 2 End Enum...
[ "c#", "vb.net", "interface", "enums" ]
7
11
4,201
2
0
2008-10-07T13:55:51.447000
2008-10-07T14:24:53.477000
178,562
178,849
How to determine the order of listeners in web.xml
I got a bunch of servlet context listeners in my Java webapp, each of them gathering some information about the environment. Some of them depend on information which is gathered by another listener. But I can't determine the order in which the listeners are registered and called, so I have to duplicate code. I understa...
All servlet containers and Java EE containers implement this part of the spec strictly. You can rely on the fact that the listeners are called in the order you specified in web.xml. You can have a Application LEVEL Data structure(HashMap) that will be updated by each Filter/Listener as it encounters the data from the r...
How to determine the order of listeners in web.xml I got a bunch of servlet context listeners in my Java webapp, each of them gathering some information about the environment. Some of them depend on information which is gathered by another listener. But I can't determine the order in which the listeners are registered ...
TITLE: How to determine the order of listeners in web.xml QUESTION: I got a bunch of servlet context listeners in my Java webapp, each of them gathering some information about the environment. Some of them depend on information which is gathered by another listener. But I can't determine the order in which the listene...
[ "java", "servlets", "jakarta-ee" ]
25
31
22,478
3
0
2008-10-07T13:55:58.670000
2008-10-07T14:58:13.833000
178,572
178,589
What is the best format for a customer number, order number?
A large international company deploys a new web and MOTO (Mail Order and Telephone Order) handling system. Among other things you are tasked to design format for both order and customer identification numbers. What would be the best format in your opinion? Please list any assumptions and considerations. Accepted Answer...
Go with all numbers or all letters. If you must mix it up, then make sure there are no ambiguous characters (Il1m, O0, etc.). When displayed/printed, put spaces in every 3-4 characters but make sure your systems can handle inputs without the spaces. Edit: Another thing to consider is having a built in way to distinguis...
What is the best format for a customer number, order number? A large international company deploys a new web and MOTO (Mail Order and Telephone Order) handling system. Among other things you are tasked to design format for both order and customer identification numbers. What would be the best format in your opinion? Pl...
TITLE: What is the best format for a customer number, order number? QUESTION: A large international company deploys a new web and MOTO (Mail Order and Telephone Order) handling system. Among other things you are tasked to design format for both order and customer identification numbers. What would be the best format i...
[ "user-interface" ]
52
41
84,326
21
0
2008-10-07T13:57:49.960000
2008-10-07T14:00:36.913000
178,578
178,595
How to disable "Security Alert" window in Webbrowser control
I'm using Webbrowser control to login to HTTPS site with "untrusted certificate". but I get popup such standart window "Security Alert" about untrusted certificate: I have to find this window by title and send it Alt + Y to press Yes: int iHandle = NativeWin32.FindWindow(null, "Security Alert"); NativeWin32.SetForegrou...
This should do it: public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; } ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate); Obviously, blindin...
How to disable "Security Alert" window in Webbrowser control I'm using Webbrowser control to login to HTTPS site with "untrusted certificate". but I get popup such standart window "Security Alert" about untrusted certificate: I have to find this window by title and send it Alt + Y to press Yes: int iHandle = NativeWin3...
TITLE: How to disable "Security Alert" window in Webbrowser control QUESTION: I'm using Webbrowser control to login to HTTPS site with "untrusted certificate". but I get popup such standart window "Security Alert" about untrusted certificate: I have to find this window by title and send it Alt + Y to press Yes: int iH...
[ "c#", "https", "browser", "certificate" ]
9
3
47,387
5
0
2008-10-07T13:58:33.110000
2008-10-07T14:02:46.457000
178,600
178,812
Microsoft ReportViewer: Session Expired Errors
The project is ASP.NET 2.0, I have never been able to reproduce this myself, but I get emails informing me it happens to clients many times a week, often a few times in a row. Here is the full error: Exception Details: Microsoft.Reporting.WebForms.AspNetSessionExpiredException: ASP.NET session has expired Stack Trace: ...
We had the same problem. So far, we only found it when the session expired but they used the back button in a browser that does aggressive caching, which is fine. But the ReportViewer tried to to a refresh even though the main page did not. So, we just added some hacky Global.asax error handling: protected void Applica...
Microsoft ReportViewer: Session Expired Errors The project is ASP.NET 2.0, I have never been able to reproduce this myself, but I get emails informing me it happens to clients many times a week, often a few times in a row. Here is the full error: Exception Details: Microsoft.Reporting.WebForms.AspNetSessionExpiredExcep...
TITLE: Microsoft ReportViewer: Session Expired Errors QUESTION: The project is ASP.NET 2.0, I have never been able to reproduce this myself, but I get emails informing me it happens to clients many times a week, often a few times in a row. Here is the full error: Exception Details: Microsoft.Reporting.WebForms.AspNetS...
[ "session", "reportviewer" ]
22
15
22,735
7
0
2008-10-07T14:04:36.747000
2008-10-07T14:48:43.850000
178,611
1,363,110
Windsor Container: How to specify a public property should not be filled by the container?
When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency which causes my application to hang. How can I explicitly tell Castle Windsor that it should not be trying to sat...
I created a facility to help with this: Castle.Facilities.OptionalPropertyInjection
Windsor Container: How to specify a public property should not be filled by the container? When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency which causes my applic...
TITLE: Windsor Container: How to specify a public property should not be filled by the container? QUESTION: When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency whic...
[ "inversion-of-control", "castle-windsor", "property-injection" ]
13
3
4,141
7
0
2008-10-07T14:06:15.403000
2009-09-01T15:29:12.147000
178,630
178,648
ASP.NET xsd dataset where do I put it
I am trying to convert an ASP.NET website into a web application project. The conversion has gone ok I think apart from previously I had 2 xsd files in the App_Code folder. I believe this folder is not used in web applications projects, so where would I put xsd files now.
I don't think you have to put them anyplace in particular. For the purposes of organization you could create a data directory. If the project is small enough, I leave it in the root.
ASP.NET xsd dataset where do I put it I am trying to convert an ASP.NET website into a web application project. The conversion has gone ok I think apart from previously I had 2 xsd files in the App_Code folder. I believe this folder is not used in web applications projects, so where would I put xsd files now.
TITLE: ASP.NET xsd dataset where do I put it QUESTION: I am trying to convert an ASP.NET website into a web application project. The conversion has gone ok I think apart from previously I had 2 xsd files in the App_Code folder. I believe this folder is not used in web applications projects, so where would I put xsd fi...
[ "asp.net", "xsd" ]
1
1
2,460
2
0
2008-10-07T14:12:29.103000
2008-10-07T14:15:42.107000
178,633
178,654
Minimum rights required to run a windows service as a domain account
Does anyone know what would be the minimum rights I would need to grant to a domain user account in order to run a windows service as that user? For simplicity, assume that the service does nothing over and above starting, stopping, and writing to the "Application" event log - i.e. no network access, no custom event lo...
Two ways: Edit the properties of the service and set the Log On user. The appropriate right will be automatically assigned. Set it manually: Go to Administrative Tools -> Local Security Policy -> Local Policies -> User Rights Assignment. Edit the item "Log on as a service" and add your domain user there.
Minimum rights required to run a windows service as a domain account Does anyone know what would be the minimum rights I would need to grant to a domain user account in order to run a windows service as that user? For simplicity, assume that the service does nothing over and above starting, stopping, and writing to the...
TITLE: Minimum rights required to run a windows service as a domain account QUESTION: Does anyone know what would be the minimum rights I would need to grant to a domain user account in order to run a windows service as that user? For simplicity, assume that the service does nothing over and above starting, stopping, ...
[ "windows-services", "permissions", "rights" ]
41
84
115,044
4
0
2008-10-07T14:12:51.753000
2008-10-07T14:16:24.603000
178,636
178,864
Way to discover which internet connection type I'm using on the iPhone
I need to know what internet connection is available when my application is running. I checked out the Reachability example from Apple, but this differs only between wifi and carrier network. What I need to know is what carrier network is selected, UMTS or EDGE or GPRS.
Currently, this information is not available. If you want this feature, file a new bug and mention that this is a duplicate of bug 6014806.
Way to discover which internet connection type I'm using on the iPhone I need to know what internet connection is available when my application is running. I checked out the Reachability example from Apple, but this differs only between wifi and carrier network. What I need to know is what carrier network is selected, ...
TITLE: Way to discover which internet connection type I'm using on the iPhone QUESTION: I need to know what internet connection is available when my application is running. I checked out the Reachability example from Apple, but this differs only between wifi and carrier network. What I need to know is what carrier net...
[ "iphone", "cocoa-touch" ]
4
7
3,271
4
0
2008-10-07T14:13:18.277000
2008-10-07T15:00:35.137000
178,645
179,486
How does WCF deserialization instantiate objects without calling a constructor?
There is some magic going on with WCF deserialization. How does it instantiate an instance of the data contract type without calling its constructor? For example, consider this data contract: [DataContract] public sealed class CreateMe { [DataMember] private readonly string _name; [DataMember] private readonly int _age...
FormatterServices.GetUninitializedObject() will create an instance without calling a constructor. I found this class by using Reflector and digging through some of the core.Net serialization classes. I tested it using the sample code below and it looks like it works great: using System; using System.Reflection; using S...
How does WCF deserialization instantiate objects without calling a constructor? There is some magic going on with WCF deserialization. How does it instantiate an instance of the data contract type without calling its constructor? For example, consider this data contract: [DataContract] public sealed class CreateMe { [D...
TITLE: How does WCF deserialization instantiate objects without calling a constructor? QUESTION: There is some magic going on with WCF deserialization. How does it instantiate an instance of the data contract type without calling its constructor? For example, consider this data contract: [DataContract] public sealed c...
[ "c#", ".net", "wcf", "reflection", "serialization" ]
80
103
20,502
2
0
2008-10-07T14:15:21.517000
2008-10-07T17:20:30.050000
178,663
178,770
Are server-assisted MVC frameworks peaking?
I've been developing web apps for over a decade now, all the way from CGI to ASP.Net and Struts + Spring + Hibernate. The prevalent architectural style seems to be server-assisted MVC, e.g. Struts, Ruby on Rails, etc. Recent developments lead me to ask if these are on the decline. Adobe's AIR and Flex Microsoft's WPF a...
I agree, to a point - we are becoming are more client-centric, but I think this is because the clients are actually advancing in a standardized way. We started out with everything on the client - because thats all there was. Then it was client-server, which separated the two, then gradually the client bit was thinned o...
Are server-assisted MVC frameworks peaking? I've been developing web apps for over a decade now, all the way from CGI to ASP.Net and Struts + Spring + Hibernate. The prevalent architectural style seems to be server-assisted MVC, e.g. Struts, Ruby on Rails, etc. Recent developments lead me to ask if these are on the dec...
TITLE: Are server-assisted MVC frameworks peaking? QUESTION: I've been developing web apps for over a decade now, all the way from CGI to ASP.Net and Struts + Spring + Hibernate. The prevalent architectural style seems to be server-assisted MVC, e.g. Struts, Ruby on Rails, etc. Recent developments lead me to ask if th...
[ "ria", "sofea" ]
2
3
403
2
0
2008-10-07T14:20:25.810000
2008-10-07T14:40:38.220000
178,667
1,421,097
Does JEditorPane have Charset problems when showing HTML?
I have the following code: import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; public class ScratchPad { public static void main(String args[]) throws Exception { String html =" "+ " "+ " "+ // this is the problem right here " Error 400 BA...
Use the follow line before setText and after setContentType. editor.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); This is one of the mystic undocumented features. setContentType create a new Document that it has no effect if you set it before.
Does JEditorPane have Charset problems when showing HTML? I have the following code: import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; public class ScratchPad { public static void main(String args[]) throws Exception { String html =" "+ ...
TITLE: Does JEditorPane have Charset problems when showing HTML? QUESTION: I have the following code: import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; public class ScratchPad { public static void main(String args[]) throws Exception { ...
[ "java", "html", "swing", "jeditorpane" ]
4
16
4,124
2
0
2008-10-07T14:21:39.927000
2009-09-14T11:53:59.063000
178,669
178,892
Flash in a browser to full screen
How can i make my flash applications in a browser in full screen mode? I know that the stage can be put in that mode, but when i run the application in any browser this doesn't work. So, this can be done, but how?
In the HTML including the Flash SWF, add the following parameter to your tag: and the following attribute to your tag: allowFullScreen="true" Or, if you are using SWFObject (as you should be), add the allowFullscreen parameter to your embed code. See the SWFObject documentation for the various ways to this. In your Fla...
Flash in a browser to full screen How can i make my flash applications in a browser in full screen mode? I know that the stage can be put in that mode, but when i run the application in any browser this doesn't work. So, this can be done, but how?
TITLE: Flash in a browser to full screen QUESTION: How can i make my flash applications in a browser in full screen mode? I know that the stage can be put in that mode, but when i run the application in any browser this doesn't work. So, this can be done, but how? ANSWER: In the HTML including the Flash SWF, add the ...
[ "flash", "actionscript-3", "browser", "fullscreen" ]
4
12
8,683
2
0
2008-10-07T14:22:19.193000
2008-10-07T15:06:16.797000
178,681
178,875
Unmanaged vc++ static libraries and C# GUI app
Basically I have a bunch of unmanaged VC++ static libraries. And the VC++ GUI application which uses those and it is based on MFC. The goal is to replace the GUI app with the one done in C# instead but using all the same static libraries. The question is if this even possible, and if yes, then what is the right way to ...
Rob is correct - you can do it in C++/CLI entirely, but we found it most useful to wrap some native classes in a managed WinForms User Control class. This managed class contained an instance of the native class, and not only marshalled data like strings in method calls, but also converted native callbacks (implemented ...
Unmanaged vc++ static libraries and C# GUI app Basically I have a bunch of unmanaged VC++ static libraries. And the VC++ GUI application which uses those and it is based on MFC. The goal is to replace the GUI app with the one done in C# instead but using all the same static libraries. The question is if this even possi...
TITLE: Unmanaged vc++ static libraries and C# GUI app QUESTION: Basically I have a bunch of unmanaged VC++ static libraries. And the VC++ GUI application which uses those and it is based on MFC. The goal is to replace the GUI app with the one done in C# instead but using all the same static libraries. The question is ...
[ "c#", "visual-c++", "mfc" ]
1
1
1,650
2
0
2008-10-07T14:25:21.993000
2008-10-07T15:02:34.963000
178,696
178,727
Why am I getting this Javascript runtime error?
I've got the following JavaScript on my web page... 64 var description = new Array(); 65 description[0] = "..." 66 description[1] = "..."... 78 function init() { 79 document.getElementById('somedivid').innerHTML = description[0]; 80 } 81 82 window.onload = init(); In Microsoft Internet Explorer it causes the following ...
Shouldn't line 82 read: window.onload = init; When you do "init()" it's a call to a function that returns void. You end up calling that function before the page loads.
Why am I getting this Javascript runtime error? I've got the following JavaScript on my web page... 64 var description = new Array(); 65 description[0] = "..." 66 description[1] = "..."... 78 function init() { 79 document.getElementById('somedivid').innerHTML = description[0]; 80 } 81 82 window.onload = init(); In Micr...
TITLE: Why am I getting this Javascript runtime error? QUESTION: I've got the following JavaScript on my web page... 64 var description = new Array(); 65 description[0] = "..." 66 description[1] = "..."... 78 function init() { 79 document.getElementById('somedivid').innerHTML = description[0]; 80 } 81 82 window.onload...
[ "javascript", "html", "internet-explorer" ]
4
13
6,058
5
0
2008-10-07T14:27:34.050000
2008-10-07T14:32:52.900000
178,700
1,980,181
Generic, annotation-driven event notification frameworks
While simple, interface-driven event notification frameworks in Java have been around since pre-Cambrian times (e.g. java.beans.PropertyChangeSupport), it is becoming increasingly popular for frameworks to use annotation-driven event notification instead. For an example, see JBossCache 2.2. The listener class has its l...
You can already do this today with EventBus. Following example is from EventBus Getting Started guide. Statusbar that updates based on published events, and no need to register statusbar control/widget as listener of publisher(s). Without EventBus, statusbar will need to be added as listener to many classes. Statusbar ...
Generic, annotation-driven event notification frameworks While simple, interface-driven event notification frameworks in Java have been around since pre-Cambrian times (e.g. java.beans.PropertyChangeSupport), it is becoming increasingly popular for frameworks to use annotation-driven event notification instead. For an ...
TITLE: Generic, annotation-driven event notification frameworks QUESTION: While simple, interface-driven event notification frameworks in Java have been around since pre-Cambrian times (e.g. java.beans.PropertyChangeSupport), it is becoming increasingly popular for frameworks to use annotation-driven event notificatio...
[ "java", "events", "annotations", "notifications" ]
7
8
13,567
8
0
2008-10-07T14:28:47.917000
2009-12-30T13:23:00.243000
178,704
178,818
Are unix timestamps the best way to store timestamps?
I always use unix timestamps for everything, but am wondering if there is a better way. What do you use to store timestamps and why?
However you choose to store a timestamp, it is important to avoid regional interpretation problems and time offset problems. A Unix timestamp is interpreted the same regardless of region, and is calculated from the same point in time regardless of time zone - these are good things. Beware storing timestamps as ambiguou...
Are unix timestamps the best way to store timestamps? I always use unix timestamps for everything, but am wondering if there is a better way. What do you use to store timestamps and why?
TITLE: Are unix timestamps the best way to store timestamps? QUESTION: I always use unix timestamps for everything, but am wondering if there is a better way. What do you use to store timestamps and why? ANSWER: However you choose to store a timestamp, it is important to avoid regional interpretation problems and tim...
[ "timestamp" ]
66
107
44,761
9
0
2008-10-07T14:29:21.957000
2008-10-07T14:50:28.357000
178,712
178,766
How to find out if a column exists in a DataRow?
I am reading an XML file into a DataSet and need to get the data out of the DataSet. Since it is a user-editable config file the fields may or may not be there. To handle missing fields well I'd like to make sure each column in the DataRow exists and is not DBNull. I already check for DBNull but I don't know how to mak...
DataRow's are nice in the way that they have their underlying table linked to them. With the underlying table you can verify that a specific row has a specific column in it. If DataRow.Table.Columns.Contains("column") Then MsgBox("YAY") End If
How to find out if a column exists in a DataRow? I am reading an XML file into a DataSet and need to get the data out of the DataSet. Since it is a user-editable config file the fields may or may not be there. To handle missing fields well I'd like to make sure each column in the DataRow exists and is not DBNull. I alr...
TITLE: How to find out if a column exists in a DataRow? QUESTION: I am reading an XML file into a DataSet and need to get the data out of the DataSet. Since it is a user-editable config file the fields may or may not be there. To handle missing fields well I'd like to make sure each column in the DataRow exists and is...
[ ".net", "vb.net", "ado.net", "dataset", "datarow" ]
62
183
116,918
4
0
2008-10-07T14:30:09.427000
2008-10-07T14:39:44.290000
178,730
178,768
Lock Active Directory accounts programmatically
I have to lock user accounts in Active Directory programmatically in C#. Unfortunately it doesn't work via the userAccountControl attribute. Every time I set userAccountControl to 528 (=normal account w/ lockout flag), Active Directory won't accept the value and resets it without further notice to 512 (=normal account)...
Make sure the account you're using to disable the account has sufficient privileges to disable accounts. See this example from Microsoft.
Lock Active Directory accounts programmatically I have to lock user accounts in Active Directory programmatically in C#. Unfortunately it doesn't work via the userAccountControl attribute. Every time I set userAccountControl to 528 (=normal account w/ lockout flag), Active Directory won't accept the value and resets it...
TITLE: Lock Active Directory accounts programmatically QUESTION: I have to lock user accounts in Active Directory programmatically in C#. Unfortunately it doesn't work via the userAccountControl attribute. Every time I set userAccountControl to 528 (=normal account w/ lockout flag), Active Directory won't accept the v...
[ "c#", "active-directory" ]
3
4
15,156
4
0
2008-10-07T14:33:00.327000
2008-10-07T14:39:56.897000
178,738
181,698
OnClick in Excel VBA
Is there a way to catch a click on a cell in VBA with Excel? I am not referring to the Worksheet_SelectionChange event, as that will not trigger multiple times if the cell is clicked multiple times. BeforeDoubleClick does not solve my problem either, as I do not want to require the user to double click that frequently....
Clearly, there is no perfect answer. However, if you want to allow the user to select certain cells allow them to change those cells, and trap each click,even repeated clicks on the same cell, then the easiest way seems to be to move the focus off the selected cell, so that clicking it will trigger a Select event. One ...
OnClick in Excel VBA Is there a way to catch a click on a cell in VBA with Excel? I am not referring to the Worksheet_SelectionChange event, as that will not trigger multiple times if the cell is clicked multiple times. BeforeDoubleClick does not solve my problem either, as I do not want to require the user to double c...
TITLE: OnClick in Excel VBA QUESTION: Is there a way to catch a click on a cell in VBA with Excel? I am not referring to the Worksheet_SelectionChange event, as that will not trigger multiple times if the cell is clicked multiple times. BeforeDoubleClick does not solve my problem either, as I do not want to require th...
[ "vba", "excel" ]
25
25
143,847
7
0
2008-10-07T14:34:13.723000
2008-10-08T07:38:39.023000
178,740
178,764
Compiler could not choose an overload between interface and exception
Trying to use an excpetion class which could provide location reference for XML parsing, found an interesting behavior - compiler could not choose between overload which consumes an interface and one which needs System.Exception when I trying to pass XmlReader as a parameter. Detais are following: //exception overloads...
The line: //fails throw new FilterXmlParseException(" element expected", reader); because XmlReader doesn't implement IXmlLineInfo. I am not sure if your cast works, but the casts are not checked statically. If it actually works, it is because the concrete class (that inherits from XmlReader) implements this interface,...
Compiler could not choose an overload between interface and exception Trying to use an excpetion class which could provide location reference for XML parsing, found an interesting behavior - compiler could not choose between overload which consumes an interface and one which needs System.Exception when I trying to pass...
TITLE: Compiler could not choose an overload between interface and exception QUESTION: Trying to use an excpetion class which could provide location reference for XML parsing, found an interesting behavior - compiler could not choose between overload which consumes an interface and one which needs System.Exception whe...
[ "c#", ".net", "compiler-construction" ]
1
1
345
5
0
2008-10-07T14:34:53.740000
2008-10-07T14:39:41.357000
178,751
178,901
Getting the whole output of a string that contains chr(0)
Here is the sample: Dim TestString As String = "Hello," & Chr(0) & "World" MsgBox(TestString,, "TestString.Length=" & TestString.Length.ToString) Result - Messagebox shows "Hello," with title says TestString.Length=12 I guess the chr(0) is treated as the end of zero terminated string, but it's not what i want. What the...
The sample code in the questioner's example ("SCORE".ToString...) works fine for me in a console application. The VS2005 debugger does not show the string correctly, but it outputs to the console just fine. So, my feeling is either that you think it's incorrect because the debugger wrongly says so or your output string...
Getting the whole output of a string that contains chr(0) Here is the sample: Dim TestString As String = "Hello," & Chr(0) & "World" MsgBox(TestString,, "TestString.Length=" & TestString.Length.ToString) Result - Messagebox shows "Hello," with title says TestString.Length=12 I guess the chr(0) is treated as the end of ...
TITLE: Getting the whole output of a string that contains chr(0) QUESTION: Here is the sample: Dim TestString As String = "Hello," & Chr(0) & "World" MsgBox(TestString,, "TestString.Length=" & TestString.Length.ToString) Result - Messagebox shows "Hello," with title says TestString.Length=12 I guess the chr(0) is trea...
[ ".net", "vb.net" ]
0
1
4,775
9
0
2008-10-07T14:36:55.840000
2008-10-07T15:07:10.630000
178,797
178,826
Do I need to set up Kerberos to use Replication in SQL Server 2005?
I want to setup replication on three SQL servers and one is not configured for Kerberos. (The SPNs are not setup yet) Do I need Kerberos and Pass-through delegation working to use replication in SQL Server 2005?
No. But you will need the replication agent(s) to run under the context of account with the relevant permissions. See MSDN here.
Do I need to set up Kerberos to use Replication in SQL Server 2005? I want to setup replication on three SQL servers and one is not configured for Kerberos. (The SPNs are not setup yet) Do I need Kerberos and Pass-through delegation working to use replication in SQL Server 2005?
TITLE: Do I need to set up Kerberos to use Replication in SQL Server 2005? QUESTION: I want to setup replication on three SQL servers and one is not configured for Kerberos. (The SPNs are not setup yet) Do I need Kerberos and Pass-through delegation working to use replication in SQL Server 2005? ANSWER: No. But you w...
[ "sql", "sql-server", "replication", "kerberos" ]
0
1
257
1
0
2008-10-07T14:45:18.147000
2008-10-07T14:52:43.827000
178,821
178,871
Using explicit interfaces to ensure programming against an interface
I have seen arguments for using explicit interfaces as a method of locking a classes usage to that interface. The argument seems to be that by forcing others to program to the interface you can ensure better decoupling of the classes and allow easier testing. Example: public interface ICut { void Cut(); } public class ...
To quote GoF chapter 1: "Program to an interface, not an implementation". "Favor object composition over class inheritance". As C# does not have multiple inheritance, object composition and programming to interfaces are the way to go. ETA: And you should never use multiple inheritance anyway but that's another topic al...
Using explicit interfaces to ensure programming against an interface I have seen arguments for using explicit interfaces as a method of locking a classes usage to that interface. The argument seems to be that by forcing others to program to the interface you can ensure better decoupling of the classes and allow easier ...
TITLE: Using explicit interfaces to ensure programming against an interface QUESTION: I have seen arguments for using explicit interfaces as a method of locking a classes usage to that interface. The argument seems to be that by forcing others to program to the interface you can ensure better decoupling of the classes...
[ "c#", "design-patterns", "interface" ]
8
4
1,619
11
0
2008-10-07T14:51:12.020000
2008-10-07T15:02:00.097000
178,824
178,927
Only creating a COM object if the DLL that implements it is signed?
We've got some code that uses LoadLibrary and GetProcAddress to implement a plugin architecture for one of our products. We ensure that the DLL about to be loaded is signed with our code-signing key. We're changing the plugin architecture to use COM instead. Is there a way to enforce code-signing (preferably with our c...
You need to do this at the DLL level using the Authenticode API. The standard API is called WinVerifyTrust() and there are samples documented there. There's another KB article number 323809 that gives an example of how to peel other details out of the authenticode information attached to your DLL. Of course, these APIs...
Only creating a COM object if the DLL that implements it is signed? We've got some code that uses LoadLibrary and GetProcAddress to implement a plugin architecture for one of our products. We ensure that the DLL about to be loaded is signed with our code-signing key. We're changing the plugin architecture to use COM in...
TITLE: Only creating a COM object if the DLL that implements it is signed? QUESTION: We've got some code that uses LoadLibrary and GetProcAddress to implement a plugin architecture for one of our products. We ensure that the DLL about to be loaded is signed with our code-signing key. We're changing the plugin architec...
[ "com", "code-signing" ]
1
2
249
2
0
2008-10-07T14:52:00.427000
2008-10-07T15:09:47.397000
178,837
178,861
How can I find repeated letters with a Perl regex?
I am looking for a regex that will find repeating letters. So any letter twice or more, for example: booooooot or abbott I won't know the letter I am looking for ahead of time. This is a question I was asked in interviews and then asked in interviews. Not so many people get it correct.
You can find any letter, then use \1 to find that same letter a second time (or more). If you only need to know the letter, then $1 will contain it. Otherwise you can concatenate the second match onto the first. my $str = "Foooooobar"; $str =~ /(\w)(\1+)/; print $1; # prints 'o' print $1. $2; # prints 'oooooo'
How can I find repeated letters with a Perl regex? I am looking for a regex that will find repeating letters. So any letter twice or more, for example: booooooot or abbott I won't know the letter I am looking for ahead of time. This is a question I was asked in interviews and then asked in interviews. Not so many peopl...
TITLE: How can I find repeated letters with a Perl regex? QUESTION: I am looking for a regex that will find repeating letters. So any letter twice or more, for example: booooooot or abbott I won't know the letter I am looking for ahead of time. This is a question I was asked in interviews and then asked in interviews....
[ "regex", "perl", "character" ]
24
54
17,097
11
0
2008-10-07T14:56:20.997000
2008-10-07T15:00:06.043000
178,838
178,877
Dereferencing Variable Size Arrays in Structs
Structs seem like a useful way to parse a binary blob of data (ie a file or network packet). This is fine and dandy until you have variable size arrays in the blob. For instance: struct nodeheader{ int flags; int data_size; char data[]; }; This allows me to find the last data character: nodeheader b; cout << b.data[b.d...
You cannot have multiple variable sized arrays. How should the compiler at compile time know where friend[] is located? The location of friend depends on the size of data[] and the size of data is unknown at compile time.
Dereferencing Variable Size Arrays in Structs Structs seem like a useful way to parse a binary blob of data (ie a file or network packet). This is fine and dandy until you have variable size arrays in the blob. For instance: struct nodeheader{ int flags; int data_size; char data[]; }; This allows me to find the last da...
TITLE: Dereferencing Variable Size Arrays in Structs QUESTION: Structs seem like a useful way to parse a binary blob of data (ie a file or network packet). This is fine and dandy until you have variable size arrays in the blob. For instance: struct nodeheader{ int flags; int data_size; char data[]; }; This allows me t...
[ "c++", "struct" ]
1
3
3,976
6
0
2008-10-07T14:56:59.950000
2008-10-07T15:02:57.863000
178,845
180,644
Calculate weeknumber from a date value
Is there some simple way to calculate a Weeknumber value from a date value stored in XML? It needs to be pure XSLT solution. I cannot use any code:(
If you can use EXSLT, there are several date functions available. All of them are implemented in Saxon, but if you're using MSXSL, Chris Bayes has implemented them as extension functions, which you can actually place within your transform inside an msxsl:script element. His implementations are linked from each specific...
Calculate weeknumber from a date value Is there some simple way to calculate a Weeknumber value from a date value stored in XML? It needs to be pure XSLT solution. I cannot use any code:(
TITLE: Calculate weeknumber from a date value QUESTION: Is there some simple way to calculate a Weeknumber value from a date value stored in XML? It needs to be pure XSLT solution. I cannot use any code:( ANSWER: If you can use EXSLT, there are several date functions available. All of them are implemented in Saxon, b...
[ "xml", "xslt", "date" ]
6
5
7,133
7
0
2008-10-07T14:58:05.253000
2008-10-07T22:05:49.693000
178,846
178,893
Visual Studio 2005 Intellisense stopped working after ReSharper installation
I installed the ReSharper evaluation version and uninstalled it. Afterwards Visual Studio's Intellisense stopped working. I have restarted computer but I still have this problem. Can anyone please help me here? I am using Visual Studio 2005. Thanks.
Try opening Visual Studio Command Prompt and entering: devenv.exe /ResetSettings
Visual Studio 2005 Intellisense stopped working after ReSharper installation I installed the ReSharper evaluation version and uninstalled it. Afterwards Visual Studio's Intellisense stopped working. I have restarted computer but I still have this problem. Can anyone please help me here? I am using Visual Studio 2005. T...
TITLE: Visual Studio 2005 Intellisense stopped working after ReSharper installation QUESTION: I installed the ReSharper evaluation version and uninstalled it. Afterwards Visual Studio's Intellisense stopped working. I have restarted computer but I still have this problem. Can anyone please help me here? I am using Vis...
[ "visual-studio", "visual-studio-2005", "resharper" ]
22
39
13,510
8
0
2008-10-07T14:58:06.140000
2008-10-07T15:06:22.507000
178,857
178,883
oledb/ado.net: Get the command's text, with all parameters replaced
Is it possible to get the text of an OleDbCommand with all parameters replaced with their values? E.g. in the code below I'm looking for a way to get the query text SELECT * FROM my_table WHERE c1 = 'hello' and c2 = 'world' after I finished assigning the parameters. var query = "SELECT * FROM my_table WHERE c1 =? and c...
No: you have to iterate through the parameters collection yourself, doing a string.Replace() to get the equivalent. It's particularly painful when you have to use the? syntax rather than the @parametername syntax. The reason for this is that the full string is never assembled. The parameters and sent to the server and ...
oledb/ado.net: Get the command's text, with all parameters replaced Is it possible to get the text of an OleDbCommand with all parameters replaced with their values? E.g. in the code below I'm looking for a way to get the query text SELECT * FROM my_table WHERE c1 = 'hello' and c2 = 'world' after I finished assigning t...
TITLE: oledb/ado.net: Get the command's text, with all parameters replaced QUESTION: Is it possible to get the text of an OleDbCommand with all parameters replaced with their values? E.g. in the code below I'm looking for a way to get the query text SELECT * FROM my_table WHERE c1 = 'hello' and c2 = 'world' after I fi...
[ "ado.net", "parameters", "oledb" ]
4
8
2,716
2
0
2008-10-07T14:59:16.093000
2008-10-07T15:04:13.180000
178,860
260,567
How do I add an MSAccess connection to CodeIgniter or CakePHP?
I'm trying to use a Microsoft Access database for a demo project that I'm thinking of doing in either CodeIgniter or CakePHP. Ignoring the possible folly of using Microsoft Access, I haven't been able to figure out precisely how the connection string corresponds to the frameworks' database settings. In straight PHP, I ...
Try setting up a DSN and changing to the following: $db['access']['hostname'] = " "; $db['access']['username'] = ""; $db['access']['password'] = ""; $db['access']['database'] = " "; There's also a section in the CodeIgniter documentation that addresses connection strings: http://codeigniter.com/user_guide/database/conn...
How do I add an MSAccess connection to CodeIgniter or CakePHP? I'm trying to use a Microsoft Access database for a demo project that I'm thinking of doing in either CodeIgniter or CakePHP. Ignoring the possible folly of using Microsoft Access, I haven't been able to figure out precisely how the connection string corres...
TITLE: How do I add an MSAccess connection to CodeIgniter or CakePHP? QUESTION: I'm trying to use a Microsoft Access database for a demo project that I'm thinking of doing in either CodeIgniter or CakePHP. Ignoring the possible folly of using Microsoft Access, I haven't been able to figure out precisely how the connec...
[ "database", "ms-access", "cakephp", "codeigniter" ]
3
1
5,540
2
0
2008-10-07T14:59:54.390000
2008-11-04T01:38:06.297000
178,867
180,808
What happens if I don't use the --Reintegrate option in Subversion 1.5?
I thought I had figured out everything I needed to know about Subversion 1.5 and was happily merging between my feature branches and the trunk. Then I realized I've not been doing what I thought I had. I have not been using the --reintegrate parameter when merging back to the trunk from a feature branch. Specifically I...
This blog post explains what might go wrong, why --reintegrate was created, and what it actually does. Merging from the feature branch back to trunk without using --reintegrate will most likely only have caused you some extra conflicts, as described in the post
What happens if I don't use the --Reintegrate option in Subversion 1.5? I thought I had figured out everything I needed to know about Subversion 1.5 and was happily merging between my feature branches and the trunk. Then I realized I've not been doing what I thought I had. I have not been using the --reintegrate parame...
TITLE: What happens if I don't use the --Reintegrate option in Subversion 1.5? QUESTION: I thought I had figured out everything I needed to know about Subversion 1.5 and was happily merging between my feature branches and the trunk. Then I realized I've not been doing what I thought I had. I have not been using the --...
[ "svn", "tortoisesvn", "merge", "reintegration" ]
1
4
468
1
0
2008-10-07T15:01:38.803000
2008-10-07T23:22:34.423000
178,876
185,025
Can I create a Database Deadlock test in Nunit?
In this asp.net I'm cleaning up it's possible for deadlocks to occur. I want to make sure that the code deals with them properly, so I'm trying to write NUnit tests which trigger a deadlock..... The DAO is split by entity. Each entity has a set of tests which are surrounded by Startup() and Teardown() methods which cre...
If your deadlock results in an exception being thrown, you want to use a Mock Object to emulate the exception being thrown. The basic idea is that you tell your Mock Object framework (I like TypeMock ) to throw an exception instead, something like this: MockObject mo = MockManager.MockObject(typeof(MyDeadlockException)...
Can I create a Database Deadlock test in Nunit? In this asp.net I'm cleaning up it's possible for deadlocks to occur. I want to make sure that the code deals with them properly, so I'm trying to write NUnit tests which trigger a deadlock..... The DAO is split by entity. Each entity has a set of tests which are surround...
TITLE: Can I create a Database Deadlock test in Nunit? QUESTION: In this asp.net I'm cleaning up it's possible for deadlocks to occur. I want to make sure that the code deals with them properly, so I'm trying to write NUnit tests which trigger a deadlock..... The DAO is split by entity. Each entity has a set of tests ...
[ "sql-server-2000", "nunit", "deadlock", "msdtc" ]
4
2
2,248
6
0
2008-10-07T15:02:40.703000
2008-10-08T21:36:54.150000
178,888
178,923
Console window displays at WinForm startup (C#)
This is a minor bug (one I'm willing to live with in the interest of go-live, frankly), but I'm wondering if anyone else has ideas to fix it. I have a C# WinForms application. When the app is launched via the executable (not via the debugger), the first thing the user sees is a console window, followed by the main wind...
My first guess would be to double check your Project Property settings and make sure that the output type is Windows Application and not Console Application.
Console window displays at WinForm startup (C#) This is a minor bug (one I'm willing to live with in the interest of go-live, frankly), but I'm wondering if anyone else has ideas to fix it. I have a C# WinForms application. When the app is launched via the executable (not via the debugger), the first thing the user see...
TITLE: Console window displays at WinForm startup (C#) QUESTION: This is a minor bug (one I'm willing to live with in the interest of go-live, frankly), but I'm wondering if anyone else has ideas to fix it. I have a C# WinForms application. When the app is launched via the executable (not via the debugger), the first ...
[ "c#", ".net", "winforms" ]
4
4
4,133
5
0
2008-10-07T15:05:29.747000
2008-10-07T15:09:14.467000
178,899
178,931
Serializing Lists of Classes to XML
I have a collection of classes that I want to serialize out to an XML file. It looks something like this: public class Foo { public List BarList { get; set; } } Where a bar is just a wrapper for a collection of properties, like this: public class Bar { public string Property1 { get; set; } public string Property2 { get...
Just to check, have you marked Bar as [Serializable]? Also, you need a parameter-less ctor on Bar, to deserialize Hmm, I used: public partial class Form1: Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Foo f = new Foo(); f.BarList = new List (); f.BarList.A...
Serializing Lists of Classes to XML I have a collection of classes that I want to serialize out to an XML file. It looks something like this: public class Foo { public List BarList { get; set; } } Where a bar is just a wrapper for a collection of properties, like this: public class Bar { public string Property1 { get; ...
TITLE: Serializing Lists of Classes to XML QUESTION: I have a collection of classes that I want to serialize out to an XML file. It looks something like this: public class Foo { public List BarList { get; set; } } Where a bar is just a wrapper for a collection of properties, like this: public class Bar { public string...
[ "c#", "xml", "serialization" ]
36
32
87,662
4
0
2008-10-07T15:06:59.633000
2008-10-07T15:10:14.540000
178,904
178,956
What is this thing in JavaScript?
Consider: var something = { wtf: null, omg: null }; My JavaScript knowledge is still horribly patchy since I last programmed with it, but I think I've relearned most of it now. Except for this. I don't recall ever seeing this before. What is it? And where can I learn more about it?
It is an object literal with two properties. Usually this is how people create associative arrays or hashes because JS doesn't natively support that data structure. Though note that it is still a fully-fledged object, you can even add functions as properties: var myobj = { name: 'SO', hello: function() { alert(this.nam...
What is this thing in JavaScript? Consider: var something = { wtf: null, omg: null }; My JavaScript knowledge is still horribly patchy since I last programmed with it, but I think I've relearned most of it now. Except for this. I don't recall ever seeing this before. What is it? And where can I learn more about it?
TITLE: What is this thing in JavaScript? QUESTION: Consider: var something = { wtf: null, omg: null }; My JavaScript knowledge is still horribly patchy since I last programmed with it, but I think I've relearned most of it now. Except for this. I don't recall ever seeing this before. What is it? And where can I learn...
[ "javascript", "object-literal" ]
9
11
1,591
8
0
2008-10-07T15:07:17.450000
2008-10-07T15:15:00.960000
178,909
179,178
How can I draw arrows on my left-docked MenuStrip?
I have a C# form into which I've placed a left-docked MenuStrip. This MenuStrip contains some menu items which contain submenus, and some menu items which are effectively buttons (clicking on them results in an action taking place; n.b., I realize this is not a good design). I would like to have the menu items which ha...
Why do you not look into using a System.Windows.Forms.ToolStrip rather than a MenuStrip. This will allow you to have the arrow functionality build in and will even solve the bad desing problem you are having. Should you want you can specify that the toolstrip items do not show images and only show text. In this way you...
How can I draw arrows on my left-docked MenuStrip? I have a C# form into which I've placed a left-docked MenuStrip. This MenuStrip contains some menu items which contain submenus, and some menu items which are effectively buttons (clicking on them results in an action taking place; n.b., I realize this is not a good de...
TITLE: How can I draw arrows on my left-docked MenuStrip? QUESTION: I have a C# form into which I've placed a left-docked MenuStrip. This MenuStrip contains some menu items which contain submenus, and some menu items which are effectively buttons (clicking on them results in an action taking place; n.b., I realize thi...
[ "c#", ".net", "winforms", "menustrip" ]
0
1
2,913
2
0
2008-10-07T15:07:54.110000
2008-10-07T15:57:29.220000
178,913
180,584
Partition a list of sets by shared elements
Here's the jist of the problem: Given a list of sets, such as: [ (1,2,3), (5,2,6), (7,8,9), (6,12,13), (21,8,34), (19,20) ] Return a list of groups of the sets, such that sets that have a shared element are in the same group. [ [ (1,2,3), (5,2,6), (6,12,13) ], [ (7,8,9), (21,8,34) ], [ (19,20) ] ] Note the stickeyness ...
The problem is exactly the computation of the connected components of an hypergraph: the integers are the vertices, and the sets are the hyperedges. A usual way of computing the connected components is by flooding them one after the other: for all i = 1 to N, do: if i has been tagged by some j < i, then continue (I mea...
Partition a list of sets by shared elements Here's the jist of the problem: Given a list of sets, such as: [ (1,2,3), (5,2,6), (7,8,9), (6,12,13), (21,8,34), (19,20) ] Return a list of groups of the sets, such that sets that have a shared element are in the same group. [ [ (1,2,3), (5,2,6), (6,12,13) ], [ (7,8,9), (21,...
TITLE: Partition a list of sets by shared elements QUESTION: Here's the jist of the problem: Given a list of sets, such as: [ (1,2,3), (5,2,6), (7,8,9), (6,12,13), (21,8,34), (19,20) ] Return a list of groups of the sets, such that sets that have a shared element are in the same group. [ [ (1,2,3), (5,2,6), (6,12,13) ...
[ "sql", "algorithm", "set" ]
5
6
451
4
0
2008-10-07T15:08:33.763000
2008-10-07T21:46:23.557000
178,915
179,066
How to save picture to iPhone photo library?
What do I need to do to save an image my program has generated (possibly from the camera, possibly not) to the system photo library on the iPhone?
You can use this function: UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo); You only need completionTarget, completionSelector and contextInfo if you want to be notified when the UIImage is done saving, otherwise you can pass in nil. See the official docume...
How to save picture to iPhone photo library? What do I need to do to save an image my program has generated (possibly from the camera, possibly not) to the system photo library on the iPhone?
TITLE: How to save picture to iPhone photo library? QUESTION: What do I need to do to save an image my program has generated (possibly from the camera, possibly not) to the system photo library on the iPhone? ANSWER: You can use this function: UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL co...
[ "ios", "iphone", "cocoa-touch", "camera", "uiimage" ]
199
417
166,641
15
0
2008-10-07T15:08:36.260000
2008-10-07T15:32:02.110000
178,921
179,043
IE 7 redirecting after jQuery ajax calls
I have the following code in my file to load a div with HTML from an AJAX call: $('#searchButton').click( function() { $('#inquiry').load('/search.php?pid=' + $('#searchValue').val()); }); This works fine in Firefox and Google Chrome, but whenever I do the search in IE I get redirected back to index.php. I grabbed the ...
More fun. I have the input text and button wrapped in this form: [HTML] and IE seems to be ignoring the return false. I tried modding the jQuery function to be like Steve's but it was still refreshing inproperly. I removed the form tags and that took care of it.
IE 7 redirecting after jQuery ajax calls I have the following code in my file to load a div with HTML from an AJAX call: $('#searchButton').click( function() { $('#inquiry').load('/search.php?pid=' + $('#searchValue').val()); }); This works fine in Firefox and Google Chrome, but whenever I do the search in IE I get red...
TITLE: IE 7 redirecting after jQuery ajax calls QUESTION: I have the following code in my file to load a div with HTML from an AJAX call: $('#searchButton').click( function() { $('#inquiry').load('/search.php?pid=' + $('#searchValue').val()); }); This works fine in Firefox and Google Chrome, but whenever I do the sear...
[ "jquery", "ajax", "internet-explorer-7" ]
4
1
2,584
5
0
2008-10-07T15:08:57.273000
2008-10-07T15:28:28.513000
178,934
178,992
Iterators.. why use them?
In the STL library some containers have iterators and it is commonly held that they are a superior way of iterating through these containers rather than simple for loops e.g. for ( int i=0; i < vecVector.size(); i++ ) {.. } Can anyone tell me why and in what cases I should use iterators and in what cases the code snip...
Note that the usually implementation of vector won't use an "int" as the type of the index/size. So your code will at the very least provoke compiler warnings. Genericity Iterators increase the genericity of your code. For example: typedef std::vector Container; void doSomething(Container & p_aC) { for(Container::iter...
Iterators.. why use them? In the STL library some containers have iterators and it is commonly held that they are a superior way of iterating through these containers rather than simple for loops e.g. for ( int i=0; i < vecVector.size(); i++ ) {.. } Can anyone tell me why and in what cases I should use iterators and i...
TITLE: Iterators.. why use them? QUESTION: In the STL library some containers have iterators and it is commonly held that they are a superior way of iterating through these containers rather than simple for loops e.g. for ( int i=0; i < vecVector.size(); i++ ) {.. } Can anyone tell me why and in what cases I should u...
[ "c++", "stl", "iterator" ]
22
28
11,437
6
0
2008-10-07T15:10:49.937000
2008-10-07T15:20:10.230000
178,936
179,016
How can I unzip the newest file in a directory in a BAT file?
I am working on a build system. The build system posts the results as a zip file in a directory. Unfortunately I have no easy way to know the name of the zip file, because it is timestamped. For the next operation, I must decompress this zip file to some specific location and then do some more file operations. I guess ...
This should do it: FOR /F usebackq %%i IN (`DIR /B /O-D *.ZIP`) DO UNZIP %%i && GOTO DONE || GOTO DONE:DONE This works as follows: DIR /B /O-D *.ZIP lists all ZIP files in reverse date order in a "bare" - i.e. name only - format. FOR /F usebackq is used to loop over the output of the command. && GOTO DONE || GOTO DONE ...
How can I unzip the newest file in a directory in a BAT file? I am working on a build system. The build system posts the results as a zip file in a directory. Unfortunately I have no easy way to know the name of the zip file, because it is timestamped. For the next operation, I must decompress this zip file to some spe...
TITLE: How can I unzip the newest file in a directory in a BAT file? QUESTION: I am working on a build system. The build system posts the results as a zip file in a directory. Unfortunately I have no easy way to know the name of the zip file, because it is timestamped. For the next operation, I must decompress this zi...
[ "build-process", "batch-file", "unzip" ]
3
11
3,276
4
0
2008-10-07T15:11:13.680000
2008-10-07T15:23:47.837000
178,948
179,021
Filter "list" of divs with Javascript
I have a repeater that outputs divs like the following for every item returned from some method. the title the description Modify Delete I need to have a textbox on the page that allows the user to filter the list based on what's in the title field. I would like it to happen as the user types. I could get this done wit...
Yes, this is dead simple with jQuery. First hide everything: $("div.title").hide(); (Matches elements of type "div" with class "title".) Now show the matches: $("div.title:contains(searchText)").show(); Help for "contains". It should not take "seconds" to do this unless your page is enormous. You can do this in onKeyDo...
Filter "list" of divs with Javascript I have a repeater that outputs divs like the following for every item returned from some method. the title the description Modify Delete I need to have a textbox on the page that allows the user to filter the list based on what's in the title field. I would like it to happen as the...
TITLE: Filter "list" of divs with Javascript QUESTION: I have a repeater that outputs divs like the following for every item returned from some method. the title the description Modify Delete I need to have a textbox on the page that allows the user to filter the list based on what's in the title field. I would like i...
[ ".net", "asp.net", "jquery", "webforms" ]
3
8
3,256
2
0
2008-10-07T15:14:20.197000
2008-10-07T15:24:25.870000
178,952
178,978
Adding floats with gmp gives "correct" results, sort of
In the code below I use mpf_add to add the string representation of two floating values. What I don't understand at this point is why 2.2 + 3.2 = 5.39999999999999999999999999999999999999. I would have thought that gmp was smart enough to give 5.4. What am I not comprehending about how gmp does floats? (BTW, when I firs...
This is because of the inherent error of using floating-point arithmetic in a binary environment. See the IEEE 754 standard for more information.
Adding floats with gmp gives "correct" results, sort of In the code below I use mpf_add to add the string representation of two floating values. What I don't understand at this point is why 2.2 + 3.2 = 5.39999999999999999999999999999999999999. I would have thought that gmp was smart enough to give 5.4. What am I not co...
TITLE: Adding floats with gmp gives "correct" results, sort of QUESTION: In the code below I use mpf_add to add the string representation of two floating values. What I don't understand at this point is why 2.2 + 3.2 = 5.39999999999999999999999999999999999999. I would have thought that gmp was smart enough to give 5.4...
[ "visual-c++", "floating-point", "bignum", "gmp" ]
1
4
2,739
3
0
2008-10-07T15:14:39.087000
2008-10-07T15:18:00.127000
178,963
179,058
flex (lexical analyzer) regular expressions - Reusing definitions
I have this working definition: IDENTIFIER [a-zA-Z][a-zA-Z0-9]* I don't want to keep repeating the [a-zA-Z] and [0-9], so I made two new definitions DIGIT [0-9] VALID [a-zA-Z] How can I rewrite the IDENTIFIER rule to use the DIGIT and VALID definitions? I don't know how to do the "second" match, I'm stuck here: IDENTIF...
It looks like you actually want: IDENTIFIER {VALID}({VALID}|{DIGIT})* [{VALID}{DIGIT}] resolves to [[A-Za-z][0-9]] which is not a legal construct.
flex (lexical analyzer) regular expressions - Reusing definitions I have this working definition: IDENTIFIER [a-zA-Z][a-zA-Z0-9]* I don't want to keep repeating the [a-zA-Z] and [0-9], so I made two new definitions DIGIT [0-9] VALID [a-zA-Z] How can I rewrite the IDENTIFIER rule to use the DIGIT and VALID definitions? ...
TITLE: flex (lexical analyzer) regular expressions - Reusing definitions QUESTION: I have this working definition: IDENTIFIER [a-zA-Z][a-zA-Z0-9]* I don't want to keep repeating the [a-zA-Z] and [0-9], so I made two new definitions DIGIT [0-9] VALID [a-zA-Z] How can I rewrite the IDENTIFIER rule to use the DIGIT and V...
[ "regex", "flex-lexer", "lexical-analysis" ]
1
4
2,525
2
0
2008-10-07T15:15:58.303000
2008-10-07T15:30:43.937000
178,964
179,015
After submitting a POST form open a new window showing the result
JavaScript post request like a form submit shows you how to submit a form that you create via POST in JavaScript. Below is my modified code. var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttribute("action", "test.jsp"); var hiddenField = document.createElement("input"); hidd...
Add or form.setAttribute("target", "_blank"); to your form's definition.
After submitting a POST form open a new window showing the result JavaScript post request like a form submit shows you how to submit a form that you create via POST in JavaScript. Below is my modified code. var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttribute("action", "tes...
TITLE: After submitting a POST form open a new window showing the result QUESTION: JavaScript post request like a form submit shows you how to submit a form that you create via POST in JavaScript. Below is my modified code. var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttrib...
[ "javascript", "html", "post" ]
153
225
296,981
5
0
2008-10-07T15:16:01.567000
2008-10-07T15:23:31.410000
178,973
179,120
How fast is a log4net logging method (Debug, Info, etc)?
I'm a big fan of log4net, but recently, some (in my department) have questioned its inclusion in our projects because of the seemingly heaviness of each logging method. I would argue that there are better techniques than others, but that's another question. I'm curious to know, what is the typical impact of a log4net D...
I am not familiar with log4net, or log.DebugFormat(...). But the cost of logging is really in two areas. The first is the logging call, and the second is the actual persisting of the log information. The guards help reduce the logging call to a minimum when the logging is not actually necessary. It tends to be very fas...
How fast is a log4net logging method (Debug, Info, etc)? I'm a big fan of log4net, but recently, some (in my department) have questioned its inclusion in our projects because of the seemingly heaviness of each logging method. I would argue that there are better techniques than others, but that's another question. I'm c...
TITLE: How fast is a log4net logging method (Debug, Info, etc)? QUESTION: I'm a big fan of log4net, but recently, some (in my department) have questioned its inclusion in our projects because of the seemingly heaviness of each logging method. I would argue that there are better techniques than others, but that's anoth...
[ "performance", "logging", "log4net" ]
6
11
6,260
4
0
2008-10-07T15:17:35.667000
2008-10-07T15:44:24.580000
178,976
178,990
Sanitizing Database Return Data
I am wondering what everyone thinks the best method of handling results from your own database is. Other teams may be involved and there is always the chance the procedure/data could be altered and erroneous results would occur. My question is this. Is it better to let and exception occur, catch and log it or try to ha...
Personally I like failing fast - with an appropriately apologetic user message, of course. There are some things it's worth recovering from, but something like a column you expect to be non-null being null sounds more significant to me. Of course, I'd also try to set up some smoke tests to make sure you find out about ...
Sanitizing Database Return Data I am wondering what everyone thinks the best method of handling results from your own database is. Other teams may be involved and there is always the chance the procedure/data could be altered and erroneous results would occur. My question is this. Is it better to let and exception occu...
TITLE: Sanitizing Database Return Data QUESTION: I am wondering what everyone thinks the best method of handling results from your own database is. Other teams may be involved and there is always the chance the procedure/data could be altered and erroneous results would occur. My question is this. Is it better to let ...
[ "c#", "asp.net", "sql", "database", "exception" ]
2
4
288
4
0
2008-10-07T15:17:54.853000
2008-10-07T15:19:37.673000
178,977
179,246
Using the same asp panel in multiple tabs
In the Ajax toolkit you can use a Tab Container and add TabPanels to this. I have some controls that I want to be able to use across all tabs and the tailor the tabs with other controls as neccessary. My question is how do I reuse a panel on multiple tabs? Essentially I after something like this //other controls here /...
Make the panel a user control and then drop the user control in each tab panel.
Using the same asp panel in multiple tabs In the Ajax toolkit you can use a Tab Container and add TabPanels to this. I have some controls that I want to be able to use across all tabs and the tailor the tabs with other controls as neccessary. My question is how do I reuse a panel on multiple tabs? Essentially I after s...
TITLE: Using the same asp panel in multiple tabs QUESTION: In the Ajax toolkit you can use a Tab Container and add TabPanels to this. I have some controls that I want to be able to use across all tabs and the tailor the tabs with other controls as neccessary. My question is how do I reuse a panel on multiple tabs? Ess...
[ "asp.net", "vb.net" ]
0
1
2,490
2
0
2008-10-07T15:17:56.100000
2008-10-07T16:14:40.557000
178,993
179,329
What are some good techniques for logging your applications?
Logging can get complicated, quickly. Considering that you have some code, how do you add logging to it? What library(ies) do you use? What are some good code techniques for getting the most out of your logging statements while having minimal impact on your application?
Some aspects I would like to add about logging practices. Make it a practice to separate functional logging from development logging. In a production environment, functional logging may involve a DBMS or some other resource. We can achieve this by writing a wrappers on actual logger. In a multi-user environment, log st...
What are some good techniques for logging your applications? Logging can get complicated, quickly. Considering that you have some code, how do you add logging to it? What library(ies) do you use? What are some good code techniques for getting the most out of your logging statements while having minimal impact on your a...
TITLE: What are some good techniques for logging your applications? QUESTION: Logging can get complicated, quickly. Considering that you have some code, how do you add logging to it? What library(ies) do you use? What are some good code techniques for getting the most out of your logging statements while having minima...
[ "logging" ]
6
0
1,661
5
0
2008-10-07T15:20:36.063000
2008-10-07T16:35:25.493000
179,004
179,116
How to manage shared libraries?
Every time I make a project I develop several generic routines/modules/libraries that I expect I'll be using with other projects. Due to the speed of development I don't spend a lot of time making these modules perfect - just good enough for this project, and well enough documented and isolatable that I can easily add ...
If you're using Subversion for all your projects, you can simply use svn:externals: this allows one repository to reference another repository, optionally fixed at a particular revision. For example, svn://svn/shared svn://svn/project1 |- dir1 |- dir2 \- svn:externals "shared -r 3 svn://svn/shared" svn://svn/project2 |...
How to manage shared libraries? Every time I make a project I develop several generic routines/modules/libraries that I expect I'll be using with other projects. Due to the speed of development I don't spend a lot of time making these modules perfect - just good enough for this project, and well enough documented and i...
TITLE: How to manage shared libraries? QUESTION: Every time I make a project I develop several generic routines/modules/libraries that I expect I'll be using with other projects. Due to the speed of development I don't spend a lot of time making these modules perfect - just good enough for this project, and well enoug...
[ "version-control" ]
9
11
2,598
4
0
2008-10-07T15:22:21.177000
2008-10-07T15:44:02.787000
179,014
179,061
How to change envelope from address using PHP mail?
I am using PHP with Apache on Linux, with Sendmail. I use the PHP mail function. The email is sent, but the envelope has the Apache_user@localhostname in MAIL FROM (example nobody@conniptin.internal) and some remote mail servers reject this because the domain doesn't exist (obviously). Using mail, can I force it to cha...
mail() has a 4th and 5th parameter (optional). The 5th argument is what should be passed as options directly to sendmail. I use the following: mail('to@blah.com','subject!','body!','From: from@blah.com','-f from@blah.com');
How to change envelope from address using PHP mail? I am using PHP with Apache on Linux, with Sendmail. I use the PHP mail function. The email is sent, but the envelope has the Apache_user@localhostname in MAIL FROM (example nobody@conniptin.internal) and some remote mail servers reject this because the domain doesn't ...
TITLE: How to change envelope from address using PHP mail? QUESTION: I am using PHP with Apache on Linux, with Sendmail. I use the PHP mail function. The email is sent, but the envelope has the Apache_user@localhostname in MAIL FROM (example nobody@conniptin.internal) and some remote mail servers reject this because t...
[ "php", "email" ]
38
78
78,292
6
0
2008-10-07T15:23:28.150000
2008-10-07T15:31:06.450000