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
147,650
147,768
Debug Pylons application through Eclipse
I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp?
Create a new launch configuration (Python Run) Main tab Use paster-script.py as main module (you can find it in the Scripts sub-directory in your python installation directory) Don't forget to add the root folder of your application in the PYTHONPATH zone Arguments Set the base directory to the root folder also. As Pro...
Debug Pylons application through Eclipse I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp?
TITLE: Debug Pylons application through Eclipse QUESTION: I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? ANSWER: Create a new launch c...
[ "python", "eclipse", "pylons", "pydev", "pyramid" ]
11
10
5,200
7
0
2008-09-29T05:41:00.353000
2008-09-29T07:03:33.540000
147,657
148,108
How to make RightToLeftLayout work for controls inside GroupBoxes and Panels?
According to MSDN form.RightToLeftLayout = True; form.RightToLeft = ifWeWantRTL()? RightToLeft.True: RightToLeft.False; is enough to mirrow the form content for RTL languages. But controls placement gets mirrowed only for controls immediately on the form, those inside a GroupBox or a Panel are not mirrowed, unless I pu...
It does seen that you have quite a nasty problem on your hands. Have played with it for a while and come up with the following: Making use of a little recursion you can run though all the controls and do the manaul RTL conversion for those controls trapped in Pannels and GroupBoxes. This is a quick little mock of code ...
How to make RightToLeftLayout work for controls inside GroupBoxes and Panels? According to MSDN form.RightToLeftLayout = True; form.RightToLeft = ifWeWantRTL()? RightToLeft.True: RightToLeft.False; is enough to mirrow the form content for RTL languages. But controls placement gets mirrowed only for controls immediately...
TITLE: How to make RightToLeftLayout work for controls inside GroupBoxes and Panels? QUESTION: According to MSDN form.RightToLeftLayout = True; form.RightToLeft = ifWeWantRTL()? RightToLeft.True: RightToLeft.False; is enough to mirrow the form content for RTL languages. But controls placement gets mirrowed only for co...
[ ".net", "winforms", "localization" ]
5
8
3,084
4
0
2008-09-29T05:46:31.400000
2008-09-29T09:38:47.457000
147,659
147,662
Get list of databases from SQL Server
How can I get the list of available databases on a SQL Server instance? I'm planning to make a list of them in a combo box in VB.NET.
Execute: SELECT name FROM master.sys.databases This the preferred approach now, rather than dbo.sysdatabases, which has been deprecated for some time. Execute this query: SELECT name FROM master.dbo.sysdatabases or if you prefer EXEC sp_databases
Get list of databases from SQL Server How can I get the list of available databases on a SQL Server instance? I'm planning to make a list of them in a combo box in VB.NET.
TITLE: Get list of databases from SQL Server QUESTION: How can I get the list of available databases on a SQL Server instance? I'm planning to make a list of them in a combo box in VB.NET. ANSWER: Execute: SELECT name FROM master.sys.databases This the preferred approach now, rather than dbo.sysdatabases, which has b...
[ "sql-server" ]
477
753
1,096,492
15
0
2008-09-29T05:50:14.077000
2008-09-29T05:51:08.723000
147,661
147,686
Is there a decent open-source gaming console
I've got a young nephew who aspires to grow up to be a game programmer and i'd like to introduce him to the world of open-source as well as get him a sweet gift. Anything like that out there?
Well, this is a tricky question because we don't know the level your nephew is at, nevermind the fact that it's difficult to produce a very nice showy game without a lot more work than a beginner might put forth. X Game Station Nevertheless, André LaMothe's X Game Station is meant to be exactly the system you're asking...
Is there a decent open-source gaming console I've got a young nephew who aspires to grow up to be a game programmer and i'd like to introduce him to the world of open-source as well as get him a sweet gift. Anything like that out there?
TITLE: Is there a decent open-source gaming console QUESTION: I've got a young nephew who aspires to grow up to be a game programmer and i'd like to introduce him to the world of open-source as well as get him a sweet gift. Anything like that out there? ANSWER: Well, this is a tricky question because we don't know th...
[ "open-source" ]
10
14
5,254
10
0
2008-09-29T05:51:07.693000
2008-09-29T06:10:49.017000
147,669
147,785
Why does regasm.exe register my c# assembly with the wrong GUID?
I've got a c# assembly which I'm invoking via COM from a Delphi (win32 native) application. This works on all the machines I've tested it on, except one. The problem is that the Delphi application gets "Class not registered" when trying to create the COM object. Now, when I look in the registry under HKEY_CLASSES_ROOT\...
The GUID in AssemblyInfo becomes the "Type-Library" GUID and usually is not what you'd be looking for. I'm going to assume you're trying to access a class, and you need to define a Guid attribute and ComVisible for the class. For example: [Guid("00001111-2222-3333-4444-555566667777"), ComVisible(true)] public class MyC...
Why does regasm.exe register my c# assembly with the wrong GUID? I've got a c# assembly which I'm invoking via COM from a Delphi (win32 native) application. This works on all the machines I've tested it on, except one. The problem is that the Delphi application gets "Class not registered" when trying to create the COM ...
TITLE: Why does regasm.exe register my c# assembly with the wrong GUID? QUESTION: I've got a c# assembly which I'm invoking via COM from a Delphi (win32 native) application. This works on all the machines I've tested it on, except one. The problem is that the Delphi application gets "Class not registered" when trying ...
[ "c#", ".net", "delphi", "com", "regasm" ]
11
12
6,539
3
0
2008-09-29T05:56:51.080000
2008-09-29T07:13:04.097000
147,670
147,680
Get list of available servers in SQL server group
How can I extract the list of available SQL servers in an SQL server group? I'm planning to put that list in a combo box in VB.NET.
The only way I knew to do it was using the command line: osql -L But I found the below article which seems to solve your specific goal filling a combobox: http://www.sqldbatips.com/showarticle.asp?ID=45
Get list of available servers in SQL server group How can I extract the list of available SQL servers in an SQL server group? I'm planning to put that list in a combo box in VB.NET.
TITLE: Get list of available servers in SQL server group QUESTION: How can I extract the list of available SQL servers in an SQL server group? I'm planning to put that list in a combo box in VB.NET. ANSWER: The only way I knew to do it was using the command line: osql -L But I found the below article which seems to s...
[ "sql", "vb.net" ]
3
5
11,903
3
0
2008-09-29T05:57:03.357000
2008-09-29T06:04:56.473000
147,671
147,712
What's the best way to deploy a JRuby on Rails application to Tomcat?
I'm looking at ways to deploy a Ruby on Rails app (running on JRuby) to a Tomcat instance for testing. The tomcat instance is running on a Solaris server that I can SSH to. I've looked at using Capistrano, but there doesn't seem to be a lot out there about using it to deploy to Tomcat, or even about running it under JR...
I don't have much experience on this, so I don't know if I can give you the BEST way, but if Capistrano doesn't work, and you can't have a separate MRI install just to run it, you have just a few alternatives left: Try running plain Rake and write your own deployment target: http://www.gra2.com/article.php/deploy-ruby-...
What's the best way to deploy a JRuby on Rails application to Tomcat? I'm looking at ways to deploy a Ruby on Rails app (running on JRuby) to a Tomcat instance for testing. The tomcat instance is running on a Solaris server that I can SSH to. I've looked at using Capistrano, but there doesn't seem to be a lot out there...
TITLE: What's the best way to deploy a JRuby on Rails application to Tomcat? QUESTION: I'm looking at ways to deploy a Ruby on Rails app (running on JRuby) to a Tomcat instance for testing. The tomcat instance is running on a Solaris server that I can SSH to. I've looked at using Capistrano, but there doesn't seem to ...
[ "ruby-on-rails", "ruby", "tomcat", "jruby", "capistrano" ]
10
3
5,410
5
0
2008-09-29T05:58:39.437000
2008-09-29T06:31:13.883000
147,684
147,698
Page working in FF, not in IE, where to start
I have a page which is largely created by DOM script, which generates a table of images (normal img elements) from several webcams (helping out a friend with a pet boarding and my HTML/DOM is a bit rusty). It works fine in FF3 or Chrome, but not in IE7, In fact, the whole table is not visible in IE (but the body backgr...
One gotcha I found is that in IE, if you dynamically create tables using document.createElement(), you need table(tbody(tr(tds))). Without a tbody, the table will not show.
Page working in FF, not in IE, where to start I have a page which is largely created by DOM script, which generates a table of images (normal img elements) from several webcams (helping out a friend with a pet boarding and my HTML/DOM is a bit rusty). It works fine in FF3 or Chrome, but not in IE7, In fact, the whole t...
TITLE: Page working in FF, not in IE, where to start QUESTION: I have a page which is largely created by DOM script, which generates a table of images (normal img elements) from several webcams (helping out a friend with a pet boarding and my HTML/DOM is a bit rusty). It works fine in FF3 or Chrome, but not in IE7, In...
[ "html", "css", "dom" ]
3
3
747
4
0
2008-09-29T06:09:50.567000
2008-09-29T06:21:31.300000
147,706
149,896
Change the resolution of image in iPhone?
I wanted to change the resolution of a image,this image I am getting from remote location.The image I am getting is too large to fit in iPhone screen is their any way to change that resolution?
If you're using a UIImageView then UIView's contentMode is what you need, you should probably set it to UIViewContentModeScaleAspectFit (or the equivalent in Interface Builder).
Change the resolution of image in iPhone? I wanted to change the resolution of a image,this image I am getting from remote location.The image I am getting is too large to fit in iPhone screen is their any way to change that resolution?
TITLE: Change the resolution of image in iPhone? QUESTION: I wanted to change the resolution of a image,this image I am getting from remote location.The image I am getting is too large to fit in iPhone screen is their any way to change that resolution? ANSWER: If you're using a UIImageView then UIView's contentMode i...
[ "iphone", "cocoa-touch" ]
0
1
2,488
4
0
2008-09-29T06:27:53.063000
2008-09-29T17:59:05.150000
147,713
147,736
How do I manipulate bits in Python?
In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python?
Bitwise operations on Python ints work much like in C. The &, | and ^ operators in Python work just like in C. The ~ operator works as for a signed integer in C; that is, ~x computes -x-1. You have to be somewhat careful with left shifts, since Python integers aren't fixed-width. Use bit masks to obtain the low order b...
How do I manipulate bits in Python? In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python?
TITLE: How do I manipulate bits in Python? QUESTION: In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python? ANSWER: Bitwise operations on Python ints work much like in C. The &, | and ^ operators in Python work j...
[ "python" ]
42
59
70,352
9
0
2008-09-29T06:31:27.423000
2008-09-29T06:45:34.347000
147,726
147,775
Saving a SecureString
One of the feature requests I've got for the program I'm working on is to be able to save the list of credentials users enter in, so they can be shared around. The specific use case that inspired this request was using our program on a large corporate network, made up of fairly good LANs connected by a flaky WAN. The i...
There is no save support in SecureString, it's intended as a mechanism to protect a in-memory managed string and is only used for interfacing with unmanaged APIs. If a password was stored in a System.String instance, security would be less due to the nature of System.String. The existence of garbage collection and inte...
Saving a SecureString One of the feature requests I've got for the program I'm working on is to be able to save the list of credentials users enter in, so they can be shared around. The specific use case that inspired this request was using our program on a large corporate network, made up of fairly good LANs connected...
TITLE: Saving a SecureString QUESTION: One of the feature requests I've got for the program I'm working on is to be able to save the list of credentials users enter in, so they can be shared around. The specific use case that inspired this request was using our program on a large corporate network, made up of fairly g...
[ ".net", "securestring" ]
9
5
19,520
7
0
2008-09-29T06:38:35.817000
2008-09-29T07:06:37.947000
147,741
147,756
Character reading from file in Python
In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do the reading. Now, is it possible to read the string in such ...
Ref: http://docs.python.org/howto/unicode Reading Unicode from a file is therefore simple: import codecs with codecs.open('unicode.rst', encoding='utf-8') as f: for line in f: print repr(line) It's also possible to open files in update mode, allowing both reading and writing: with codecs.open('test', encoding='utf-8', ...
Character reading from file in Python In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do the reading. Now, is i...
TITLE: Character reading from file in Python QUESTION: In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do the ...
[ "python", "unicode", "encoding", "ascii" ]
122
196
309,226
9
0
2008-09-29T06:47:47.900000
2008-09-29T06:55:23.980000
147,747
147,759
Return "correct" error code, or protect privacy?
OK, probably best to give an example here of what I mean. Imagine a web based forum system, where the user authentication is done by some external method, which the system is aware of. Now, say for example, a user enters the URL for a thread that they do not have access to. For this should I return a 403 (Forbidden), l...
Above everything else, comply with HTTP spec. Returning 403 in place of 404 is not a good thing. Returning 404 in place of 403 probably is ok (or not a big blunder), but I would just let the software tell the truth. If user only knows the ID of a topic, it's not much anyway. And he could try timing attacks to determine...
Return "correct" error code, or protect privacy? OK, probably best to give an example here of what I mean. Imagine a web based forum system, where the user authentication is done by some external method, which the system is aware of. Now, say for example, a user enters the URL for a thread that they do not have access ...
TITLE: Return "correct" error code, or protect privacy? QUESTION: OK, probably best to give an example here of what I mean. Imagine a web based forum system, where the user authentication is done by some external method, which the system is aware of. Now, say for example, a user enters the URL for a thread that they d...
[ "security", "authentication" ]
3
5
671
9
0
2008-09-29T06:51:02.183000
2008-09-29T06:57:52.383000
147,752
147,793
In Django is there a way to display choices as checkboxes?
In the admin interface and newforms there is the brilliant helper of being able to define choices. You can use code like this: APPROVAL_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), ('cancelled', 'Cancelled'), ) client_approved = models.CharField(choices=APPROVAL_CHOICES) to create a drop down box in your form and force t...
In terms of the forms library, you would use the MultipleChoiceField field with a CheckboxSelectMultiple widget to do that. You could validate the number of choices which were made by writing a validation method for the field: class MyForm(forms.Form): my_field = forms.MultipleChoiceField(choices=SOME_CHOICES, widget=f...
In Django is there a way to display choices as checkboxes? In the admin interface and newforms there is the brilliant helper of being able to define choices. You can use code like this: APPROVAL_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), ('cancelled', 'Cancelled'), ) client_approved = models.CharField(choices=APPROVAL_...
TITLE: In Django is there a way to display choices as checkboxes? QUESTION: In the admin interface and newforms there is the brilliant helper of being able to define choices. You can use code like this: APPROVAL_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), ('cancelled', 'Cancelled'), ) client_approved = models.CharField...
[ "python", "django" ]
54
93
43,374
2
0
2008-09-29T06:53:13.083000
2008-09-29T07:17:46.533000
147,767
154,312
How to be successful in web user interface testing?
We are setting up a Selenium test campaign on a big web application. The first thing we've done was to build a framework which initialize SQL data in database before the test, launch the test, archive results and then clear data. We've integrate that in a Maven 2 process, run every day by TeamCity on a dedicated databa...
Testability helps a lot. The biggest win for testability in web apps is if all of the HTML elements you need to interact with on the page have unique and consistent attributes. If the attributes you are using to identify the HTML elements (Selenium uses xpath) are not consistent/reliable from build-to-build, or session...
How to be successful in web user interface testing? We are setting up a Selenium test campaign on a big web application. The first thing we've done was to build a framework which initialize SQL data in database before the test, launch the test, archive results and then clear data. We've integrate that in a Maven 2 proc...
TITLE: How to be successful in web user interface testing? QUESTION: We are setting up a Selenium test campaign on a big web application. The first thing we've done was to build a framework which initialize SQL data in database before the test, launch the test, archive results and then clear data. We've integrate that...
[ "user-interface", "testing", "selenium", "automated-tests" ]
3
1
1,151
3
0
2008-09-29T07:03:28.407000
2008-09-30T18:24:55.767000
147,777
337,815
MS VC++ 6 class wizard
Ok, I'm developing an application that has been in pretty much continous development over the last 16 years, from C in DOS, through various flavours of C++ and now is largely based around C++ with MFC and StingRay GUIs and various other SDKs. While I use VS 2005 for the release builds, I still use MSVC 6 for much of th...
A follow up to those who are interested. ClassWizard may be re-introduced in VS2010, from Tarek Madkour [VC++ Team] 'We are considering adding the Class Wizard back to VS10. We hope this will make DDX/DDV function creation more keyboard-centric just like it was in VC6. There are some schedule challenges that we will ne...
MS VC++ 6 class wizard Ok, I'm developing an application that has been in pretty much continous development over the last 16 years, from C in DOS, through various flavours of C++ and now is largely based around C++ with MFC and StingRay GUIs and various other SDKs. While I use VS 2005 for the release builds, I still us...
TITLE: MS VC++ 6 class wizard QUESTION: Ok, I'm developing an application that has been in pretty much continous development over the last 16 years, from C in DOS, through various flavours of C++ and now is largely based around C++ with MFC and StingRay GUIs and various other SDKs. While I use VS 2005 for the release ...
[ "mfc", "visual-c++-6", "classwizard" ]
2
3
2,289
5
0
2008-09-29T07:08:11.657000
2008-12-03T16:40:54.510000
147,798
220,108
Is there a SAPI module for PHP 5 for supporting the thttpd web server?
Is there a SAPI module for PHP 5 for supporting the thttpd web server? Oddly, the one included on PHP 5.2.6 source is for PHP 4.x. Thanks, Kenneth
The thttpd SAPI that ships with PHP 5 works. Ignore the README where it says "PHP 4". However, understand that PHP for thttpd is single-threaded. All other requests will stall while PHP is executing. This is might be acceptable for a low traffic site or embedded application. If not, I recommend trying nginx, another li...
Is there a SAPI module for PHP 5 for supporting the thttpd web server? Is there a SAPI module for PHP 5 for supporting the thttpd web server? Oddly, the one included on PHP 5.2.6 source is for PHP 4.x. Thanks, Kenneth
TITLE: Is there a SAPI module for PHP 5 for supporting the thttpd web server? QUESTION: Is there a SAPI module for PHP 5 for supporting the thttpd web server? Oddly, the one included on PHP 5.2.6 source is for PHP 4.x. Thanks, Kenneth ANSWER: The thttpd SAPI that ships with PHP 5 works. Ignore the README where it say...
[ "php", "sapi", "thttpd" ]
1
2
1,410
1
0
2008-09-29T07:20:21.190000
2008-10-20T22:00:12.307000
147,801
147,814
Best way to parse float?
What is the best way to parse a float in CSharp? I know about TryParse, but what I'm particularly wondering about is dots, commas etc. I'm having problems with my website. On my dev server, the ',' is for decimals, the '.' for separator. On the prod server though, it is the other way round. How can I best capture this?
Depends where the input is coming from. If your input comes from the user, you should use the CultureInfo the user/page is using ( Thread.CurrentThread.CurrentUICulture ). You can get and indication of the culture of the user, by looking at the HttpRequest.UserLanguages property. (Not correct 100%, but I've found it a ...
Best way to parse float? What is the best way to parse a float in CSharp? I know about TryParse, but what I'm particularly wondering about is dots, commas etc. I'm having problems with my website. On my dev server, the ',' is for decimals, the '.' for separator. On the prod server though, it is the other way round. How...
TITLE: Best way to parse float? QUESTION: What is the best way to parse a float in CSharp? I know about TryParse, but what I'm particularly wondering about is dots, commas etc. I'm having problems with my website. On my dev server, the ',' is for decimals, the '.' for separator. On the prod server though, it is the ot...
[ "c#", "parsing", "floating-point", "currentculture" ]
51
28
117,504
11
0
2008-09-29T07:23:43.803000
2008-09-29T07:31:11.120000
147,802
147,898
Why does Swing in my Java Applet flicker on fast mouse over?
I made a Java Applet with some Standard GUI Components on it. I used the MigLayout Manager. If I move the mouse slowly over the various GUI Components everything appears to be fine, but if I move the mouse fast, it flickers. What could make that nasty ugly redraw? (Core 2 Duo 6300, 2GB Ram, Windows XP)
One thought would be to check your code (and/or the MigLayout code) for unnecessary repaint() operations. Custom UIs and layouts can cause weird problems sometimes...
Why does Swing in my Java Applet flicker on fast mouse over? I made a Java Applet with some Standard GUI Components on it. I used the MigLayout Manager. If I move the mouse slowly over the various GUI Components everything appears to be fine, but if I move the mouse fast, it flickers. What could make that nasty ugly re...
TITLE: Why does Swing in my Java Applet flicker on fast mouse over? QUESTION: I made a Java Applet with some Standard GUI Components on it. I used the MigLayout Manager. If I move the mouse slowly over the various GUI Components everything appears to be fine, but if I move the mouse fast, it flickers. What could make ...
[ "java", "swing", "applet" ]
2
3
1,216
3
0
2008-09-29T07:25:14.393000
2008-09-29T08:14:40.967000
147,816
147,878
Preserving signatures of decorated functions
Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): args = [int(x) for x in args] kwargs = dict((k, int(v)) for k, v in kwargs.it...
Install decorator module: $ pip install decorator Adapt definition of args_as_ints(): import decorator @decorator.decorator def args_as_ints(f, *args, **kwargs): args = [int(x) for x in args] kwargs = dict((k, int(v)) for k, v in kwargs.items()) return f(*args, **kwargs) @args_as_ints def funny_function(x, y, z=3): "...
Preserving signatures of decorated functions Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): args = [int(x) for x in args] kw...
TITLE: Preserving signatures of decorated functions QUESTION: Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): args = [int(x)...
[ "python", "decorator" ]
144
106
27,294
8
0
2008-09-29T07:32:55.873000
2008-09-29T08:08:30.187000
147,821
150,091
Loading .sql files from within PHP
I'm creating an installation script for an application that I'm developing and need to create databases dynamically from within PHP. I've got it to create the database but now I need to load in several.sql files. I had planned to open the file and mysql_query it a line at a time - until I looked at the schema files and...
I'm getting the feeling that everyone here who's answered this question doesn't know what it's like to be a web application developer who allows people to install the application on their own servers. Shared hosting, especially, doesn't allow you to use SQL like the "LOAD DATA" query mentioned previously. Most shared h...
Loading .sql files from within PHP I'm creating an installation script for an application that I'm developing and need to create databases dynamically from within PHP. I've got it to create the database but now I need to load in several.sql files. I had planned to open the file and mysql_query it a line at a time - unt...
TITLE: Loading .sql files from within PHP QUESTION: I'm creating an installation script for an application that I'm developing and need to create databases dynamically from within PHP. I've got it to create the database but now I need to load in several.sql files. I had planned to open the file and mysql_query it a li...
[ "php", "sql", "mysql", "import", "scripting" ]
79
55
160,383
31
0
2008-09-29T07:38:09.323000
2008-09-29T18:48:05.033000
147,824
148,613
How to find whether a particular string has unicode characters (esp. Double Byte characters)
To be more precise, I need to know whether (and if possible, how) I can find whether a given string has double byte characters or not. Basically, I need to open a pop-up to display a given text which can contain double byte characters, like Chinese or Japanese. In this case, we need to adjust the window size than it wo...
JavaScript holds text internally as UCS-2, which can encode a fairly extensive subset of Unicode. But that's not really germane to your question. One solution might be to loop through the string and examine the character codes at each position: function isDoubleByte(str) { for (var i = 0, n = str.length; i < n; i++) { ...
How to find whether a particular string has unicode characters (esp. Double Byte characters) To be more precise, I need to know whether (and if possible, how) I can find whether a given string has double byte characters or not. Basically, I need to open a pop-up to display a given text which can contain double byte cha...
TITLE: How to find whether a particular string has unicode characters (esp. Double Byte characters) QUESTION: To be more precise, I need to know whether (and if possible, how) I can find whether a given string has double byte characters or not. Basically, I need to open a pop-up to display a given text which can conta...
[ "javascript", "unicode", "double-byte" ]
39
34
52,557
6
0
2008-09-29T07:39:58.600000
2008-09-29T13:18:00.100000
147,837
149,084
CouchDB modeling for multi-user
I am already excited about document databases and especially about CouchDB's simplicity. But I have a hard time understanding if such databases are a viable option for multi user systems. Since those systems require some kind of relations between records which document databases do not provide. Is it completely the wro...
There was a discussion on the mailing list awhile back that fits this question fairly well. The rule of thumb was to only store data in a document that is likely to change vs. grow. If the data is more likely to grow then you most likely want to store separate docs. So in the case of a multi-user system one way of impl...
CouchDB modeling for multi-user I am already excited about document databases and especially about CouchDB's simplicity. But I have a hard time understanding if such databases are a viable option for multi user systems. Since those systems require some kind of relations between records which document databases do not p...
TITLE: CouchDB modeling for multi-user QUESTION: I am already excited about document databases and especially about CouchDB's simplicity. But I have a hard time understanding if such databases are a viable option for multi user systems. Since those systems require some kind of relations between records which document ...
[ "database-design", "couchdb" ]
7
9
4,052
3
0
2008-09-29T07:43:53.663000
2008-09-29T15:09:09.490000
147,850
147,890
When using ANT, how can I define a task only if I have some specific java version?
I have the problem that an specific step in Ant can only be executed when we have Java 1.5 installed in the build computer. The task definition uses uses a jar file that was compiled using 1.5, so running with a 1.4 virtual machine will throw an IncompatibleClassVersion exception. I have to find a solution meanwhile to...
The Java version is exposed via the ant.java.version property. Use a condition to set a property and execute the task only if it is true.
When using ANT, how can I define a task only if I have some specific java version? I have the problem that an specific step in Ant can only be executed when we have Java 1.5 installed in the build computer. The task definition uses uses a jar file that was compiled using 1.5, so running with a 1.4 virtual machine will ...
TITLE: When using ANT, how can I define a task only if I have some specific java version? QUESTION: I have the problem that an specific step in Ant can only be executed when we have Java 1.5 installed in the build computer. The task definition uses uses a jar file that was compiled using 1.5, so running with a 1.4 vir...
[ "java", "ant", "conditional-statements" ]
5
10
4,113
2
0
2008-09-29T07:52:36.370000
2008-09-29T08:10:54.627000
147,859
148,329
Customization of Hibernate sequence generation
I have one hibernate sequence, that generates all sequence-numbers in my app. When I generate the schemas from hibernate (target Oracle10), it genererates: create sequence hibernate_sequence; I would like to change the configuration of the sequence. I have to use something like: create sequence hibernate_sequence order...
You can create a custom sequence generator. See http://www.hibernate.org/296.html for details.
Customization of Hibernate sequence generation I have one hibernate sequence, that generates all sequence-numbers in my app. When I generate the schemas from hibernate (target Oracle10), it genererates: create sequence hibernate_sequence; I would like to change the configuration of the sequence. I have to use something...
TITLE: Customization of Hibernate sequence generation QUESTION: I have one hibernate sequence, that generates all sequence-numbers in my app. When I generate the schemas from hibernate (target Oracle10), it genererates: create sequence hibernate_sequence; I would like to change the configuration of the sequence. I hav...
[ "java", "hibernate" ]
2
2
6,705
1
0
2008-09-29T07:56:45.677000
2008-09-29T11:32:55.063000
147,867
148,015
What is your favourite Java Script WYSIWYG Editor component?
I definitifely like the one at stackoverflow, because it's clean and simple. Also the live preview with code/syntax hilighting is really helpful (and motivating). What is your favourite Javascript Editor Framework and why?
I like widgEditor because it's very simple and it only do the minimum. TinyMCE or FCKeditor are goods, but they are too big for what I need.
What is your favourite Java Script WYSIWYG Editor component? I definitifely like the one at stackoverflow, because it's clean and simple. Also the live preview with code/syntax hilighting is really helpful (and motivating). What is your favourite Javascript Editor Framework and why?
TITLE: What is your favourite Java Script WYSIWYG Editor component? QUESTION: I definitifely like the one at stackoverflow, because it's clean and simple. Also the live preview with code/syntax hilighting is really helpful (and motivating). What is your favourite Javascript Editor Framework and why? ANSWER: I like wi...
[ "javascript", "html", "editor", "textarea", "wysiwyg" ]
5
4
2,519
8
0
2008-09-29T08:03:46.487000
2008-09-29T09:00:07.193000
147,875
147,900
How to convert generic dictionary to non-generic without enumerating?
I want to convert an instance of generic IDictionary<,> to non generic IDictionary. Can I do it without creating new instance of IDictionary? Is any framework support for this task? I tried wrapping the generic IDictionary<,> in a class that implements nongenetic IDictionary however I discovered that I then have to als...
It all depends on the concrete implementation you are using. For example, Dictionary implements both the generic IDictionary and the non-generic IDictionary - so if you have a Dictionary you can use it as either without issue: Dictionary lookup = new Dictionary (); IDictionary typed = lookup; IDictionary untyped = look...
How to convert generic dictionary to non-generic without enumerating? I want to convert an instance of generic IDictionary<,> to non generic IDictionary. Can I do it without creating new instance of IDictionary? Is any framework support for this task? I tried wrapping the generic IDictionary<,> in a class that implemen...
TITLE: How to convert generic dictionary to non-generic without enumerating? QUESTION: I want to convert an instance of generic IDictionary<,> to non generic IDictionary. Can I do it without creating new instance of IDictionary? Is any framework support for this task? I tried wrapping the generic IDictionary<,> in a c...
[ ".net", "collections" ]
9
21
5,529
1
0
2008-09-29T08:07:27.710000
2008-09-29T08:16:29.823000
147,897
148,877
In SQL Server can I insert multiple nodes into XML from a table?
I want to generate some XML in a stored procedure based on data in a table. The following insert allows me to add many nodes but they have to be hard-coded or use variables (sql:variable): SET @MyXml.modify(' insert {sql:variable("@MyVariable")} into (/root[1]) ') So I could loop through each record in my table, put th...
Have you tried nesting FOR XML PATH scalar valued functions? With the nesting technique, you can brake your SQL into very managable/readable elemental pieces Disclaimer: the following, while adapted from a working example, has not itself been literally tested Some reference links for the general audience http://msdn2.m...
In SQL Server can I insert multiple nodes into XML from a table? I want to generate some XML in a stored procedure based on data in a table. The following insert allows me to add many nodes but they have to be hard-coded or use variables (sql:variable): SET @MyXml.modify(' insert {sql:variable("@MyVariable")} into (/ro...
TITLE: In SQL Server can I insert multiple nodes into XML from a table? QUESTION: I want to generate some XML in a stored procedure based on data in a table. The following insert allows me to add many nodes but they have to be hard-coded or use variables (sql:variable): SET @MyXml.modify(' insert {sql:variable("@MyVar...
[ "sql-server", "xml", "t-sql", "insert", "xquery" ]
2
7
21,393
3
0
2008-09-29T08:13:50.673000
2008-09-29T14:21:17.107000
147,908
147,928
How do I databind a ColumnDefinition's Width or RowDefinition's Height?
Under the View-Model-ViewModel pattern for WPF, I am trying to databind the Heights and Widths of various definitions for grid controls, so I can store the values the user sets them to after using a GridSplitter. However, the normal pattern doesn't seem to work for these particular properties. Note: I'm posting this as...
There were a number of gotchas I discovered: Although it may appear like a double in XAML, the actual value for a *Definition's Height or Width is a 'GridLength' struct. All the properties of GridLength are readonly, you have to create a new one each time you change it. Unlike every other property in WPF, Width and Hei...
How do I databind a ColumnDefinition's Width or RowDefinition's Height? Under the View-Model-ViewModel pattern for WPF, I am trying to databind the Heights and Widths of various definitions for grid controls, so I can store the values the user sets them to after using a GridSplitter. However, the normal pattern doesn't...
TITLE: How do I databind a ColumnDefinition's Width or RowDefinition's Height? QUESTION: Under the View-Model-ViewModel pattern for WPF, I am trying to databind the Heights and Widths of various definitions for grid controls, so I can store the values the user sets them to after using a GridSplitter. However, the norm...
[ "wpf", "data-binding", "grid", "column-width", "row-height" ]
41
24
39,244
4
0
2008-09-29T08:18:32.457000
2008-09-29T08:25:28.990000
147,918
148,139
SBCL on Vista crashes. Do you know how to make it work?
I've searched a lot for an answer for this question in the web: they say it's true, SBCL doesn't work under Vista. But I really need to work with lisp on my home Vista laptop and VM doesn't help really... And CL is not so interesting because of speed... If you have any recommendation, please share!
Have you seen these articles? http://robert.zubek.net/blog/2008/04/09/sbcl-emacs-windows-vista/ http://brainrack.wordpress.com/2008/05/29/running-sbcl-on-windows/
SBCL on Vista crashes. Do you know how to make it work? I've searched a lot for an answer for this question in the web: they say it's true, SBCL doesn't work under Vista. But I really need to work with lisp on my home Vista laptop and VM doesn't help really... And CL is not so interesting because of speed... If you hav...
TITLE: SBCL on Vista crashes. Do you know how to make it work? QUESTION: I've searched a lot for an answer for this question in the web: they say it's true, SBCL doesn't work under Vista. But I really need to work with lisp on my home Vista laptop and VM doesn't help really... And CL is not so interesting because of s...
[ "windows-vista", "lisp", "crash", "sbcl" ]
3
5
378
2
0
2008-09-29T08:22:13.710000
2008-09-29T09:52:01.203000
147,920
147,954
Can you create collapsible #Region like scopes in C++ within VS 2008?
I miss it so much (used it a lot in C#). can you do it in C++?
Yes, you can. See here. #pragma region Region_Name //Your content. #pragma endregion Region_Name
Can you create collapsible #Region like scopes in C++ within VS 2008? I miss it so much (used it a lot in C#). can you do it in C++?
TITLE: Can you create collapsible #Region like scopes in C++ within VS 2008? QUESTION: I miss it so much (used it a lot in C#). can you do it in C++? ANSWER: Yes, you can. See here. #pragma region Region_Name //Your content. #pragma endregion Region_Name
[ "c++", "visual-studio", "visual-studio-2008", "pragma", "readability" ]
9
18
4,662
3
0
2008-09-29T08:23:20.433000
2008-09-29T08:34:24.727000
147,925
147,943
What's the best way to get the name of a folder that doesn't exist?
What's the best way to get a string containing a folder name that I can be certain does not exist? That is, if I call DirectoryInfo.Exists for the given path, it should return false. EDIT: The reason behind it is I am writing a test for an error checker, the error checker tests whether the path exists, so I wondered al...
Name it after a GUID - just take out the illegal characters.
What's the best way to get the name of a folder that doesn't exist? What's the best way to get a string containing a folder name that I can be certain does not exist? That is, if I call DirectoryInfo.Exists for the given path, it should return false. EDIT: The reason behind it is I am writing a test for an error checke...
TITLE: What's the best way to get the name of a folder that doesn't exist? QUESTION: What's the best way to get a string containing a folder name that I can be certain does not exist? That is, if I call DirectoryInfo.Exists for the given path, it should return false. EDIT: The reason behind it is I am writing a test f...
[ "c#", "directory" ]
3
9
650
8
0
2008-09-29T08:24:56.263000
2008-09-29T08:29:48.387000
147,929
147,950
C# - Sending messages to Google Chrome from C# application
I've been searching around, and I haven't found how I would do this from C#. I was wanting to make it so I could tell Google Chrome to go Forward, Back, Open New Tab, Close Tab, Open New Window, and Close Window from my C# application. I did something similar with WinAmp using [DllImport("user32", EntryPoint = "SendMes...
Start your research at http://dev.chromium.org/developers EDIT: Sending a message to a window is only half of the work. The window has to respond to that message and act accordingly. If that window doesn't know about a message or doesn't care at all you have no chance to control it by sending window messages. You're lo...
C# - Sending messages to Google Chrome from C# application I've been searching around, and I haven't found how I would do this from C#. I was wanting to make it so I could tell Google Chrome to go Forward, Back, Open New Tab, Close Tab, Open New Window, and Close Window from my C# application. I did something similar w...
TITLE: C# - Sending messages to Google Chrome from C# application QUESTION: I've been searching around, and I haven't found how I would do this from C#. I was wanting to make it so I could tell Google Chrome to go Forward, Back, Open New Tab, Close Tab, Open New Window, and Close Window from my C# application. I did s...
[ "c#", "google-chrome", "message" ]
19
10
25,334
4
0
2008-09-29T08:25:35.480000
2008-09-29T08:33:26.303000
147,941
147,961
How can I read an Http response stream twice in C#?
I am trying to read an Http response stream twice via the following: HttpWebResponse response = (HttpWebResponse)request.GetResponse(); stream = response.GetResponseStream(); RssReader reader = new RssReader(stream); do { element = reader.Read(); if (element is RssChannel) { feed.Channels.Add((RssChannel)element); } } ...
Copy it into a new MemoryStream first. Then you can re-read the MemoryStream as many times as you like: Stream responseStream = CopyAndClose(resp.GetResponseStream()); // Do something with the stream responseStream.Position = 0; // Do something with the stream again private static Stream CopyAndClose(Stream inputStrea...
How can I read an Http response stream twice in C#? I am trying to read an Http response stream twice via the following: HttpWebResponse response = (HttpWebResponse)request.GetResponse(); stream = response.GetResponseStream(); RssReader reader = new RssReader(stream); do { element = reader.Read(); if (element is RssCha...
TITLE: How can I read an Http response stream twice in C#? QUESTION: I am trying to read an Http response stream twice via the following: HttpWebResponse response = (HttpWebResponse)request.GetResponse(); stream = response.GetResponseStream(); RssReader reader = new RssReader(stream); do { element = reader.Read(); if ...
[ "c#", "stream" ]
42
71
37,735
3
0
2008-09-29T08:29:14.600000
2008-09-29T08:36:32.523000
147,953
147,987
What is the best way to list a member and all of its descendants in MDX?
In an OLAP database I work with there is a 'Location' hierarchy consisting of the levels Company, Region, Area, Site, Room, Till. For a particular company I need to write some MDX that lists all regions, areas and sites (but not any levels below Site). Currently I am achieving this with the following MDX HIERARCHIZE({ ...
DESCENDANTS([Location].[Test Company],[Location].[Site], SELF_AND_BEFORE)
What is the best way to list a member and all of its descendants in MDX? In an OLAP database I work with there is a 'Location' hierarchy consisting of the levels Company, Region, Area, Site, Room, Till. For a particular company I need to write some MDX that lists all regions, areas and sites (but not any levels below S...
TITLE: What is the best way to list a member and all of its descendants in MDX? QUESTION: In an OLAP database I work with there is a 'Location' hierarchy consisting of the levels Company, Region, Area, Site, Room, Till. For a particular company I need to write some MDX that lists all regions, areas and sites (but not ...
[ "mdx" ]
3
5
770
2
0
2008-09-29T08:34:20.280000
2008-09-29T08:47:04.900000
147,962
148,167
Dynamic search and display
I have a big load of documents, text-files, that I want to search for relevant content. I've seen a searching tool, can't remeber where, that implemented a nice method as I describe in my requirement below. My requirement is as follows: I need an optimised search function: I supply this search function with a list (one...
What you're talking about is known as an inverted index or posting list, and operates similary to what you propose and what Mecki proposes. There's a lot of literature about inverted indexes out there; the Wikipedia article is a good place to start. Better, rather than trying to build it yourself, use an existing inver...
Dynamic search and display I have a big load of documents, text-files, that I want to search for relevant content. I've seen a searching tool, can't remeber where, that implemented a nice method as I describe in my requirement below. My requirement is as follows: I need an optimised search function: I supply this searc...
TITLE: Dynamic search and display QUESTION: I have a big load of documents, text-files, that I want to search for relevant content. I've seen a searching tool, can't remeber where, that implemented a nice method as I describe in my requirement below. My requirement is as follows: I need an optimised search function: I...
[ "algorithm", "search" ]
1
2
646
4
0
2008-09-29T08:37:04.940000
2008-09-29T10:11:22.917000
147,969
1,261,375
Is it idiomatic Ruby to add an assert( ) method to Ruby's Kernel class?
I'm expanding my Ruby understanding by coding an equivalent of Kent Beck's xUnit in Ruby. Python (which Kent writes in) has an assert() method in the language which is used extensively. Ruby does not. I think it should be easy to add this but is Kernel the right place to put it? BTW, I know of the existence of the vari...
No it's not a best practice. The best analogy to assert() in Ruby is just raising raise "This is wrong" unless expr and you can implement your own exceptions if you want to provide for more specific exception handling
Is it idiomatic Ruby to add an assert( ) method to Ruby's Kernel class? I'm expanding my Ruby understanding by coding an equivalent of Kent Beck's xUnit in Ruby. Python (which Kent writes in) has an assert() method in the language which is used extensively. Ruby does not. I think it should be easy to add this but is Ke...
TITLE: Is it idiomatic Ruby to add an assert( ) method to Ruby's Kernel class? QUESTION: I'm expanding my Ruby understanding by coding an equivalent of Kent Beck's xUnit in Ruby. Python (which Kent writes in) has an assert() method in the language which is used extensively. Ruby does not. I think it should be easy to ...
[ "ruby", "assert", "xunit" ]
93
135
45,263
5
0
2008-09-29T08:39:16.180000
2009-08-11T16:08:15.127000
147,973
148,590
.NET Remoting and Server 2008 (64 Bit)
I have a.NET application that is meant to be run on a local PC and started from a file share on the LAN. It works fine on 32 bit Windows XP and Vista workstations. But it fails with a System.InvalidOperationException on 64 bit Windows Server 2008. It runs fine locally on all three configurations. What could be the caus...
Are the projects set to run in x86 mode? Use the configuration Manager to check.
.NET Remoting and Server 2008 (64 Bit) I have a.NET application that is meant to be run on a local PC and started from a file share on the LAN. It works fine on 32 bit Windows XP and Vista workstations. But it fails with a System.InvalidOperationException on 64 bit Windows Server 2008. It runs fine locally on all three...
TITLE: .NET Remoting and Server 2008 (64 Bit) QUESTION: I have a.NET application that is meant to be run on a local PC and started from a file share on the LAN. It works fine on 32 bit Windows XP and Vista workstations. But it fails with a System.InvalidOperationException on 64 bit Windows Server 2008. It runs fine lo...
[ ".net", "windows-server-2008", "network-share" ]
2
1
1,430
3
0
2008-09-29T08:41:50.887000
2008-09-29T13:12:01.533000
147,976
173,474
.html() jQuery method bizzare bug - resolves to empty space locally, but not on production
I'm making a simple jquery command: element.html(" "); using the attributes/html method: http://docs.jquery.com/Attributes/html It works on my local app engine server, but it doesn't work once I push to the Google server. The element empties but doesn't fill with spaces. So instead of " " (6 spaces) it's just "". Once ...
You could try generating the space during run-time, so it won't be trimmed or whatever happens during transport: element.html(String.fromCharCode(32));
.html() jQuery method bizzare bug - resolves to empty space locally, but not on production I'm making a simple jquery command: element.html(" "); using the attributes/html method: http://docs.jquery.com/Attributes/html It works on my local app engine server, but it doesn't work once I push to the Google server. The ele...
TITLE: .html() jQuery method bizzare bug - resolves to empty space locally, but not on production QUESTION: I'm making a simple jquery command: element.html(" "); using the attributes/html method: http://docs.jquery.com/Attributes/html It works on my local app engine server, but it doesn't work once I push to the Goog...
[ "javascript", "jquery", "html", "google-app-engine" ]
3
3
3,851
5
0
2008-09-29T08:43:01.790000
2008-10-06T07:34:26.443000
147,988
148,269
Standard algorithm to tokenize a string, keep delimiters (in PHP)
I want to split an arithmetic expression into tokens, to convert it into RPN. Java has the StringTokenizer, which can optionally keep the delimiters. That way, I could use the operators as delimiters. Unfortunately, I need to do this in PHP, which has strtok, but that throws away the delimiters, so I need to brew somet...
As often, I would just use a regular expression to do this: $expr = '(5*(7 + 2 * -9.3) - 8 )/ 11'; $tokens = preg_split('/([*\/^+-]+)\s*|([\d.]+)\s*/', $expr, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $tts = print_r($tokens, true); echo " x=$tts "; It needs a little more work to accept numbers with exponent ...
Standard algorithm to tokenize a string, keep delimiters (in PHP) I want to split an arithmetic expression into tokens, to convert it into RPN. Java has the StringTokenizer, which can optionally keep the delimiters. That way, I could use the operators as delimiters. Unfortunately, I need to do this in PHP, which has st...
TITLE: Standard algorithm to tokenize a string, keep delimiters (in PHP) QUESTION: I want to split an arithmetic expression into tokens, to convert it into RPN. Java has the StringTokenizer, which can optionally keep the delimiters. That way, I could use the operators as delimiters. Unfortunately, I need to do this in...
[ "php", "algorithm", "parsing" ]
2
1
1,646
3
0
2008-09-29T08:47:36.053000
2008-09-29T11:01:44.403000
147,990
148,177
How to get WCF statistics from inside an application that uses it?
Is it possible to gather performance statistics programmatically from inside a WCF application? For example, the number of connections open or requests received.
Look into WCF Performance Counters. You can query performance counters using the respective.NET Framework Classes. Also, you could enable WMI for your WCF Services and query this information from inside your application. Probably depends on the kind of information you need to get.
How to get WCF statistics from inside an application that uses it? Is it possible to gather performance statistics programmatically from inside a WCF application? For example, the number of connections open or requests received.
TITLE: How to get WCF statistics from inside an application that uses it? QUESTION: Is it possible to gather performance statistics programmatically from inside a WCF application? For example, the number of connections open or requests received. ANSWER: Look into WCF Performance Counters. You can query performance co...
[ ".net", "wcf", "performance", "networking", "monitoring" ]
0
0
959
1
0
2008-09-29T08:48:32.073000
2008-09-29T10:17:33.043000
147,992
148,013
Is having different users for different types of queries a good practice?
I am using MySQL and PHP for a project I am working. I have created separate users for carrying out different functions (one for running select queries, one for running update queries, etc.) to provide an extra layer of security. This way, I figure if someone does manage to carry out an injection attack (which is unlik...
Aside from the extended logic, you will also have different connections and essential overhead in that area. IMHO it's wise to not do all your queries in a webapp with the root user and if the data is so hot, then make sure the designated user has no DROP, DELETE etc. priviledges. You could implement soft-delete if it'...
Is having different users for different types of queries a good practice? I am using MySQL and PHP for a project I am working. I have created separate users for carrying out different functions (one for running select queries, one for running update queries, etc.) to provide an extra layer of security. This way, I figu...
TITLE: Is having different users for different types of queries a good practice? QUESTION: I am using MySQL and PHP for a project I am working. I have created separate users for carrying out different functions (one for running select queries, one for running update queries, etc.) to provide an extra layer of security...
[ "mysql" ]
3
6
234
2
0
2008-09-29T08:49:55.500000
2008-09-29T08:59:46.630000
147,995
6,056,413
Why doesnt paginator remember my custom parameters when I go to page 2?
When using the paginator helper in cakephp views, it doesnt remember parts of the url that are custom for my useage. For example: http://example.org/users/index/moderators/page:2/sort:name/dir:asc here moderators is a parameter that helps me filter by that type. But pressing a paginator link will not include this link.
To add to Alexander Morland's answer above, it's worth remembering that the syntax has changed in CakePHP 1.3 and is now: $this->Paginator->options(array('url' => $this->passedArgs)); This is described further in the pagination in views section of the CakePHP book.
Why doesnt paginator remember my custom parameters when I go to page 2? When using the paginator helper in cakephp views, it doesnt remember parts of the url that are custom for my useage. For example: http://example.org/users/index/moderators/page:2/sort:name/dir:asc here moderators is a parameter that helps me filter...
TITLE: Why doesnt paginator remember my custom parameters when I go to page 2? QUESTION: When using the paginator helper in cakephp views, it doesnt remember parts of the url that are custom for my useage. For example: http://example.org/users/index/moderators/page:2/sort:name/dir:asc here moderators is a parameter th...
[ "cakephp", "pagination", "paginator" ]
12
4
7,532
6
0
2008-09-29T08:51:20.270000
2011-05-19T09:19:25.750000
147,996
148,111
How do you write the end of a file opened with FILE_FLAG_NO_BUFFERING?
I am using VB6 and the Win32 API to write data to a file, this functionality is for the export of data, therefore write performance to the disk is the key factor in my considerations. As such I am using the FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH options when opening the file with a call to CreateFile. FILE_...
I'm not sure, but are YOU sure that setting FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH give you maximum performance? They'll certainly result in your data hitting the disk as soon as possible, but that sort of thing doesn't actually help performance - it just helps reliability for things like journal files that...
How do you write the end of a file opened with FILE_FLAG_NO_BUFFERING? I am using VB6 and the Win32 API to write data to a file, this functionality is for the export of data, therefore write performance to the disk is the key factor in my considerations. As such I am using the FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE...
TITLE: How do you write the end of a file opened with FILE_FLAG_NO_BUFFERING? QUESTION: I am using VB6 and the Win32 API to write data to a file, this functionality is for the export of data, therefore write performance to the disk is the key factor in my considerations. As such I am using the FILE_FLAG_NO_BUFFERING a...
[ "winapi", "vb6", "file-io", "buffer" ]
4
2
2,687
3
0
2008-09-29T08:51:41.830000
2008-09-29T09:39:18.970000
148,003
148,030
Algorithm for finding the maximum difference in an array of numbers
I have an array of a few million numbers. double* const data = new double (3600000); I need to iterate through the array and find the range (the largest value in the array minus the smallest value). However, there is a catch. I only want to find the range where the smallest and largest values are within 1,000 samples o...
The algorithm you describe is really O(N), but i think the constant is too high. Another solution which looks reasonable is to use O(N*log(N)) algorithm the following way: * create sorted container (std::multiset) of first 1000 numbers * in loop (j=1, j<(3600000-1000); ++j) - calculate range - remove from the set numbe...
Algorithm for finding the maximum difference in an array of numbers I have an array of a few million numbers. double* const data = new double (3600000); I need to iterate through the array and find the range (the largest value in the array minus the smallest value). However, there is a catch. I only want to find the ra...
TITLE: Algorithm for finding the maximum difference in an array of numbers QUESTION: I have an array of a few million numbers. double* const data = new double (3600000); I need to iterate through the array and find the range (the largest value in the array minus the smallest value). However, there is a catch. I only w...
[ "c++", "algorithm", "statistics" ]
18
8
6,891
7
0
2008-09-29T08:55:56.423000
2008-09-29T09:07:04.477000
148,004
148,028
Find out the calling stored procedure in SQL Server
Is it possible to find out who called a stored procedure? For example, say I get an error in proc3. From within that proc I want to know if it was called by proc1 or proc2.
I would use an extra input parameter, to specify the source, if this is important for your logic. This will also make it easier to port your database to another platform, since you don't depend on some obscure platform dependent function.
Find out the calling stored procedure in SQL Server Is it possible to find out who called a stored procedure? For example, say I get an error in proc3. From within that proc I want to know if it was called by proc1 or proc2.
TITLE: Find out the calling stored procedure in SQL Server QUESTION: Is it possible to find out who called a stored procedure? For example, say I get an error in proc3. From within that proc I want to know if it was called by proc1 or proc2. ANSWER: I would use an extra input parameter, to specify the source, if this...
[ "sql", "sql-server", "database", "stored-procedures", "sql-server-2005" ]
21
11
37,764
4
0
2008-09-29T08:56:14.223000
2008-09-29T09:06:28.550000
148,005
148,017
How to update unique values in SQL using a PostgreSQL sequence?
In SQL, how do update a table, setting a column to a different value for each row? I want to update some rows in a PostgreSQL database, setting one column to a number from a sequence, where that column has a unique constraint. I hoped that I could just use: update person set unique_number = (select nextval('number_sequ...
Don't use a subselect, rather use the nextval function directly, like this: update person set unique_number = nextval('number_sequence');
How to update unique values in SQL using a PostgreSQL sequence? In SQL, how do update a table, setting a column to a different value for each row? I want to update some rows in a PostgreSQL database, setting one column to a number from a sequence, where that column has a unique constraint. I hoped that I could just use...
TITLE: How to update unique values in SQL using a PostgreSQL sequence? QUESTION: In SQL, how do update a table, setting a column to a different value for each row? I want to update some rows in a PostgreSQL database, setting one column to a number from a sequence, where that column has a unique constraint. I hoped tha...
[ "sql", "postgresql", "sequences" ]
17
38
18,792
2
0
2008-09-29T08:56:43.317000
2008-09-29T09:01:21.340000
148,020
148,045
How can I plot data with a non-numeric X-axis?
I have a series of performance tests I would like to show as a graph. I have a set of tests (about 10) which I run on a set of components (currently 3), and get throughput results. The Y-axis would be the throughput result from the test, and the X-axis should have an abbreviated name of the test, with the results from ...
See this very helpful page. Essentially you create a number-label mapping using set xtics ("lbl1" 1, "lbl2" 2, "lbl3" 3, "lbl4" 4) Then plot as normal.
How can I plot data with a non-numeric X-axis? I have a series of performance tests I would like to show as a graph. I have a set of tests (about 10) which I run on a set of components (currently 3), and get throughput results. The Y-axis would be the throughput result from the test, and the X-axis should have an abbre...
TITLE: How can I plot data with a non-numeric X-axis? QUESTION: I have a series of performance tests I would like to show as a graph. I have a set of tests (about 10) which I run on a set of components (currently 3), and get throughput results. The Y-axis would be the throughput result from the test, and the X-axis sh...
[ "plot", "gnuplot" ]
8
16
7,302
1
0
2008-09-29T09:01:55.533000
2008-09-29T09:13:04.993000
148,024
149,641
Why is my parameter passed by reference not modified within the function?
I have got a C function in a static library, let's call it A, with the following interface: int A(unsigned int a, unsigned long long b, unsigned int *y, unsigned char *z); This function will change the value of y an z (this is for sure). I use it from within a dynamic C++ library, using extern "C". Now, here is what st...
First of all, I am very grateful to everyone for your help. Thanks to the numerous ideas and clues you gave me, I have been able to finally sort out this problem. Your advices helped me to question what I took for granted. Short answer to my problem: The problem was that my C++ library used an old version of the C libr...
Why is my parameter passed by reference not modified within the function? I have got a C function in a static library, let's call it A, with the following interface: int A(unsigned int a, unsigned long long b, unsigned int *y, unsigned char *z); This function will change the value of y an z (this is for sure). I use it...
TITLE: Why is my parameter passed by reference not modified within the function? QUESTION: I have got a C function in a static library, let's call it A, with the following interface: int A(unsigned int a, unsigned long long b, unsigned int *y, unsigned char *z); This function will change the value of y an z (this is f...
[ "c++", "c", "parameters", "linker", "pass-by-reference" ]
0
1
1,276
10
0
2008-09-29T09:04:22.283000
2008-09-29T17:00:05.183000
148,039
148,077
What's the best approach to migrate a CGI to a Framework?
i have a big web application running in perl CGI. It's running ok, it's well written, but as it was done in the past, all the html are defined hardcoded in the CGI calls, so as you could imagine, it's hard to mantain, improve and etc. So now i would like to start to add some templating and integrate with a framework (c...
Write tests first (for example with Test::WWW::Mechanize ). Then when you change things you always know if something breaks, and what it is that breaks. Then extract HTML into templates, and commonly used subs into modules. After that it's a piece of cake to switch to a framework. In general, go step by step so that yo...
What's the best approach to migrate a CGI to a Framework? i have a big web application running in perl CGI. It's running ok, it's well written, but as it was done in the past, all the html are defined hardcoded in the CGI calls, so as you could imagine, it's hard to mantain, improve and etc. So now i would like to star...
TITLE: What's the best approach to migrate a CGI to a Framework? QUESTION: i have a big web application running in perl CGI. It's running ok, it's well written, but as it was done in the past, all the html are defined hardcoded in the CGI calls, so as you could imagine, it's hard to mantain, improve and etc. So now i ...
[ "perl", "model-view-controller", "cgi", "catalyst" ]
7
10
708
5
0
2008-09-29T09:10:16.170000
2008-09-29T09:23:36.777000
148,042
148,048
Using OR comparisons with IF statements
When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept multiple values when checking for "equals to"? For example, if job == "mech...
if job in ("mechanic", "tech"): print "awesome" elif job in ("tool", "rock"): print "dolt" The values in parentheses are a tuple. The in operator checks to see whether the left hand side item occurs somewhere inside the right handle tuple. Note that when Python searches a tuple or list using the in operator, it does a ...
Using OR comparisons with IF statements When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept multiple values when checking for "...
TITLE: Using OR comparisons with IF statements QUESTION: When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept multiple values w...
[ "python", "comparison", "boolean" ]
16
39
73,800
6
0
2008-09-29T09:12:24.933000
2008-09-29T09:13:53.337000
148,056
148,122
Is it OK to have object instantation 'hooks' in base classes?
I have created my own Tree implementation for various reasons and have come up with two classes, a 'base' class that is a generic tree node that is chock full of logic and another class that extends that one which is more specialised. In my base class certain methods involve instantiating new tree nodes (e.g. adding ch...
So, after getting my copy of Design Patterns and opening it for what I'm fairly sure is the first time ever I discovered what I want. It's called the Factory Method and it's mostly a perfect fit. It's still a bit ugly because my super class ( Foo in the above example) is not abstract which means subclasses are not forc...
Is it OK to have object instantation 'hooks' in base classes? I have created my own Tree implementation for various reasons and have come up with two classes, a 'base' class that is a generic tree node that is chock full of logic and another class that extends that one which is more specialised. In my base class certai...
TITLE: Is it OK to have object instantation 'hooks' in base classes? QUESTION: I have created my own Tree implementation for various reasons and have come up with two classes, a 'base' class that is a generic tree node that is chock full of logic and another class that extends that one which is more specialised. In my...
[ "java", "inheritance" ]
2
3
288
3
0
2008-09-29T09:15:59.917000
2008-09-29T09:44:04.387000
148,057
151,656
Call a Mathematica program from the command line, with command-line args, stdin, stdout, and stderr
If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and with -initfile foo.m (or -run "< ) and the command line arguments are available in $CommandLine (with extra junk in there) but is there a way to just have some mathematica code like #!/usr/bin/env MathKernel x = 2+2; Print[x]; Print["T...
MASH -- Mathematica Scripting Hack -- will do this. Since Mathematica version 6, the following perl script suffices: http://ai.eecs.umich.edu/people/dreeves/mash/mash.pl For previous Mathematica versions, a C program is needed: http://ai.eecs.umich.edu/people/dreeves/mash/pre6 UPDATE: At long last, Mathematica 8 suppor...
Call a Mathematica program from the command line, with command-line args, stdin, stdout, and stderr If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and with -initfile foo.m (or -run "< ) and the command line arguments are available in $CommandLine (with extra junk in there) but is there...
TITLE: Call a Mathematica program from the command line, with command-line args, stdin, stdout, and stderr QUESTION: If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and with -initfile foo.m (or -run "< ) and the command line arguments are available in $CommandLine (with extra junk in t...
[ "command-line", "scripting", "wolfram-mathematica" ]
18
11
13,136
6
0
2008-09-29T09:16:13.067000
2008-09-30T03:29:27.867000
148,059
148,070
How would you test an SSL connection?
I'm experimenting with OpenSSL on my network application and I want to test if the data sent is encrypted and can't be seen by eavesdropper. What tools can you use to check? Could this be done programmatically so it could be placed in a unit test?
check out wire shark http://www.wireshark.org/ and tcp dump http://en.wikipedia.org/wiki/Tcpdump Not sure about integrating these into unit tests. They will let you look at a very low level whats going on at the network level. Perhaps for the unit test determine what the stream looks like unencrypted and make sure the ...
How would you test an SSL connection? I'm experimenting with OpenSSL on my network application and I want to test if the data sent is encrypted and can't be seen by eavesdropper. What tools can you use to check? Could this be done programmatically so it could be placed in a unit test?
TITLE: How would you test an SSL connection? QUESTION: I'm experimenting with OpenSSL on my network application and I want to test if the data sent is encrypted and can't be seen by eavesdropper. What tools can you use to check? Could this be done programmatically so it could be placed in a unit test? ANSWER: check o...
[ "security", "network-programming", "openssl" ]
28
10
82,460
7
0
2008-09-29T09:16:29.040000
2008-09-29T09:21:39.590000
148,071
174,086
Problem using large binary segment in OOXML
System Description A plotting component that uses OOXML to generate a document. Plotting component consists of several parts. All parts are written in C++ as exe + dll's, with the exception of the interface to the OOXML document. The latter component is a COM component that was created in C#/.NET. The main reason for t...
You might try to unzip the package yourself (instead of using the.NET package API), write directly to the file which represents the binary segment and zip it again.
Problem using large binary segment in OOXML System Description A plotting component that uses OOXML to generate a document. Plotting component consists of several parts. All parts are written in C++ as exe + dll's, with the exception of the interface to the OOXML document. The latter component is a COM component that w...
TITLE: Problem using large binary segment in OOXML QUESTION: System Description A plotting component that uses OOXML to generate a document. Plotting component consists of several parts. All parts are written in C++ as exe + dll's, with the exception of the interface to the OOXML document. The latter component is a CO...
[ "c#", ".net", "c++", "com", "openxml" ]
7
2
709
2
0
2008-09-29T09:21:40.603000
2008-10-06T12:35:42.357000
148,074
148,081
Is the sorting algorithm used by .NET's `Array.Sort()` method a stable algorithm?
Is the sorting algorithm used by.NET's Array.Sort() method a stable algorithm?
From MSDN: This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. The sort uses introspective sort. (Quicksort in version 4.0 and earlier of the.NET framework). If you need a stable...
Is the sorting algorithm used by .NET's `Array.Sort()` method a stable algorithm? Is the sorting algorithm used by.NET's Array.Sort() method a stable algorithm?
TITLE: Is the sorting algorithm used by .NET's `Array.Sort()` method a stable algorithm? QUESTION: Is the sorting algorithm used by.NET's Array.Sort() method a stable algorithm? ANSWER: From MSDN: This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In...
[ "c#", ".net" ]
72
76
27,563
5
0
2008-09-29T09:22:39.183000
2008-09-29T09:24:31.953000
148,078
148,104
How to make a method exclusive in a multithreaded context?
I have a method which should be executed in an exclusive fashion. Basically, it's a multi threaded application where the method is invoked periodically by a timer, but which could also be manually triggered by a user action. Let's take an example: The timer elapses, so the method is called. The task could take a few se...
This looks reasonable if you are just interested in not having the method run in parallel. There's nothing to stop it from running immediately after each other, say that you pushed the button half a microsecond after the timer executed the Monitor.Exit(). And having the lock object as readonly static also make sense.
How to make a method exclusive in a multithreaded context? I have a method which should be executed in an exclusive fashion. Basically, it's a multi threaded application where the method is invoked periodically by a timer, but which could also be manually triggered by a user action. Let's take an example: The timer ela...
TITLE: How to make a method exclusive in a multithreaded context? QUESTION: I have a method which should be executed in an exclusive fashion. Basically, it's a multi threaded application where the method is invoked periodically by a timer, but which could also be manually triggered by a user action. Let's take an exam...
[ "c#", ".net", "multithreading", "locking" ]
3
4
1,385
8
0
2008-09-29T09:23:37.527000
2008-09-29T09:36:39.383000
148,079
148,093
How to convert a string into bignum in C code which extends Guile?
In Guile 1.6.*, the function scm_istring2number(char *str,int strlen,int radix) does the work. However, this function does not exist in Guile 1.8.. How can I accomplish the same task in Guile 1.8.? This is not trivial because the function scm_string_to_number(SCM str,int radix) does not convert numbers larger than 2 31...
According to the 1.8 ChangeLog, the function has been renamed scm_c_locale_stringn_to_number.
How to convert a string into bignum in C code which extends Guile? In Guile 1.6.*, the function scm_istring2number(char *str,int strlen,int radix) does the work. However, this function does not exist in Guile 1.8.. How can I accomplish the same task in Guile 1.8.? This is not trivial because the function scm_string_to_...
TITLE: How to convert a string into bignum in C code which extends Guile? QUESTION: In Guile 1.6.*, the function scm_istring2number(char *str,int strlen,int radix) does the work. However, this function does not exist in Guile 1.8.. How can I accomplish the same task in Guile 1.8.? This is not trivial because the funct...
[ "c", "guile" ]
0
3
528
1
0
2008-09-29T09:23:56.387000
2008-09-29T09:29:43.643000
148,084
148,102
How to deploy an ASP.NET Application with zero downtime
To deploy a new version of our website we do the following: Zip up the new code, and upload it to the server. On the live server, delete all the live code from the IIS website directory. Extract the new code zipfile into the now empty IIS directory This process is all scripted, and happens quite quickly, but there can ...
You need 2 servers and a load balancer. Here's in steps: Turn all traffic on Server 2 Deploy on Server 1 Test Server 1 Turn all traffic on Server 1 Deploy on Server 2 Test Server 2 Turn traffic on both servers Thing is, even in this case you will still have application restarts and loss of sessions if you are using "st...
How to deploy an ASP.NET Application with zero downtime To deploy a new version of our website we do the following: Zip up the new code, and upload it to the server. On the live server, delete all the live code from the IIS website directory. Extract the new code zipfile into the now empty IIS directory This process is...
TITLE: How to deploy an ASP.NET Application with zero downtime QUESTION: To deploy a new version of our website we do the following: Zip up the new code, and upload it to the server. On the live server, delete all the live code from the IIS website directory. Extract the new code zipfile into the now empty IIS directo...
[ "asp.net", "iis", "deployment", "redundancy" ]
137
87
39,124
13
0
2008-09-29T09:25:41.607000
2008-09-29T09:35:03.880000
148,086
148,095
"Colorizing" images in .NET
Is there any simple way to programatically colorize images in.NET? Basically we have a black and white image and need to put a layer of say pink above it and reduce the opacity of that layer to make the picture colorized in pink.
You should use the wonderful ImageMagick library. It has.NET bindings so no problem there. Have fun!:)
"Colorizing" images in .NET Is there any simple way to programatically colorize images in.NET? Basically we have a black and white image and need to put a layer of say pink above it and reduce the opacity of that layer to make the picture colorized in pink.
TITLE: "Colorizing" images in .NET QUESTION: Is there any simple way to programatically colorize images in.NET? Basically we have a black and white image and need to put a layer of say pink above it and reduce the opacity of that layer to make the picture colorized in pink. ANSWER: You should use the wonderful ImageM...
[ ".net", "image-manipulation", "episerver", "colorize" ]
1
2
403
5
0
2008-09-29T09:26:17.317000
2008-09-29T09:30:25.233000
148,097
148,131
enabling/disabling asp.net web service extension via script
In IIS 6, I can use the Web Service Extensions folder in Inetmgr to allow/prohibit isapi filters, such as ASP.net. I want to be able to do this programmatically (in particular, from an installer script/exe). Any ideas?
Adding Web Service Extension Files Using Iisext.vbs should be pretty much what you're looking for (the linked article describes how to add a new filter: if you just need to enable it, scroll down and see the list of linked articles for exact instructions on how to achieve that)
enabling/disabling asp.net web service extension via script In IIS 6, I can use the Web Service Extensions folder in Inetmgr to allow/prohibit isapi filters, such as ASP.net. I want to be able to do this programmatically (in particular, from an installer script/exe). Any ideas?
TITLE: enabling/disabling asp.net web service extension via script QUESTION: In IIS 6, I can use the Web Service Extensions folder in Inetmgr to allow/prohibit isapi filters, such as ASP.net. I want to be able to do this programmatically (in particular, from an installer script/exe). Any ideas? ANSWER: Adding Web Ser...
[ "asp.net", "iis" ]
3
2
2,318
2
0
2008-09-29T09:31:34.637000
2008-09-29T09:48:52.893000
148,118
148,248
What framework would you recommend for making desktop-like apps for the web?
Several frameworks for writing web-based desktop-like applications have recently appeared. E.g. SproutCore and Cappuccino. Do you have any experience using them? What's your impression? Did I miss some other framework? I've seen related questions on StackOverflow, but they generate mostly standard answers like "use jQu...
Due to the speed issues these high-level frameworks cause for many larger (as in: non-trivial) applications, we only use plain jQuery. In our tests, all high-level frameworks broke down in situations where there are many draggable objects or many drop targets, and in situation where long lists (with >1000 entries) were...
What framework would you recommend for making desktop-like apps for the web? Several frameworks for writing web-based desktop-like applications have recently appeared. E.g. SproutCore and Cappuccino. Do you have any experience using them? What's your impression? Did I miss some other framework? I've seen related questi...
TITLE: What framework would you recommend for making desktop-like apps for the web? QUESTION: Several frameworks for writing web-based desktop-like applications have recently appeared. E.g. SproutCore and Cappuccino. Do you have any experience using them? What's your impression? Did I miss some other framework? I've s...
[ "javascript", "web-applications", "frameworks" ]
5
7
4,475
8
0
2008-09-29T09:43:10.583000
2008-09-29T10:54:08.120000
148,129
148,199
Performance considerations for Triggers vs Constraints
I'm trying to find out whether I should be using business critical logic in a trigger or constraint inside of my database. So far I've added logic in triggers as it gives me the control over what happens next and means I can provide custom user messages instead of an error that will probably confuse the users. Is there...
Constraints hands down! With constraints you specify relational principles, i.e. facts about your data. You will never need to change your constraints, unless some fact changes (i.e. new requirements). With triggers you specify how to handle data (in inserts, updates etc.). This is a "non-relational" way of doing thing...
Performance considerations for Triggers vs Constraints I'm trying to find out whether I should be using business critical logic in a trigger or constraint inside of my database. So far I've added logic in triggers as it gives me the control over what happens next and means I can provide custom user messages instead of ...
TITLE: Performance considerations for Triggers vs Constraints QUESTION: I'm trying to find out whether I should be using business critical logic in a trigger or constraint inside of my database. So far I've added logic in triggers as it gives me the control over what happens next and means I can provide custom user me...
[ "database-design", "triggers", "constraints" ]
19
16
13,709
12
0
2008-09-29T09:47:57.187000
2008-09-29T10:25:39.483000
148,130
148,135
How do I peek at the first two bytes in an InputStream?
Should be pretty simple: I have an InputStream where I want to peek at (not read) the first two bytes, i.e. I want the "current position" of the InputStream to stil be at 0 after my peeking. What is the best and safest way to do this? Answer - As I had suspected, the solution was to wrap it in a BufferedInputStream whi...
For a general InputStream, I would wrap it in a BufferedInputStream and do something like this: BufferedInputStream bis = new BufferedInputStream(inputStream); bis.mark(2); int byte1 = bis.read(); int byte2 = bis.read(); bis.reset(); // note: you must continue using the BufferedInputStream instead of the inputStream
How do I peek at the first two bytes in an InputStream? Should be pretty simple: I have an InputStream where I want to peek at (not read) the first two bytes, i.e. I want the "current position" of the InputStream to stil be at 0 after my peeking. What is the best and safest way to do this? Answer - As I had suspected, ...
TITLE: How do I peek at the first two bytes in an InputStream? QUESTION: Should be pretty simple: I have an InputStream where I want to peek at (not read) the first two bytes, i.e. I want the "current position" of the InputStream to stil be at 0 after my peeking. What is the best and safest way to do this? Answer - As...
[ "java", "inputstream", "bufferedinputstream" ]
39
58
22,537
4
0
2008-09-29T09:48:05.627000
2008-09-29T09:51:05.900000
148,136
148,159
Oracle sql query, concatenate fileds with CASE section
I'm currently generating SQL insert statements from more than one tables, and in the generated data I need to use a CASE statement, like this: select 'INSERT INTO TABLE1 (f1, f2, f3, f4...) values (' ||t.f1||',' ||CASE WHEN t.f2 > 0 THEN '1' ELSE '0' END CASE from table2 t, table3 t3 But at this point if I want to cont...
Use END instead of END CASE select 'INSERT INTO TABLE1 (f1, f2, f3, f4...) values (' ||t.f1||',' ||CASE WHEN t.f2 > 0 THEN '1' ELSE '0' END||','||t.f2 from table2 t, table3 t3
Oracle sql query, concatenate fileds with CASE section I'm currently generating SQL insert statements from more than one tables, and in the generated data I need to use a CASE statement, like this: select 'INSERT INTO TABLE1 (f1, f2, f3, f4...) values (' ||t.f1||',' ||CASE WHEN t.f2 > 0 THEN '1' ELSE '0' END CASE from ...
TITLE: Oracle sql query, concatenate fileds with CASE section QUESTION: I'm currently generating SQL insert statements from more than one tables, and in the generated data I need to use a CASE statement, like this: select 'INSERT INTO TABLE1 (f1, f2, f3, f4...) values (' ||t.f1||',' ||CASE WHEN t.f2 > 0 THEN '1' ELSE ...
[ "sql", "oracle", "syntax", "case", "toad" ]
2
3
13,893
2
0
2008-09-29T09:51:22.170000
2008-09-29T10:04:49.970000
148,143
148,628
Is there anyway to tell Visual Studio not to open all the documents when I load solution?
When you open a solution in Visual Studio 2008 (or ealier versions for that matter), it opens all the documents that you did not close before you closed Visual Studio. Is there anyway to turn this functionality off, or a plugin that fixes this behavior? It takes forever to load a solution with 50 files open?
You can automate the process of closing all the files prior to closing a solution by adding a handler for the BeforeClosing event of EnvDTE.SolutionEvents -- this will get invoked when VS is exiting. In VS2005, adding the following to the EnvironmentEvents macro module will close all open documents: Private Sub Solutio...
Is there anyway to tell Visual Studio not to open all the documents when I load solution? When you open a solution in Visual Studio 2008 (or ealier versions for that matter), it opens all the documents that you did not close before you closed Visual Studio. Is there anyway to turn this functionality off, or a plugin th...
TITLE: Is there anyway to tell Visual Studio not to open all the documents when I load solution? QUESTION: When you open a solution in Visual Studio 2008 (or ealier versions for that matter), it opens all the documents that you did not close before you closed Visual Studio. Is there anyway to turn this functionality o...
[ "visual-studio" ]
23
12
7,902
7
0
2008-09-29T09:56:29.227000
2008-09-29T13:22:07.140000
148,169
148,187
When deleting hasOne or hasMany associations, should the foreignKey be set to NULL?
Given: Group hasMany Persons but the relationship is independent (ie. Persons can exist without belonging to a Group), should the foreign key in the persons' table (ie group_id) be set to 0 (or NULL) when deleting a group? If you do not, the person will try to belong to a group that doesn't exist. The reason I ask is t...
Yes, the foreign keys should be set to NULL (or 0, if this is your chosen 'no group' value) or you lose referential integrity. If your database supports it, you should be able to set an 'On delete' trigger or a cascade rule in your framework to enforce this. And the behaviour in CakePHP seems correct. If the value is d...
When deleting hasOne or hasMany associations, should the foreignKey be set to NULL? Given: Group hasMany Persons but the relationship is independent (ie. Persons can exist without belonging to a Group), should the foreign key in the persons' table (ie group_id) be set to 0 (or NULL) when deleting a group? If you do not...
TITLE: When deleting hasOne or hasMany associations, should the foreignKey be set to NULL? QUESTION: Given: Group hasMany Persons but the relationship is independent (ie. Persons can exist without belonging to a Group), should the foreign key in the persons' table (ie group_id) be set to 0 (or NULL) when deleting a gr...
[ "cakephp", "associations", "model-driven" ]
1
3
1,898
4
0
2008-09-29T10:11:55.570000
2008-09-29T10:21:01.273000
148,178
1,612,595
Strange MFC / VC++ Linker Error (std::list<CRect> already defined)
I've got a really odd error message that only occurs when I add the following line to my project: std::list myVar; It's worth noting that it doesn't have to be a std::list, it can be std::vector or any other STL container I assume. Here is the error message: Error 1 error LNK2005: "public: __thiscall std::list::list >(...
I recently stumbled across this error again in our project and decided to have a more thorough investigation compared to just patching it up with a hack like last time (swap std::list for CArray). It turns out that one of our low level libraries was inheriting from std::list, e.g. class LIB_EXPORT CRectList: public std...
Strange MFC / VC++ Linker Error (std::list<CRect> already defined) I've got a really odd error message that only occurs when I add the following line to my project: std::list myVar; It's worth noting that it doesn't have to be a std::list, it can be std::vector or any other STL container I assume. Here is the error mes...
TITLE: Strange MFC / VC++ Linker Error (std::list<CRect> already defined) QUESTION: I've got a really odd error message that only occurs when I add the following line to my project: std::list myVar; It's worth noting that it doesn't have to be a std::list, it can be std::vector or any other STL container I assume. Her...
[ "visual-studio-2008", "mfc", "linker" ]
3
1
2,015
6
0
2008-09-29T10:18:09.050000
2009-10-23T10:32:41.353000
148,181
148,184
What is the best way to create a script to use with the rails request profiler?
The rails scirpt script/performance/request require a session script, what is the best way to generate this session script?
Add this code to your application.rb file before_filter:benchmark_log def benchmark_log File.open("request_log.txt","a") do |f| f.puts request.method.to_s + " '" + request.request_uri + "', " + params.except(:action).except(:controller).inspect.gsub(/(^\{|\}$)/,"") end end Then you can visit several pages in your brow...
What is the best way to create a script to use with the rails request profiler? The rails scirpt script/performance/request require a session script, what is the best way to generate this session script?
TITLE: What is the best way to create a script to use with the rails request profiler? QUESTION: The rails scirpt script/performance/request require a session script, what is the best way to generate this session script? ANSWER: Add this code to your application.rb file before_filter:benchmark_log def benchmark_log ...
[ "ruby-on-rails", "performance", "profiling" ]
5
5
113
1
0
2008-09-29T10:19:02.370000
2008-09-29T10:19:56.970000
148,185
2,458,276
How efficient is define in PHP?
C++ preprocessor #define is totally different. Is the PHP define() any different than just creating a var? define("SETTING", 0); $something = SETTING; vs $setting = 0; $something = $setting;
'define' operation itself is rather slow - confirmed by xdebug profiler. Here is benchmarks from http://t3.dotgnu.info/blog/php/my-first-php-extension.html: pure 'define' 380.785 fetches/sec 14.2647 mean msecs/first-response constants defined with 'hidef' extension 930.783 fetches/sec 6.30279 mean msecs/first-response ...
How efficient is define in PHP? C++ preprocessor #define is totally different. Is the PHP define() any different than just creating a var? define("SETTING", 0); $something = SETTING; vs $setting = 0; $something = $setting;
TITLE: How efficient is define in PHP? QUESTION: C++ preprocessor #define is totally different. Is the PHP define() any different than just creating a var? define("SETTING", 0); $something = SETTING; vs $setting = 0; $something = $setting; ANSWER: 'define' operation itself is rather slow - confirmed by xdebug profile...
[ "php", "c-preprocessor" ]
20
17
18,492
10
0
2008-09-29T10:20:15.830000
2010-03-16T21:25:40.640000
148,190
148,254
SQL2005 Express slow from remote VB6 application
I have a legacy VB6 application that was built using MSDE. As many client's database grow towards the MSDE 2 GB limit they are upgraded to SQL 2005 Express. This has proven very successful until today. I have spent the entire day troubleshooting a client's network on which our application runs unacceptably slowly, when...
Make a checklist and systematiccaly work through it: Add all suggestions of all posts here and some I add below: Network Cables Network Speed Defrag Hard Disk No Network errors - do a ping and look for missing packets Ram per Machine Processors Virusses etc. etc,
SQL2005 Express slow from remote VB6 application I have a legacy VB6 application that was built using MSDE. As many client's database grow towards the MSDE 2 GB limit they are upgraded to SQL 2005 Express. This has proven very successful until today. I have spent the entire day troubleshooting a client's network on whi...
TITLE: SQL2005 Express slow from remote VB6 application QUESTION: I have a legacy VB6 application that was built using MSDE. As many client's database grow towards the MSDE 2 GB limit they are upgraded to SQL 2005 Express. This has proven very successful until today. I have spent the entire day troubleshooting a clien...
[ "sql-server-2005-express" ]
1
1
1,256
4
0
2008-09-29T10:22:57.493000
2008-09-29T10:55:53.217000
148,202
148,301
Integrating jQuery into an existing ASP.NET Web Application?
Microsoft recently announced that the Javascript/HTML DOM library jQuery will be integrated into the ASP.NET MVC framework and into ASP.NET / Visual Studio. What is the best practice or strategy adopting jQuery using ASP.NET 2.0? I'd like to prepare a large, existing ASP.NET Web Application ( not MVC) for jQuery. How w...
For me, problems arise when using UpdatePanels and jQuery (no problem with MVC, which doesn't have a Page Life-Cycle and is truly stateless). For instance, the useful jQuery idiom $(function() { // some actions }); used to enhance your DOM or attach events to the DOM elements may not interact very well with the ASP.NET...
Integrating jQuery into an existing ASP.NET Web Application? Microsoft recently announced that the Javascript/HTML DOM library jQuery will be integrated into the ASP.NET MVC framework and into ASP.NET / Visual Studio. What is the best practice or strategy adopting jQuery using ASP.NET 2.0? I'd like to prepare a large, ...
TITLE: Integrating jQuery into an existing ASP.NET Web Application? QUESTION: Microsoft recently announced that the Javascript/HTML DOM library jQuery will be integrated into the ASP.NET MVC framework and into ASP.NET / Visual Studio. What is the best practice or strategy adopting jQuery using ASP.NET 2.0? I'd like to...
[ "asp.net", "jquery", "asp.net-2.0" ]
3
3
1,408
2
0
2008-09-29T10:27:08.590000
2008-09-29T11:22:36.273000
148,204
148,221
Equivalent of PHP's print_r in Java?
last time I asked how to populate a data structure here. Now I would like to know if there's something in Java, like the print_r I use in PHP, to represent what I have populated in the Maps and lists without having to do my own algorithm. Any ideas?
Calling toString on the collection should return a string containing all the elements string representations. This won't work with built-in arrays though, as they don't have a toString override and will just give you a memory address.
Equivalent of PHP's print_r in Java? last time I asked how to populate a data structure here. Now I would like to know if there's something in Java, like the print_r I use in PHP, to represent what I have populated in the Maps and lists without having to do my own algorithm. Any ideas?
TITLE: Equivalent of PHP's print_r in Java? QUESTION: last time I asked how to populate a data structure here. Now I would like to know if there's something in Java, like the print_r I use in PHP, to represent what I have populated in the Maps and lists without having to do my own algorithm. Any ideas? ANSWER: Callin...
[ "java", "data-structures" ]
18
10
28,903
9
0
2008-09-29T10:28:40.910000
2008-09-29T10:39:59.323000
148,225
148,230
How to extract four unsigned short ints from one long long int?
Suppose I have one long long int and want to take its bits and construct four unsigned short ints out of it. Particular order doesn't matter much here. I generally know that I need to shift bits and truncate to the size of unsigned short int. But I think I may make some weird mistake somewhere, so I ask.
#include #include union ui64 { uint64_t one; uint16_t four[4]; }; int main() { union ui64 number = {0x123456789abcdef0}; printf("%x %x %x %x\n", number.four[0], number.four[1], number.four[2], number.four[3]); return 0; }
How to extract four unsigned short ints from one long long int? Suppose I have one long long int and want to take its bits and construct four unsigned short ints out of it. Particular order doesn't matter much here. I generally know that I need to shift bits and truncate to the size of unsigned short int. But I think I...
TITLE: How to extract four unsigned short ints from one long long int? QUESTION: Suppose I have one long long int and want to take its bits and construct four unsigned short ints out of it. Particular order doesn't matter much here. I generally know that I need to shift bits and truncate to the size of unsigned short ...
[ "c++", "c", "64-bit", "bit-manipulation" ]
5
12
2,634
3
0
2008-09-29T10:41:43.017000
2008-09-29T10:44:58.627000
148,239
148,246
LOAD SQL Table from flat file
I am am trying to load a SQL table from a flat file. The flat i am talking about is a comma separated file. This has all the data required to populate a table will each column separated by a comma ",". I need some way by which i can load this content into the table faster.
If you are using SQL Server, use BULK INSERT If you are using Oracle, see my answer here
LOAD SQL Table from flat file I am am trying to load a SQL table from a flat file. The flat i am talking about is a comma separated file. This has all the data required to populate a table will each column separated by a comma ",". I need some way by which i can load this content into the table faster.
TITLE: LOAD SQL Table from flat file QUESTION: I am am trying to load a SQL table from a flat file. The flat i am talking about is a comma separated file. This has all the data required to populate a table will each column separated by a comma ",". I need some way by which i can load this content into the table faster...
[ "sql", "sql-server-2005" ]
3
5
4,276
6
0
2008-09-29T10:49:28.537000
2008-09-29T10:53:37.607000
148,249
148,259
Is there any way to check which kind of RAM my computer uses without opening it up?
I would like to check which type of RAM my computer uses before I order an upgrade. I'm fairly sure its DDR2 but I would like to double check this. Is there any way to check this in Windows XP without opening the case up and looking? EDIT The content police seem to have gotten the wrong end of the stick, I was looking ...
CPU-Z can tell you. On the SPD tab you can view the DIMM specific information
Is there any way to check which kind of RAM my computer uses without opening it up? I would like to check which type of RAM my computer uses before I order an upgrade. I'm fairly sure its DDR2 but I would like to double check this. Is there any way to check this in Windows XP without opening the case up and looking? ED...
TITLE: Is there any way to check which kind of RAM my computer uses without opening it up? QUESTION: I would like to check which type of RAM my computer uses before I order an upgrade. I'm fairly sure its DDR2 but I would like to double check this. Is there any way to check this in Windows XP without opening the case ...
[ "memory", "windows-xp", "hardware", "system-information" ]
2
6
11,580
7
0
2008-09-29T10:54:14.110000
2008-09-29T10:58:51.277000
148,251
148,374
CSS centering tricks
My favorite equation for centering an xhtml element using only CSS is as follows: display: block; position: absolute; width: _insert width here_; left: 50%; margin-left: _insert width divided by two & multiplied by negative one here_ There's also the simpler margin:auto method in browsers that support it. Does anyone e...
Stick with Margin: 0 auto; for horizontal alignment; If you need vertical alignment as well use position: absolute; top: 50%; margin-top: -(width/2)px; Be aware though, If your container has more width than your screen a part of it will fall off screen on the left side using the Position: absolute method.
CSS centering tricks My favorite equation for centering an xhtml element using only CSS is as follows: display: block; position: absolute; width: _insert width here_; left: 50%; margin-left: _insert width divided by two & multiplied by negative one here_ There's also the simpler margin:auto method in browsers that supp...
TITLE: CSS centering tricks QUESTION: My favorite equation for centering an xhtml element using only CSS is as follows: display: block; position: absolute; width: _insert width here_; left: 50%; margin-left: _insert width divided by two & multiplied by negative one here_ There's also the simpler margin:auto method in ...
[ "css", "layout", "positioning", "center" ]
12
6
8,492
9
0
2008-09-29T10:55:07.820000
2008-09-29T11:52:47.463000
148,275
152,297
How do I draw transparent DirectX content in a transparent window?
I want to draw DirectX content so that it appears to be floating over top of the desktop and any other applications that are running. I also need to be able to make the directx content semi-transparent, so other things show through. Is there a way of doing this? I am using Managed DX with C#.
I found a solution which works on Vista, starting from the link provided by OregonGhost. This is the basic process, in C# syntax. This code is in a class inheriting from Form. It doesn't seem to work if in a UserControl: //this will allow you to import the necessary functions from the.dll using System.Runtime.InteropSe...
How do I draw transparent DirectX content in a transparent window? I want to draw DirectX content so that it appears to be floating over top of the desktop and any other applications that are running. I also need to be able to make the directx content semi-transparent, so other things show through. Is there a way of do...
TITLE: How do I draw transparent DirectX content in a transparent window? QUESTION: I want to draw DirectX content so that it appears to be floating over top of the desktop and any other applications that are running. I also need to be able to make the directx content semi-transparent, so other things show through. Is...
[ "c#", "windows", "directx", "transparent", "direct3d" ]
5
5
16,583
4
0
2008-09-29T11:05:53.067000
2008-09-30T08:57:30.467000
148,279
148,544
Word spell check runs slow on Word 2007/Vista
I have written a DLL that uses MS Word to spell check the content of a RichtextBox. The project uses Microsoft Word 11.0 Object Library. I have read that you can use that reference on machines using that version of Word or later, and that seem to be true. However... When I run the dll in a test app on a machine with Wi...
You should approach this like any other engineering problem: 1. Profile the code to see if it's your fault or not 2a. If it's your fault, correct as needed 2b. If it's that particular.dll, define your spell checking object as an interface or an abstract class and at runtime, use a concrete instance of that interface th...
Word spell check runs slow on Word 2007/Vista I have written a DLL that uses MS Word to spell check the content of a RichtextBox. The project uses Microsoft Word 11.0 Object Library. I have read that you can use that reference on machines using that version of Word or later, and that seem to be true. However... When I ...
TITLE: Word spell check runs slow on Word 2007/Vista QUESTION: I have written a DLL that uses MS Word to spell check the content of a RichtextBox. The project uses Microsoft Word 11.0 Object Library. I have read that you can use that reference on machines using that version of Word or later, and that seem to be true. ...
[ "word-automation" ]
1
1
1,144
1
0
2008-09-29T11:07:47.417000
2008-09-29T12:55:26.957000
148,281
150,158
Eclipse C++ pretty printing?
The output we get when printing C++ sources from Eclipse is rather ugly. Is there are way/a plugin to pretty print C++ source code like e.g. with a2ps (which is probably using yet another filter for C source code)?
I also use enscript for this. Here's an alias I often use: alias cpp2ps='enscript --color --pretty-print=cpp --language=PostScript' and I use it like this: cpp2ps -P main.ps main.cpp There are several other great options in enscript including rotating, 2-column output, line numbers, headers/footers, etc. Check out the ...
Eclipse C++ pretty printing? The output we get when printing C++ sources from Eclipse is rather ugly. Is there are way/a plugin to pretty print C++ source code like e.g. with a2ps (which is probably using yet another filter for C source code)?
TITLE: Eclipse C++ pretty printing? QUESTION: The output we get when printing C++ sources from Eclipse is rather ugly. Is there are way/a plugin to pretty print C++ source code like e.g. with a2ps (which is probably using yet another filter for C source code)? ANSWER: I also use enscript for this. Here's an alias I o...
[ "c++", "eclipse", "printing", "eclipse-cdt" ]
3
2
4,518
3
0
2008-09-29T11:08:18.803000
2008-09-29T19:05:00.653000
148,295
148,347
How to print values at points with Google Chart API?
I have gone through their developer guide but haven't been able to find a way to print the value at points (in case of line charts) or after bars (bar charts).Is there a way to do it?
You can achieve this with a label, it's in the documentation - it has an example with a bar chart.
How to print values at points with Google Chart API? I have gone through their developer guide but haven't been able to find a way to print the value at points (in case of line charts) or after bars (bar charts).Is there a way to do it?
TITLE: How to print values at points with Google Chart API? QUESTION: I have gone through their developer guide but haven't been able to find a way to print the value at points (in case of line charts) or after bars (bar charts).Is there a way to do it? ANSWER: You can achieve this with a label, it's in the documenta...
[ "charts" ]
0
2
1,217
2
0
2008-09-29T11:18:26.937000
2008-09-29T11:39:53.017000
148,298
148,302
How to check for equals? (0 == i) or (i == 0)
Okay, we know that the following two lines are equivalent - (0 == i) (i == 0) Also, the first method was encouraged in the past because that would have allowed the compiler to give an error message if you accidentally used '=' instead of '=='. My question is - in today's generation of pretty slick IDE's and intelligent...
I prefer the second one, (i == 0), because it feel much more natural when reading it. You ask people, "Are you 21 or older?", not, "Is 21 less than or equal to your age?"
How to check for equals? (0 == i) or (i == 0) Okay, we know that the following two lines are equivalent - (0 == i) (i == 0) Also, the first method was encouraged in the past because that would have allowed the compiler to give an error message if you accidentally used '=' instead of '=='. My question is - in today's ge...
TITLE: How to check for equals? (0 == i) or (i == 0) QUESTION: Okay, we know that the following two lines are equivalent - (0 == i) (i == 0) Also, the first method was encouraged in the past because that would have allowed the compiler to give an error message if you accidentally used '=' instead of '=='. My question ...
[ "c++", "c", "coding-style" ]
22
74
16,733
28
0
2008-09-29T11:20:44.983000
2008-09-29T11:23:50.373000
148,305
160,207
Best Way to Manage Configuration Data
I'm working on a SaaS application where each customer will have different configurations depending on the edition they have purchased, additional features they have purchased, etc. For example, a customer might have a limit of 3 custom reports. Obviously I want to store this configuration in the database, but I am unsu...
I think this would depend on how your product was sold to the customer. If you only sell it in packages... PACKAGE 1 -> 3 reports, date entry, some other stuff. PACKAGE 2 -> 6 reports, more stuff PACKAGE 3 -> 12 reports, almost all the stuff UBER PACKAGE -> everything I would think it would be easier to setup a table o...
Best Way to Manage Configuration Data I'm working on a SaaS application where each customer will have different configurations depending on the edition they have purchased, additional features they have purchased, etc. For example, a customer might have a limit of 3 custom reports. Obviously I want to store this config...
TITLE: Best Way to Manage Configuration Data QUESTION: I'm working on a SaaS application where each customer will have different configurations depending on the edition they have purchased, additional features they have purchased, etc. For example, a customer might have a limit of 3 custom reports. Obviously I want to...
[ "database-design", "configuration", "saas" ]
3
2
1,443
5
0
2008-09-29T11:24:09.827000
2008-10-01T23:22:43.437000
148,322
148,360
How to upload files from ASP.NET to another web application
I have a scenario where I need to upload a file from one web application and use it in another one. My setup is the following. One server, hosting two web applications in IIS - both are ASP.NET One of the applications is used to administer the other one + a bunch more stuff I need to upload a file from this admin app, ...
Since both applications are on the same server this should be straightforward: Save the uploaded file somewhere on the server. Create a virtual directory in any application needing to expose the files pointing to the physical path. Save the virtual path in the db for flexibility
How to upload files from ASP.NET to another web application I have a scenario where I need to upload a file from one web application and use it in another one. My setup is the following. One server, hosting two web applications in IIS - both are ASP.NET One of the applications is used to administer the other one + a bu...
TITLE: How to upload files from ASP.NET to another web application QUESTION: I have a scenario where I need to upload a file from one web application and use it in another one. My setup is the following. One server, hosting two web applications in IIS - both are ASP.NET One of the applications is used to administer th...
[ "asp.net", "file", "upload" ]
4
4
3,298
4
0
2008-09-29T11:30:54.943000
2008-09-29T11:45:52.880000
148,350
148,390
how to register url handler for apache commons httpclient
I want to be able to access custom URLs with apache httpclient. Something like this: HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("media:///squishy.jpg"); int statusCode = client.executeMethod(method); Can I somehow register a custom URL handler? Or should I just register one with Java, using...
I don't think there's a way to do this in commons httpclient. It doesn't make a whole lot of sense either, after all it is a HTTP client and "media:///squishy.jpg" is not HTTP, so all the code to implement the HTTP protocol probably couldn't be used anyways. URL.setURLStreamHandlerFactory(...) could be the way to go, b...
how to register url handler for apache commons httpclient I want to be able to access custom URLs with apache httpclient. Something like this: HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("media:///squishy.jpg"); int statusCode = client.executeMethod(method); Can I somehow register a custom U...
TITLE: how to register url handler for apache commons httpclient QUESTION: I want to be able to access custom URLs with apache httpclient. Something like this: HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("media:///squishy.jpg"); int statusCode = client.executeMethod(method); Can I somehow r...
[ "java", "httpclient" ]
1
0
1,907
2
0
2008-09-29T11:41:51.047000
2008-09-29T11:59:37.587000
148,354
148,386
Is it possible to create and then upload an Image file to a web server from silverlight?
I have just started using silverlight 2 beta and cannot find how to or if it is possible to render a canvas to an bitmap image and then upload it to my web server? Is this possible and if so how would I complete this task? Update: This is now possible under silverlight 3 using a writable bitmap to save the XAML as a JP...
You can't render a canvas to a bitmap in Silverlight 2, but if you could generate a XAML version of your Canvas, you could pass it to the server and do something like this server side: http://www.thedatafarm.com/blog/2008/01/31/ConvertingSilverlightInkPresenterImagesToAPNGFile.aspx
Is it possible to create and then upload an Image file to a web server from silverlight? I have just started using silverlight 2 beta and cannot find how to or if it is possible to render a canvas to an bitmap image and then upload it to my web server? Is this possible and if so how would I complete this task? Update: ...
TITLE: Is it possible to create and then upload an Image file to a web server from silverlight? QUESTION: I have just started using silverlight 2 beta and cannot find how to or if it is possible to render a canvas to an bitmap image and then upload it to my web server? Is this possible and if so how would I complete t...
[ "c#", "silverlight", "image-manipulation", "silverlight-2.0" ]
1
3
390
2
0
2008-09-29T11:43:27.300000
2008-09-29T11:57:45.657000
148,358
148,376
Where do you check to if a hotfix from Microsoft have been applied to any service packs?
I have a interest in a reported bug which Microsoft have made available a hotfix for. When looking on the site, I'm not able to figure out if this fix is included in a service pack or not. Do anyone know where I can find this out?
You didn't mention your product but: List of fixes in Service Pack 1 for XP: http://support.microsoft.com/kb/324720 List of fixes in Service Pack 2 for XP: http://support.microsoft.com/kb/811113 List of fixes in Service Pack 3 for XP: http://support.microsoft.com/kb/946480 List of fixes in Service Pack 1 for Vista: htt...
Where do you check to if a hotfix from Microsoft have been applied to any service packs? I have a interest in a reported bug which Microsoft have made available a hotfix for. When looking on the site, I'm not able to figure out if this fix is included in a service pack or not. Do anyone know where I can find this out?
TITLE: Where do you check to if a hotfix from Microsoft have been applied to any service packs? QUESTION: I have a interest in a reported bug which Microsoft have made available a hotfix for. When looking on the site, I'm not able to figure out if this fix is included in a service pack or not. Do anyone know where I c...
[ "hotfix" ]
1
1
1,298
2
0
2008-09-29T11:45:37.293000
2008-09-29T11:53:50.723000
148,361
148,444
How can I give keyboard focus to a DIV and attach keyboard event handlers to it?
I am building an application where I want to be able to click a rectangle represented by a DIV, and then use the keyboard to move that DIV by listing for keyboard events. Rather than using an event listener for those keyboard events at the document level, can I listen for keyboard events at the DIV level, perhaps by gi...
Sorted - I added tabindex attribute to the target DIV, which causes it to pick up keyboard events, for example this div can now have focus and receive keyboard events Information gleaned from http://www.w3.org/WAI/GL/WCAG20/WD-WCAG20-TECHS/SCR29.html
How can I give keyboard focus to a DIV and attach keyboard event handlers to it? I am building an application where I want to be able to click a rectangle represented by a DIV, and then use the keyboard to move that DIV by listing for keyboard events. Rather than using an event listener for those keyboard events at the...
TITLE: How can I give keyboard focus to a DIV and attach keyboard event handlers to it? QUESTION: I am building an application where I want to be able to click a rectangle represented by a DIV, and then use the keyboard to move that DIV by listing for keyboard events. Rather than using an event listener for those keyb...
[ "javascript", "events", "keyboard" ]
87
177
77,199
2
0
2008-09-29T11:46:09.103000
2008-09-29T12:18:32.300000
148,373
148,408
Restrict Template Function
I wrote a sample program at http://codepad.org/ko8vVCDF that uses a template function. How do I retrict the template function to only use numbers? (int, double etc.) #include #include using namespace std; template T sum(vector & a) { T result = 0; int size = a.size(); for(int i = 0; i < size; i++) { result += a[i]; } ...
The only way to restrict a template is to make it so that it uses something from the types that you want, that other types don't have. So, you construct with an int, use + and +=, call a copy constructor, etc. Any type that has all of these will work with your function -- so, if I create a new type that has these featu...
Restrict Template Function I wrote a sample program at http://codepad.org/ko8vVCDF that uses a template function. How do I retrict the template function to only use numbers? (int, double etc.) #include #include using namespace std; template T sum(vector & a) { T result = 0; int size = a.size(); for(int i = 0; i < size...
TITLE: Restrict Template Function QUESTION: I wrote a sample program at http://codepad.org/ko8vVCDF that uses a template function. How do I retrict the template function to only use numbers? (int, double etc.) #include #include using namespace std; template T sum(vector & a) { T result = 0; int size = a.size(); for(i...
[ "c++", "templates" ]
16
19
25,753
8
0
2008-09-29T11:52:12.893000
2008-09-29T12:04:13.600000
148,384
148,428
How do I inspect the Asp.Net request pipeline?
When I measure request times on "the inside" of an Asp.Net application and compare it to timings on "the outside" of the app, I get different values -- 1000-5000ms strange overheads from time to time. Maybe the requests are beeing queued up in front of IIS? Or something strange is going on in an HttpModule? The questio...
You can create your own module and register it on top to trace every request with more accuracy, but the measure will start once the IIS delegates the request to the ASP.NET ISAPI module. To get more accuracy you can go to IIS logs.
How do I inspect the Asp.Net request pipeline? When I measure request times on "the inside" of an Asp.Net application and compare it to timings on "the outside" of the app, I get different values -- 1000-5000ms strange overheads from time to time. Maybe the requests are beeing queued up in front of IIS? Or something st...
TITLE: How do I inspect the Asp.Net request pipeline? QUESTION: When I measure request times on "the inside" of an Asp.Net application and compare it to timings on "the outside" of the app, I get different values -- 1000-5000ms strange overheads from time to time. Maybe the requests are beeing queued up in front of II...
[ "asp.net", "iis" ]
2
1
2,217
4
0
2008-09-29T11:56:42.183000
2008-09-29T12:10:58.030000
148,398
148,465
Are there any disadvantages to always using nvarchar(MAX)?
In SQL Server 2005, are there any disadvantages to making all character fields nvarchar(MAX) rather than specifying a length explicitly, e.g. nvarchar(255)? (Apart from the obvious one that you aren't able to limit the field length at the database level)
Same question was asked on MSDN Forums: Varchar(max) vs Varchar(255) From the original post (much more information there): When you store data to a VARCHAR(N) column, the values are physically stored in the same way. But when you store it to a VARCHAR(MAX) column, behind the screen the data is handled as a TEXT value. ...
Are there any disadvantages to always using nvarchar(MAX)? In SQL Server 2005, are there any disadvantages to making all character fields nvarchar(MAX) rather than specifying a length explicitly, e.g. nvarchar(255)? (Apart from the obvious one that you aren't able to limit the field length at the database level)
TITLE: Are there any disadvantages to always using nvarchar(MAX)? QUESTION: In SQL Server 2005, are there any disadvantages to making all character fields nvarchar(MAX) rather than specifying a length explicitly, e.g. nvarchar(255)? (Apart from the obvious one that you aren't able to limit the field length at the data...
[ "sql", "sql-server", "sql-server-2005" ]
385
180
188,403
24
0
2008-09-29T12:01:11.750000
2008-09-29T12:25:44.703000
148,407
148,423
Why does the code below return true only for a = 1?
Why does the code below return true only for a = 1? main(){ int a = 10; if (true == a) cout<<"Why am I not getting executed"; }
When a Bool true is converted to an int, it's always converted to 1. Your code is thus, equivalent to: main(){ int a = 10; if (1 == a) cout<<"y i am not getting executed"; } This is part of the C++ standard, so it's something you would expect to happen with every C++ standards compliant compiler.
Why does the code below return true only for a = 1? Why does the code below return true only for a = 1? main(){ int a = 10; if (true == a) cout<<"Why am I not getting executed"; }
TITLE: Why does the code below return true only for a = 1? QUESTION: Why does the code below return true only for a = 1? main(){ int a = 10; if (true == a) cout<<"Why am I not getting executed"; } ANSWER: When a Bool true is converted to an int, it's always converted to 1. Your code is thus, equivalent to: main(){ in...
[ "c++", "conditional-statements" ]
13
38
2,180
11
0
2008-09-29T12:03:51.307000
2008-09-29T12:08:55.383000
148,421
148,440
Removing button while progress is displayed
I have a button on an ASP.NET wep application form and when clicked goes off and posts information a third party web service. I have an UpdateProgress associated with the button. how do disable/hide the button while the progress is visible (i.e. the server has not completed the operation) I am looking at doing this to ...
You'll have to hook a javascript method to the page request manager (Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest). Here is the code I would use to hide the buttons, I would prefer the disable them (see how that's done in the link at the bottom). ASP.NET Javascript See more about this at Why my A...
Removing button while progress is displayed I have a button on an ASP.NET wep application form and when clicked goes off and posts information a third party web service. I have an UpdateProgress associated with the button. how do disable/hide the button while the progress is visible (i.e. the server has not completed t...
TITLE: Removing button while progress is displayed QUESTION: I have a button on an ASP.NET wep application form and when clicked goes off and posts information a third party web service. I have an UpdateProgress associated with the button. how do disable/hide the button while the progress is visible (i.e. the server h...
[ "asp.net", "vb.net", "ajax" ]
3
3
637
3
0
2008-09-29T12:08:13.090000
2008-09-29T12:15:23.713000
148,441
148,447
How can I get the content of the file specified as the 'src' of a <script> tag?
If I have a script tag like this: I would like to get the content of the "script.js" file. I'm thinking about something like document.getElementById("myscript").text but it doesn't work in this case.
Do you want to get the contents of the file http://www.example.com/script.js? If so, you could turn to AJAX methods to fetch its content, assuming it resides on the same server as the page itself.
How can I get the content of the file specified as the 'src' of a <script> tag? If I have a script tag like this: I would like to get the content of the "script.js" file. I'm thinking about something like document.getElementById("myscript").text but it doesn't work in this case.
TITLE: How can I get the content of the file specified as the 'src' of a <script> tag? QUESTION: If I have a script tag like this: I would like to get the content of the "script.js" file. I'm thinking about something like document.getElementById("myscript").text but it doesn't work in this case. ANSWER: Do you want t...
[ "javascript" ]
79
12
63,689
17
0
2008-09-29T12:15:52.963000
2008-09-29T12:20:32.530000
148,451
148,473
How to use sed to replace only the first occurrence in a file?
I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file. How do I get sed to replace just the first occurrence of a string in a file rather than replacing every occurr...
# sed script to change "foo" to "bar" only on the first occurrence 1{x;s/^/first/;x;} 1,/foo/{x;/first/s///;x;s/foo/bar/;} #---end of script--- or, if you prefer: Editor's note: works with GNU sed only. sed '0,/foo/s//bar/' file Source
How to use sed to replace only the first occurrence in a file? I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file. How do I get sed to replace just the first occu...
TITLE: How to use sed to replace only the first occurrence in a file? QUESTION: I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file. How do I get sed to replace j...
[ "command-line", "sed", "text-processing" ]
328
184
523,351
25
0
2008-09-29T12:22:33.710000
2008-09-29T12:29:27.737000
148,478
196,912
Java 2D Drawing Optimal Performance
I'm in the process of writing a Java 2D game. I'm using the built-in Java 2D drawing libraries, drawing on a Graphics2D I acquire from a BufferStrategy from a Canvas in a JFrame (which is sometimes full-screened). The BufferStrategy is double-buffered. Repainting is done actively, via a timer. I'm having some performan...
I'm having the same issues as you are I think. Check out my post here: Java2D Performance Issues It shows the reason for the performance degradation and how to fix it. It's not guaranteed to work well on all platforms though. You'll see why in the post.
Java 2D Drawing Optimal Performance I'm in the process of writing a Java 2D game. I'm using the built-in Java 2D drawing libraries, drawing on a Graphics2D I acquire from a BufferStrategy from a Canvas in a JFrame (which is sometimes full-screened). The BufferStrategy is double-buffered. Repainting is done actively, vi...
TITLE: Java 2D Drawing Optimal Performance QUESTION: I'm in the process of writing a Java 2D game. I'm using the built-in Java 2D drawing libraries, drawing on a Graphics2D I acquire from a BufferStrategy from a Canvas in a JFrame (which is sometimes full-screened). The BufferStrategy is double-buffered. Repainting is...
[ "java", "performance", "graphics", "java-2d" ]
33
17
45,120
9
0
2008-09-29T12:32:30.067000
2008-10-13T07:23:08.977000
148,493
148,631
Advantages and drawbacks of chainable methods?
I really love the philosophy of chaining methods, like jQuery emphasys in its library. I found it quite elegant and clear. Being primarily Java developper, I've always wondering myself why this practice was not more used in this language. For example, the Collection interface was not designed in the that way (for addin...
Martin Fowler discusses this topic as 'fluent interfaces' at http://www.martinfowler.com/bliki/FluentInterface.html. One main issue is that fluent interfaces are designed for humans, therefore frameworks like Spring are not able to understand them. Simplistically using a fluent interface provides maintainability in one...
Advantages and drawbacks of chainable methods? I really love the philosophy of chaining methods, like jQuery emphasys in its library. I found it quite elegant and clear. Being primarily Java developper, I've always wondering myself why this practice was not more used in this language. For example, the Collection interf...
TITLE: Advantages and drawbacks of chainable methods? QUESTION: I really love the philosophy of chaining methods, like jQuery emphasys in its library. I found it quite elegant and clear. Being primarily Java developper, I've always wondering myself why this practice was not more used in this language. For example, the...
[ "language-agnostic" ]
8
0
463
7
0
2008-09-29T12:38:14.437000
2008-09-29T13:23:29.243000
148,511
148,551
Limiting range of value types in C++
Suppose I have a LimitedValue class which holds a value, and is parameterized on int types 'min' and 'max'. You'd use it as a container for holding values which can only be in a certain range. You could use it such: LimitedValue< float, 0, 360 > someAngle( 45.0 ); someTrigFunction( someAngle ); so that 'someTrigFunctio...
You can do this using templates -- try something like this: template< typename T, int min, int max >class LimitedValue { template< int min2, int max2 >LimitedValue( const LimitedValue< T, min2, max2 > &other ) { static_assert( min <= min2, "Parameter minimum must be >= this minimum" ); static_assert( max >= max2, "Para...
Limiting range of value types in C++ Suppose I have a LimitedValue class which holds a value, and is parameterized on int types 'min' and 'max'. You'd use it as a container for holding values which can only be in a certain range. You could use it such: LimitedValue< float, 0, 360 > someAngle( 45.0 ); someTrigFunction( ...
TITLE: Limiting range of value types in C++ QUESTION: Suppose I have a LimitedValue class which holds a value, and is parameterized on int types 'min' and 'max'. You'd use it as a container for holding values which can only be in a certain range. You could use it such: LimitedValue< float, 0, 360 > someAngle( 45.0 ); ...
[ "c++", "templates" ]
27
18
25,848
9
0
2008-09-29T12:43:52.520000
2008-09-29T13:00:35.493000
148,518
148,526
How to Regex search/replace only first occurrence in a string in .NET?
It seems the.NET Regex.Replace method automatically replaces all matching occurrences. I could provide a MatchEvaluator delegate that returns the matched string after the first replacement, rendering no change, but that sounds very inefficient to me. What is the most efficient way to stop after the first replacement?
From MSDN: Replace(String, String, Int32) Within a specified input string, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string. Isn't this what you want?
How to Regex search/replace only first occurrence in a string in .NET? It seems the.NET Regex.Replace method automatically replaces all matching occurrences. I could provide a MatchEvaluator delegate that returns the matched string after the first replacement, rendering no change, but that sounds very inefficient to me...
TITLE: How to Regex search/replace only first occurrence in a string in .NET? QUESTION: It seems the.NET Regex.Replace method automatically replaces all matching occurrences. I could provide a MatchEvaluator delegate that returns the matched string after the first replacement, rendering no change, but that sounds very...
[ ".net", "regex" ]
33
32
27,081
4
0
2008-09-29T12:47:22.187000
2008-09-29T12:48:45.007000
148,530
148,606
NoClassDefFoundError with a long classname on Tomcat with java 1.4.2_07-b05
I have a java class: it.eng.ancona.view.RuoliView$TabElaborazioneFattureValidazione$ElencoDettaglioElaborazioneFattureValidazione$RigaElencoDettaglioElaborazioneFattureValidazione It's so long for multiple inner class. If I use 1.4.2_07-b05 on Eclipse and I call this class, all goes fine. If I use 1.4.2_07-b05 on Tomca...
This could be caused by the maximum path length of Windows. Try moving your Tomcat server to something like C:\TC to see if you still have a problem. Also check if the jar that this class should be in, actually does have it.
NoClassDefFoundError with a long classname on Tomcat with java 1.4.2_07-b05 I have a java class: it.eng.ancona.view.RuoliView$TabElaborazioneFattureValidazione$ElencoDettaglioElaborazioneFattureValidazione$RigaElencoDettaglioElaborazioneFattureValidazione It's so long for multiple inner class. If I use 1.4.2_07-b05 on ...
TITLE: NoClassDefFoundError with a long classname on Tomcat with java 1.4.2_07-b05 QUESTION: I have a java class: it.eng.ancona.view.RuoliView$TabElaborazioneFattureValidazione$ElencoDettaglioElaborazioneFattureValidazione$RigaElencoDettaglioElaborazioneFattureValidazione It's so long for multiple inner class. If I us...
[ "java", "tomcat", "noclassdeffounderror", "classname" ]
0
2
488
2
0
2008-09-29T12:50:09.247000
2008-09-29T13:16:08.217000