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
195,072
195,083
Possible circular dependency issue with PHP application
I'm experiencing what I believe is a circular dependency issue with my PHP application. Please let me know if this is incorrect. Here is the situation: Two classes, LogManager and DBSession. DBSession is used to interact with the database, and LogManager is used to log to files. Both are widely used in my application. ...
Don't extend LogManager, let it be an aggregate type. And delay the choice of where you want to log, i.e.: $logManager = new LogManager(); $dbSession = new DbSession($logManager); $logManager->add(new FileLog($filename) ); $logManager->add(new DBLog($dbSession) ); Where of course FileLog and DBLog share a common interf...
Possible circular dependency issue with PHP application I'm experiencing what I believe is a circular dependency issue with my PHP application. Please let me know if this is incorrect. Here is the situation: Two classes, LogManager and DBSession. DBSession is used to interact with the database, and LogManager is used t...
TITLE: Possible circular dependency issue with PHP application QUESTION: I'm experiencing what I believe is a circular dependency issue with my PHP application. Please let me know if this is incorrect. Here is the situation: Two classes, LogManager and DBSession. DBSession is used to interact with the database, and Lo...
[ "php", "oop", "dependencies", "instantiation", "circular-dependency" ]
7
8
1,268
4
0
2008-10-12T03:57:57.877000
2008-10-12T04:11:16.057000
195,078
195,223
Is it possible to make the -init method private in Objective-C?
I need to hide (make private) the -init method of my class in Objective-C. How can I do that?
Objective-C, like Smalltalk, has no concept of "private" versus "public" methods. Any message can be sent to any object at any time. What you can do is throw an NSInternalInconsistencyException if your -init method is invoked: - (id)init { [self release]; @throw [NSException exceptionWithName:NSInternalInconsistencyExc...
Is it possible to make the -init method private in Objective-C? I need to hide (make private) the -init method of my class in Objective-C. How can I do that?
TITLE: Is it possible to make the -init method private in Objective-C? QUESTION: I need to hide (make private) the -init method of my class in Objective-C. How can I do that? ANSWER: Objective-C, like Smalltalk, has no concept of "private" versus "public" methods. Any message can be sent to any object at any time. Wh...
[ "objective-c" ]
157
90
45,380
9
0
2008-10-12T04:07:40.543000
2008-10-12T08:04:50.813000
195,096
195,110
Is there a site that emails out daily C# tips and tricks?
I subscribe to a newsletter from www.sqlservercentral.com that I like because each day I get an email digest with some interesting headlines & summaries of SQL Server articles that are already out there on the web. It's a great way to learn something new a bit at a time. Is there something like this for C#? (If your fa...
In addition to codeproject, I believe there are other sites like C# Corner, C# help which does the same.. Couple more I found useful (Not specific to C#): visualstudiomagazine Dr. Dobb's
Is there a site that emails out daily C# tips and tricks? I subscribe to a newsletter from www.sqlservercentral.com that I like because each day I get an email digest with some interesting headlines & summaries of SQL Server articles that are already out there on the web. It's a great way to learn something new a bit a...
TITLE: Is there a site that emails out daily C# tips and tricks? QUESTION: I subscribe to a newsletter from www.sqlservercentral.com that I like because each day I get an email digest with some interesting headlines & summaries of SQL Server articles that are already out there on the web. It's a great way to learn som...
[ "c#", "newsletter" ]
8
8
7,542
4
0
2008-10-12T04:26:08.897000
2008-10-12T04:51:14.370000
195,101
195,152
Running a web app in Grails vs Django
I'm currently in the planning stage for a web application and I find myself trying to decide on using Grails or Django. From an operation perspective: Which ecosystem is easier to maintain (migrations, backup, disaster recovery etc.)? If using grails it'll probably be a typical tomcat + mysql on linux. If django it'll ...
You can run grails in 256 megs of ram. Many members of the community are doing so. That being said I would say in either platform you want much more ram than that to make sure your performant. But I might also reccomend checking out www.linode.com. You can get quality hosting for a very reasonable cost and adding a bit...
Running a web app in Grails vs Django I'm currently in the planning stage for a web application and I find myself trying to decide on using Grails or Django. From an operation perspective: Which ecosystem is easier to maintain (migrations, backup, disaster recovery etc.)? If using grails it'll probably be a typical tom...
TITLE: Running a web app in Grails vs Django QUESTION: I'm currently in the planning stage for a web application and I find myself trying to decide on using Grails or Django. From an operation perspective: Which ecosystem is easier to maintain (migrations, backup, disaster recovery etc.)? If using grails it'll probabl...
[ "python", "django", "grails", "groovy", "web-applications" ]
5
9
5,138
5
0
2008-10-12T04:36:49.203000
2008-10-12T06:23:56.257000
195,109
195,247
Running compiled python (py2exe) as administrator in Vista
Is it possible to programaticly run compiled Python (comiled via py2exe) as administrator in Vista? Some more clarification: I have written a program that modifies the windows hosts file (c:\Windows\system32\drivers\etc\hosts) in Vista the program will not run and will fail with an exception unless you right-click and ...
Do you mean that you want Windows to prompt for elevation when your program is run? This is controlled by adding a UAC manifest to the EXE's resources. This blog entry explains how to create the manifest and how to compile it into a.RES file. I don't know what facilities py2exe has for embedding custom.RES files, so yo...
Running compiled python (py2exe) as administrator in Vista Is it possible to programaticly run compiled Python (comiled via py2exe) as administrator in Vista? Some more clarification: I have written a program that modifies the windows hosts file (c:\Windows\system32\drivers\etc\hosts) in Vista the program will not run ...
TITLE: Running compiled python (py2exe) as administrator in Vista QUESTION: Is it possible to programaticly run compiled Python (comiled via py2exe) as administrator in Vista? Some more clarification: I have written a program that modifies the windows hosts file (c:\Windows\system32\drivers\etc\hosts) in Vista the pro...
[ "python", "windows-vista", "permissions", "py2exe" ]
8
5
8,877
4
0
2008-10-12T04:46:16.627000
2008-10-12T08:55:22.693000
195,114
195,128
Custom button in C#: How to remove hover background?
I'm trying to do a custom button to my form (which has FormBorderStyle = none) using Visual Studio 2005. I have my 3 states button images in an ImageList linked to the button. this.btnClose.AutoSize = false; this.btnClose.BackColor = System.Drawing.Color.Transparent; this.btnClose.BackgroundImageLayout = System.Windows...
The grey background is due to the setting of "System.Windows.Forms.FlatStyle.Flat", it's the default behaviour, since it need to highlight the button when you hover. To eliminate that, you might have to write a custom button class, inherit from the original button and do some custom painting to achieve that. Btw, inste...
Custom button in C#: How to remove hover background? I'm trying to do a custom button to my form (which has FormBorderStyle = none) using Visual Studio 2005. I have my 3 states button images in an ImageList linked to the button. this.btnClose.AutoSize = false; this.btnClose.BackColor = System.Drawing.Color.Transparent;...
TITLE: Custom button in C#: How to remove hover background? QUESTION: I'm trying to do a custom button to my form (which has FormBorderStyle = none) using Visual Studio 2005. I have my 3 states button images in an ImageList linked to the button. this.btnClose.AutoSize = false; this.btnClose.BackColor = System.Drawing....
[ "c#", ".net", "winforms", "button" ]
9
11
35,051
8
0
2008-10-12T04:56:27.527000
2008-10-12T05:17:01.557000
195,116
195,124
Is there a faster alternative to python's Decimal?
Does anyone know of a faster decimal implementation in python? As the example below demonstrates, the standard library's decimal module is ~100 times slower than float. from timeit import Timer def run(val, the_class): test = the_class(1) for c in xrange(10000): d = the_class(val) d + test d - test d * test d / test d...
The GMP library is one of the best arbitrary precision math libraries around, and there is a Python binding available at GMPY. I would try that method.
Is there a faster alternative to python's Decimal? Does anyone know of a faster decimal implementation in python? As the example below demonstrates, the standard library's decimal module is ~100 times slower than float. from timeit import Timer def run(val, the_class): test = the_class(1) for c in xrange(10000): d = t...
TITLE: Is there a faster alternative to python's Decimal? QUESTION: Does anyone know of a faster decimal implementation in python? As the example below demonstrates, the standard library's decimal module is ~100 times slower than float. from timeit import Timer def run(val, the_class): test = the_class(1) for c in xr...
[ "python", "python-decimal" ]
19
12
17,500
5
0
2008-10-12T05:03:05.843000
2008-10-12T05:11:37.947000
195,117
195,122
How do I set the login info for SQL Server 2008 in Entity Framework?
Okay I'm still learning the ropes with the Entity Framework and I came across one more small issue. When I create my Entity Model from the SQL Server 2008 database it warns me about saving the login information in the connection string in the config file. Initially I wasn't concerned about that so I just left it in the...
Check this out: Security Considerations (Entity Framework) Encrypting Connections to SQL Server Encrypting Configuration Information Using Protected Configuration
How do I set the login info for SQL Server 2008 in Entity Framework? Okay I'm still learning the ropes with the Entity Framework and I came across one more small issue. When I create my Entity Model from the SQL Server 2008 database it warns me about saving the login information in the connection string in the config f...
TITLE: How do I set the login info for SQL Server 2008 in Entity Framework? QUESTION: Okay I'm still learning the ropes with the Entity Framework and I came across one more small issue. When I create my Entity Model from the SQL Server 2008 database it warns me about saving the login information in the connection stri...
[ "c#", ".net", "entity-framework", "sql-server-2008", "connection-string" ]
0
2
233
1
0
2008-10-12T05:03:12.567000
2008-10-12T05:09:56.533000
195,133
195,166
What are the options available for cross platform rich user interfaces development?
Some of the requirements (restrictions) for such a ui framework/toolkit are: No single vendor lock down Ability for real time data visualization Good initial widgets Good dash boarding capabilities cross platform Good development/debug environment No flash
It's a pity you can't/won't use Flash. Else I could really recommend Adobe AIR. It has a good editor (Flex Builder built on Eclipse), a good component framework with many out of the box components, charting components set, ability to communicate with many different protocols (and you could write your own protocol imple...
What are the options available for cross platform rich user interfaces development? Some of the requirements (restrictions) for such a ui framework/toolkit are: No single vendor lock down Ability for real time data visualization Good initial widgets Good dash boarding capabilities cross platform Good development/debug ...
TITLE: What are the options available for cross platform rich user interfaces development? QUESTION: Some of the requirements (restrictions) for such a ui framework/toolkit are: No single vendor lock down Ability for real time data visualization Good initial widgets Good dash boarding capabilities cross platform Good ...
[ "ajax", "user-interface", "real-time", "dashboard" ]
3
3
551
7
0
2008-10-12T05:31:43.930000
2008-10-12T07:00:33.780000
195,151
195,171
How do I handle foreign keys with WPF databinding?
I have a ListView in WPF that is databound to a basic table that I pull from the database. The code for the ListView is as follows: Set Language Number Artwork The IdCst column is a foreign key to a separate table, and I'd like to display the actual name field from that table instead of just the Id. Does anybody know h...
This blog post may help:...I assumed the foreign key should be bound to the ‘SelectedValue’ property, and there is an ItemSource that I can bind to my fact table so the drop down is populated. At this point my dropdown worked, but nothing would appear in the combobox. I finally noticed a ‘SelectedItemPath’ property - I...
How do I handle foreign keys with WPF databinding? I have a ListView in WPF that is databound to a basic table that I pull from the database. The code for the ListView is as follows: Set Language Number Artwork The IdCst column is a foreign key to a separate table, and I'd like to display the actual name field from tha...
TITLE: How do I handle foreign keys with WPF databinding? QUESTION: I have a ListView in WPF that is databound to a basic table that I pull from the database. The code for the ListView is as follows: Set Language Number Artwork The IdCst column is a foreign key to a separate table, and I'd like to display the actual n...
[ "wpf", "data-binding" ]
2
3
4,594
3
0
2008-10-12T06:20:59.883000
2008-10-12T07:07:07.933000
195,173
195,181
When running UPDATE ... datetime = NOW(); will all rows updated have the same date/time?
When you run something similar to: UPDATE table SET datetime = NOW(); on a table with 1 000 000 000 records and the query takes 10 seconds to run, will all the rows have the exact same time (minutes and seconds) or will they have different times? In other words, will the time be when the query started or when each row ...
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now "NOW() returns a constant time that indicates the time at which the statement began to execute. (Within a stored routine or trigger, NOW() returns the time at which the routine or triggering statement began to execute.) This differs from t...
When running UPDATE ... datetime = NOW(); will all rows updated have the same date/time? When you run something similar to: UPDATE table SET datetime = NOW(); on a table with 1 000 000 000 records and the query takes 10 seconds to run, will all the rows have the exact same time (minutes and seconds) or will they have d...
TITLE: When running UPDATE ... datetime = NOW(); will all rows updated have the same date/time? QUESTION: When you run something similar to: UPDATE table SET datetime = NOW(); on a table with 1 000 000 000 records and the query takes 10 seconds to run, will all the rows have the exact same time (minutes and seconds) o...
[ "mysql", "sql", "datetime", "sql-update" ]
52
53
113,417
4
0
2008-10-12T07:08:15.233000
2008-10-12T07:14:12.537000
195,175
195,271
Building User ID/Password Functionality with Ruby on Rails? Overkill?
I am new to this community, but I am working on a site that requires implementation of a user/password/register check upon entry, which would check against a database, or write to the database, in the case of registration. I have experience with XHTML and CSS, and just discovered RoR. I honestly have very little insigh...
I would recommend looking at Restful Authentication. Also, for good code examples in general, have a look at Altered Beast. It's a forum built in Ruby on Rails and it uses Restful Authentication.
Building User ID/Password Functionality with Ruby on Rails? Overkill? I am new to this community, but I am working on a site that requires implementation of a user/password/register check upon entry, which would check against a database, or write to the database, in the case of registration. I have experience with XHTM...
TITLE: Building User ID/Password Functionality with Ruby on Rails? Overkill? QUESTION: I am new to this community, but I am working on a site that requires implementation of a user/password/register check upon entry, which would check against a database, or write to the database, in the case of registration. I have ex...
[ "ruby-on-rails", "passwords", "userid" ]
0
1
1,134
3
0
2008-10-12T07:09:59.597000
2008-10-12T09:19:07.370000
195,177
195,708
How to update contacts in Zimbra by scripting?
I have a Zimbra installation and I need to programmaticaly update contacts in it. It seems that its REST interface is only working to add new contacts, but I need to update existing ones. Is there a way, tool or something, open-source, to do that?
Well, I have an answer to my question: you may use the "zmmailbox" command. Under the Zimbra system user, it is possible to modify content in a mailbox. Since quite everything is stored in the Zimbra mailbox, contacts can be edited. I need now to find a way to use this: box$ zmmailbox help contact autoComplete(ac) [op...
How to update contacts in Zimbra by scripting? I have a Zimbra installation and I need to programmaticaly update contacts in it. It seems that its REST interface is only working to add new contacts, but I need to update existing ones. Is there a way, tool or something, open-source, to do that?
TITLE: How to update contacts in Zimbra by scripting? QUESTION: I have a Zimbra installation and I need to programmaticaly update contacts in it. It seems that its REST interface is only working to add new contacts, but I need to update existing ones. Is there a way, tool or something, open-source, to do that? ANSWER...
[ "open-source", "scripting", "system-administration", "zimbra" ]
3
2
4,461
4
0
2008-10-12T07:12:02.980000
2008-10-12T17:07:36.973000
195,189
195,230
Quick Rhinomocks Help
Can someone take a look at this code and tell me if there's any obvious reason it shouldn't be working? When service.getResponse is called within my code the mocking framework only returns null, not the object I specified. [Test] public void Get_All_Milestones() { var mockRepo = new MockRepository(); var service = mock...
A dynamic mock will return null if the input data does not match the expected, so my guess would be that your code is calling service.GetResponse() with different values for the RestRequestObject or that equality for the RestRequestObject does not work as you expect it to. I think I would try replacing the dynamic mock...
Quick Rhinomocks Help Can someone take a look at this code and tell me if there's any obvious reason it shouldn't be working? When service.getResponse is called within my code the mocking framework only returns null, not the object I specified. [Test] public void Get_All_Milestones() { var mockRepo = new MockRepository...
TITLE: Quick Rhinomocks Help QUESTION: Can someone take a look at this code and tell me if there's any obvious reason it shouldn't be working? When service.getResponse is called within my code the mocking framework only returns null, not the object I specified. [Test] public void Get_All_Milestones() { var mockRepo = ...
[ "unit-testing", "tdd", "rhino-mocks" ]
0
0
150
1
0
2008-10-12T07:21:22.680000
2008-10-12T08:22:06.037000
195,207
195,209
Unresolved external symbol on static class members
Very simply put: I have a class that consists mostly of static public members, so I can group similar functions together that still have to be called from other classes/functions. Anyway, I have defined two static unsigned char variables in my class public scope, when I try to modify these values in the same class' con...
If you are using C++ 17 you can just use the inline specifier (see https://stackoverflow.com/a/11711082/55721 ) If using older versions of the C++ standard, you must add the definitions to match your declarations of X and Y unsigned char test::X; unsigned char test::Y; somewhere. You might want to also initialize a sta...
Unresolved external symbol on static class members Very simply put: I have a class that consists mostly of static public members, so I can group similar functions together that still have to be called from other classes/functions. Anyway, I have defined two static unsigned char variables in my class public scope, when ...
TITLE: Unresolved external symbol on static class members QUESTION: Very simply put: I have a class that consists mostly of static public members, so I can group similar functions together that still have to be called from other classes/functions. Anyway, I have defined two static unsigned char variables in my class p...
[ "c++", "class", "static", "members" ]
160
179
173,489
6
0
2008-10-12T07:45:06.517000
2008-10-12T07:49:10.860000
195,212
195,219
What are the advantages of using a GET request over a POST request?
Several of my ajax applications in the past have used GET request but now I'm starting to use POST request instead. POST requests seem to be slightly more secure and definitely more url friendly/pretty. Thus, i'm wondering if there is any reason why I should use GET request at all.
I generally set up the question as thus: Does anything important change after the request? (Logging and the like notwithstanding). If it does, it should be a POST request, if it doesn't, it should be a GET request. I'm glad that you call POST requests "slightly" more secure, because that's pretty much what they are; it...
What are the advantages of using a GET request over a POST request? Several of my ajax applications in the past have used GET request but now I'm starting to use POST request instead. POST requests seem to be slightly more secure and definitely more url friendly/pretty. Thus, i'm wondering if there is any reason why I ...
TITLE: What are the advantages of using a GET request over a POST request? QUESTION: Several of my ajax applications in the past have used GET request but now I'm starting to use POST request instead. POST requests seem to be slightly more secure and definitely more url friendly/pretty. Thus, i'm wondering if there is...
[ "ajax", "http", "http-post", "protocols", "http-get" ]
34
27
22,848
8
0
2008-10-12T07:51:05.660000
2008-10-12T07:58:33.757000
195,240
195,248
How do I check if a tag exists in XSLT?
I have the following template one two three I would like to only display the headers (one,two,three) if there is at least one member of the corresponding template. How do I check for this?
one Alternatively, you could create a named template, and then call as: But to be honest, that looks like more work to me... only useful if drawing a header is complex... for a simple... I'd be tempted to leave it inline. If the header title is always the node name, you could simplifiy the template by removing the "$he...
How do I check if a tag exists in XSLT? I have the following template one two three I would like to only display the headers (one,two,three) if there is at least one member of the corresponding template. How do I check for this?
TITLE: How do I check if a tag exists in XSLT? QUESTION: I have the following template one two three I would like to only display the headers (one,two,three) if there is at least one member of the corresponding template. How do I check for this? ANSWER: one Alternatively, you could create a named template, and then c...
[ "xslt", "tags" ]
9
15
15,932
2
0
2008-10-12T08:39:07.407000
2008-10-12T08:55:35.657000
195,262
195,575
Can I turn off antialiasing on an HTML <canvas> element?
I'm playing around with the element, drawing lines and such. I've noticed that my diagonal lines are antialiased. I'd prefer the jaggy look for what I'm doing - is there any way of turning this feature off?
For images there's now context.imageSmoothingEnabled = false. However, there's nothing that explicitly controls line drawing. You may need to draw your own lines ( the hard way ) using getImageData and putImageData.
Can I turn off antialiasing on an HTML <canvas> element? I'm playing around with the element, drawing lines and such. I've noticed that my diagonal lines are antialiased. I'd prefer the jaggy look for what I'm doing - is there any way of turning this feature off?
TITLE: Can I turn off antialiasing on an HTML <canvas> element? QUESTION: I'm playing around with the element, drawing lines and such. I've noticed that my diagonal lines are antialiased. I'd prefer the jaggy look for what I'm doing - is there any way of turning this feature off? ANSWER: For images there's now contex...
[ "javascript", "html", "canvas", "antialiasing" ]
118
85
120,504
16
0
2008-10-12T09:07:06.477000
2008-10-12T14:52:11.520000
195,270
196,523
Professional jQuery based Combobox control?
Are there any professional Combobox controls (dropdown list with autosuggestion) based on the jQuery library? It should be able to handle large datasets and have some skinning options. A multi-column result list would be great too. I'm working with ASP.NET, but it's a not a problem if I had to write a wrapper for it. I...
Unfortunately, the best thing I have seen is the jquery.combobox, but it doesn't really look like something I'd really want to use in my web applications. I think there are some usability issues with this control, but as a user I don't think I'd know to start typing for the dropdownlist to turn into a textbox. I much p...
Professional jQuery based Combobox control? Are there any professional Combobox controls (dropdown list with autosuggestion) based on the jQuery library? It should be able to handle large datasets and have some skinning options. A multi-column result list would be great too. I'm working with ASP.NET, but it's a not a p...
TITLE: Professional jQuery based Combobox control? QUESTION: Are there any professional Combobox controls (dropdown list with autosuggestion) based on the jQuery library? It should be able to handle large datasets and have some skinning options. A multi-column result list would be great too. I'm working with ASP.NET, ...
[ "javascript", "jquery", "combobox", "controls" ]
87
25
135,289
22
0
2008-10-12T09:18:53.423000
2008-10-13T02:12:09.010000
195,286
195,309
A mod_rewrite problem
I'm trying to implement the following mod_rewrite rule: host.com/developer/ => host.com/developer/index.py host.com/developer/branchX => host.com/developer/index.py?branch=branchX host.com/developer/branchX/commitY => host.com/developer/index.py?branch=branchX&commit=commitY Currently, the appropriate config section lo...
The problem is that the url you are rewriting to is matched in the next pass. L specifies the last rule but only for this execution of the rules, URLs are processed again under certain circumstances (in this case, internal redirects). The solution is to add a RewriteCond to prevent looping, like this: RewriteEngine on ...
A mod_rewrite problem I'm trying to implement the following mod_rewrite rule: host.com/developer/ => host.com/developer/index.py host.com/developer/branchX => host.com/developer/index.py?branch=branchX host.com/developer/branchX/commitY => host.com/developer/index.py?branch=branchX&commit=commitY Currently, the appropr...
TITLE: A mod_rewrite problem QUESTION: I'm trying to implement the following mod_rewrite rule: host.com/developer/ => host.com/developer/index.py host.com/developer/branchX => host.com/developer/index.py?branch=branchX host.com/developer/branchX/commitY => host.com/developer/index.py?branch=branchX&commit=commitY Curr...
[ "apache", "mod-rewrite" ]
0
0
350
1
0
2008-10-12T09:44:30.470000
2008-10-12T10:21:21.990000
195,287
195,295
Swap every pair of characters in string
I'd like to get all the permutations of swapped characters pairs of a string. For example: Base string: abcd Combinations: bacd acbd abdc etc. Edit I want to swap only letters that are next to each other. Like first with second, second with third, but not third with sixth. What's the best way to do this? Edit Just for ...
Edit: Markdown hates me today... $input = "abcd"; $len = strlen($input); $output = array(); for ($i = 0; $i < $len - 1; ++$i) { $output[] = substr($input, 0, $i). substr($input, $i + 1, 1). substr($input, $i, 1). substr($input, $i + 2); } print_r($output);
Swap every pair of characters in string I'd like to get all the permutations of swapped characters pairs of a string. For example: Base string: abcd Combinations: bacd acbd abdc etc. Edit I want to swap only letters that are next to each other. Like first with second, second with third, but not third with sixth. What's...
TITLE: Swap every pair of characters in string QUESTION: I'd like to get all the permutations of swapped characters pairs of a string. For example: Base string: abcd Combinations: bacd acbd abdc etc. Edit I want to swap only letters that are next to each other. Like first with second, second with third, but not third ...
[ "php", "string" ]
5
3
4,920
5
0
2008-10-12T09:45:39.847000
2008-10-12T10:00:34.090000
195,288
201,365
ASP.NET OleDbConnection Problem
I'm working on an ASP.NET website where I am using an asp:repeater with paging done through a VB.NET code-behind file. I'm having trouble with the database connection though. As far as I can tell, the paging is working, but I can't get the data to be certain. The database is a Microsoft Access database. The function th...
Problem solved! Pretty much banging my head against the wall now considering how simple it was. It was the Page_Load, I changed it to the following: Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load doPaging() End Sub And voila, it works! Also, for the connection string, I en...
ASP.NET OleDbConnection Problem I'm working on an ASP.NET website where I am using an asp:repeater with paging done through a VB.NET code-behind file. I'm having trouble with the database connection though. As far as I can tell, the paging is working, but I can't get the data to be certain. The database is a Microsoft ...
TITLE: ASP.NET OleDbConnection Problem QUESTION: I'm working on an ASP.NET website where I am using an asp:repeater with paging done through a VB.NET code-behind file. I'm having trouble with the database connection though. As far as I can tell, the paging is working, but I can't get the data to be certain. The databa...
[ "asp.net", "vb.net", "repeater", "paging", "oledbconnection" ]
0
0
2,369
3
0
2008-10-12T09:47:16.503000
2008-10-14T14:24:20.797000
195,293
195,308
Disable Visual Studio's validation of non-xml files that look like xml?
I have a bunch of Velocity template files in a Visual Studio 2008 project, the problem is that despite the fact that the extension is.vm instead of.xml or similar Visual Studio thinks that the HTML they contains must conform to XML naming standards and generates errors (not just warnings even) on each compilation. How ...
Xml errors usually only show if the file is open. You can normally disable it by not opening it into the xml editor; the errors don't normally stop a build - they just look like they do. Right click -> Open With... Source (Text) Editor (or HTML if you prefer) (and set as default).
Disable Visual Studio's validation of non-xml files that look like xml? I have a bunch of Velocity template files in a Visual Studio 2008 project, the problem is that despite the fact that the extension is.vm instead of.xml or similar Visual Studio thinks that the HTML they contains must conform to XML naming standards...
TITLE: Disable Visual Studio's validation of non-xml files that look like xml? QUESTION: I have a bunch of Velocity template files in a Visual Studio 2008 project, the problem is that despite the fact that the extension is.vm instead of.xml or similar Visual Studio thinks that the HTML they contains must conform to XM...
[ "visual-studio-2008" ]
13
16
4,721
3
0
2008-10-12T09:58:55.653000
2008-10-12T10:20:48.057000
195,304
195,331
Check if serial port is listening
I have an Arduino sending and receiving instructions with a Python script via a serial port. The Arduino takes a button state and when it is pushed, it will send a message via the serial port to a Python script and await a response. (via Serial.available() ). It works well enough. However, if the Python script has cras...
You have a limited ability to detect if there is something listening on the other side by using the DSR/DTR pins. When you open the serial port on the machine your scripts runs on, it should raise its DTR pin (or you should be able to convince it to do so: the documentation of the library you use to drive the COM port ...
Check if serial port is listening I have an Arduino sending and receiving instructions with a Python script via a serial port. The Arduino takes a button state and when it is pushed, it will send a message via the serial port to a Python script and await a response. (via Serial.available() ). It works well enough. Howe...
TITLE: Check if serial port is listening QUESTION: I have an Arduino sending and receiving instructions with a Python script via a serial port. The Arduino takes a button state and when it is pushed, it will send a message via the serial port to a Python script and await a response. (via Serial.available() ). It works...
[ "serial-port", "arduino" ]
6
7
9,817
3
0
2008-10-12T10:15:19.007000
2008-10-12T10:46:23.873000
195,321
195,328
Why is Class.newInstance() "evil"?
Ryan Delucchi asked here in comment #3 to Tom Hawtin 's answer: why is Class.newInstance() "evil"? this in response to the code sample: // Avoid Class.newInstance, for it is evil. Constructor ctor = runClass.getConstructor(); Runnable doRun = ctor.newInstance(); so, why is it Evil?
The Java API documentation explains why ( http://java.sun.com/javase/6/docs/api/java/lang/Class.html#newInstance() ): Note that this method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would ot...
Why is Class.newInstance() "evil"? Ryan Delucchi asked here in comment #3 to Tom Hawtin 's answer: why is Class.newInstance() "evil"? this in response to the code sample: // Avoid Class.newInstance, for it is evil. Constructor ctor = runClass.getConstructor(); Runnable doRun = ctor.newInstance(); so, why is it Evil?
TITLE: Why is Class.newInstance() "evil"? QUESTION: Ryan Delucchi asked here in comment #3 to Tom Hawtin 's answer: why is Class.newInstance() "evil"? this in response to the code sample: // Avoid Class.newInstance, for it is evil. Constructor ctor = runClass.getConstructor(); Runnable doRun = ctor.newInstance(); so, ...
[ "java", "constructor", "runtime", "instantiation" ]
100
86
79,751
3
0
2008-10-12T10:40:12.497000
2008-10-12T10:43:31.913000
195,323
195,350
What is the most elegant way to read a text file with c++?
I'd like to read whole content of a text file to a std::string object with c++. With Python, I can write: text = open("text.txt", "rt").read() It is very simple and elegant. I hate ugly stuff, so I'd like to know - what is the most elegant way to read a text file with C++? Thanks.
There are many ways, you pick which is the most elegant for you. Reading into char*: ifstream file ("file.txt", ios::in|ios::binary|ios::ate); if (file.is_open()) { file.seekg(0, ios::end); size = file.tellg(); char *contents = new char [size]; file.seekg (0, ios::beg); file.read (contents, size); file.close(); //... d...
What is the most elegant way to read a text file with c++? I'd like to read whole content of a text file to a std::string object with c++. With Python, I can write: text = open("text.txt", "rt").read() It is very simple and elegant. I hate ugly stuff, so I'd like to know - what is the most elegant way to read a text fi...
TITLE: What is the most elegant way to read a text file with c++? QUESTION: I'd like to read whole content of a text file to a std::string object with c++. With Python, I can write: text = open("text.txt", "rt").read() It is very simple and elegant. I hate ugly stuff, so I'd like to know - what is the most elegant way...
[ "c++", "text", "file-io" ]
67
138
73,241
5
0
2008-10-12T10:40:15.833000
2008-10-12T11:06:34.907000
195,332
195,395
How to deal with old, obsolete database data of a long running system?
What are the possibilities of a programmer to handle data that are rarely used but cannot be simply deleted because at least reporting still requires it? Some examples I am thinking of: Discountinued funding types of older years of a university Unused currencies (e.g. Italian lira) Names of disappeared countries (e.g. ...
With old data not used in most queries the best solution is to partition tables by the the key which differentiates stale from current data (such as date, currency_id or things like that). You can then put the stale data in separate tables, databases or even servers (depending on the configuration you have running). Th...
How to deal with old, obsolete database data of a long running system? What are the possibilities of a programmer to handle data that are rarely used but cannot be simply deleted because at least reporting still requires it? Some examples I am thinking of: Discountinued funding types of older years of a university Unus...
TITLE: How to deal with old, obsolete database data of a long running system? QUESTION: What are the possibilities of a programmer to handle data that are rarely used but cannot be simply deleted because at least reporting still requires it? Some examples I am thinking of: Discountinued funding types of older years of...
[ "database-design" ]
10
4
3,457
11
0
2008-10-12T10:46:46.213000
2008-10-12T12:01:10.227000
195,340
196,110
ASP.NET, XSLT and dynamic controls
I wish to use xml and xsl to generate controls on an asp.net page. I currently have a asp.net content page that contains a xml control. When the page is loaded, an xml file is loaded and the required element is extracted and set as the xml control's DocumentContent and the xml control's TransformSource is set to the ap...
The generated output of transform is not parsed to be added to the page as set of controls. Rather the generated output is sent to the response. Therefore you cannot apply a transform to an XML control that will generate new controls. There may be a way to create the transform result and invoke some parsing that can be...
ASP.NET, XSLT and dynamic controls I wish to use xml and xsl to generate controls on an asp.net page. I currently have a asp.net content page that contains a xml control. When the page is loaded, an xml file is loaded and the required element is extracted and set as the xml control's DocumentContent and the xml control...
TITLE: ASP.NET, XSLT and dynamic controls QUESTION: I wish to use xml and xsl to generate controls on an asp.net page. I currently have a asp.net content page that contains a xml control. When the page is loaded, an xml file is loaded and the required element is extracted and set as the xml control's DocumentContent a...
[ "asp.net", "xml", "xslt" ]
0
0
1,915
3
0
2008-10-12T10:55:31.077000
2008-10-12T21:17:57.403000
195,353
195,430
Where to find a good reference when choosing a database?
I and two others are working on a project at the university. In the project we are making a prototype of a MMORPG. We have decided to use PostgreSQL as our database. The other databases we considered were MS SQL-server and MySQL. Does somebody have a good reference which will justify our choice? (preferably written dur...
Someone recently recommended me wikivs.com: MySQL vs. PostgreSQL - it is a quite detailed comparison of those two, and might be of help to you.
Where to find a good reference when choosing a database? I and two others are working on a project at the university. In the project we are making a prototype of a MMORPG. We have decided to use PostgreSQL as our database. The other databases we considered were MS SQL-server and MySQL. Does somebody have a good referen...
TITLE: Where to find a good reference when choosing a database? QUESTION: I and two others are working on a project at the university. In the project we are making a prototype of a MMORPG. We have decided to use PostgreSQL as our database. The other databases we considered were MS SQL-server and MySQL. Does somebody h...
[ "mysql", "sql-server", "postgresql" ]
4
4
545
5
0
2008-10-12T11:10:06.477000
2008-10-12T12:26:17.383000
195,359
195,361
Where do I find the Eclipse JavaServer Faces config editor palette?
While running through the cheat sheet "create a navigation rule" for the Eclipse JavaServer Faces tooling it says "select the page control from the palette and...". But where's this "palette"?
It turns out, in Ganymede at least, on the right-hand border of the JavaServer Faces configuration editor tab there is a subtle left arrow head. clicking that shows palette.
Where do I find the Eclipse JavaServer Faces config editor palette? While running through the cheat sheet "create a navigation rule" for the Eclipse JavaServer Faces tooling it says "select the page control from the palette and...". But where's this "palette"?
TITLE: Where do I find the Eclipse JavaServer Faces config editor palette? QUESTION: While running through the cheat sheet "create a navigation rule" for the Eclipse JavaServer Faces tooling it says "select the page control from the palette and...". But where's this "palette"? ANSWER: It turns out, in Ganymede at lea...
[ "eclipse", "editor", "palette" ]
2
3
3,798
2
0
2008-10-12T11:18:54.790000
2008-10-12T11:21:44.270000
195,363
195,382
Inserting a newline into a pre tag (IE, Javascript)
In IE when I insert text into a tag the newlines are ignored: Using \r\n instead of a plain \n does not work. does work but inserts an extra blank line in FF, which is not acceptable for my purposes.
These quirksmode.org bug report and comments about innerHTML behaviour of Internet Explorer could help: " IE applies HTML normalization to the data that is assigned to the innerHTML property. This causes incorrect display of whitespace in elements that ought to preserve formatting, such as and. "
Inserting a newline into a pre tag (IE, Javascript) In IE when I insert text into a tag the newlines are ignored: Using \r\n instead of a plain \n does not work. does work but inserts an extra blank line in FF, which is not acceptable for my purposes.
TITLE: Inserting a newline into a pre tag (IE, Javascript) QUESTION: In IE when I insert text into a tag the newlines are ignored: Using \r\n instead of a plain \n does not work. does work but inserts an extra blank line in FF, which is not acceptable for my purposes. ANSWER: These quirksmode.org bug report and comme...
[ "javascript", "html", "internet-explorer", "pre" ]
16
13
25,982
11
0
2008-10-12T11:24:29.317000
2008-10-12T11:46:31.503000
195,377
195,383
Transactions, when should be discarded and rolledback
I'm trying to debug an application (under PostgreSQL) and came across the following error: "current transaction is aborted, commands ignored". As far as I can understand a "transaction" is just a notion related to the underlying database connection. If the connection has an auto commit "false", you can execute queries ...
That error means that one of the queries sent in a transaction has failed, so the rest of the queries are ignored until the end of the current transaction (which will automatically be a rollback). To PostgreSQL the transaction has failed, and it will be rolled back in any case after the error with one exception. You ha...
Transactions, when should be discarded and rolledback I'm trying to debug an application (under PostgreSQL) and came across the following error: "current transaction is aborted, commands ignored". As far as I can understand a "transaction" is just a notion related to the underlying database connection. If the connectio...
TITLE: Transactions, when should be discarded and rolledback QUESTION: I'm trying to debug an application (under PostgreSQL) and came across the following error: "current transaction is aborted, commands ignored". As far as I can understand a "transaction" is just a notion related to the underlying database connection...
[ "postgresql", "transactions", "autocommit" ]
1
3
1,326
2
0
2008-10-12T11:38:32.347000
2008-10-12T11:48:06.213000
195,408
195,413
Limit displayed length of string on web page
I'm looking for a technique (javascript, CSS, whatever???) that will let me control the amount of a string that is displayed. The string is the result of a search (and therefore not initially known). A simple Character count approach is trivial, but not acceptable, as it needs to handle proportional fonts. In otherword...
Perhaps the CSS property overflow: hidden; can help you, in conjuntion with width.
Limit displayed length of string on web page I'm looking for a technique (javascript, CSS, whatever???) that will let me control the amount of a string that is displayed. The string is the result of a search (and therefore not initially known). A simple Character count approach is trivial, but not acceptable, as it nee...
TITLE: Limit displayed length of string on web page QUESTION: I'm looking for a technique (javascript, CSS, whatever???) that will let me control the amount of a string that is displayed. The string is the result of a search (and therefore not initially known). A simple Character count approach is trivial, but not acc...
[ "javascript", "css", "string", "dhtml" ]
2
3
7,406
5
0
2008-10-12T12:12:57.020000
2008-10-12T12:16:07.467000
195,410
196,630
How to log in an Oracle database?
I am interested in what methods of logging is frequent in an Oracle database. Our method is the following: We create a log table for the table to be logged. The log table contains all the columns of the original table plus some special fields including timestamp, modification type (insert, update, delete), modifier's i...
It sounds like you are after 'auditing'. Oracle has a built-in feature called Fine Grain Auditing (FGA). In a nutshell you can audit everything or specific conditions. What is really cool is you can 'audit' selects as well as transactions. Simple command to get started with auditing: audit UPDATE on SCOTT.EMP by access...
How to log in an Oracle database? I am interested in what methods of logging is frequent in an Oracle database. Our method is the following: We create a log table for the table to be logged. The log table contains all the columns of the original table plus some special fields including timestamp, modification type (ins...
TITLE: How to log in an Oracle database? QUESTION: I am interested in what methods of logging is frequent in an Oracle database. Our method is the following: We create a log table for the table to be logged. The log table contains all the columns of the original table plus some special fields including timestamp, modi...
[ "database", "oracle", "logging" ]
6
10
14,936
5
0
2008-10-12T12:13:30.297000
2008-10-13T03:20:47.767000
195,420
195,427
TransactionScope bug in .NET? More information?
I have read (or perhaps heard from a colleague) that in.NET, TransactionScope can hit its timeout and then VoteCommit (as opposed to VoteRollback). Is this accurate or hearsay? I couldn't track down information on the web that talked about this issue (if it IS an issue), so I wonder if anyone has any direct experience ...
If you mean in relation to SQL Server, then there is an issue that you can fix in the connection string; see my reply here, or the full details here. The short version is: ensure you have Transaction Binding=Explicit Unbind; in the connection string. It isn't actually doing a vote commit - the transaction (and any earl...
TransactionScope bug in .NET? More information? I have read (or perhaps heard from a colleague) that in.NET, TransactionScope can hit its timeout and then VoteCommit (as opposed to VoteRollback). Is this accurate or hearsay? I couldn't track down information on the web that talked about this issue (if it IS an issue), ...
TITLE: TransactionScope bug in .NET? More information? QUESTION: I have read (or perhaps heard from a colleague) that in.NET, TransactionScope can hit its timeout and then VoteCommit (as opposed to VoteRollback). Is this accurate or hearsay? I couldn't track down information on the web that talked about this issue (if...
[ "c#", ".net", "transactions" ]
24
27
5,985
2
0
2008-10-12T12:20:55.460000
2008-10-12T12:25:28.540000
195,439
195,442
Can you have two forms on a page with ASP.NET MVC?
Using web forms I know that you can only have one ASP.NET form on a page. I've done some implementations where I've used Javascript to add other forms to a page to support things like logon controls (that post back to Logon.aspx instead of the current page). I'm wondering if the single form per page is still present in...
You'll probably want to use regular HTML forms in your MVC code with the action attribute pointing to the appropriate controller action. So you can have as many forms on the page as you want.
Can you have two forms on a page with ASP.NET MVC? Using web forms I know that you can only have one ASP.NET form on a page. I've done some implementations where I've used Javascript to add other forms to a page to support things like logon controls (that post back to Logon.aspx instead of the current page). I'm wonder...
TITLE: Can you have two forms on a page with ASP.NET MVC? QUESTION: Using web forms I know that you can only have one ASP.NET form on a page. I've done some implementations where I've used Javascript to add other forms to a page to support things like logon controls (that post back to Logon.aspx instead of the current...
[ ".net", "asp.net-mvc" ]
3
5
1,265
3
0
2008-10-12T12:39:03.880000
2008-10-12T12:41:30.177000
195,450
196,469
What should I use the "My" namespace for in VB .NET?
I'm considering building a framework for VB.NET, and using the My namespace to plug it into VB seems like a reasonable idea. What is "My" used for?
The purpose of My, as I understand it, is to be an easy shortcut to certain API tasks that are common but hard-to-find or hard-to-use. You probably shouldn't completely subsume your framework under My. (For one thing, C# people using your framework may get grouchy.) Instead, you should design it as a normal framework. ...
What should I use the "My" namespace for in VB .NET? I'm considering building a framework for VB.NET, and using the My namespace to plug it into VB seems like a reasonable idea. What is "My" used for?
TITLE: What should I use the "My" namespace for in VB .NET? QUESTION: I'm considering building a framework for VB.NET, and using the My namespace to plug it into VB seems like a reasonable idea. What is "My" used for? ANSWER: The purpose of My, as I understand it, is to be an easy shortcut to certain API tasks that a...
[ "vb.net" ]
16
14
11,840
12
0
2008-10-12T12:48:27.137000
2008-10-13T01:32:10.200000
195,451
270,373
How to fetch the middle mouse button in java?
I use public boolean mouseDown(Event ev, int x, int y) to detect a click of the mouse. I can distinguish between the right mouse button (ev.metaDown() is true) and the left and middle. How can i differentiate the left from the middle button? Or if it is impossible with mouseDown, what should i use?
Try using ALT_MASK: This flag indicates that the Alt key was down when the event occurred. For mouse events, this flag indicates that the middle mouse button was pressed or released. So your code might be: if (ev.modifiers & Event.ALT_MASK!= 0) { // middle button was pressed } Of course, all this is assuming you have a...
How to fetch the middle mouse button in java? I use public boolean mouseDown(Event ev, int x, int y) to detect a click of the mouse. I can distinguish between the right mouse button (ev.metaDown() is true) and the left and middle. How can i differentiate the left from the middle button? Or if it is impossible with mous...
TITLE: How to fetch the middle mouse button in java? QUESTION: I use public boolean mouseDown(Event ev, int x, int y) to detect a click of the mouse. I can distinguish between the right mouse button (ev.metaDown() is true) and the left and middle. How can i differentiate the left from the middle button? Or if it is im...
[ "java", "events", "mouse" ]
0
1
5,230
3
0
2008-10-12T12:48:36.590000
2008-11-06T21:32:26.103000
195,454
215,100
Password protected .NET ClickOnce deployment?
How can I protect a ClickOnce deployed application with a password? Do I have to change the IIS settings of the web or is there a way to do it programmatically? I'm using Visual Studio 2005 (.NET 2.0). If I have to use web credentials, are auto-updates of the application still possible? Would be great if you could prov...
I found a possible solution by myself in this MSDN article: ClickOnce Deployment and Security. ASP.NET Form-Based Authentication If you want to control which deployments each user can access, you should not enable anonymous access to ClickOnce applications deployed on a Web server. Rather, you would enable users access...
Password protected .NET ClickOnce deployment? How can I protect a ClickOnce deployed application with a password? Do I have to change the IIS settings of the web or is there a way to do it programmatically? I'm using Visual Studio 2005 (.NET 2.0). If I have to use web credentials, are auto-updates of the application st...
TITLE: Password protected .NET ClickOnce deployment? QUESTION: How can I protect a ClickOnce deployed application with a password? Do I have to change the IIS settings of the web or is there a way to do it programmatically? I'm using Visual Studio 2005 (.NET 2.0). If I have to use web credentials, are auto-updates of ...
[ ".net", "winforms", "security", "deployment", "clickonce" ]
12
12
7,867
4
0
2008-10-12T12:50:10.627000
2008-10-18T14:26:12.833000
195,460
195,496
Unit testing a module that checks internet connectivity
I have a C# module responsible for acquiring the list of network adapters that are "connected to the internet" on a windows Vista machine. The module uses the " Network List Manager API " (or NLM API) to iterate over all network connections and returns all those for which the IsConnectedToInternet value is true. I rece...
I can only answer your question about the unit test. The code you're testing is, in your own words, "a C# module responsible for acquiring the list of network adapters that are 'connected to the internet' on a windows Vista machine. The module uses the 'Network List Manager API' (or NLM API) to iterate over all network...
Unit testing a module that checks internet connectivity I have a C# module responsible for acquiring the list of network adapters that are "connected to the internet" on a windows Vista machine. The module uses the " Network List Manager API " (or NLM API) to iterate over all network connections and returns all those f...
TITLE: Unit testing a module that checks internet connectivity QUESTION: I have a C# module responsible for acquiring the list of network adapters that are "connected to the internet" on a windows Vista machine. The module uses the " Network List Manager API " (or NLM API) to iterate over all network connections and r...
[ "windows", "unit-testing", "networking", "nlm" ]
2
4
1,479
3
0
2008-10-12T12:54:35.033000
2008-10-12T13:40:40.387000
195,468
195,796
synchronizing io operation in java on a string method argument?
Basically, I have a class with 2 methods: one to serialize an object into an XML file and another to read an object from XML. Here is an example of synchronized part from the method that restores an object: public T restore(String from) throws Exception { // variables declaration synchronized (from) { try { decoder = n...
1. Yes, it's OK to synchronize on a String, however you'd need to synchronize on the string. intern() in order to always get the same Object StringBuffer sb = new StringBuffer(); sb.append("a").append("b"); String a = new String(sb.toString()); String b = new String(sb.toString()); a == b; //false a.equals(b); //true a...
synchronizing io operation in java on a string method argument? Basically, I have a class with 2 methods: one to serialize an object into an XML file and another to read an object from XML. Here is an example of synchronized part from the method that restores an object: public T restore(String from) throws Exception { ...
TITLE: synchronizing io operation in java on a string method argument? QUESTION: Basically, I have a class with 2 methods: one to serialize an object into an XML file and another to read an object from XML. Here is an example of synchronized part from the method that restores an object: public T restore(String from) t...
[ "java", "multithreading", "synchronization", "io" ]
2
5
4,275
4
0
2008-10-12T13:03:59.897000
2008-10-12T18:10:49.153000
195,483
195,493
C# check if a COM (Serial) port is already open
Is there an easy way of programmatically checking if a serial COM port is already open/being used? Normally I would use: try { // open port } catch (Exception ex) { // handle the exception } However, I would like to programatically check so I can attempt to use another COM port or some such.
I needed something similar some time ago, to search for a device. I obtained a list of available COM ports and then simply iterated over them, if it didn't throw an exception i tried to communicate with the device. A bit rough but working. var portNames = SerialPort.GetPortNames(); foreach(var port in portNames) { //T...
C# check if a COM (Serial) port is already open Is there an easy way of programmatically checking if a serial COM port is already open/being used? Normally I would use: try { // open port } catch (Exception ex) { // handle the exception } However, I would like to programatically check so I can attempt to use another CO...
TITLE: C# check if a COM (Serial) port is already open QUESTION: Is there an easy way of programmatically checking if a serial COM port is already open/being used? Normally I would use: try { // open port } catch (Exception ex) { // handle the exception } However, I would like to programatically check so I can attempt...
[ "c#", ".net", "serial-port" ]
25
16
102,556
9
0
2008-10-12T13:24:38.313000
2008-10-12T13:38:59.233000
195,485
195,567
Why do old editors like Vim and Emacs expose the difference between a File and a Buffer in the interface?
Does my question make sense? Using either Vim or Emacs, you come to understand that the interface exposes the code's representation of the state of the file you are editing in the buffer, the file is the on-disk storage you can fill a buffer from or write a buffer to. All these things a programmer would know, but when ...
For starters, Emacs uses plenty of buffers that aren't associated with any file. Any time you open a directory, read your mail, open a terminal, compile a program, launch an interactive Python session, or connect to a database, you get a buffer. Hence, Emacs's basic unit of work is a buffer and not a file, and the same...
Why do old editors like Vim and Emacs expose the difference between a File and a Buffer in the interface? Does my question make sense? Using either Vim or Emacs, you come to understand that the interface exposes the code's representation of the state of the file you are editing in the buffer, the file is the on-disk st...
TITLE: Why do old editors like Vim and Emacs expose the difference between a File and a Buffer in the interface? QUESTION: Does my question make sense? Using either Vim or Emacs, you come to understand that the interface exposes the code's representation of the state of the file you are editing in the buffer, the file...
[ "vim", "emacs", "editor" ]
13
31
2,851
7
0
2008-10-12T13:27:09.070000
2008-10-12T14:44:46.683000
195,504
195,511
Switch Requests to Content Specific to Requesting Domain
Lets say I have several web sites on my web server, all as applications under one domain. How could I register other domains to point to the same web server, and redirect requests to, e.g. a web site linked to the requesting domain? I know I'll have to have a root site, and I'm guessing I may have have to do some voodo...
On Apache you could do something like this: NameVirtualHost *:80 ServerName acme.net DocumentRoot C:/www/ ServerName acme.root.net DocumentRoot C:/www/ I hope it could be useful for you.
Switch Requests to Content Specific to Requesting Domain Lets say I have several web sites on my web server, all as applications under one domain. How could I register other domains to point to the same web server, and redirect requests to, e.g. a web site linked to the requesting domain? I know I'll have to have a roo...
TITLE: Switch Requests to Content Specific to Requesting Domain QUESTION: Lets say I have several web sites on my web server, all as applications under one domain. How could I register other domains to point to the same web server, and redirect requests to, e.g. a web site linked to the requesting domain? I know I'll ...
[ "asp.net", "apache", "iis" ]
0
1
114
1
0
2008-10-12T13:49:18.933000
2008-10-12T13:58:16.607000
195,509
195,552
Is Javascript a proper platform for cryptography? Or, can it be?
I noticed a good while back that Wikipedia links to a Javascript implementation of different hash functions. Also found Clipperz Crypto. Even Mozilla implements a crypto object in Firefox. So, Is Javascript a proper platform for cryptography? Or, can it be? Or, I suppose.. Are there any purposes or benefits for hashing...
There are uses for hashing functions in Javascript, for example validating captchas client side (by comparing hash in session to computed hash from input). Obviously, the uses are limited since it runs almost exclusively client side (and you can't trust client input), but the potential is there.
Is Javascript a proper platform for cryptography? Or, can it be? I noticed a good while back that Wikipedia links to a Javascript implementation of different hash functions. Also found Clipperz Crypto. Even Mozilla implements a crypto object in Firefox. So, Is Javascript a proper platform for cryptography? Or, can it b...
TITLE: Is Javascript a proper platform for cryptography? Or, can it be? QUESTION: I noticed a good while back that Wikipedia links to a Javascript implementation of different hash functions. Also found Clipperz Crypto. Even Mozilla implements a crypto object in Firefox. So, Is Javascript a proper platform for cryptogr...
[ "javascript", "security", "language-agnostic", "cryptography" ]
5
4
2,196
7
0
2008-10-12T13:55:48.950000
2008-10-12T14:32:27.973000
195,532
195,562
ASP.NET Photo API (Shutterfly, etc . .)
I have a website with all my photos, I would like people to be able to click on my pictures and order prints, etc through a third party service (Shutterfly, etc). Does anyone have any best practices or code examples of doing this in C#, ASP.NET?
I have no idea if this information is still up to date, but here is a description of the Shutterfly API. The API seems to consist in a simple HTTP form post with embedded name-value pairs. Example: It should not be a difficult task to write some C# wrapper for it.
ASP.NET Photo API (Shutterfly, etc . .) I have a website with all my photos, I would like people to be able to click on my pictures and order prints, etc through a third party service (Shutterfly, etc). Does anyone have any best practices or code examples of doing this in C#, ASP.NET?
TITLE: ASP.NET Photo API (Shutterfly, etc . .) QUESTION: I have a website with all my photos, I would like people to be able to click on my pictures and order prints, etc through a third party service (Shutterfly, etc). Does anyone have any best practices or code examples of doing this in C#, ASP.NET? ANSWER: I have ...
[ "c#", "asp.net", "photos" ]
2
2
953
1
0
2008-10-12T14:13:01.537000
2008-10-12T14:40:36.520000
195,534
1,038,043
In production, Apache + mod_wsgi or Nginx + mod_wsgi?
What to use for a medium to large python WSGI application, Apache + mod_wsgi or Nginx + mod_wsgi? Which combination will need more memory and CPU time? Which one is faster? Which is known for being more stable than the other? I am also thinking to use CherryPy's WSGI server but I hear it's not very suitable for a very ...
For nginx/mod_wsgi, ensure you read: http://blog.dscpl.com.au/2009/05/blocking-requests-and-nginx-version-of.html Because of how nginx is an event driven system underneath, it has behavioural characteristics which are detrimental to blocking applications such as is the case with WSGI based applications. Worse case scen...
In production, Apache + mod_wsgi or Nginx + mod_wsgi? What to use for a medium to large python WSGI application, Apache + mod_wsgi or Nginx + mod_wsgi? Which combination will need more memory and CPU time? Which one is faster? Which is known for being more stable than the other? I am also thinking to use CherryPy's WSG...
TITLE: In production, Apache + mod_wsgi or Nginx + mod_wsgi? QUESTION: What to use for a medium to large python WSGI application, Apache + mod_wsgi or Nginx + mod_wsgi? Which combination will need more memory and CPU time? Which one is faster? Which is known for being more stable than the other? I am also thinking to ...
[ "python", "apache", "nginx", "mod-wsgi" ]
69
78
32,860
4
0
2008-10-12T14:14:19.833000
2009-06-24T12:26:01.277000
195,537
202,044
How would you implement an RSS feed in a Java web environment?
I am working on an implementation for RSS feeds for a collaboration platform. Say there are several thousands of different collaboration rooms where users can share information, and each needs to publish an RSS feed with news, changes, etc... Using a plain servlet (i.e. http://www.site.com/RSSServlet/?id=roomID ) is co...
You say that a new http request to your servlet "will trigger the entire servlet lifecycle", which as Alexander has already pointed out, isn't exactly true. It will simply trigger another method call to your doGet() or doPost() methods. I think what you mean to say is that if you have a doGet / doPost method which cont...
How would you implement an RSS feed in a Java web environment? I am working on an implementation for RSS feeds for a collaboration platform. Say there are several thousands of different collaboration rooms where users can share information, and each needs to publish an RSS feed with news, changes, etc... Using a plain ...
TITLE: How would you implement an RSS feed in a Java web environment? QUESTION: I am working on an implementation for RSS feeds for a collaboration platform. Say there are several thousands of different collaboration rooms where users can share information, and each needs to publish an RSS feed with news, changes, etc...
[ "java", "servlets", "rss" ]
3
5
5,829
2
0
2008-10-12T14:15:36.337000
2008-10-14T17:16:49.887000
195,548
195,885
Deriving COM interfaces in .NET
Due to company constraints out of my control, I have the following scenario: A COM library that defines the following interface (no CoClass, just the interface): [ object, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx), dual, nonextensible, helpstring("IService Interface"), pointer_default(unique) ] IService: IDispatch { H...
It could be a problem with the name IServiceProvider. Check that you haven't already imported an interface with the same name. When I create an COM Interface library using your IDL, and then try to import it from another client, I get the warning: Warning 65 warning C4192: automatically excluding 'IServiceProvider' whi...
Deriving COM interfaces in .NET Due to company constraints out of my control, I have the following scenario: A COM library that defines the following interface (no CoClass, just the interface): [ object, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx), dual, nonextensible, helpstring("IService Interface"), pointer_default(u...
TITLE: Deriving COM interfaces in .NET QUESTION: Due to company constraints out of my control, I have the following scenario: A COM library that defines the following interface (no CoClass, just the interface): [ object, uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx), dual, nonextensible, helpstring("IService Interface"),...
[ "c#", "c++", ".net", "interface", "com" ]
6
6
3,835
2
0
2008-10-12T14:28:27.683000
2008-10-12T19:21:35.923000
195,549
195,570
Flex - Laying out text within a Canvas
Here's a problem I keep running into: I have a lot of situations where I need to display some text with a styled container like so: As you can see - the text in constrained by the left and right margins of the canvas and I have not specified a height for the text control because I want it to grow vertically when I add ...
The Text component needs a width if you want it to automatically wrap for you. If you used a string with newlines in it it will work grow as you expected without a width. For you, use: Edit: Ok, you want it centered in a canvas of varying size. Then you can:
Flex - Laying out text within a Canvas Here's a problem I keep running into: I have a lot of situations where I need to display some text with a styled container like so: As you can see - the text in constrained by the left and right margins of the canvas and I have not specified a height for the text control because I...
TITLE: Flex - Laying out text within a Canvas QUESTION: Here's a problem I keep running into: I have a lot of situations where I need to display some text with a styled container like so: As you can see - the text in constrained by the left and right margins of the canvas and I have not specified a height for the text...
[ "apache-flex", "actionscript-3", "mxml" ]
1
2
2,598
2
0
2008-10-12T14:28:56.997000
2008-10-12T14:47:39.843000
195,571
195,577
Is there a tool which lists exported methods from a DLL?
As the question states - is there a good tool out there which lists methods an unmanaged DLL exports? I would like it to list COM methods and interfaces too.
For DLLs, use the Dependency Viewer ( depends.exe ). For COM objects, use oleview.exe
Is there a tool which lists exported methods from a DLL? As the question states - is there a good tool out there which lists methods an unmanaged DLL exports? I would like it to list COM methods and interfaces too.
TITLE: Is there a tool which lists exported methods from a DLL? QUESTION: As the question states - is there a good tool out there which lists methods an unmanaged DLL exports? I would like it to list COM methods and interfaces too. ANSWER: For DLLs, use the Dependency Viewer ( depends.exe ). For COM objects, use olev...
[ "com", "dll" ]
5
12
6,399
3
0
2008-10-12T14:49:03.413000
2008-10-12T14:53:40.427000
195,578
195,601
Is it possible to set a style of link that shows only when the linked webpage is being viewed?
I got a problem like this (this is html/css menu): Eshop | Another eshop | Another eshop Client wants it work like this: User comes to website, clicks on Eshop. Eshop changes to red color with red box outline. User decides to visit Another eshop, so Eshop will go back to normaln color without red box outline, and anoth...
The same that Joe Skora has written but more specific:.red { outline-color:red; outline-width:10px; } Now you could use Javascript (in this example using jQuery ) in the click-event-handler: $('.red').removeClass('red'); // removes class red from all items with class red $(this).addClass('red'); // adds class red to th...
Is it possible to set a style of link that shows only when the linked webpage is being viewed? I got a problem like this (this is html/css menu): Eshop | Another eshop | Another eshop Client wants it work like this: User comes to website, clicks on Eshop. Eshop changes to red color with red box outline. User decides to...
TITLE: Is it possible to set a style of link that shows only when the linked webpage is being viewed? QUESTION: I got a problem like this (this is html/css menu): Eshop | Another eshop | Another eshop Client wants it work like this: User comes to website, clicks on Eshop. Eshop changes to red color with red box outlin...
[ "css", "hyperlink", "visited" ]
1
2
454
8
0
2008-10-12T14:54:22.703000
2008-10-12T15:31:19.100000
195,582
195,599
What is the meaning of 'attempt to index upvalue'
I am taking my first steps programming in Lua and get this error when I run my script: attempt to index upvalue 'base' (a function value) It's probably due to something very basic that I haven't grasped yet, but I can't find any good information about it when googling. Could someone explain to me what it means?
In this case it looks base is a function, but you're trying to index it like a table (eg. base[5] or base.somefield ). The 'upvalue' part is just telling you what kind of variable base is, in this case an upvalue (aka external local variable).
What is the meaning of 'attempt to index upvalue' I am taking my first steps programming in Lua and get this error when I run my script: attempt to index upvalue 'base' (a function value) It's probably due to something very basic that I haven't grasped yet, but I can't find any good information about it when googling. ...
TITLE: What is the meaning of 'attempt to index upvalue' QUESTION: I am taking my first steps programming in Lua and get this error when I run my script: attempt to index upvalue 'base' (a function value) It's probably due to something very basic that I haven't grasped yet, but I can't find any good information about ...
[ "lua", "upvalue" ]
16
19
34,111
2
0
2008-10-12T15:02:01.173000
2008-10-12T15:24:35.887000
195,587
195,693
Serializing java.lang.Locale
Got a class that serializes into xml with XMLEncoder nicely with all the variables there. Except for the one that holds java.util.Locale. What could be the trick?
The problem is that java.util.Locale is not a bean. From the XMLEncoder doc: The XMLEncoder class is a complementary alternative to the ObjectOutputStream and can used to generate a textual representation of a JavaBean in the same way that the ObjectOutputStream can be used to create binary representation of Serializab...
Serializing java.lang.Locale Got a class that serializes into xml with XMLEncoder nicely with all the variables there. Except for the one that holds java.util.Locale. What could be the trick?
TITLE: Serializing java.lang.Locale QUESTION: Got a class that serializes into xml with XMLEncoder nicely with all the variables there. Except for the one that holds java.util.Locale. What could be the trick? ANSWER: The problem is that java.util.Locale is not a bean. From the XMLEncoder doc: The XMLEncoder class is ...
[ "java", "serialization", "locale" ]
3
8
4,434
2
0
2008-10-12T15:06:43.613000
2008-10-12T16:57:25.170000
195,590
195,594
Locating a file on the path
Does anybody know how to determine the location of a file that's in one of the folders specified by the PATH environmental variable other than doing a dir filename.exe /s from the root folder? I know this is stretching the bounds of a programming question but this is useful for deployment-related issues, also I need to...
You can use the where.exe utility in the C:\Windows\System32 directory.
Locating a file on the path Does anybody know how to determine the location of a file that's in one of the folders specified by the PATH environmental variable other than doing a dir filename.exe /s from the root folder? I know this is stretching the bounds of a programming question but this is useful for deployment-re...
TITLE: Locating a file on the path QUESTION: Does anybody know how to determine the location of a file that's in one of the folders specified by the PATH environmental variable other than doing a dir filename.exe /s from the root folder? I know this is stretching the bounds of a programming question but this is useful...
[ "windows" ]
19
51
18,106
7
0
2008-10-12T15:12:50.667000
2008-10-12T15:17:44.387000
195,593
195,613
Why use a owner window in MessageBox.Show?
MessageBox.Show has forms like MessageBox.Show( ownerWindow,.... ). What do I gain by assigning a owner window?
A message box is a modal form, which means that its parent window is disabled until the message box is dismissed. If a Show() overload is called that does not take an owner identifier, then a parent form is usually chosen automatically. I can't find anything in the documentation that describes how that form is chosen, ...
Why use a owner window in MessageBox.Show? MessageBox.Show has forms like MessageBox.Show( ownerWindow,.... ). What do I gain by assigning a owner window?
TITLE: Why use a owner window in MessageBox.Show? QUESTION: MessageBox.Show has forms like MessageBox.Show( ownerWindow,.... ). What do I gain by assigning a owner window? ANSWER: A message box is a modal form, which means that its parent window is disabled until the message box is dismissed. If a Show() overload is ...
[ ".net", "winforms" ]
29
29
24,019
8
0
2008-10-12T15:15:24.483000
2008-10-12T15:39:54.840000
195,606
195,615
Storing a c# DateTimeOffset value in a SQL Server 2005 database
I want to store a a c# DateTimeOffset value in a SQL Server 2005 database. Sql 2008 has this as a built-in-type, but SQL Server 2005 does not. The DateTimeOffset structure has a DateTime value which I store as DateTime, an an Offset property (of type TimeSpan). Since this is the time zone relative to UTC, presumably it...
It's not a good idea to assume that an offset is a number of hours or half-hours - there are certainly quarter-hour timezones around. Using milliseconds for the offset is probably the most flexible, but I'd argue that minutes is a lot easier to read. If you're ever going to look at the "raw" data in the database, it's ...
Storing a c# DateTimeOffset value in a SQL Server 2005 database I want to store a a c# DateTimeOffset value in a SQL Server 2005 database. Sql 2008 has this as a built-in-type, but SQL Server 2005 does not. The DateTimeOffset structure has a DateTime value which I store as DateTime, an an Offset property (of type TimeS...
TITLE: Storing a c# DateTimeOffset value in a SQL Server 2005 database QUESTION: I want to store a a c# DateTimeOffset value in a SQL Server 2005 database. Sql 2008 has this as a built-in-type, but SQL Server 2005 does not. The DateTimeOffset structure has a DateTime value which I store as DateTime, an an Offset prope...
[ "c#", "sql-server-2005", "datetimeoffset" ]
5
7
4,633
3
0
2008-10-12T15:34:27.800000
2008-10-12T15:42:16.350000
195,625
195,647
What is the time complexity of popping elements from list in Python?
I wonder what the time complexity of the pop method of list objects is in Python (in CPython particulary). Also does the value of N for list.pop(N) affect the complexity?
Pop() for the last element ought to be O(1) since you only need to return the element referred to by the last element in the array and update the index of the last element. I would expect pop() for an arbitrary element to be O(N) and require on average N/2 operations since you would need to move any elements beyond the...
What is the time complexity of popping elements from list in Python? I wonder what the time complexity of the pop method of list objects is in Python (in CPython particulary). Also does the value of N for list.pop(N) affect the complexity?
TITLE: What is the time complexity of popping elements from list in Python? QUESTION: I wonder what the time complexity of the pop method of list objects is in Python (in CPython particulary). Also does the value of N for list.pop(N) affect the complexity? ANSWER: Pop() for the last element ought to be O(1) since you...
[ "python", "list", "performance" ]
76
45
94,780
4
0
2008-10-12T15:58:59.077000
2008-10-12T16:15:39.403000
195,626
195,962
How to avoid computation every time a python module is reloaded
I have a python module that makes use of a huge dictionary global variable, currently I put the computation code in the top section, every first time import or reload of the module takes more then one minute which is totally unacceptable. How can I save the computation result somewhere so that the next import/reload do...
Just to clarify: the code in the body of a module is not executed every time the module is imported - it is run only once, after which future imports find the already created module, rather than recreating it. Take a look at sys.modules to see the list of cached modules. However, if your problem is the time it takes fo...
How to avoid computation every time a python module is reloaded I have a python module that makes use of a huge dictionary global variable, currently I put the computation code in the top section, every first time import or reload of the module takes more then one minute which is totally unacceptable. How can I save th...
TITLE: How to avoid computation every time a python module is reloaded QUESTION: I have a python module that makes use of a huge dictionary global variable, currently I put the computation code in the top section, every first time import or reload of the module takes more then one minute which is totally unacceptable....
[ "python", "nltk" ]
6
17
4,101
13
0
2008-10-12T15:59:48.170000
2008-10-12T20:12:25.073000
195,632
195,637
How to change an input button image using CSS
So, I can create an input button with an image using But, I can't get the same behavior using CSS. For instance, I've tried where "myButton" is defined in the CSS file as.myButton { background:url(/images/Btn.PNG) no-repeat; cursor:pointer; width: 200px; height: 100px; border: none; } If that's all I wanted to do, I co...
If you're wanting to style the button using CSS, make it a type="submit" button instead of type="image". type="image" expects a SRC, which you can't set in CSS. Note that Safari won't let you style any button in the manner you're looking for. If you need Safari support, you'll need to place an image and have an onclick...
How to change an input button image using CSS So, I can create an input button with an image using But, I can't get the same behavior using CSS. For instance, I've tried where "myButton" is defined in the CSS file as.myButton { background:url(/images/Btn.PNG) no-repeat; cursor:pointer; width: 200px; height: 100px; bord...
TITLE: How to change an input button image using CSS QUESTION: So, I can create an input button with an image using But, I can't get the same behavior using CSS. For instance, I've tried where "myButton" is defined in the CSS file as.myButton { background:url(/images/Btn.PNG) no-repeat; cursor:pointer; width: 200px; h...
[ "css", "input-button-image" ]
193
123
787,655
12
0
2008-10-12T16:04:13.700000
2008-10-12T16:10:18.913000
195,635
195,673
How do I pass in an owner window to MessageBox.Show on a different thread?
I am trying to figure out Messagebox( ownerWindow,... ). Using reflector I see that the ownerWindow defaults to the ActiveWindow for the thread. So the only time I need the ownerWindow parameter is to call Show from another thread. However when I try this, I get a cross threading exception. private void button1_Click( ...
You may want to take a look at Win32 Window Hierarchy and Styles to understand the difference between owner and parent windows. It's not always necessary that the ActiveWindows needs to own the messagebox, I've worked on application where the ActiveWindow was not necessarily the owner of the MessageBox. Also according ...
How do I pass in an owner window to MessageBox.Show on a different thread? I am trying to figure out Messagebox( ownerWindow,... ). Using reflector I see that the ownerWindow defaults to the ActiveWindow for the thread. So the only time I need the ownerWindow parameter is to call Show from another thread. However when ...
TITLE: How do I pass in an owner window to MessageBox.Show on a different thread? QUESTION: I am trying to figure out Messagebox( ownerWindow,... ). Using reflector I see that the ownerWindow defaults to the ActiveWindow for the thread. So the only time I need the ownerWindow parameter is to call Show from another thr...
[ ".net" ]
3
0
8,283
4
0
2008-10-12T16:09:53.127000
2008-10-12T16:38:51.773000
195,639
195,680
What libs can I use to bind POJOs to external files for TDD without much overhead?
I need a way to bind POJO objects to an external entity, that could be XML, YAML, structured text or anything easy to write and maintain in order to create Mock data for unit testing and TDD. Below are some libraries I tried, but the main problems with them were that I am stuck (for at least more 3 months) to Java 1.4....
If the objects to be populated are simple beans it may be a good idea to look at apache common's BeanUtils class. The populate() method might suit the described cases. Generally dependency injection frameworks like Spring can be very useful, but that might not be answer for the current problem. For input in form of xml...
What libs can I use to bind POJOs to external files for TDD without much overhead? I need a way to bind POJO objects to an external entity, that could be XML, YAML, structured text or anything easy to write and maintain in order to create Mock data for unit testing and TDD. Below are some libraries I tried, but the mai...
TITLE: What libs can I use to bind POJOs to external files for TDD without much overhead? QUESTION: I need a way to bind POJO objects to an external entity, that could be XML, YAML, structured text or anything easy to write and maintain in order to create Mock data for unit testing and TDD. Below are some libraries I ...
[ "java", "binding", "pojo" ]
1
2
712
3
0
2008-10-12T16:13:01.327000
2008-10-12T16:44:38.453000
195,641
195,654
Windows could not start the Apache2 on Local Computer - problem
During the installation of Apache2 I got the following message into cmd window: Installing the Apache2.2 service The Apache2.2 service is successfully installed. Testing httpd.conf.... Errors reported here must be corrected before the service can be started. httpd.exe: Could not reliably determine the server's fully qu...
There is some other program listening on port 80, usual suspects are Skype (Listens on port 80) NOD32 (Add Apache to the IMON exceptions' list for it to allow apache to bind) Some other antivirus (Same as above) Way to correct it is either shutting down the program that's using the port 80 or configure it to use a diff...
Windows could not start the Apache2 on Local Computer - problem During the installation of Apache2 I got the following message into cmd window: Installing the Apache2.2 service The Apache2.2 service is successfully installed. Testing httpd.conf.... Errors reported here must be corrected before the service can be starte...
TITLE: Windows could not start the Apache2 on Local Computer - problem QUESTION: During the installation of Apache2 I got the following message into cmd window: Installing the Apache2.2 service The Apache2.2 service is successfully installed. Testing httpd.conf.... Errors reported here must be corrected before the ser...
[ "windows", "windows-xp", "apache2" ]
71
139
408,578
20
0
2008-10-12T16:13:14.680000
2008-10-12T16:21:55.303000
195,648
195,703
Does this set of regular expressions FULLY protect against cross site scripting?
What's an example of something dangerous that would not be caught by the code below? EDIT: After some of the comments I added another line, commented below. See Vinko's comment in David Grant's answer. So far only Vinko has answered the question, which asks for specific examples that would slip through this function. V...
It's never enough – whitelist, don't blacklist For example javascript: pseudo-URL can be obfuscated with HTML entities, you've forgotten about and there are dangerous CSS properties like behavior and expression in IE. There are countless ways to evade filters and such approach is bound to fail. Even if you find and blo...
Does this set of regular expressions FULLY protect against cross site scripting? What's an example of something dangerous that would not be caught by the code below? EDIT: After some of the comments I added another line, commented below. See Vinko's comment in David Grant's answer. So far only Vinko has answered the qu...
TITLE: Does this set of regular expressions FULLY protect against cross site scripting? QUESTION: What's an example of something dangerous that would not be caught by the code below? EDIT: After some of the comments I added another line, commented below. See Vinko's comment in David Grant's answer. So far only Vinko h...
[ "regex", "security", "xss" ]
6
48
16,886
11
0
2008-10-12T16:16:40.633000
2008-10-12T17:04:36.637000
195,651
195,751
Any open sourced websites?
I have heard of desktop applications whose code has been open-sourced, but are there any websites whose code has been open-sourced? I don't think I have heard of any. If there are aren't any, are there any reasons why? This will have the advantage of not having to wait for the web development team to include a new feat...
Many answers have addressed the competitive aspect, but that really applies equally to all FOSS projects, web-based or not. The distinctive feature of web sites is that, by and large, the users of the software do not have access to the code in any form - source or binary - so the typical FOSS requirement that you make ...
Any open sourced websites? I have heard of desktop applications whose code has been open-sourced, but are there any websites whose code has been open-sourced? I don't think I have heard of any. If there are aren't any, are there any reasons why? This will have the advantage of not having to wait for the web development...
TITLE: Any open sourced websites? QUESTION: I have heard of desktop applications whose code has been open-sourced, but are there any websites whose code has been open-sourced? I don't think I have heard of any. If there are aren't any, are there any reasons why? This will have the advantage of not having to wait for t...
[ "open-source" ]
3
2
540
9
0
2008-10-12T16:20:35.413000
2008-10-12T17:35:56.760000
195,655
195,663
How to copy a file to multiple directories using the gnu cp command
Is it possible to copy a single file to multiple directories using the cp command? I tried the following, which did not work: cp file1 /foo/ /bar/ cp file1 {/foo/,/bar} I know it's possible using a for loop, or find. But is it possible using the gnu cp command?
No, cp can copy multiple sources but will only copy to a single destination. You need to arrange to invoke cp multiple times - once per destination - for what you want to do; using, as you say, a loop or some other tool.
How to copy a file to multiple directories using the gnu cp command Is it possible to copy a single file to multiple directories using the cp command? I tried the following, which did not work: cp file1 /foo/ /bar/ cp file1 {/foo/,/bar} I know it's possible using a for loop, or find. But is it possible using the gnu cp...
TITLE: How to copy a file to multiple directories using the gnu cp command QUESTION: Is it possible to copy a single file to multiple directories using the cp command? I tried the following, which did not work: cp file1 /foo/ /bar/ cp file1 {/foo/,/bar} I know it's possible using a for loop, or find. But is it possibl...
[ "linux", "bash", "shell" ]
219
113
169,892
22
0
2008-10-12T16:21:56.363000
2008-10-12T16:28:07.677000
195,657
195,737
can i use bdb(berkeley db) file created by c implementation (python bsddb) by oracle berkeley db java edition?
I have a berkeley db file (*.bdb) which is created by the C implementation(python bsddb module). Is it possible to read this file by a pure java implementation of Berkeley Db? I tried to read it using berkeley db java edition (je) but could not. je throws out an exception saying that it could not detect the berkeley da...
No. According to the Berkeley DB Java Edition FAQ, Berkeley DB and Berkeley DB Java Edition are not compatible with one another because they have a different file layout structure.
can i use bdb(berkeley db) file created by c implementation (python bsddb) by oracle berkeley db java edition? I have a berkeley db file (*.bdb) which is created by the C implementation(python bsddb module). Is it possible to read this file by a pure java implementation of Berkeley Db? I tried to read it using berkeley...
TITLE: can i use bdb(berkeley db) file created by c implementation (python bsddb) by oracle berkeley db java edition? QUESTION: I have a berkeley db file (*.bdb) which is created by the C implementation(python bsddb module). Is it possible to read this file by a pure java implementation of Berkeley Db? I tried to read...
[ "compatibility", "berkeley-db", "language-interoperability" ]
4
5
1,362
3
0
2008-10-12T16:23:31.163000
2008-10-12T17:27:25.827000
195,682
195,747
How do you mock classes that use RAII in c++
Here's my issue, I'd like to mock a class that creates a thread at initialization and closes it at destruction. There's no reason for my mock class to actually create and close threads. But, to mock a class, I have inherit from it. When I create a new instance of my mock class, the base classes constructor is called, c...
You instead make an interface that describes the type, and have both the real class and the mock class inherit from that. So if you had: class RAIIClass { public: RAIIClass(Foo* f); ~RAIIClass(); bool DoOperation(); private:... }; You would make an interface like: class MockableInterface { public: MockableInterface(Fo...
How do you mock classes that use RAII in c++ Here's my issue, I'd like to mock a class that creates a thread at initialization and closes it at destruction. There's no reason for my mock class to actually create and close threads. But, to mock a class, I have inherit from it. When I create a new instance of my mock cla...
TITLE: How do you mock classes that use RAII in c++ QUESTION: Here's my issue, I'd like to mock a class that creates a thread at initialization and closes it at destruction. There's no reason for my mock class to actually create and close threads. But, to mock a class, I have inherit from it. When I create a new insta...
[ "c++", "unit-testing", "mocking" ]
10
13
1,834
4
0
2008-10-12T16:47:18.463000
2008-10-12T17:34:37.543000
195,688
195,837
Converting a char string to its underlying data type
I have a string(char*), and i need to find its underlying datatype such as int, float, double, short, long, or just a character array containing alphabets with or with out digits(like varchar in SQL). For ex: char* str1 = "12312" char* str2 = "231.342" char* str3 = "234234243234" char* str4 = "4323434.2432342" char* st...
In C (not in C++), I would use a combination of strtod/strol and max values from and: #include #include #include #include /* Now, we know the following values: INT_MAX, INT_MIN, SHRT_MAX, SHRT_MIN, CHAR_MAX, CHAR_MIN, etc. */ typedef union tagMyUnion { char TChar_; short TShort_; long TLong_; double TDouble_; } MyUnio...
Converting a char string to its underlying data type I have a string(char*), and i need to find its underlying datatype such as int, float, double, short, long, or just a character array containing alphabets with or with out digits(like varchar in SQL). For ex: char* str1 = "12312" char* str2 = "231.342" char* str3 = "...
TITLE: Converting a char string to its underlying data type QUESTION: I have a string(char*), and i need to find its underlying datatype such as int, float, double, short, long, or just a character array containing alphabets with or with out digits(like varchar in SQL). For ex: char* str1 = "12312" char* str2 = "231.3...
[ "c", "types" ]
2
1
1,928
4
0
2008-10-12T16:54:06.547000
2008-10-12T18:46:05.683000
195,696
498,958
Why would waveOutWrite() cause an exception in the debug heap?
While researching this issue, I found multiple mentions of the following scenario online, invariably as unanswered questions on programming forums. I hope that posting this here will at least serve to document my findings. First, the symptom: While running pretty standard code that uses waveOutWrite() to output PCM aud...
You're not alone with this issue: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100589
Why would waveOutWrite() cause an exception in the debug heap? While researching this issue, I found multiple mentions of the following scenario online, invariably as unanswered questions on programming forums. I hope that posting this here will at least serve to document my findings. First, the symptom: While running ...
TITLE: Why would waveOutWrite() cause an exception in the debug heap? QUESTION: While researching this issue, I found multiple mentions of the following scenario online, invariably as unanswered questions on programming forums. I hope that posting this here will at least serve to document my findings. First, the sympt...
[ "c++", "windows", "audio", "waveoutwrite" ]
13
2
5,889
9
0
2008-10-12T16:59:55.240000
2009-01-31T15:06:29.067000
195,697
195,870
How can I extract specific tags using LINQ to XML in F#?
I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string) = let xml = XDocument.Load(xmlFile) Once I have the XDocument I need to navigate it using LINQ to XML and extract all specific tags. Part of my solution is: let xname (tag:string) = XName.Get(tag) let tagUrl (tag:XElement) = let attribute =...
#light open System open System.Xml.Linq let xname s = XName.Get(s) let bookmarks (xmlFile: string) = let xd = XDocument.Load xmlFile xd.Descendants <| xname "bookmark" This will find all the descendant elements of "bookmark". If you only want direct descendants, use the Elements method (xd.Root.Elements <| xname "what...
How can I extract specific tags using LINQ to XML in F#? I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string) = let xml = XDocument.Load(xmlFile) Once I have the XDocument I need to navigate it using LINQ to XML and extract all specific tags. Part of my solution is: let xname (tag:string) = X...
TITLE: How can I extract specific tags using LINQ to XML in F#? QUESTION: I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string) = let xml = XDocument.Load(xmlFile) Once I have the XDocument I need to navigate it using LINQ to XML and extract all specific tags. Part of my solution is: let xnam...
[ "f#", "linq-to-xml" ]
7
10
3,290
2
0
2008-10-12T17:00:19.967000
2008-10-12T19:12:23.057000
195,714
196,248
Design: Large archive file editor, file mapping
I'm writing an editor for large archive files (see below) of 4GB+, in native&managed C++. For accessing the files, I'm using file mapping (see below) like any sane person. This is absolutely great for reading data, but a problem arises in actually editing the archive. File mapping does not allow resizing a file while i...
What I do is to close view handle(s) and FileMapping handle, set the file size then reopen mapping / view handles. // Open memory mapped file HANDLE FileHandle =::CreateFileW(file_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); size_t Size =::GetFileSize(FileHandle, 0); HANDLE MappingHandle =::Cre...
Design: Large archive file editor, file mapping I'm writing an editor for large archive files (see below) of 4GB+, in native&managed C++. For accessing the files, I'm using file mapping (see below) like any sane person. This is absolutely great for reading data, but a problem arises in actually editing the archive. Fil...
TITLE: Design: Large archive file editor, file mapping QUESTION: I'm writing an editor for large archive files (see below) of 4GB+, in native&managed C++. For accessing the files, I'm using file mapping (see below) like any sane person. This is absolutely great for reading data, but a problem arises in actually editin...
[ "c++", "visual-studio", "winapi", "file-io" ]
2
1
1,181
6
0
2008-10-12T17:11:56.573000
2008-10-12T23:03:37.427000
195,741
195,762
shared library problems on linux
I'm trying to compile/link a very old piece of software on a linux system and I can't for some reason link with a shared library that's installed on my system. I get the following error from the linker: /usr/bin/ld: cannot find -lXaw However, the lib itself is installed. If I run ldconfig -v | grep libXaw I get (among ...
The linker may be looking, literally, for "libXaw.so". Is that in /usr/lib? If not, you could try adding it as another soft link from libXaw7.so.7.0.0.
shared library problems on linux I'm trying to compile/link a very old piece of software on a linux system and I can't for some reason link with a shared library that's installed on my system. I get the following error from the linker: /usr/bin/ld: cannot find -lXaw However, the lib itself is installed. If I run ldconf...
TITLE: shared library problems on linux QUESTION: I'm trying to compile/link a very old piece of software on a linux system and I can't for some reason link with a shared library that's installed on my system. I get the following error from the linker: /usr/bin/ld: cannot find -lXaw However, the lib itself is installe...
[ "linux", "gcc", "shared-libraries" ]
4
3
1,932
4
0
2008-10-12T17:30:09.860000
2008-10-12T17:40:53.677000
195,742
195,749
I can't connect to my server over the internet
I can run the server on my local machine and connect to it on the same machine, but when I try to connect to it from a different computer over the internet, there is not sign of activity on my server, nor a response from the server on the computer I'm testing it on. I've tried both XP and Vista, turn off firewalls, ope...
I think that the problem is in your router, not your computer. When packets come from the Internet, it should be routed to an specific server. You have to configure your router to redirect the traffic on port 3326 to your server.
I can't connect to my server over the internet I can run the server on my local machine and connect to it on the same machine, but when I try to connect to it from a different computer over the internet, there is not sign of activity on my server, nor a response from the server on the computer I'm testing it on. I've t...
TITLE: I can't connect to my server over the internet QUESTION: I can run the server on my local machine and connect to it on the same machine, but when I try to connect to it from a different computer over the internet, there is not sign of activity on my server, nor a response from the server on the computer I'm tes...
[ "c#", "networking", "sockets" ]
1
8
2,819
4
0
2008-10-12T17:30:53.633000
2008-10-12T17:35:28.507000
195,764
195,774
Problems with deleting XML elements using PHP DOM
Here's the XML file i'm working on: swimming running soccer The index.php, page that shows the list of activities with checkboxes, a button to delete the checked activities, and a field to add new activities: load('sample.xml', LIBXML_NOBLANKS); $count = 0; $activities = $xmldoc->firstChild->firstChild; //prints the ...
the DOMNodeList items are indexed starting with 0; You need to move the $count++ to the end of the while loop in the output step.
Problems with deleting XML elements using PHP DOM Here's the XML file i'm working on: swimming running soccer The index.php, page that shows the list of activities with checkboxes, a button to delete the checked activities, and a field to add new activities: load('sample.xml', LIBXML_NOBLANKS); $count = 0; $activitie...
TITLE: Problems with deleting XML elements using PHP DOM QUESTION: Here's the XML file i'm working on: swimming running soccer The index.php, page that shows the list of activities with checkboxes, a button to delete the checked activities, and a field to add new activities: load('sample.xml', LIBXML_NOBLANKS); $coun...
[ "php", "xml", "dom" ]
2
2
6,752
3
0
2008-10-12T17:42:13.737000
2008-10-12T17:52:54.527000
195,794
198,411
How to initialise a rather complex char array in C?
Assuming Visual C/C++ 6, I have a complex data structure of 22399 elements that looks like this: { { "(SAME", "AS", "U+4E18)", "HILLOCK", "OR", "MOUND"}, { "TO", "LICK;", {1, 1, 0}, "TASTE,", "A", "MAT,", "BAMBOO", "BARK"}, { "(J)", "NON-STANDARD", "FORM", "OF", "U+559C", ",", {1, 1, 0}, "LIKE,", "LOVE,", "ENJOY;", {1,...
I just read your new posts and re-read the original post, and I think I just fully understood the goal here. Sorry it took so long, I'm kind of slow. To paraphrase the question, on line 4 of the original example: { "(AN", "ANCIENT", {1, 2, 2}, {1, 2, 3}, "U+4E94)", "FIVE"}, You'd want to translate the triples into refe...
How to initialise a rather complex char array in C? Assuming Visual C/C++ 6, I have a complex data structure of 22399 elements that looks like this: { { "(SAME", "AS", "U+4E18)", "HILLOCK", "OR", "MOUND"}, { "TO", "LICK;", {1, 1, 0}, "TASTE,", "A", "MAT,", "BAMBOO", "BARK"}, { "(J)", "NON-STANDARD", "FORM", "OF", "U+55...
TITLE: How to initialise a rather complex char array in C? QUESTION: Assuming Visual C/C++ 6, I have a complex data structure of 22399 elements that looks like this: { { "(SAME", "AS", "U+4E18)", "HILLOCK", "OR", "MOUND"}, { "TO", "LICK;", {1, 1, 0}, "TASTE,", "A", "MAT,", "BAMBOO", "BARK"}, { "(J)", "NON-STANDARD", "...
[ "c", "arrays", "visual-c++", "initialization" ]
0
2
3,054
6
0
2008-10-12T18:10:01.713000
2008-10-13T17:49:22.380000
195,809
4,004,413
Is it possible to develop a powerful web search engine using Erlang, Mnesia & Yaws?
I am thinking of developing a web search engine using Erlang, Mnesia & Yaws. Is it possible to make a powerful and the fastest web search engine using these software? What will it need to accomplish this and how what do I start with?
Erlang can make the most powerful web crawler today. Let me take you through my simple crawler. Step 1. I create a simple parallelism module, which i call mapreduce -module(mapreduce). -export([compute/2]). %%===================================================================== %% usage example %% Module = string %% Fu...
Is it possible to develop a powerful web search engine using Erlang, Mnesia & Yaws? I am thinking of developing a web search engine using Erlang, Mnesia & Yaws. Is it possible to make a powerful and the fastest web search engine using these software? What will it need to accomplish this and how what do I start with?
TITLE: Is it possible to develop a powerful web search engine using Erlang, Mnesia & Yaws? QUESTION: I am thinking of developing a web search engine using Erlang, Mnesia & Yaws. Is it possible to make a powerful and the fastest web search engine using these software? What will it need to accomplish this and how what d...
[ "erlang", "search-engine", "web-crawler", "mnesia", "yaws" ]
6
20
4,134
4
0
2008-10-12T18:17:29.767000
2010-10-23T14:17:35.323000
195,829
195,833
What's the best way to use memcache with a single-server app?
For a single-server LAMP site (which is usually under quite high load), what is best way to use memcache? Does it make sense to run the memcache daemon on the same server as the application, or is that just going to take valuable memory away from MySQL, giving a net performance loss. Does it even make sense to use memc...
Usually, the recommendation (see What about shared memory? in the memcached page ) is to run memcached on the same machines as web servers, on the premise that web applications are CPU-heavy (which memcached is not), whereas memcached is memory-heavy (which most web applications are not, at least in comparison). So, if...
What's the best way to use memcache with a single-server app? For a single-server LAMP site (which is usually under quite high load), what is best way to use memcache? Does it make sense to run the memcache daemon on the same server as the application, or is that just going to take valuable memory away from MySQL, givi...
TITLE: What's the best way to use memcache with a single-server app? QUESTION: For a single-server LAMP site (which is usually under quite high load), what is best way to use memcache? Does it make sense to run the memcache daemon on the same server as the application, or is that just going to take valuable memory awa...
[ "linux", "caching", "memcached", "lamp" ]
6
11
3,575
2
0
2008-10-12T18:41:23.943000
2008-10-12T18:43:28.200000
195,834
196,211
What factors should be taken into consideration when writing a custom exception class?
When are custom Exception classes most-valuable? Are there cases when they should or should not be used? What are the benefits? Related questions: Performace Considerations for throwing Exceptions Do you write exceptions for specific issues or general exceptions?
Questions to ask yourself: Who will be catching it? If no one, then you don't really need a custom exception. Where will you be throwing it? Is there enough context readily available, or will you need to catch and re-throw several times before the exception is useful to the final catcher? Why are you throwing it? Becau...
What factors should be taken into consideration when writing a custom exception class? When are custom Exception classes most-valuable? Are there cases when they should or should not be used? What are the benefits? Related questions: Performace Considerations for throwing Exceptions Do you write exceptions for specific...
TITLE: What factors should be taken into consideration when writing a custom exception class? QUESTION: When are custom Exception classes most-valuable? Are there cases when they should or should not be used? What are the benefits? Related questions: Performace Considerations for throwing Exceptions Do you write excep...
[ "exception", "oop" ]
7
10
1,994
7
0
2008-10-12T18:44:34.377000
2008-10-12T22:21:34.140000
195,835
196,425
CruiseControl [.Net] vs TeamCity for continuous integration?
I would like to ask you which automated build environment you consider better, based on practical experience. I'm planning to do some.Net and some Java development, so I would like to have a tool that supports both these platforms. I've been reading around and found out about CruiseControl.NET, used on stackoverflow de...
I have worked on and with Continuous Integration tools since the one that spawned Cruise Control (java version). I've tried almost all of them at some point. I've never been happier than I am with TeamCity. It is very simple to set up and still provides a great deal of power. The build statistics page that shows build ...
CruiseControl [.Net] vs TeamCity for continuous integration? I would like to ask you which automated build environment you consider better, based on practical experience. I'm planning to do some.Net and some Java development, so I would like to have a tool that supports both these platforms. I've been reading around an...
TITLE: CruiseControl [.Net] vs TeamCity for continuous integration? QUESTION: I would like to ask you which automated build environment you consider better, based on practical experience. I'm planning to do some.Net and some Java development, so I would like to have a tool that supports both these platforms. I've been...
[ "continuous-integration", "build-automation", "cruisecontrol.net", "teamcity", "cruisecontrol" ]
117
111
30,090
11
0
2008-10-12T18:45:18.400000
2008-10-13T00:49:36.167000
195,842
809,259
Capture which step of an animated system cursor is being shown on Windows
I want to capture as a bitmap the system cursor on Windows OSes as accurately as possible. The provided API for this is to my knowledge GetCursorInfo, DrawIconEx. The simple chain of actions is: Get cursor by using GetCursorInfo Paint the cursor in a memory DC by using DrawIconEx. Here is how the code looks roughly. CU...
Unfortunately, I don't think there's a Windows API that discloses the current frame of the cursor animation. I assume that's what you're after: the look of the cursor at the instant you make the snapshot.
Capture which step of an animated system cursor is being shown on Windows I want to capture as a bitmap the system cursor on Windows OSes as accurately as possible. The provided API for this is to my knowledge GetCursorInfo, DrawIconEx. The simple chain of actions is: Get cursor by using GetCursorInfo Paint the cursor ...
TITLE: Capture which step of an animated system cursor is being shown on Windows QUESTION: I want to capture as a bitmap the system cursor on Windows OSes as accurately as possible. The provided API for this is to my knowledge GetCursorInfo, DrawIconEx. The simple chain of actions is: Get cursor by using GetCursorInfo...
[ "c++", "winapi" ]
4
2
1,189
2
0
2008-10-12T18:50:56.827000
2009-04-30T21:45:08.953000
195,844
198,961
Saving XML-Data in UserSettings
I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a.NET Winforms Project. Is there a Possibility to do that or would it be better to save this Data in a seperated File? Thanks for your Answers!
You can store an XML document's string representation in a setting of type String. To save the document, load it into an XmlDocument and set the setting to the value of the XmlDocument.OuterXml property. To retrieve it, create a new XmlDocument and use its LoadXml method to parse the string into an XML document. This i...
Saving XML-Data in UserSettings I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a.NET Winforms Project. Is there a Possibility to do that or would it be better to save this Data in a seperated File? Thanks for your Answers!
TITLE: Saving XML-Data in UserSettings QUESTION: I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a.NET Winforms Project. Is there a Possibility to do that or would it be better to save this Data in a seperated File? Thanks for your Answers! ANSWER: You can store an XM...
[ "c#", ".net", "xml", "app-config" ]
4
5
1,345
3
0
2008-10-12T18:53:24.140000
2008-10-13T20:40:57.853000
195,849
197,358
How to find full path of Outlook .pst file?
Is there a way to programmatically find the location of the current user's Outlook.pst file(s) through an API call or registry entry?
With Outlook Redemption, you can iterate the message stores in VBA using RDOStores collection, accessible via the RDOSession.Stores property. I am looking into the possibility of doing something similar in out-of-the-box VBA... EDIT: Obviously, the path to the PST is encoded in the StoreId string. Google turned up this...
How to find full path of Outlook .pst file? Is there a way to programmatically find the location of the current user's Outlook.pst file(s) through an API call or registry entry?
TITLE: How to find full path of Outlook .pst file? QUESTION: Is there a way to programmatically find the location of the current user's Outlook.pst file(s) through an API call or registry entry? ANSWER: With Outlook Redemption, you can iterate the message stores in VBA using RDOStores collection, accessible via the R...
[ "winapi", "vba", "outlook", "registry", "pst" ]
5
5
16,109
2
0
2008-10-12T18:57:17.220000
2008-10-13T12:09:40.193000
195,856
197,332
Writing Quality Tests
We know that code coverage is a poor metric to use when gauging the quality of test code. We also know that testing the language/framework is a waste of time. On the other hand, what metrics can we use to identify quality tests? Are there any best practices or rules of thumbs that you've learned to help you identify an...
Make sure your tests are independent of each other. A test shouldn't depend on the execution or results of some other test. Make sure each test has clearly defined entry criteria, test steps and exit criteria. Set up a Requirements Verification Traceability Matrix (RVTM). Each test should verify one or more requirement...
Writing Quality Tests We know that code coverage is a poor metric to use when gauging the quality of test code. We also know that testing the language/framework is a waste of time. On the other hand, what metrics can we use to identify quality tests? Are there any best practices or rules of thumbs that you've learned t...
TITLE: Writing Quality Tests QUESTION: We know that code coverage is a poor metric to use when gauging the quality of test code. We also know that testing the language/framework is a waste of time. On the other hand, what metrics can we use to identify quality tests? Are there any best practices or rules of thumbs tha...
[ "testing" ]
15
16
1,507
7
0
2008-10-12T19:02:20.643000
2008-10-13T11:53:29.040000
195,872
195,878
Multiple forms in an HTML page posting to itself
I need to have multiple forms in the same webpage, all of them POSTing to itself and then performing different actions depending on the type of form. What's the best way to achieve this? To be more specific, the page shows the details of an event, with a form to subscribe (a drop-down box) and another form for each of ...
A few ideas for you: A hidden field in each form Or setting the action url to include a querystring Named buttons so you know which was clicked. And then check that firstForm (et al) has been returned Edit: the code-sampling on SO doesn't seem to work for HTML properly. (Worryingly) it's not escaping forms, so I've cut...
Multiple forms in an HTML page posting to itself I need to have multiple forms in the same webpage, all of them POSTing to itself and then performing different actions depending on the type of form. What's the best way to achieve this? To be more specific, the page shows the details of an event, with a form to subscrib...
TITLE: Multiple forms in an HTML page posting to itself QUESTION: I need to have multiple forms in the same webpage, all of them POSTing to itself and then performing different actions depending on the type of form. What's the best way to achieve this? To be more specific, the page shows the details of an event, with ...
[ "html" ]
3
9
6,712
2
0
2008-10-12T19:14:05.360000
2008-10-12T19:17:31.157000
195,886
195,893
Committing binaries to SVN
I've searched around a bit, but haven't found a satisfactory answer, so I'd like to hear your opinions on this. I have a couple of tools which I have to update and deploy to a few servers every now and then. The source is managed in a SVN repository. To save myself the bother of copying the binaries to the production s...
There's nothing weird about your setup (I'm doing similar things with both build tools and build artifacts when I need to preserve the exact bits.) The layout you want is definitely possible - to "include" specific versions of other branches or tags in your tags/project1/release2, all you need to do is set svn:external...
Committing binaries to SVN I've searched around a bit, but haven't found a satisfactory answer, so I'd like to hear your opinions on this. I have a couple of tools which I have to update and deploy to a few servers every now and then. The source is managed in a SVN repository. To save myself the bother of copying the b...
TITLE: Committing binaries to SVN QUESTION: I've searched around a bit, but haven't found a satisfactory answer, so I'd like to hear your opinions on this. I have a couple of tools which I have to update and deploy to a few servers every now and then. The source is managed in a SVN repository. To save myself the bothe...
[ "svn", "tags" ]
9
9
4,429
5
0
2008-10-12T19:22:46.980000
2008-10-12T19:29:11.757000
195,887
195,932
What is the fascination with code metrics?
I've seen a number of 'code metrics' related questions on SO lately, and have to wonder what the fascination is? Here are some recent examples: what code metrics convince you that provided code is crappy when if ever is number of lines of code a useful metric writing quality tests In my mind, no metric can substitute f...
The answers in this thread are kind of odd as they speak of: "the team", like "the one and only beneficiary" of those said metrics; "the metrics", like they mean anything in themselves. 1/ Metrics is not for one population, but for three: developers: they are concerned with instantaneous static code metrics regarding s...
What is the fascination with code metrics? I've seen a number of 'code metrics' related questions on SO lately, and have to wonder what the fascination is? Here are some recent examples: what code metrics convince you that provided code is crappy when if ever is number of lines of code a useful metric writing quality t...
TITLE: What is the fascination with code metrics? QUESTION: I've seen a number of 'code metrics' related questions on SO lately, and have to wonder what the fascination is? Here are some recent examples: what code metrics convince you that provided code is crappy when if ever is number of lines of code a useful metric...
[ "code-metrics" ]
89
88
12,960
18
0
2008-10-12T19:23:37.837000
2008-10-12T19:49:51.827000
195,919
196,149
Removing files when uninstalling WiX
When uninstalling my application, I'd like to configure the Wix setup to remove all the files that were added after the original installation. It seems like the uninstaller removes only the directories and files that were originally installed from the MSI file and it leaves everything else that was added later in the a...
Use RemoveFile element with On=" uninstall ". Here's an example: Update It didn't work 100%. It removed the files, however none of the additional directories - the ones created after the installation - were removed. Any thoughts on that? – pribeiro Unfortunately Windows Installer doesn't support deleting directories wi...
Removing files when uninstalling WiX When uninstalling my application, I'd like to configure the Wix setup to remove all the files that were added after the original installation. It seems like the uninstaller removes only the directories and files that were originally installed from the MSI file and it leaves everythi...
TITLE: Removing files when uninstalling WiX QUESTION: When uninstalling my application, I'd like to configure the Wix setup to remove all the files that were added after the original installation. It seems like the uninstaller removes only the directories and files that were originally installed from the MSI file and ...
[ "wix", "installation", "windows-installer", "custom-action" ]
93
90
91,442
6
0
2008-10-12T19:41:29.113000
2008-10-12T21:38:42.043000
195,951
196,038
How can I change an element's class with JavaScript?
How can I change the class of an HTML element in response to an onclick or any other events using JavaScript?
Modern HTML5 Techniques for changing classes Modern browsers have added classList which provides methods to make it easier to manipulate classes without needing a library: document.getElementById("MyElement").classList.add('MyClass'); document.getElementById("MyElement").classList.remove('MyClass'); if ( document.get...
How can I change an element's class with JavaScript? How can I change the class of an HTML element in response to an onclick or any other events using JavaScript?
TITLE: How can I change an element's class with JavaScript? QUESTION: How can I change the class of an HTML element in response to an onclick or any other events using JavaScript? ANSWER: Modern HTML5 Techniques for changing classes Modern browsers have added classList which provides methods to make it easier to mani...
[ "javascript", "html", "dom" ]
3,418
4,623
3,509,882
34
0
2008-10-12T20:06:43.663000
2008-10-12T20:45:36.347000
195,956
195,960
Generating random number excluding range
How do you generate a random number within a range while excluding certain range(s). Eg. range 1-10 but not in 2-4 or 7. Solutions I've used so far: Generate a random an test if it is within the dis-allowed range. Based on result either output the number or try again. Map allowed ranges to a uniform range. Get a random...
(b) Use the single range and map to allowed values. (a) Is slower and running time is non-deterministic because you have to wait until you get a number in the right range. If you were to skip a large range, you'd be hosed. (c) Is more complex than (b); don't add complexity if it isn't required.
Generating random number excluding range How do you generate a random number within a range while excluding certain range(s). Eg. range 1-10 but not in 2-4 or 7. Solutions I've used so far: Generate a random an test if it is within the dis-allowed range. Based on result either output the number or try again. Map allowe...
TITLE: Generating random number excluding range QUESTION: How do you generate a random number within a range while excluding certain range(s). Eg. range 1-10 but not in 2-4 or 7. Solutions I've used so far: Generate a random an test if it is within the dis-allowed range. Based on result either output the number or try...
[ "language-agnostic", "random" ]
6
8
2,424
5
0
2008-10-12T20:09:46.403000
2008-10-12T20:11:48.490000
195,973
195,997
Validating Web Pages
I have been developing websites for a couple of years now and I almost never check if my pages are valid HTML and CSS. My check is by using a site such as browsershots.org and checking how it looks in all the different browsers. However recently I have been taking a college course and the prof wants us to validate ever...
Yes, for the reasons already covered here. I realise you are not necessarily talking about commercial websites, but it is good to act as if you are anyway.
Validating Web Pages I have been developing websites for a couple of years now and I almost never check if my pages are valid HTML and CSS. My check is by using a site such as browsershots.org and checking how it looks in all the different browsers. However recently I have been taking a college course and the prof want...
TITLE: Validating Web Pages QUESTION: I have been developing websites for a couple of years now and I almost never check if my pages are valid HTML and CSS. My check is by using a site such as browsershots.org and checking how it looks in all the different browsers. However recently I have been taking a college course...
[ "html", "css", "validation", "xhtml" ]
1
4
403
13
0
2008-10-12T20:15:56
2008-10-12T20:26:59.207000
195,975
196,018
How can I make a char string from a C macro's value?
For example, how can I avoid writing the 'func_name' twice? #ifndef TEST_FUN # define TEST_FUN func_name # define TEST_FUN_NAME "func_name" #endif I'd like to follow the Single Point of Truth rule. Version of C preprocessor: cpp --version Output: cpp (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14)
He who is Shy * gave you the germ of an answer, but only the germ. The basic technique for converting a value into a string in the C pre-processor is indeed via the '#' operator, but a simple transliteration of the proposed solution gets a compilation error: #define TEST_FUNC test_func #define TEST_FUNC_NAME #TEST_FUNC...
How can I make a char string from a C macro's value? For example, how can I avoid writing the 'func_name' twice? #ifndef TEST_FUN # define TEST_FUN func_name # define TEST_FUN_NAME "func_name" #endif I'd like to follow the Single Point of Truth rule. Version of C preprocessor: cpp --version Output: cpp (GCC) 4.1.2 2007...
TITLE: How can I make a char string from a C macro's value? QUESTION: For example, how can I avoid writing the 'func_name' twice? #ifndef TEST_FUN # define TEST_FUN func_name # define TEST_FUN_NAME "func_name" #endif I'd like to follow the Single Point of Truth rule. Version of C preprocessor: cpp --version Output: cp...
[ "c", "c-preprocessor", "dry" ]
62
89
138,460
3
0
2008-10-12T20:16:05.190000
2008-10-12T20:35:11.890000
195,991
196,030
Best way to implement tab stops in valid XHTML?
For explanation imagine a simple address. Written in a HTML paragraph with line breaks it would like this: Street: Example Street 1 City: Vienna Zip Code: 1010 Country: Austria Most of the time that's completely okay, but sometimes I have to achieve the following output: Street: Example Street 1 City: Vienna Zip Code: ...
I find that definition lists make much more sense than tables here. Float the dt to the left with a specific width and have it clear on the left. If either the label or the data are going to wrap, you'll have to do some post-element-float-clearing trickery to make this work, but it doesn't sound like you'll need that. ...
Best way to implement tab stops in valid XHTML? For explanation imagine a simple address. Written in a HTML paragraph with line breaks it would like this: Street: Example Street 1 City: Vienna Zip Code: 1010 Country: Austria Most of the time that's completely okay, but sometimes I have to achieve the following output: ...
TITLE: Best way to implement tab stops in valid XHTML? QUESTION: For explanation imagine a simple address. Written in a HTML paragraph with line breaks it would like this: Street: Example Street 1 City: Vienna Zip Code: 1010 Country: Austria Most of the time that's completely okay, but sometimes I have to achieve the ...
[ "html", "css" ]
9
9
7,212
7
0
2008-10-12T20:23:40.057000
2008-10-12T20:40:37.777000
196,001
196,129
Is the design view for aspx pages in Visual Studio useful?
I have never really found the design view in Visual Studio useful when developing aspx pages, and so I basically never use it. Am I missing something or is it just one of those features that isn't particularly useful? Do you use the design view? If so, how do you find it useful? If not, why not?
Is the design view for aspx pages in Visual Studio useful? It surely is, if you fit one of these profiles You don't know HTML or CSS You don't care if your HTML is readable or valid You don't care if your site renders properly in anything other than IE You are being forced at gunpoint into building a webpage when you h...
Is the design view for aspx pages in Visual Studio useful? I have never really found the design view in Visual Studio useful when developing aspx pages, and so I basically never use it. Am I missing something or is it just one of those features that isn't particularly useful? Do you use the design view? If so, how do y...
TITLE: Is the design view for aspx pages in Visual Studio useful? QUESTION: I have never really found the design view in Visual Studio useful when developing aspx pages, and so I basically never use it. Am I missing something or is it just one of those features that isn't particularly useful? Do you use the design vie...
[ "asp.net", "visual-studio", "visual-studio-2008" ]
2
13
2,955
7
0
2008-10-12T20:27:30.033000
2008-10-12T21:26:07.873000
196,017
196,065
Unique (non-repeating) random numbers in O(1)?
I'd like to generate unique random numbers between 0 and 1000 that never repeat (i.e. 6 doesn't show up twice), but that doesn't resort to something like an O(N) search of previous values to do it. Is this possible?
Initialize an array of 1001 integers with the values 0-1000 and set a variable, max, to the current max index of the array (starting with 1000). Pick a random number, r, between 0 and max, swap the number at the position r with the number at position max and return the number now at position max. Decrement max by 1 and...
Unique (non-repeating) random numbers in O(1)? I'd like to generate unique random numbers between 0 and 1000 that never repeat (i.e. 6 doesn't show up twice), but that doesn't resort to something like an O(N) search of previous values to do it. Is this possible?
TITLE: Unique (non-repeating) random numbers in O(1)? QUESTION: I'd like to generate unique random numbers between 0 and 1000 that never repeat (i.e. 6 doesn't show up twice), but that doesn't resort to something like an O(N) search of previous values to do it. Is this possible? ANSWER: Initialize an array of 1001 in...
[ "algorithm", "math", "random", "language-agnostic" ]
197
267
119,034
23
0
2008-10-12T20:34:22.297000
2008-10-12T20:57:02.080000
196,027
196,138
Is there a more accurate way to create a Javascript timer than setTimeout?
Something that has always bugged me is how unpredictable the setTimeout() method in Javascript is. In my experience, the timer is horribly inaccurate in a lot of situations. By inaccurate, I mean the actual delay time seems to vary by 250-500ms more or less. Although this isn't a huge amount of time, when using it to h...
Are there any tricks that can be done to ensure that setTimeout() performs accurately (without resorting to an external API) or is this a lost cause? No and no. You're not going to get anything close to a perfectly accurate timer with setTimeout() - browsers aren't set up for that. However, you don't need to rely on it...
Is there a more accurate way to create a Javascript timer than setTimeout? Something that has always bugged me is how unpredictable the setTimeout() method in Javascript is. In my experience, the timer is horribly inaccurate in a lot of situations. By inaccurate, I mean the actual delay time seems to vary by 250-500ms ...
TITLE: Is there a more accurate way to create a Javascript timer than setTimeout? QUESTION: Something that has always bugged me is how unpredictable the setTimeout() method in Javascript is. In my experience, the timer is horribly inaccurate in a lot of situations. By inaccurate, I mean the actual delay time seems to ...
[ "javascript", "timer" ]
80
82
46,295
16
0
2008-10-12T20:38:35.707000
2008-10-12T21:32:23.833000
196,029
196,036
How can I split a PHP script that takes a long time to run into smaller chunks?
I have a PHP script that initialises an image gallery. It loops through all images, checks if they are thumbnailed and watermarks them. My shared hosting account only lets me have 30 seconds of execution per script, as set in the php.ini settings. I can't change that. What can I do to get round this? Currently I refres...
three ideas: you could offload this to a script that runs on the server (PHP CLI perhaps?) and have your current script check the progress (still running! check back later!). if javascript is ok in your environment, perhaps you could make ajax calls to handle this as well. the first solution allows the user to keep wan...
How can I split a PHP script that takes a long time to run into smaller chunks? I have a PHP script that initialises an image gallery. It loops through all images, checks if they are thumbnailed and watermarks them. My shared hosting account only lets me have 30 seconds of execution per script, as set in the php.ini se...
TITLE: How can I split a PHP script that takes a long time to run into smaller chunks? QUESTION: I have a PHP script that initialises an image gallery. It loops through all images, checks if they are thumbnailed and watermarks them. My shared hosting account only lets me have 30 seconds of execution per script, as set...
[ "php" ]
4
3
5,404
8
0
2008-10-12T20:39:54.207000
2008-10-12T20:43:38.097000
196,032
196,071
Code formatting across Windows and Unix
What Visual Studio settings and.emacs macros improve the likelihood that code written on Windows (in visual studio) will still look good in Emacs (and vice versa)? I've recently taken to turning off tabs in emacs (so tabs are rendered via spaces) and this at least makes the code look the same (tho people who like certa...
Always use tabs for indenting only and nothing else, and there's no problem. Anything involving aligning characters across lines (not indenting) should use spaces. Just do that, then people can set their tab size to whatever they like, and everything will all be fine.
Code formatting across Windows and Unix What Visual Studio settings and.emacs macros improve the likelihood that code written on Windows (in visual studio) will still look good in Emacs (and vice versa)? I've recently taken to turning off tabs in emacs (so tabs are rendered via spaces) and this at least makes the code ...
TITLE: Code formatting across Windows and Unix QUESTION: What Visual Studio settings and.emacs macros improve the likelihood that code written on Windows (in visual studio) will still look good in Emacs (and vice versa)? I've recently taken to turning off tabs in emacs (so tabs are rendered via spaces) and this at lea...
[ "visual-studio", "emacs", "cross-platform", "code-formatting", "dos2unix" ]
0
3
848
4
0
2008-10-12T20:41:17.417000
2008-10-12T20:59:25.180000
196,037
196,107
How can I access a public static member of a Java class from ColdFusion?
How can I access a public static member of a Java class from ColdFusion?
You run the createObject but don't call the "init" before running the static method. For example: #systemObject.currentTimeMillis()# In this case "currentTimeMillis()" is a static method of the System class.
How can I access a public static member of a Java class from ColdFusion? How can I access a public static member of a Java class from ColdFusion?
TITLE: How can I access a public static member of a Java class from ColdFusion? QUESTION: How can I access a public static member of a Java class from ColdFusion? ANSWER: You run the createObject but don't call the "init" before running the static method. For example: #systemObject.currentTimeMillis()# In this case "...
[ "java", "coldfusion" ]
9
17
2,258
2
0
2008-10-12T20:43:49.703000
2008-10-12T21:17:29.590000
196,049
196,055
When generating html, do you including formatting such as newlines and tabs?
Sometimes I add a \n at the end, and the relevant number of \t the beginning, and sometimes not - what's the recommended way to do this?
It depends whether you want the HTML to be human readable or not. In most cases however, I would suggest that generated markup should always be human-readable, as it makes debugging a whole lot easier.
When generating html, do you including formatting such as newlines and tabs? Sometimes I add a \n at the end, and the relevant number of \t the beginning, and sometimes not - what's the recommended way to do this?
TITLE: When generating html, do you including formatting such as newlines and tabs? QUESTION: Sometimes I add a \n at the end, and the relevant number of \t the beginning, and sometimes not - what's the recommended way to do this? ANSWER: It depends whether you want the HTML to be human readable or not. In most cases...
[ "html", "code-formatting" ]
1
5
163
8
0
2008-10-12T20:50:59.223000
2008-10-12T20:52:47.487000