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
196,053
201,873
Best Way to Handle Multiple Scrolling Columns
I am in the process of developing a web application that consists visually of a header above a body containing four columns of variable-height content. The design gods have decreed it to be fixed height, mainly because each of the columns can potentially get very long, and so (being designers) they are wanting iframes ...
I'm pretty sure this does exactly what you need: Liquid 4 column layout with fixed height banner and footer No iframes, no java script, and each column automatically fills the available height.
Best Way to Handle Multiple Scrolling Columns I am in the process of developing a web application that consists visually of a header above a body containing four columns of variable-height content. The design gods have decreed it to be fixed height, mainly because each of the columns can potentially get very long, and ...
TITLE: Best Way to Handle Multiple Scrolling Columns QUESTION: I am in the process of developing a web application that consists visually of a header above a body containing four columns of variable-height content. The design gods have decreed it to be fixed height, mainly because each of the columns can potentially g...
[ "css" ]
6
9
7,179
4
0
2008-10-12T20:52:07.830000
2008-10-14T16:23:38.433000
196,059
196,704
Small problem with painting scroll bars with MFC
In an MFC application there is a small rectangular region where the scroll bars meet (bottom right of the window). It seems that this region only invalidates when the frame is resized. On other occasions (for example, if another window is dragged over it), this region does not repaint. I've been able to reproduce it in...
One work around would be to trap the OnPaint method of the CScrollView and in this method add code to always paint the bottom corner of the client window. But this painting code would also need to call GetDC to get a new CDC, so that it can bypass the clipping regions of the BeginPaint CDC passed in by the WM_PAINT mes...
Small problem with painting scroll bars with MFC In an MFC application there is a small rectangular region where the scroll bars meet (bottom right of the window). It seems that this region only invalidates when the frame is resized. On other occasions (for example, if another window is dragged over it), this region do...
TITLE: Small problem with painting scroll bars with MFC QUESTION: In an MFC application there is a small rectangular region where the scroll bars meet (bottom right of the window). It seems that this region only invalidates when the frame is resized. On other occasions (for example, if another window is dragged over i...
[ "visual-studio", "visual-c++", "mfc" ]
1
1
1,172
1
0
2008-10-12T20:54:16.517000
2008-10-13T04:22:45.083000
196,087
196,113
What is a component
I listen to the podcast java posse, on this there is often discussion about components (note components are not (clearly) objects). They lament the fact that Java does not have components, and contrast with.NET that does. Components apparently makes developing applications (not just GUI apps) easier. I can figure from ...
Software Engineering Radio has an episode on exactly this topic: https://se-radio.net/2008/02/episode-87-software-components/ The general idea is that a software component can describe what its own dependencies and services are, in the form of metadata. I don't know why you might have heard that Java does not have comp...
What is a component I listen to the podcast java posse, on this there is often discussion about components (note components are not (clearly) objects). They lament the fact that Java does not have components, and contrast with.NET that does. Components apparently makes developing applications (not just GUI apps) easier...
TITLE: What is a component QUESTION: I listen to the podcast java posse, on this there is often discussion about components (note components are not (clearly) objects). They lament the fact that Java does not have components, and contrast with.NET that does. Components apparently makes developing applications (not jus...
[ "java", ".net", "object" ]
13
3
15,818
6
0
2008-10-12T21:06:58.067000
2008-10-12T21:19:49.570000
196,088
196,151
Coercing template class with operator T* when passing as T* argument of a function template
Assume I have a function template like this: template inline void doStuff(T* arr) { // stuff that needs to use sizeof(T) } Then in another.h filee I have a template class Foo that has: public: operator T*() const; Now, I realize that those are different Ts. But If I have a variable Foo f on the stack, the only way to c...
GCC is correct. In template arguments only exact matches are considered, type conversions are not. This is because otherwise an infinite (or at least exponential) amount of conversions could have to be considered. If Foo is the only other template that you're going to run in to, the best solution would be to add: templ...
Coercing template class with operator T* when passing as T* argument of a function template Assume I have a function template like this: template inline void doStuff(T* arr) { // stuff that needs to use sizeof(T) } Then in another.h filee I have a template class Foo that has: public: operator T*() const; Now, I realize...
TITLE: Coercing template class with operator T* when passing as T* argument of a function template QUESTION: Assume I have a function template like this: template inline void doStuff(T* arr) { // stuff that needs to use sizeof(T) } Then in another.h filee I have a template class Foo that has: public: operator T*() con...
[ "c++", "templates", "coercion" ]
0
3
2,378
5
0
2008-10-12T21:07:01.187000
2008-10-12T21:39:03.867000
196,094
196,117
How can I find out what enums are defined by a class?
I know I can get the public static members of a class by doing something like: obj.getClass().getFields() but this doesn't get me the enums. I'd like to be able to get them from the Class object returned by the getClass method. Any ideas?
(Turned into a community wiki as it looks like there's scope for a fair amount of expansion, e.g. to include tackline's comments. No sense in me just transcribing comments when everyone could be expanding it.) Do you mean enums nested within a top-level class? If so, use Class.getDeclaredClasses() and iterate through t...
How can I find out what enums are defined by a class? I know I can get the public static members of a class by doing something like: obj.getClass().getFields() but this doesn't get me the enums. I'd like to be able to get them from the Class object returned by the getClass method. Any ideas?
TITLE: How can I find out what enums are defined by a class? QUESTION: I know I can get the public static members of a class by doing something like: obj.getClass().getFields() but this doesn't get me the enums. I'd like to be able to get them from the Class object returned by the getClass method. Any ideas? ANSWER: ...
[ "java" ]
3
6
303
2
0
2008-10-12T21:11:26.920000
2008-10-12T21:22:22.683000
196,097
196,105
XHTML and code inside textareas
On a site of mine in which a textarea is used for submission, I have code that can appear something along the lines of the following: text When validating (XHTML 1.0 Transitional), this error arises, line 88 column 50 - Error: document type does not allow element "p" here If this is not a valid method, then what is exp...
is there a reason you're trying to put a within? as you found out it's not valid. if it's for display purposes (ie, showing code) it should be translated: <p>text</p> beyond validation issues, allowing arbitrary tags (which are not properly encoded as above) to display can be a huge security issue. it's paramount to ma...
XHTML and code inside textareas On a site of mine in which a textarea is used for submission, I have code that can appear something along the lines of the following: text When validating (XHTML 1.0 Transitional), this error arises, line 88 column 50 - Error: document type does not allow element "p" here If this is not ...
TITLE: XHTML and code inside textareas QUESTION: On a site of mine in which a textarea is used for submission, I have code that can appear something along the lines of the following: text When validating (XHTML 1.0 Transitional), this error arises, line 88 column 50 - Error: document type does not allow element "p" he...
[ "validation", "xhtml" ]
5
8
3,833
6
0
2008-10-12T21:12:55.947000
2008-10-12T21:16:34.803000
196,109
197,554
Flex media framework
Does anybody know of a good media framework for Flex? I'd like to be able to create apps that can play not only those formats that the Flex framework provides support for, but other formats as well (like wav, wma, ogg and other...). EDIT 13.10.2008.: It was recently pointed out to me in the answers section that I shoul...
You might need to make your question more specific - like, is there a way to play ogg vorbis in Flash? Then I could answer, hell yes! It's right here.
Flex media framework Does anybody know of a good media framework for Flex? I'd like to be able to create apps that can play not only those formats that the Flex framework provides support for, but other formats as well (like wav, wma, ogg and other...). EDIT 13.10.2008.: It was recently pointed out to me in the answers...
TITLE: Flex media framework QUESTION: Does anybody know of a good media framework for Flex? I'd like to be able to create apps that can play not only those formats that the Flex framework provides support for, but other formats as well (like wav, wma, ogg and other...). EDIT 13.10.2008.: It was recently pointed out to...
[ "apache-flex", "frameworks", "media" ]
1
1
363
2
0
2008-10-12T21:17:48.123000
2008-10-13T13:16:45.207000
196,114
196,119
Why do I get "permission denied" in PHP when trying to rename a directory?
I chmod'ed the directory to 777, same with the directory contents. Still, I get a "permission denied" error. Does PHP throw this error if apache is not the group/owner, regardless of the file permissions? Here's the call that's failing: rename('/correct/path/to/dir/1', '/correct/path/to/dir/2');
You're editing the higher level directory, so the PHP user needs to have write access to that directory.
Why do I get "permission denied" in PHP when trying to rename a directory? I chmod'ed the directory to 777, same with the directory contents. Still, I get a "permission denied" error. Does PHP throw this error if apache is not the group/owner, regardless of the file permissions? Here's the call that's failing: rename('...
TITLE: Why do I get "permission denied" in PHP when trying to rename a directory? QUESTION: I chmod'ed the directory to 777, same with the directory contents. Still, I get a "permission denied" error. Does PHP throw this error if apache is not the group/owner, regardless of the file permissions? Here's the call that's...
[ "php", "permissions", "rename" ]
5
12
20,492
6
0
2008-10-12T21:20:11.113000
2008-10-12T21:23:32.197000
196,115
198,900
SharePoint does not find my custom RenderingTemplate
So I've created a custom RenderingTemplate and deployed it to CONTROLTEMPLATES\MyControlTemplates\ It basically dictates how a custom content type that i've created should be rendered when displayed. For that I've added this: CustomDispForm However, SharePoint does not find my custom RenderingTemplate when it's located...
I have noticed the same behaviour when putting control templates in a custom directory. You are right, SharePoint is supposed to look in subdirectories by default as well (the exact location in the config files eludes me at the moment) but it does not seem to do so. I loaded my templates programatically, perhaps this i...
SharePoint does not find my custom RenderingTemplate So I've created a custom RenderingTemplate and deployed it to CONTROLTEMPLATES\MyControlTemplates\ It basically dictates how a custom content type that i've created should be rendered when displayed. For that I've added this: CustomDispForm However, SharePoint does n...
TITLE: SharePoint does not find my custom RenderingTemplate QUESTION: So I've created a custom RenderingTemplate and deployed it to CONTROLTEMPLATES\MyControlTemplates\ It basically dictates how a custom content type that i've created should be rendered when displayed. For that I've added this: CustomDispForm However,...
[ "sharepoint", "wss", "controltemplates" ]
4
5
2,789
1
0
2008-10-12T21:20:36.290000
2008-10-13T20:22:02.353000
196,136
196,191
Other than malloc/free does a program need the OS to provide anything else?
I'm working on designing the kernel (which I'm going to actually call the "core" just to be different, but its basically the same) for an OS I'm working on. The specifics of the OS itself are irrelevant if I can't get multi-tasking, memory management, and other basic things up and running, so I need to work on that fir...
malloc is generally implemented in the C runtime in userspace, relying on specific OS system calls to map in pages of virtual memory. The job of malloc and free is to manage those pages of memory, which are fixed in size (typically 4 KB, but sometimes bigger), and to slice and dice them into pieces that applications ca...
Other than malloc/free does a program need the OS to provide anything else? I'm working on designing the kernel (which I'm going to actually call the "core" just to be different, but its basically the same) for an OS I'm working on. The specifics of the OS itself are irrelevant if I can't get multi-tasking, memory mana...
TITLE: Other than malloc/free does a program need the OS to provide anything else? QUESTION: I'm working on designing the kernel (which I'm going to actually call the "core" just to be different, but its basically the same) for an OS I'm working on. The specifics of the OS itself are irrelevant if I can't get multi-ta...
[ "operating-system", "kernel", "malloc", "heap-memory", "osdev" ]
9
16
5,567
7
0
2008-10-12T21:32:20.370000
2008-10-12T22:03:01.730000
196,150
196,158
Is there a way I can retrieve sa password in sql server 2005
I just forgot the password. Can anyone help me how to get back the password.
There is no way to get the old password back. Log into the SQL server management console as a machine or domain admin using integrated authentication, you can then change any password (including sa). Start the SQL service again and use the new created login (recovery in my example) Go via the security panel to the prop...
Is there a way I can retrieve sa password in sql server 2005 I just forgot the password. Can anyone help me how to get back the password.
TITLE: Is there a way I can retrieve sa password in sql server 2005 QUESTION: I just forgot the password. Can anyone help me how to get back the password. ANSWER: There is no way to get the old password back. Log into the SQL server management console as a machine or domain admin using integrated authentication, you ...
[ "sql-server", "sql-server-2005", "passwords" ]
6
27
115,993
4
0
2008-10-12T21:39:02.463000
2008-10-12T21:41:15.923000
196,171
196,196
Oracle 10gr2: prevent any dates that fall on a Sunday?
Is it possible to use a CHECK constraint to prevent any date that falls on a Sunday? I don't want to use a trigger.
Yes, a check constraint can check that the day of the week is not Sunday. Here's an example: create table date_test (entry_date date); alter table date_test add constraint day_is_not_sunday check ( to_char(entry_date,'DAY','NLS_DATE_LANGUAGE = ENGLISH') not like 'SUNDAY%'); --There are blank spaces to the right of SUN...
Oracle 10gr2: prevent any dates that fall on a Sunday? Is it possible to use a CHECK constraint to prevent any date that falls on a Sunday? I don't want to use a trigger.
TITLE: Oracle 10gr2: prevent any dates that fall on a Sunday? QUESTION: Is it possible to use a CHECK constraint to prevent any date that falls on a Sunday? I don't want to use a trigger. ANSWER: Yes, a check constraint can check that the day of the week is not Sunday. Here's an example: create table date_test (entry...
[ "oracle", "constraints" ]
1
8
769
2
0
2008-10-12T21:52:43.170000
2008-10-12T22:05:51.550000
196,173
196,209
How I do I make controls/elements move with inertia?
Modern UI's are starting to give their UI elments nice inertia when moving. Tabs slide in, page transitions, even some listboxes and scroll elments have nice inertia to them (the iphone for example). What is the best algorythm for this? It is more than just gravity as they speed up, and then slow down as they fall into...
You're talking about two different things here. One is momentum - giving things residual motion when you release them from a drag. This is simply about remembering the velocity of a thing when the user releases it, then applying that velocity to the object every frame and also reducing the velocity every frame by some ...
How I do I make controls/elements move with inertia? Modern UI's are starting to give their UI elments nice inertia when moving. Tabs slide in, page transitions, even some listboxes and scroll elments have nice inertia to them (the iphone for example). What is the best algorythm for this? It is more than just gravity a...
TITLE: How I do I make controls/elements move with inertia? QUESTION: Modern UI's are starting to give their UI elments nice inertia when moving. Tabs slide in, page transitions, even some listboxes and scroll elments have nice inertia to them (the iphone for example). What is the best algorythm for this? It is more t...
[ "user-interface", "look-and-feel" ]
9
18
5,270
5
0
2008-10-12T21:52:49.113000
2008-10-12T22:18:14.817000
196,177
196,195
Is LINQ to SQL InsertOnSubmit() subject to SQL Injection Attack?
I have code like this: var newMsg = new Msg { Var1 = var1, Var2 = var2 }; using (AppDataContext appDataContext = new AppDataContext(ConnectionString)) { appDataContext.CClass.InsertOnSubmit(newMsg); appDataContext.SubmitChanges(); } After reading this post I believe that the same logic applies. Does anyone think that ...
The second answer in the post you're referencing says it: LINQ to SQL uses execute_sql with parameters. It does not concatenate property values into a one big INSERT... VALUES('...', '...')
Is LINQ to SQL InsertOnSubmit() subject to SQL Injection Attack? I have code like this: var newMsg = new Msg { Var1 = var1, Var2 = var2 }; using (AppDataContext appDataContext = new AppDataContext(ConnectionString)) { appDataContext.CClass.InsertOnSubmit(newMsg); appDataContext.SubmitChanges(); } After reading this po...
TITLE: Is LINQ to SQL InsertOnSubmit() subject to SQL Injection Attack? QUESTION: I have code like this: var newMsg = new Msg { Var1 = var1, Var2 = var2 }; using (AppDataContext appDataContext = new AppDataContext(ConnectionString)) { appDataContext.CClass.InsertOnSubmit(newMsg); appDataContext.SubmitChanges(); } Aft...
[ "c#", ".net", "linq-to-sql", "sql-injection" ]
0
5
2,432
3
0
2008-10-12T21:56:05.847000
2008-10-12T22:04:12.663000
196,179
196,301
Shift reduce conflict
I'm having a problem understanding the shift/reduce confict for a grammar that I know has no ambiguity. The case is one of the if else type but it's not the 'dangling else' problem since I have mandatory END clauses delimiting code blocks. Here is the grammar for gppg (Its a Bison like compiler compiler... and that was...
Your revised ELSEIF rule has no markers for a condition -- it should nominally have '(' and ')' added. More seriously, you now have a rule for elsebody: else | elseifs else; and elseifs: /* Nothing */ | elseifs...something...; The 'nothing' is not needed; it is implicitly taken care of by the 'elsebody' without the 'el...
Shift reduce conflict I'm having a problem understanding the shift/reduce confict for a grammar that I know has no ambiguity. The case is one of the if else type but it's not the 'dangling else' problem since I have mandatory END clauses delimiting code blocks. Here is the grammar for gppg (Its a Bison like compiler co...
TITLE: Shift reduce conflict QUESTION: I'm having a problem understanding the shift/reduce confict for a grammar that I know has no ambiguity. The case is one of the if else type but it's not the 'dangling else' problem since I have mandatory END clauses delimiting code blocks. Here is the grammar for gppg (Its a Biso...
[ "grammar", "conflict", "gppg" ]
10
6
9,746
6
0
2008-10-12T21:58:09.740000
2008-10-12T23:39:21.253000
196,203
196,239
How to avoid blinking when updating page from ajax
I've got a table with a header, a row with input fields, rows with data. Like this. http://brow.hu/sitegen/stackoverflow_table_example.png If somebody enters something into an input field I want to filter the data with an ajax query. After receiving the new table I change the content of the old one: div.innerHTML = req...
One way to avoid flicker is called double-buffering. In Ajax, this can be done simply with 2 divs occupying the same space, one of them with the style 'display: none', the other 'display: inline'. Always write to the invisible one, and then swap display styles. If the divs have absolute positioning and size, there is a...
How to avoid blinking when updating page from ajax I've got a table with a header, a row with input fields, rows with data. Like this. http://brow.hu/sitegen/stackoverflow_table_example.png If somebody enters something into an input field I want to filter the data with an ajax query. After receiving the new table I cha...
TITLE: How to avoid blinking when updating page from ajax QUESTION: I've got a table with a header, a row with input fields, rows with data. Like this. http://brow.hu/sitegen/stackoverflow_table_example.png If somebody enters something into an input field I want to filter the data with an ajax query. After receiving t...
[ "html", "ajax" ]
5
8
5,806
2
0
2008-10-12T22:11:49.230000
2008-10-12T22:58:14.393000
196,221
196,507
Custom ID in session handling by Java Servlet API
Is it possible to assign a custom ID to a HTTP session through Servlet API? I know that session handling from any application server, Tomcat for example, it's enough good to generate unique IDs. But I have custom unique session IDs based on information per user and time, so it won't be repeated. And I looked at every d...
If you are using Tomcat, you may be able to create a custom session manager (see this discussion ). You would then have access to the Tomcat Session object and could call setId.
Custom ID in session handling by Java Servlet API Is it possible to assign a custom ID to a HTTP session through Servlet API? I know that session handling from any application server, Tomcat for example, it's enough good to generate unique IDs. But I have custom unique session IDs based on information per user and time...
TITLE: Custom ID in session handling by Java Servlet API QUESTION: Is it possible to assign a custom ID to a HTTP session through Servlet API? I know that session handling from any application server, Tomcat for example, it's enough good to generate unique IDs. But I have custom unique session IDs based on information...
[ "java", "session", "web-applications", "servlets" ]
4
5
8,046
3
0
2008-10-12T22:33:31.310000
2008-10-13T02:01:33.010000
196,224
196,271
Combining different javascript objects rendered by multiple components
I have a component which writes/generates javascript from a server side renderer. This component can be used in multiple times in a same page. However, once the page is loaded I have to collect all the variables or JSO written by this multiple components in the page. How can I do this so that I will have a collection o...
You will need to be a little more specific about your problem, maybe with an example page but here are some thoughts. If you have a server-side component that writes JavaScript during page generation, I would generate a function call each time, something like: Component_appendArray(['First', 'Second']);... Component_ap...
Combining different javascript objects rendered by multiple components I have a component which writes/generates javascript from a server side renderer. This component can be used in multiple times in a same page. However, once the page is loaded I have to collect all the variables or JSO written by this multiple compo...
TITLE: Combining different javascript objects rendered by multiple components QUESTION: I have a component which writes/generates javascript from a server side renderer. This component can be used in multiple times in a same page. However, once the page is loaded I have to collect all the variables or JSO written by t...
[ "javascript", "jsf" ]
0
1
749
2
0
2008-10-12T22:37:25.013000
2008-10-12T23:18:24.807000
196,244
196,280
Secure access to files in a directory identified by an environment variable?
Can anyone point to some code that deals with the security of files access via a path specified (in part) by an environment variable, specifically for Unix and its variants, but Windows solutions are also of interest? This is a big long question - I'm not sure how well it fits the SO paradigm. Consider this scenario: B...
Option 2 works, if you write a new value for $PQRHOME after resolving its real path and check its security. That way very little of your code needs changing thereafter. As far as keeping the setuid privileges, it would help if you can do some sort of privilege separation, so that any operations involving input from the...
Secure access to files in a directory identified by an environment variable? Can anyone point to some code that deals with the security of files access via a path specified (in part) by an environment variable, specifically for Unix and its variants, but Windows solutions are also of interest? This is a big long questi...
TITLE: Secure access to files in a directory identified by an environment variable? QUESTION: Can anyone point to some code that deals with the security of files access via a path specified (in part) by an environment variable, specifically for Unix and its variants, but Windows solutions are also of interest? This is...
[ "security", "unix", "environment-variables", "setuid" ]
3
2
481
2
0
2008-10-12T23:02:09.800000
2008-10-12T23:24:00.270000
196,294
196,451
What is a catamorphism and can it be implemented in C# 3.0?
I'm trying to learn about catamorphisms and I've read the Wikipedia article and the first couple posts in the series of the topic for F# on the Inside F# blog. I understand that it's a generalization of folds (i.e., mapping a structure of many values to one value, including a list of values to another list). And I gath...
LINQ's Aggregate() is just for IEnumerables. Catamorphisms in general refer to the pattern of folding for an arbitrary data type. So Aggregate() is to IEnumerables what FoldTree (below) is to Trees (below); both are catamorphisms for their respective data types. I translated some of the code in part 4 of the series int...
What is a catamorphism and can it be implemented in C# 3.0? I'm trying to learn about catamorphisms and I've read the Wikipedia article and the first couple posts in the series of the topic for F# on the Inside F# blog. I understand that it's a generalization of folds (i.e., mapping a structure of many values to one va...
TITLE: What is a catamorphism and can it be implemented in C# 3.0? QUESTION: I'm trying to learn about catamorphisms and I've read the Wikipedia article and the first couple posts in the series of the topic for F# on the Inside F# blog. I understand that it's a generalization of folds (i.e., mapping a structure of man...
[ "c#", "f#", "functional-programming", "catamorphism", "recursion-schemes" ]
27
32
13,399
5
0
2008-10-12T23:33:39.877000
2008-10-13T01:06:37.070000
196,326
196,335
Progress button for Windows Forms
.NET newbie here... I'd like to make a button in a Windows form that displays a progress or "cooldown" effect. That is, when the button is pressed, it becomes disabled. As some event or timer is progressing, the button shows the progress graphically. When the progress is finished, the graphic completes and the button b...
If you really need to have it on the button, I'd go with a custom paint event. something similar to: button += new buttonPaintEvent(buttonPaintEventHandlerMethod);
Progress button for Windows Forms .NET newbie here... I'd like to make a button in a Windows form that displays a progress or "cooldown" effect. That is, when the button is pressed, it becomes disabled. As some event or timer is progressing, the button shows the progress graphically. When the progress is finished, the ...
TITLE: Progress button for Windows Forms QUESTION: .NET newbie here... I'd like to make a button in a Windows form that displays a progress or "cooldown" effect. That is, when the button is pressed, it becomes disabled. As some event or timer is progressing, the button shows the progress graphically. When the progress...
[ ".net", "button", "progress" ]
3
0
677
3
0
2008-10-13T00:02:01.177000
2008-10-13T00:09:07.403000
196,329
196,350
OSX lacks memalign
I'm working on a project in C and it requires memalign(). Really, posix_memalign() would do as well, but darwin/OSX lacks both of them. What is a good solution to shoehorn-in memalign? I don't understand the licensing for posix-C code if I were to rip off memalign.c and put it in my project- I don't want any viral-type...
Mac OS X appears to be 16-byte mem aligned. Quote from the website: I had a hard time finding a definitive statement on MacOS X memory alignment so I did my own tests. On 10.4/intel, both stack and heap memory is 16 byte aligned. So people porting software can stop looking for memalign() and posix_memalign(). It’s not ...
OSX lacks memalign I'm working on a project in C and it requires memalign(). Really, posix_memalign() would do as well, but darwin/OSX lacks both of them. What is a good solution to shoehorn-in memalign? I don't understand the licensing for posix-C code if I were to rip off memalign.c and put it in my project- I don't ...
TITLE: OSX lacks memalign QUESTION: I'm working on a project in C and it requires memalign(). Really, posix_memalign() would do as well, but darwin/OSX lacks both of them. What is a good solution to shoehorn-in memalign? I don't understand the licensing for posix-C code if I were to rip off memalign.c and put it in my...
[ "c++", "c", "macos", "posix" ]
18
14
16,230
9
0
2008-10-13T00:03:54.200000
2008-10-13T00:15:21.320000
196,340
196,362
Should I only store fixed-size data elements in a database?
If the amount of data stored within a given field of a database is unknown, and could be very large, should I store it in an external file rather than within a field in the database?
You should choose a database management system which has the capability to handle large data efficiently. The database system might store it within the database file or in an external file linked to from within the database. SQL Server 2008 can do both, transparently; not sure what other systems offer.
Should I only store fixed-size data elements in a database? If the amount of data stored within a given field of a database is unknown, and could be very large, should I store it in an external file rather than within a field in the database?
TITLE: Should I only store fixed-size data elements in a database? QUESTION: If the amount of data stored within a given field of a database is unknown, and could be very large, should I store it in an external file rather than within a field in the database? ANSWER: You should choose a database management system whi...
[ "database-design" ]
0
1
296
5
0
2008-10-13T00:11:35.837000
2008-10-13T00:18:44.623000
196,357
197,092
Making iTerm to translate 'meta-key' in the same way as in other OSes
In bash shell with emacs key-binding, you can use key combination like M-f, M-b to move one word forward or backward on the shell prompt respectively. Usually, the meta key is mapped to Alt key on Windows and Linux. However, in iTerm, I could not find a way to map this meta key to either Option or Command key on my Mac...
Open "Preferences" ( ⌘, ) -> Profiles -> Keys -> General tab. Set Left Option key: to act as Esc+. Works for me in Emacs, though I'm not sure if it will have any other undesirable effects.
Making iTerm to translate 'meta-key' in the same way as in other OSes In bash shell with emacs key-binding, you can use key combination like M-f, M-b to move one word forward or backward on the shell prompt respectively. Usually, the meta key is mapped to Alt key on Windows and Linux. However, in iTerm, I could not fin...
TITLE: Making iTerm to translate 'meta-key' in the same way as in other OSes QUESTION: In bash shell with emacs key-binding, you can use key combination like M-f, M-b to move one word forward or backward on the shell prompt respectively. Usually, the meta key is mapped to Alt key on Windows and Linux. However, in iTer...
[ "macos", "command-line", "keyboard-shortcuts" ]
220
282
102,589
15
0
2008-10-13T00:17:53.483000
2008-10-13T09:27:33.360000
196,382
1,070,416
How do I use the Queue library in SML/NJ
I see that the SML/NJ includes a queue structure. I can't figure out how to use it. How do I use the additional libraries provided by SML/NJ?
The Queue structure is not specified by SML '97, but it is present in SML/NJ's top-level environment. $ sml Standard ML of New Jersey v110.69 [built: Fri Mar 13 16:02:47 2009] - Queue.mkQueue (); [autoloading] [library $SMLNJ-LIB/Util/smlnj-lib.cm is stable] [autoloading done] stdIn:1.1-1.17 Warning: type vars not gene...
How do I use the Queue library in SML/NJ I see that the SML/NJ includes a queue structure. I can't figure out how to use it. How do I use the additional libraries provided by SML/NJ?
TITLE: How do I use the Queue library in SML/NJ QUESTION: I see that the SML/NJ includes a queue structure. I can't figure out how to use it. How do I use the additional libraries provided by SML/NJ? ANSWER: The Queue structure is not specified by SML '97, but it is present in SML/NJ's top-level environment. $ sml St...
[ "queue", "sml", "smlnj", "ml" ]
3
3
1,859
3
0
2008-10-13T00:26:06.480000
2009-07-01T17:38:26.250000
196,390
196,397
Can you write a block of c++ code inside C#?
I heard somewhere that you can drop down to C++ directly inside C# code. How is this done? Or did I hear wrong? Note: I do not mean C++ / CLI.
You might be thinking of unsafe blocks where you can write code that looks a lot like C++, since you can use pointers.
Can you write a block of c++ code inside C#? I heard somewhere that you can drop down to C++ directly inside C# code. How is this done? Or did I hear wrong? Note: I do not mean C++ / CLI.
TITLE: Can you write a block of c++ code inside C#? QUESTION: I heard somewhere that you can drop down to C++ directly inside C# code. How is this done? Or did I hear wrong? Note: I do not mean C++ / CLI. ANSWER: You might be thinking of unsafe blocks where you can write code that looks a lot like C++, since you can ...
[ "c#", ".net", "c++" ]
3
9
2,793
5
0
2008-10-13T00:30:28.983000
2008-10-13T00:32:51.410000
196,407
196,464
How do you find the base url from a DLL in C#?
From within a DLL that's being called by a C#.NET web app, how do you find the base url of the web app?
Will this work? HttpContext.Current.Request.Url UPDATE: To get the base URL you can use: HttpContext.Current.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped)
How do you find the base url from a DLL in C#? From within a DLL that's being called by a C#.NET web app, how do you find the base url of the web app?
TITLE: How do you find the base url from a DLL in C#? QUESTION: From within a DLL that's being called by a C#.NET web app, how do you find the base url of the web app? ANSWER: Will this work? HttpContext.Current.Request.Url UPDATE: To get the base URL you can use: HttpContext.Current.Request.Url.GetComponents(UriComp...
[ "c#", ".net", "asp.net", "url", "web-applications" ]
3
12
6,825
5
0
2008-10-13T00:38:36.203000
2008-10-13T01:22:50.437000
196,415
196,416
Date ranges in T/SQL
For a current project I am working I need to return an aggregate report based on date ranges. I have 3 types of reports, yearly, monthly and daily. To assist in returning this report I need a function that will return all of the sub-ranges of datetimes, within a big range. So for example if I as for all the daily range...
There are quite a few tricks in here, hope you find it useful create function dbo.fnGetDateRanges ( @type char(1), @start datetime, @finish datetime ) returns @ranges table(start datetime, finish datetime) as begin declare @from datetime declare @to datetime set @from = @start if @type = 'd' begin set @to = dateadd(d...
Date ranges in T/SQL For a current project I am working I need to return an aggregate report based on date ranges. I have 3 types of reports, yearly, monthly and daily. To assist in returning this report I need a function that will return all of the sub-ranges of datetimes, within a big range. So for example if I as fo...
TITLE: Date ranges in T/SQL QUESTION: For a current project I am working I need to return an aggregate report based on date ranges. I have 3 types of reports, yearly, monthly and daily. To assist in returning this report I need a function that will return all of the sub-ranges of datetimes, within a big range. So for ...
[ "sql-server" ]
2
2
870
4
0
2008-10-13T00:42:18.973000
2008-10-13T00:42:48.817000
196,418
196,448
How can I programmatically determine whether an MP3 file is CBR or VBR? (preferrably using c#)
I know of many utilities that can tell me the bitrate of an MP3 file, but I've never seen one that can tell me whether or not the MP3 file is VBR (variable bit rate - the bit rate fluctuates within the file) or a CBR (constant bit rate - the bit rate stays the same within the file). My guess is that most programs aren'...
MP3 files are essentially build of so called frames. Each frame has a small header that stores information about the frame. The header also stores which bitrate was used for the frame. In CBR files, all frames use the same bitrate and therefore every header has the same bitrate information. To detect if a file uses VBR...
How can I programmatically determine whether an MP3 file is CBR or VBR? (preferrably using c#) I know of many utilities that can tell me the bitrate of an MP3 file, but I've never seen one that can tell me whether or not the MP3 file is VBR (variable bit rate - the bit rate fluctuates within the file) or a CBR (constan...
TITLE: How can I programmatically determine whether an MP3 file is CBR or VBR? (preferrably using c#) QUESTION: I know of many utilities that can tell me the bitrate of an MP3 file, but I've never seen one that can tell me whether or not the MP3 file is VBR (variable bit rate - the bit rate fluctuates within the file)...
[ "c#", "mp3" ]
6
7
7,553
2
0
2008-10-13T00:44:26.787000
2008-10-13T01:02:44.847000
196,420
196,433
What's the best way to use SqlBulkCopy to fill a really large table?
Nightly, I need to fill a SQL Server 2005 table from an ODBC source with over 8 million records. Currently I am using an insert statement from linked server with syntax select similar to this: Insert Into SQLStagingTable from Select * from OpenQuery(ODBCSource, 'Select * from SourceTable') This is really inefficient an...
The easiest way would be to use ExecuteReader() against your odbc data source and pass the IDataReader to the WriteToServer(IDataReader) overload. Most data reader implementations will only keep a very small portion of the total results in memory.
What's the best way to use SqlBulkCopy to fill a really large table? Nightly, I need to fill a SQL Server 2005 table from an ODBC source with over 8 million records. Currently I am using an insert statement from linked server with syntax select similar to this: Insert Into SQLStagingTable from Select * from OpenQuery(O...
TITLE: What's the best way to use SqlBulkCopy to fill a really large table? QUESTION: Nightly, I need to fill a SQL Server 2005 table from an ODBC source with over 8 million records. Currently I am using an insert statement from linked server with syntax select similar to this: Insert Into SQLStagingTable from Select ...
[ "c#", ".net", "sql-server", "vb.net", "sqlbulkcopy" ]
2
4
3,141
3
0
2008-10-13T00:45:15.893000
2008-10-13T00:54:12.820000
196,424
196,428
Proper use of try .. catch
Should I be using this method of throwing errors: if (isset($this->dbfields[$var])) { return $this->dbfields[$var]; } else { throw new FieldNotFoundException($var); } or this style: try { return $this->dbfields[$var]; } catch (Exception $e) { throw new FieldNotFoundException($var); }...or something else altogether? qui...
The second example is bad. You're taking a lot of overhead to catch an exception when, as you demonstrate, it's just as easy to prevent the exception in the first place. Plus you also assume you know why that exception was thrown - if there was some other exception, like say an out of memory or something, you're report...
Proper use of try .. catch Should I be using this method of throwing errors: if (isset($this->dbfields[$var])) { return $this->dbfields[$var]; } else { throw new FieldNotFoundException($var); } or this style: try { return $this->dbfields[$var]; } catch (Exception $e) { throw new FieldNotFoundException($var); }...or som...
TITLE: Proper use of try .. catch QUESTION: Should I be using this method of throwing errors: if (isset($this->dbfields[$var])) { return $this->dbfields[$var]; } else { throw new FieldNotFoundException($var); } or this style: try { return $this->dbfields[$var]; } catch (Exception $e) { throw new FieldNotFoundException...
[ "error-handling" ]
6
10
1,590
7
0
2008-10-13T00:48:12.177000
2008-10-13T00:52:08.313000
196,465
196,748
What is a type and effect system?
The Wikipedia article on Effect system is currently just a short stub and I've been wondering for a while as to what is an effect system. Are there any languages that have an effect system in addition to a type system? What would a possible (hypothetical) notation in a mainstream language, that you're familiar, with lo...
A "type and effect system" describes not only the kinds of values in a program, but the changes in those values. "Typestate" checking is a related idea. An example might be a type system that tracks file handles: instead of having a function close with return type void, the type system would record the effect of close ...
What is a type and effect system? The Wikipedia article on Effect system is currently just a short stub and I've been wondering for a while as to what is an effect system. Are there any languages that have an effect system in addition to a type system? What would a possible (hypothetical) notation in a mainstream langu...
TITLE: What is a type and effect system? QUESTION: The Wikipedia article on Effect system is currently just a short stub and I've been wondering for a while as to what is an effect system. Are there any languages that have an effect system in addition to a type system? What would a possible (hypothetical) notation in ...
[ "types", "effects", "type-systems", "type-theory", "effect-systems" ]
15
21
4,994
2
0
2008-10-13T01:22:52.777000
2008-10-13T04:56:49.817000
196,468
196,493
Cobertura refuses to acknowledge code was covered
I am using the Maven (2) Cobertura plug-in to create reports on code coverage, and I have the following stub I am using in a method: try { System.exit(0); } catch (final SecurityException exception) { exception.printStackTrace(); } System.err.println("The program never exited!"); I know that I need to log the exception...
I haven't used Cobertura in a while (2005?), and saw this behavior back then. A similar problem exists with NCover for C# and curly braces following catch/finally blocks. My suggestion would be to add to this Cobertura bug report detailing a similar issue. Also, follow @tvanfosson's advice and realize not having covera...
Cobertura refuses to acknowledge code was covered I am using the Maven (2) Cobertura plug-in to create reports on code coverage, and I have the following stub I am using in a method: try { System.exit(0); } catch (final SecurityException exception) { exception.printStackTrace(); } System.err.println("The program never ...
TITLE: Cobertura refuses to acknowledge code was covered QUESTION: I am using the Maven (2) Cobertura plug-in to create reports on code coverage, and I have the following stub I am using in a method: try { System.exit(0); } catch (final SecurityException exception) { exception.printStackTrace(); } System.err.println("...
[ "java", "maven-2", "code-coverage", "cobertura" ]
3
1
4,528
4
0
2008-10-13T01:32:03.210000
2008-10-13T01:46:58.890000
196,471
196,475
Is a custom module the best way to access an external API in Drupal?
I'm new to extending Drupal, though I've done similar kinds of things for other CMSes. Anyone care to share opinions on the best way to access an external API from within Drupal? I need to show things like search results, listings, and listing summaries. In my reading up on Drupal, I think this implies I need to create...
Yes, they are all possible from within the same module; consult the various hook functions on how to declare nodes and blocks in a function. There's also the PHP filter, which lets you embed pure PHP code on content pages, and doesn't require any module development, but for anything non-trivial I cannot recommend it.
Is a custom module the best way to access an external API in Drupal? I'm new to extending Drupal, though I've done similar kinds of things for other CMSes. Anyone care to share opinions on the best way to access an external API from within Drupal? I need to show things like search results, listings, and listing summari...
TITLE: Is a custom module the best way to access an external API in Drupal? QUESTION: I'm new to extending Drupal, though I've done similar kinds of things for other CMSes. Anyone care to share opinions on the best way to access an external API from within Drupal? I need to show things like search results, listings, a...
[ "php", "api", "drupal" ]
2
3
360
2
0
2008-10-13T01:34:31.630000
2008-10-13T01:38:04.540000
196,480
555,538
Identify full vs half yearly datasets in SQL
I have a table with two fields of interest for this particular exercise: a CHAR(3) ID and a DATETIME. The ID identifies the submitter of the data - several thousand rows. The DATETIME is not necessarily unique, either. (The primary keys are other fields of the table.) Data for this table is submitted every six months. ...
I later realised that I was supposed to check to make sure that there was data for both July to December and January to June. So this is what I wound up in v2: SELECT @avgmonths = AVG(x.[count]) FROM ( SELECT CAST(COUNT(DISTINCT DATEPART(month, DATEADD(month, DATEDIFF(month, 0, dscdate), 0))) AS FLOAT) AS [count] FROM ...
Identify full vs half yearly datasets in SQL I have a table with two fields of interest for this particular exercise: a CHAR(3) ID and a DATETIME. The ID identifies the submitter of the data - several thousand rows. The DATETIME is not necessarily unique, either. (The primary keys are other fields of the table.) Data f...
TITLE: Identify full vs half yearly datasets in SQL QUESTION: I have a table with two fields of interest for this particular exercise: a CHAR(3) ID and a DATETIME. The ID identifies the submitter of the data - several thousand rows. The DATETIME is not necessarily unique, either. (The primary keys are other fields of ...
[ "sql", "sql-server-2005", "t-sql" ]
1
0
819
3
0
2008-10-13T01:39:44.770000
2009-02-17T04:36:27.560000
196,488
197,040
How can I write a complex find query in CakePHP without using `$this->Model->query()`?
Hey all I'm hoping someone has enough experience with Cake PHP to make this work. I'm working on something that at the moment could affectionately be called a twitter clone. Essentially I have a set up like this. Users have many friends. This is a many to many relationship to the user table. It is stored in a link tabl...
If all you need in the results of the query is a list of tips, I'd be tempted to do this in 2 queries. The first to find a list of user ids of this user and their friends, the second to find the tips that belong to any one of these ids. So, in your Tip model: function findTipsByUserAndFriends($userId) { //FriendsUser i...
How can I write a complex find query in CakePHP without using `$this->Model->query()`? Hey all I'm hoping someone has enough experience with Cake PHP to make this work. I'm working on something that at the moment could affectionately be called a twitter clone. Essentially I have a set up like this. Users have many frie...
TITLE: How can I write a complex find query in CakePHP without using `$this->Model->query()`? QUESTION: Hey all I'm hoping someone has enough experience with Cake PHP to make this work. I'm working on something that at the moment could affectionately be called a twitter clone. Essentially I have a set up like this. Us...
[ "php", "mysql", "cakephp" ]
0
3
3,933
3
0
2008-10-13T01:42:18.353000
2008-10-13T08:52:30.437000
196,498
196,510
How do I load the contents of a text file into a javascript variable?
I have a text file in the root of my web app http://localhost/foo.txt and I'd like to load it into a variable in javascript.. in groovy I would do this: def fileContents = 'http://localhost/foo.txt'.toURL().text; println fileContents; How can I get a similar result in javascript?
XMLHttpRequest, i.e. AJAX, without the XML. The precise manner you do this is dependent on what JavaScript framework you're using, but if we disregard interoperability issues, your code will look something like: var client = new XMLHttpRequest(); client.open('GET', '/foo.txt'); client.onreadystatechange = function() { ...
How do I load the contents of a text file into a javascript variable? I have a text file in the root of my web app http://localhost/foo.txt and I'd like to load it into a variable in javascript.. in groovy I would do this: def fileContents = 'http://localhost/foo.txt'.toURL().text; println fileContents; How can I get a...
TITLE: How do I load the contents of a text file into a javascript variable? QUESTION: I have a text file in the root of my web app http://localhost/foo.txt and I'd like to load it into a variable in javascript.. in groovy I would do this: def fileContents = 'http://localhost/foo.txt'.toURL().text; println fileContent...
[ "javascript" ]
209
166
604,405
9
0
2008-10-13T01:57:13.627000
2008-10-13T02:02:19.920000
196,505
196,742
Using Wordpress LOOP with pages instead of posts?
Is there a way to use THE LOOP in Wordpress to load pages instead of posts? I would like to be able to query a set of child pages, and then use THE LOOP function calls on it - things like the_permalink() and the_title(). Is there a way to do this? I didn't see anything in query_posts() documentation.
Yes, that's possible. You can create a new WP_Query object. Do something like this: query_posts(array('showposts' =>, 'post_parent' =>, 'post_type' => 'page')); while (have_posts()) { the_post(); /* Do whatever you want to do for every page... */ } wp_reset_query(); // Restore global post data Addition: There are a l...
Using Wordpress LOOP with pages instead of posts? Is there a way to use THE LOOP in Wordpress to load pages instead of posts? I would like to be able to query a set of child pages, and then use THE LOOP function calls on it - things like the_permalink() and the_title(). Is there a way to do this? I didn't see anything ...
TITLE: Using Wordpress LOOP with pages instead of posts? QUESTION: Is there a way to use THE LOOP in Wordpress to load pages instead of posts? I would like to be able to query a set of child pages, and then use THE LOOP function calls on it - things like the_permalink() and the_title(). Is there a way to do this? I di...
[ "php", "wordpress" ]
34
57
50,637
2
0
2008-10-13T02:00:51.110000
2008-10-13T04:47:51.303000
196,512
196,549
Is there a sorted collection type in .NET?
I'm looking for a container that keeps all its items in order. I looked at SortedList, but that requires a separate key, and does not allow duplicate keys. I could also just use an unsorted container and explicitly sort it after each insert. Usage: Occasional insert Frequent traversal in order Ideally not working with ...
You might want to take a look at the Wintellect Power Collections. It is available on CodePlex and contains quite a few collections that are very helpful. The OrderedBag collection in the project is exactly what you are looking for. It essentially uses a red-black tree to provide a pretty efficient sort.
Is there a sorted collection type in .NET? I'm looking for a container that keeps all its items in order. I looked at SortedList, but that requires a separate key, and does not allow duplicate keys. I could also just use an unsorted container and explicitly sort it after each insert. Usage: Occasional insert Frequent t...
TITLE: Is there a sorted collection type in .NET? QUESTION: I'm looking for a container that keeps all its items in order. I looked at SortedList, but that requires a separate key, and does not allow duplicate keys. I could also just use an unsorted container and explicitly sort it after each insert. Usage: Occasional...
[ "c#", ".net", "sorting", "containers" ]
26
20
20,424
7
0
2008-10-13T02:05:47.307000
2008-10-13T02:25:29.250000
196,518
196,963
Problem with dynamic controls in .NET
Problem with dynamic controls Hello all, I'm wanting to create some dynamic controls, and have them persist their viewstate across page loads. Easy enough, right? All I have to do is re-create the controls upon each page load, using the same IDs. HOWEVER, here's the catch - in my PreRender event, I'm wanting to clear t...
ViewState-backed properties are only persisted to ViewState if the control is currently tracking ViewState. This is by design to keep ViewState as small as possible: it should only contain data that is truly dynamic. The upshot of this is that: ViewState propeties set during the Init event are not backed to ViewState (...
Problem with dynamic controls in .NET Problem with dynamic controls Hello all, I'm wanting to create some dynamic controls, and have them persist their viewstate across page loads. Easy enough, right? All I have to do is re-create the controls upon each page load, using the same IDs. HOWEVER, here's the catch - in my P...
TITLE: Problem with dynamic controls in .NET QUESTION: Problem with dynamic controls Hello all, I'm wanting to create some dynamic controls, and have them persist their viewstate across page loads. Easy enough, right? All I have to do is re-create the controls upon each page load, using the same IDs. HOWEVER, here's t...
[ "c#", "asp.net", "dynamic", "controls", "viewstate" ]
15
19
13,211
9
0
2008-10-13T02:07:56.430000
2008-10-13T07:56:53.887000
196,520
196,536
PHP: Best way to extract text within parenthesis?
What's the best/most efficient way to extract text set between parenthesis? Say I wanted to get the string "text" from the string "ignore everything except this (text)" in the most efficient manner possible. So far, the best I've come up with is this: $fullString = "ignore everything except this (text)"; $start = strpo...
i'd just do a regex and get it over with. unless you are doing enough iterations that it becomes a huge performance issue, it's just easier to code (and understand when you look back on it) $text = 'ignore everything except this (text)'; preg_match('#\((.*?)\)#', $text, $match); print $match[1];
PHP: Best way to extract text within parenthesis? What's the best/most efficient way to extract text set between parenthesis? Say I wanted to get the string "text" from the string "ignore everything except this (text)" in the most efficient manner possible. So far, the best I've come up with is this: $fullString = "ign...
TITLE: PHP: Best way to extract text within parenthesis? QUESTION: What's the best/most efficient way to extract text set between parenthesis? Say I wanted to get the string "text" from the string "ignore everything except this (text)" in the most efficient manner possible. So far, the best I've come up with is this: ...
[ "php", "parsing", "string" ]
94
171
113,899
10
0
2008-10-13T02:08:55.400000
2008-10-13T02:16:39.843000
196,522
196,545
In C++ what are the benefits of using exceptions and try / catch instead of just returning an error code?
I've programmed C and C++ for a long time and so far I've never used exceptions and try / catch. What are the benefits of using that instead of just having functions return error codes?
Possibly an obvious point - a developer can ignore (or not be aware of) your return status and go on blissfully unaware that something failed. An exception needs to be acknowledged in some way - it can't be silently ignored without actively putting something in place to do so.
In C++ what are the benefits of using exceptions and try / catch instead of just returning an error code? I've programmed C and C++ for a long time and so far I've never used exceptions and try / catch. What are the benefits of using that instead of just having functions return error codes?
TITLE: In C++ what are the benefits of using exceptions and try / catch instead of just returning an error code? QUESTION: I've programmed C and C++ for a long time and so far I've never used exceptions and try / catch. What are the benefits of using that instead of just having functions return error codes? ANSWER: P...
[ "c++", "exception", "try-catch" ]
25
29
13,415
13
0
2008-10-13T02:11:32.477000
2008-10-13T02:23:36.570000
196,554
205,603
At what point do MaxTextureRepeat limitations come into play?
When executing a pixel shader under Direct3D, do the limits on texture coordinates imposed by MaxTextureRepeat only become an issue during calls to texture lookup functions such as Tex2D(), or do they come into play anytime the texture coordinates are accessed within the shader? I wish to know whether it's possible to ...
Texture coordinates are at native interpolator precision. On pixel shader 2.0 capable hardware, this is at least 24 bits floating point (or perhaps 32 bits, not sure). Internally the calculations in pixel shader must be at least 24 bits floating point. Most modern GPUs run at 32 bits floating point precision. The MaxTe...
At what point do MaxTextureRepeat limitations come into play? When executing a pixel shader under Direct3D, do the limits on texture coordinates imposed by MaxTextureRepeat only become an issue during calls to texture lookup functions such as Tex2D(), or do they come into play anytime the texture coordinates are access...
TITLE: At what point do MaxTextureRepeat limitations come into play? QUESTION: When executing a pixel shader under Direct3D, do the limits on texture coordinates imposed by MaxTextureRepeat only become an issue during calls to texture lookup functions such as Tex2D(), or do they come into play anytime the texture coor...
[ "directx", "direct3d", "textures", "hlsl", "shader" ]
1
0
227
1
0
2008-10-13T02:27:51.100000
2008-10-15T17:16:03.430000
196,566
200,664
Java webservice (soap) client - use certificates
I am trying to connect to a webservice over ssl with a client certificate. Is there an elegant way of doing this apart from shoving things like "javax.net.ssl.keyStore" into System.properties. Any pointers to code examples would be appreciated.
You could just install the cert into the system keystore. (Location varies across platforms, and you will need admin rights).
Java webservice (soap) client - use certificates I am trying to connect to a webservice over ssl with a client certificate. Is there an elegant way of doing this apart from shoving things like "javax.net.ssl.keyStore" into System.properties. Any pointers to code examples would be appreciated.
TITLE: Java webservice (soap) client - use certificates QUESTION: I am trying to connect to a webservice over ssl with a client certificate. Is there an elegant way of doing this apart from shoving things like "javax.net.ssl.keyStore" into System.properties. Any pointers to code examples would be appreciated. ANSWER:...
[ "java", "web-services", "soap", "certificate" ]
2
0
11,790
4
0
2008-10-13T02:34:33.863000
2008-10-14T10:30:32.250000
196,567
196,579
How do I make <li> with block elements sit beside each other?
I have a mockup layout for something here. Essentially there are sections, columns and fields, which are all written as a combination of and elements. This is done specifically for later parsing. A snippet of the HTML: [Column] [Text] A field [Text] Another field [Text] Yet another field [Column] [Text] More fields [Te...
I just added this to your css: ul.section-children li.layout { display: inline-block; } Unfortunately, I don't know how well supported inline-block is nowadays.
How do I make <li> with block elements sit beside each other? I have a mockup layout for something here. Essentially there are sections, columns and fields, which are all written as a combination of and elements. This is done specifically for later parsing. A snippet of the HTML: [Column] [Text] A field [Text] Another ...
TITLE: How do I make <li> with block elements sit beside each other? QUESTION: I have a mockup layout for something here. Essentially there are sections, columns and fields, which are all written as a combination of and elements. This is done specifically for later parsing. A snippet of the HTML: [Column] [Text] A fie...
[ "html", "css" ]
11
8
29,659
8
0
2008-10-13T02:35:00.540000
2008-10-13T02:43:58.493000
196,585
196,607
How can you see the sql that is causing an error on SubmitChanges in LINQ to SQL?
I've got some LINQ to SQL that sometimes throws a "Cannot insert duplicate key row in object 'dbo.Table' with unique index 'IX_Indexname'.The statement has been terminated." Is there some way I can turn on logging or at least debug into the datacontext to see what sql is being executed at the time that error is raised?...
A simple way to do this is to use the DataContext.Log property: using (MyDataContext ctx = new MyDataContext()) { StringWriter sw = new StringWriter(); ctx.Log = sw; // execute some LINQ to SQL operations... string sql = sw.ToString(); // put a breakpoint here, log it to a file, etc... }
How can you see the sql that is causing an error on SubmitChanges in LINQ to SQL? I've got some LINQ to SQL that sometimes throws a "Cannot insert duplicate key row in object 'dbo.Table' with unique index 'IX_Indexname'.The statement has been terminated." Is there some way I can turn on logging or at least debug into t...
TITLE: How can you see the sql that is causing an error on SubmitChanges in LINQ to SQL? QUESTION: I've got some LINQ to SQL that sometimes throws a "Cannot insert duplicate key row in object 'dbo.Table' with unique index 'IX_Indexname'.The statement has been terminated." Is there some way I can turn on logging or at ...
[ "c#", ".net", "sql", "linq", "linq-to-sql" ]
6
11
2,196
6
0
2008-10-13T02:48:59.623000
2008-10-13T03:02:24.107000
196,591
196,599
Integer formatting, padding to a given length
I need to pad the output of an integer to a given length. For example, with a length of 4 digits, the output of the integer 4 is "0004" instead of "4". How can I do this in C# 2.0?
Use the string.Format command. output = String.Format("{0:0000}", intVariable); More details: http://msdn.microsoft.com/en-us/library/fht0f5be.aspx
Integer formatting, padding to a given length I need to pad the output of an integer to a given length. For example, with a length of 4 digits, the output of the integer 4 is "0004" instead of "4". How can I do this in C# 2.0?
TITLE: Integer formatting, padding to a given length QUESTION: I need to pad the output of an integer to a given length. For example, with a length of 4 digits, the output of the integer 4 is "0004" instead of "4". How can I do this in C# 2.0? ANSWER: Use the string.Format command. output = String.Format("{0:0000}", ...
[ "c#", "string", "integer", "format" ]
14
23
6,850
3
0
2008-10-13T02:54:23.280000
2008-10-13T02:57:27.437000
196,603
4,332,114
How to navigate between fields with Enter Key
My company has a large application written in VB6, and for historical reasons, the application is navigated with the Enter key instead of with the Tab key. I don't know VB6, but I know that they currently set the focus for each control in a big select statement in the Form's KeyUp event if it's an EnterKey. Now we are ...
A better implementation is to use the Form's AcceptButton property, set it to a hidden button somewhere on the form. Then when the user presses enter the button is clicked, then in the button on-click event you do the code to move to the next control. To select the next control you could just select through the list of...
How to navigate between fields with Enter Key My company has a large application written in VB6, and for historical reasons, the application is navigated with the Enter key instead of with the Tab key. I don't know VB6, but I know that they currently set the focus for each control in a big select statement in the Form'...
TITLE: How to navigate between fields with Enter Key QUESTION: My company has a large application written in VB6, and for historical reasons, the application is navigated with the Enter key instead of with the Tab key. I don't know VB6, but I know that they currently set the focus for each control in a big select stat...
[ ".net", "vb.net", "winforms" ]
2
2
1,655
2
0
2008-10-13T03:00:00.523000
2010-12-02T05:53:20.247000
196,608
215,595
Harder, Better, Faster, Stronger... Techniques for an image-based CAPTCHA?
There are lots of non-image-based CAPTCHA ideas floating around. But what about the old-fashioned way? What are the elements of a good image CAPTCHA? What visual elements are hard for computers, but easier for humans? What about mistakes, elements that are easier for computers than they are for humans? What are good te...
Make letters difficult to separate. Use handwriting-like font or add lines that join letters. Decrease and randomize spacing between letters. Add wave distortion in other axis too. Distortion in one axis only can be relatively easily analyzed and reversed. Don't bother with color background at all. It's super-easy to a...
Harder, Better, Faster, Stronger... Techniques for an image-based CAPTCHA? There are lots of non-image-based CAPTCHA ideas floating around. But what about the old-fashioned way? What are the elements of a good image CAPTCHA? What visual elements are hard for computers, but easier for humans? What about mistakes, elemen...
TITLE: Harder, Better, Faster, Stronger... Techniques for an image-based CAPTCHA? QUESTION: There are lots of non-image-based CAPTCHA ideas floating around. But what about the old-fashioned way? What are the elements of a good image CAPTCHA? What visual elements are hard for computers, but easier for humans? What abou...
[ "captcha", "spam-prevention" ]
7
4
1,124
10
0
2008-10-13T03:05:32.820000
2008-10-18T21:25:44.620000
196,610
196,620
Java: Triple Curly Bracing
I've been given some code with commenting unlike anything I've come across before: //{{{ Imports import imports; //}}} It is the same for each method block, //{{{ above the code block //}}} below the code block Also see: http://en.wikipedia.org/wiki/Folding_editor
A quick search for "triple curly" comment suggests it's " Emacs folding mode ". Or some other code folding marker in any case.
Java: Triple Curly Bracing I've been given some code with commenting unlike anything I've come across before: //{{{ Imports import imports; //}}} It is the same for each method block, //{{{ above the code block //}}} below the code block Also see: http://en.wikipedia.org/wiki/Folding_editor
TITLE: Java: Triple Curly Bracing QUESTION: I've been given some code with commenting unlike anything I've come across before: //{{{ Imports import imports; //}}} It is the same for each method block, //{{{ above the code block //}}} below the code block Also see: http://en.wikipedia.org/wiki/Folding_editor ANSWER: A...
[ "java", "coding-style", "folding" ]
3
8
1,098
5
0
2008-10-13T03:06:15.750000
2008-10-13T03:12:09.187000
196,626
196,648
Escaping in a ILIKE query
I need to do a query that search for a text with 'Nome % teste \ / ' as prefix. I'm doing the query using: where "name" ILIKE 'Nome a% teste \ /%' ESCAPE 'a' (using a as escape character). There is a row that match this, but this query returns nothing. Removing the slash ( 'Nome % teste \' ), it works. But I don't see ...
Use the "ESCAPE" specifier WHERE "name" ILIKE 'Nome ~% teste \\/' ESCAPE '~' http://www.postgresql.org/docs/8.2/static/functions-matching.html Note: you still need to have the \ twice for the string parser. Without the ESCAPE you would need to do WHERE "name" ILIKE 'Nome \% test \\\\/' ( 4 \ 's to represent one literal...
Escaping in a ILIKE query I need to do a query that search for a text with 'Nome % teste \ / ' as prefix. I'm doing the query using: where "name" ILIKE 'Nome a% teste \ /%' ESCAPE 'a' (using a as escape character). There is a row that match this, but this query returns nothing. Removing the slash ( 'Nome % teste \' ), ...
TITLE: Escaping in a ILIKE query QUESTION: I need to do a query that search for a text with 'Nome % teste \ / ' as prefix. I'm doing the query using: where "name" ILIKE 'Nome a% teste \ /%' ESCAPE 'a' (using a as escape character). There is a row that match this, but this query returns nothing. Removing the slash ( 'N...
[ "database", "postgresql", "escaping" ]
1
2
5,261
2
0
2008-10-13T03:17:14.777000
2008-10-13T03:38:07.887000
196,628
196,642
Printing out items in any Collection in reverse order?
I have the following problem in my Data Structures and Problem Solving using Java book: Write a routine that uses the Collections API to print out the items in any Collection in reverse order. Do not use a ListIterator. I'm not putting it up here because I want somebody to do my homework, I just can't seem to understan...
Regardless from the question not making much sense as half of the collections have no gstable ordering of have fixed-ordering (i.e. TreeSet or PriorityQueue), you can use the following statement for printing the contents of a collection in reverse-natural order: List temp = new ArrayList(src); Collections.reverse(temp)...
Printing out items in any Collection in reverse order? I have the following problem in my Data Structures and Problem Solving using Java book: Write a routine that uses the Collections API to print out the items in any Collection in reverse order. Do not use a ListIterator. I'm not putting it up here because I want som...
TITLE: Printing out items in any Collection in reverse order? QUESTION: I have the following problem in my Data Structures and Problem Solving using Java book: Write a routine that uses the Collections API to print out the items in any Collection in reverse order. Do not use a ListIterator. I'm not putting it up here ...
[ "java", "collections" ]
7
17
15,669
5
0
2008-10-13T03:20:08.767000
2008-10-13T03:32:06.540000
196,636
1,850,676
How do read/interact with an old ActiveX SSUltraGrid using UIAutomation
I am investigating automated testing of an old Win32 application that used ActiveX controls. I am spiking use White (from Thougthworks) that uses Microsoft UIAutomation. I can find the AutomationElement related to the control, but how do I interact with it? Spy++ sees the grid control as a single window, so I can't tal...
The basic problem with some ActiveX and other custom controls like SSUltraGrid is what you mentioned, they're presented as just one window. So unless they've provided an API that makes them "friendly" to your GUI automation tool, you'll always face this challenge. Of course many companies offer newer versions of their ...
How do read/interact with an old ActiveX SSUltraGrid using UIAutomation I am investigating automated testing of an old Win32 application that used ActiveX controls. I am spiking use White (from Thougthworks) that uses Microsoft UIAutomation. I can find the AutomationElement related to the control, but how do I interact...
TITLE: How do read/interact with an old ActiveX SSUltraGrid using UIAutomation QUESTION: I am investigating automated testing of an old Win32 application that used ActiveX controls. I am spiking use White (from Thougthworks) that uses Microsoft UIAutomation. I can find the AutomationElement related to the control, but...
[ "c#", "com", "activex", "ui-automation" ]
1
1
529
1
0
2008-10-13T03:27:42.103000
2009-12-05T01:02:33.893000
196,652
196,678
Prepared Statement vs. Stored Procedure
If you are using php5 and mysql5, is there a substantial advantage to using stored procs over prepared statements? ( i read somewhere you may not get substantial performance gains from mysql5 stored proc)
They are not really the same thing - with stored procedures, your database logic resides inside the database. Prepared statements basically avoid re-parsing queries if they are called multiple times - the performance benefit can vary greatly. The choice to use one or the other is really dependent on your specific situa...
Prepared Statement vs. Stored Procedure If you are using php5 and mysql5, is there a substantial advantage to using stored procs over prepared statements? ( i read somewhere you may not get substantial performance gains from mysql5 stored proc)
TITLE: Prepared Statement vs. Stored Procedure QUESTION: If you are using php5 and mysql5, is there a substantial advantage to using stored procs over prepared statements? ( i read somewhere you may not get substantial performance gains from mysql5 stored proc) ANSWER: They are not really the same thing - with stored...
[ "php", "mysql", "stored-procedures", "prepared-statement" ]
20
29
22,350
7
0
2008-10-13T03:41:50.343000
2008-10-13T04:02:02.300000
196,656
196,663
Anyone know of a good algorithm for rendering an HTML table to an image?
There is a standard two-pass algorithm mentioned in RFC 1942: http://www.ietf.org/rfc/rfc1942.txt however I haven't seen any good real-world implementations. Anyone know of any? I haven't been able to find anything useful in the Mozilla or WebKit code bases, but I am not entirely sure where to look. I guess this might ...
html table rendering is non-trivial due to the various ways that the sizes of the cells may be specified, tables nested within tables, etc. if all you want is the image, a simple solution would be the.NET browser control (which is basically the COM component for IE) and a screen-capture function if you want to get some...
Anyone know of a good algorithm for rendering an HTML table to an image? There is a standard two-pass algorithm mentioned in RFC 1942: http://www.ietf.org/rfc/rfc1942.txt however I haven't seen any good real-world implementations. Anyone know of any? I haven't been able to find anything useful in the Mozilla or WebKit ...
TITLE: Anyone know of a good algorithm for rendering an HTML table to an image? QUESTION: There is a standard two-pass algorithm mentioned in RFC 1942: http://www.ietf.org/rfc/rfc1942.txt however I haven't seen any good real-world implementations. Anyone know of any? I haven't been able to find anything useful in the ...
[ "html", "algorithm", "image-processing" ]
1
0
2,500
6
0
2008-10-13T03:45:58.790000
2008-10-13T03:51:05.613000
196,661
196,977
Calling a static method on a generic type parameter
I was hoping to do something like this, but it appears to be illegal in C#: public Collection MethodThatFetchesSomething () where T: SomeBaseClass { return T.StaticMethodOnSomeBaseClassThatReturnsCollection(); } I get a compile-time error: 'T' is a 'type parameter', which is not valid in the given context. Given a gene...
In this case you should just call the static method on the constrainted type directly. C# (and the CLR) do not support virtual static methods. So: T.StaticMethodOnSomeBaseClassThatReturnsCollection...can be no different than: SomeBaseClass.StaticMethodOnSomeBaseClassThatReturnsCollection Going through the generic type ...
Calling a static method on a generic type parameter I was hoping to do something like this, but it appears to be illegal in C#: public Collection MethodThatFetchesSomething () where T: SomeBaseClass { return T.StaticMethodOnSomeBaseClassThatReturnsCollection(); } I get a compile-time error: 'T' is a 'type parameter', w...
TITLE: Calling a static method on a generic type parameter QUESTION: I was hoping to do something like this, but it appears to be illegal in C#: public Collection MethodThatFetchesSomething () where T: SomeBaseClass { return T.StaticMethodOnSomeBaseClassThatReturnsCollection(); } I get a compile-time error: 'T' is a '...
[ "c#", "generics" ]
128
69
99,301
10
0
2008-10-13T03:49:43.293000
2008-10-13T08:08:15.877000
196,664
196,672
Print out post values
I have a form that has multiple fields, and for testing purposes is there a way I could print out the values entered in all the fields, without having to individually print each value.
You should be able to do a var_dump($_REQUEST); https://www.php.net/manual/en/reserved.variables.request.php https://www.php.net/manual/en/function.var-dump.php
Print out post values I have a form that has multiple fields, and for testing purposes is there a way I could print out the values entered in all the fields, without having to individually print each value.
TITLE: Print out post values QUESTION: I have a form that has multiple fields, and for testing purposes is there a way I could print out the values entered in all the fields, without having to individually print each value. ANSWER: You should be able to do a var_dump($_REQUEST); https://www.php.net/manual/en/reserved...
[ "php" ]
20
26
80,557
11
0
2008-10-13T03:51:13.663000
2008-10-13T03:55:38.333000
196,668
206,403
External Styles in JasperReports
I'm working on a system that includes a large number of reports, generated using JasperReports. One of the newer features is that you can define styles for reports. From the available docs I believe there is some way to have an external file defining styles to use, and you can reference that in your jasper reports. Thi...
Use JasperReport templates. A JasperReports template is one that ends in.jrtx, and may look similar to this ( styles.jrtx ): and then in your.jrxml file, include it as a template:... "styles.jrtx"... iReport also understands this, so your styles are imported and shown in iReport correctly (though I did notice sometimes...
External Styles in JasperReports I'm working on a system that includes a large number of reports, generated using JasperReports. One of the newer features is that you can define styles for reports. From the available docs I believe there is some way to have an external file defining styles to use, and you can reference...
TITLE: External Styles in JasperReports QUESTION: I'm working on a system that includes a large number of reports, generated using JasperReports. One of the newer features is that you can define styles for reports. From the available docs I believe there is some way to have an external file defining styles to use, and...
[ "jasper-reports", "styles" ]
24
30
29,103
3
0
2008-10-13T03:53:45.703000
2008-10-15T20:47:52.410000
196,669
200,716
Archiving Files
I really like the way gmail has the archive system implemented. I can archive any file after adding a tag to it (if needed) and I can search for it whenever I want to. Is there any program in Windows/Linux which behaves in a similar fashion?
When you "Archive" in gmail you are just removing a hidden tag ("INBOX"). It does not seem a useful thing to do in your own file system, since you are not actually "archiving" anything. Good luck!
Archiving Files I really like the way gmail has the archive system implemented. I can archive any file after adding a tag to it (if needed) and I can search for it whenever I want to. Is there any program in Windows/Linux which behaves in a similar fashion?
TITLE: Archiving Files QUESTION: I really like the way gmail has the archive system implemented. I can archive any file after adding a tag to it (if needed) and I can search for it whenever I want to. Is there any program in Windows/Linux which behaves in a similar fashion? ANSWER: When you "Archive" in gmail you are...
[ "file-management" ]
1
2
292
3
0
2008-10-13T03:53:48.977000
2008-10-14T10:54:21.983000
196,677
196,697
Can you mix .net languages within a single project?
Can you mix.net languages within a single project? So pre-compiled, I would like to call classes and methods of other source files. For both web and apps? In particular I'd be interested in F# and C#.
You can mix languages in a single assembly with ILMerge and MSBuild. Here is a very good example about it.
Can you mix .net languages within a single project? Can you mix.net languages within a single project? So pre-compiled, I would like to call classes and methods of other source files. For both web and apps? In particular I'd be interested in F# and C#.
TITLE: Can you mix .net languages within a single project? QUESTION: Can you mix.net languages within a single project? So pre-compiled, I would like to call classes and methods of other source files. For both web and apps? In particular I'd be interested in F# and C#. ANSWER: You can mix languages in a single assemb...
[ "c#", ".net", "f#" ]
18
16
8,827
5
0
2008-10-13T04:01:23.097000
2008-10-13T04:12:39.813000
196,684
196,687
jQuery get specific option tag text
Suppose I have a drop-down list like: Option A Option B Option C Given the value '2' (i.e., using a specific value, not necessarily the selected one ), what selector can I use to get "Option B"? I tried $("#list[value='2']").text();, but it is not working.
It's looking for an element with id list which has a property value equal to 2. What you want is the option child of the list: $("#list option[value='2']").text()
jQuery get specific option tag text Suppose I have a drop-down list like: Option A Option B Option C Given the value '2' (i.e., using a specific value, not necessarily the selected one ), what selector can I use to get "Option B"? I tried $("#list[value='2']").text();, but it is not working.
TITLE: jQuery get specific option tag text QUESTION: Suppose I have a drop-down list like: Option A Option B Option C Given the value '2' (i.e., using a specific value, not necessarily the selected one ), what selector can I use to get "Option B"? I tried $("#list[value='2']").text();, but it is not working. ANSWER: ...
[ "javascript", "jquery", "jquery-selectors", "html-select" ]
1,285
1,147
1,097,803
23
0
2008-10-13T04:06:34.693000
2008-10-13T04:08:03.723000
196,695
196,868
Is there a pattern for dealing with non-memory resources on cleaning up an ObjC object?
It's usual for objects which have some state related to a non-memory resource to provide a method for explicitly 'finishing' with that resource. Is there a preferred common practice for dealing with the case where an object deallocation is attempted while still in the "using my resource" state? I have seen a couple of ...
Since most of the Cocoa framework objects predate garbage collection, you can't make the assumption that NSFileHandle, for example, is doing it the best way. I think this problem is one of many where we'd like to have one pattern to follow for every scenario and save us the trouble of making a choice. Unfortunately, I ...
Is there a pattern for dealing with non-memory resources on cleaning up an ObjC object? It's usual for objects which have some state related to a non-memory resource to provide a method for explicitly 'finishing' with that resource. Is there a preferred common practice for dealing with the case where an object dealloca...
TITLE: Is there a pattern for dealing with non-memory resources on cleaning up an ObjC object? QUESTION: It's usual for objects which have some state related to a non-memory resource to provide a method for explicitly 'finishing' with that resource. Is there a preferred common practice for dealing with the case where ...
[ "objective-c", "cocoa" ]
4
1
213
1
0
2008-10-13T04:11:39.503000
2008-10-13T06:38:40.097000
196,702
196,718
Where to place JavaScript in an HTML file?
Say I have a fairly hefty JavaScript file, packed down to roughly 100kb or so. By file I mean it’s an external file that would be linked in via
The Yahoo! Exceptional Performance team recommend placing scripts at the bottom of your page because of the way browsers download components. Of course Levi's comment "just before you need it and no sooner" is really the correct answer, i.e. "it depends".
Where to place JavaScript in an HTML file? Say I have a fairly hefty JavaScript file, packed down to roughly 100kb or so. By file I mean it’s an external file that would be linked in via
TITLE: Where to place JavaScript in an HTML file? QUESTION: Say I have a fairly hefty JavaScript file, packed down to roughly 100kb or so. By file I mean it’s an external file that would be linked in via ANSWER: The Yahoo! Exceptional Performance team recommend placing scripts at the bottom of your page because of th...
[ "javascript", "html", "optimization" ]
232
183
146,433
12
0
2008-10-13T04:19:52.390000
2008-10-13T04:34:18.257000
196,713
196,743
Match Regex with JavaScript
I need to match something in the form to find the number, in this case 5, using JavaScript. I have no idea how to use regexes, so I was wondering if anyone here could help out.
Just to make sure you know what's going on, the pattern you posted in your own answer will match exactly one digit between 0 and 9. If you want to match integers with one or more digits, you might try the pattern /[0-9]+/ Check out Wikipedia's article on Regular Expressions for a great overview. Regular Expressions can...
Match Regex with JavaScript I need to match something in the form to find the number, in this case 5, using JavaScript. I have no idea how to use regexes, so I was wondering if anyone here could help out.
TITLE: Match Regex with JavaScript QUESTION: I need to match something in the form to find the number, in this case 5, using JavaScript. I have no idea how to use regexes, so I was wondering if anyone here could help out. ANSWER: Just to make sure you know what's going on, the pattern you posted in your own answer wi...
[ "javascript", "regex" ]
1
2
2,501
3
0
2008-10-13T04:26:53.887000
2008-10-13T04:48:43.953000
196,721
1,618,213
How to get Cobertura to fail M2 build for low code coverage
I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book Java Power Tools, but with no success. Here's the relevant snippet of my project's Maven 2 POM:... org.codehaus.mojo cobertura-maven...
To my knowledge, if the element is set to true and any of the specified checks fails, then Cobertura will cause the build to fail which is what you're asking for. But actually, this element defaults to true if you do not specify it so you don't have to add it to your configuration checks. Failing the build below any co...
How to get Cobertura to fail M2 build for low code coverage I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book Java Power Tools, but with no success. Here's the relevant snippet of my...
TITLE: How to get Cobertura to fail M2 build for low code coverage QUESTION: I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book Java Power Tools, but with no success. Here's the rele...
[ "java", "maven-2", "build-automation", "code-coverage", "cobertura" ]
9
17
10,203
3
0
2008-10-13T04:35:31.327000
2009-10-24T15:06:37.870000
196,726
3,029,802
Hashes vs Numeric id's
When creating a web application that some how displays the display of a unique identifier for a recurring entity (videos on YouTube, or book section on a site like mine), would it be better to use a uniform length identifier like a hash or the unique key of the item in the database (1, 2, 3, etc). Besides revealing a l...
Unless you're trying to hide the state of your internal object ID counter, hashes are needlessly slow (to generate and to compare), needlessly long, needlessly ugly, and needlessly capable of colliding. GUIDs are also long and ugly, making them just as unsuitable for human consumption as hashes are. For inventory-like ...
Hashes vs Numeric id's When creating a web application that some how displays the display of a unique identifier for a recurring entity (videos on YouTube, or book section on a site like mine), would it be better to use a uniform length identifier like a hash or the unique key of the item in the database (1, 2, 3, etc)...
TITLE: Hashes vs Numeric id's QUESTION: When creating a web application that some how displays the display of a unique identifier for a recurring entity (videos on YouTube, or book section on a site like mine), would it be better to use a uniform length identifier like a hash or the unique key of the item in the datab...
[ "hash", "web-applications" ]
10
6
6,550
8
0
2008-10-13T04:38:47.030000
2010-06-12T19:11:55.673000
196,729
196,761
The stack size used in kernel development
I'm developing an operating system and rather than programming the kernel, I'm designing the kernel. This operating system is targeted at the x86 architecture and my target is for modern computers. The estimated number of required RAM is 256Mb or more. What is a good size to make the stack for each thread run on the sy...
Stack size depends on what your threads are doing. My advice: make the stack size a parameter at thread creation time (different threads will do different things, and hence will need different stack sizes) provide a reasonable default for those who don't want to be bothered with specifying a stack size (4K appeals to t...
The stack size used in kernel development I'm developing an operating system and rather than programming the kernel, I'm designing the kernel. This operating system is targeted at the x86 architecture and my target is for modern computers. The estimated number of required RAM is 256Mb or more. What is a good size to ma...
TITLE: The stack size used in kernel development QUESTION: I'm developing an operating system and rather than programming the kernel, I'm designing the kernel. This operating system is targeted at the x86 architecture and my target is for modern computers. The estimated number of required RAM is 256Mb or more. What is...
[ "operating-system", "stack", "size", "kernel", "osdev" ]
9
11
8,485
5
0
2008-10-13T04:41:28.010000
2008-10-13T05:10:57.840000
196,730
196,907
Best way to extract the second level domain from the HTTP_Host Variable in VBScript
I need to extract only the 2nd level part of the domain from request.servervariables("HTTP_HOST") what is the best way to do this?
This can be solved through a regular expression. Since the HTTP_HOST server variable can contain only valid host names, we don't need to care about validating the string, only about finding out its structure. Therefore the regex is kept fairly simple, but would not work reliably in broader contexts. And the structure i...
Best way to extract the second level domain from the HTTP_Host Variable in VBScript I need to extract only the 2nd level part of the domain from request.servervariables("HTTP_HOST") what is the best way to do this?
TITLE: Best way to extract the second level domain from the HTTP_Host Variable in VBScript QUESTION: I need to extract only the 2nd level part of the domain from request.servervariables("HTTP_HOST") what is the best way to do this? ANSWER: This can be solved through a regular expression. Since the HTTP_HOST server va...
[ "asp-classic", "vbscript" ]
2
1
2,553
4
0
2008-10-13T04:42:11.253000
2008-10-13T07:17:33.263000
196,732
197,696
How do I efficiently empty a Perl DBM file?
I've inherited a piece of code with a snippet which empties the database as follows: dbmopen (%db,"file.db",0666); foreach $key (keys %db) { delete $db{$key}; } dbmclose (%db); This is usually okay but sometimes the database grows very large before this cleanup code is called and it's usually when a user wants to do so...
You can just delete the file: unlink $file; Since your third argument to dbmopen is a file mode and not undef, dbmopen will recreate the file the next time it's called: dbmopen my %db, $file, 0666;
How do I efficiently empty a Perl DBM file? I've inherited a piece of code with a snippet which empties the database as follows: dbmopen (%db,"file.db",0666); foreach $key (keys %db) { delete $db{$key}; } dbmclose (%db); This is usually okay but sometimes the database grows very large before this cleanup code is called...
TITLE: How do I efficiently empty a Perl DBM file? QUESTION: I've inherited a piece of code with a snippet which empties the database as follows: dbmopen (%db,"file.db",0666); foreach $key (keys %db) { delete $db{$key}; } dbmclose (%db); This is usually okay but sometimes the database grows very large before this clea...
[ "perl", "dbm" ]
7
10
1,065
3
0
2008-10-13T04:42:33.967000
2008-10-13T14:10:33.680000
196,733
197,157
How can I use covariant return types with smart pointers?
I have code like this: class RetInterface {...} class Ret1: public RetInterface {...} class AInterface { public: virtual boost::shared_ptr get_r() const = 0;... }; class A1: public AInterface { public: boost::shared_ptr get_r() const {...}... }; This code does not compile. In visual studio it raises C2555: overridin...
Firstly, this is indeed how it works in C++: the return type of a virtual function in a derived class must be the same as in the base class. There is the special exception that a function that returns a reference/pointer to some class X can be overridden by a function that returns a reference/pointer to a class that de...
How can I use covariant return types with smart pointers? I have code like this: class RetInterface {...} class Ret1: public RetInterface {...} class AInterface { public: virtual boost::shared_ptr get_r() const = 0;... }; class A1: public AInterface { public: boost::shared_ptr get_r() const {...}... }; This code doe...
TITLE: How can I use covariant return types with smart pointers? QUESTION: I have code like this: class RetInterface {...} class Ret1: public RetInterface {...} class AInterface { public: virtual boost::shared_ptr get_r() const = 0;... }; class A1: public AInterface { public: boost::shared_ptr get_r() const {...}.....
[ "c++", "covariance", "smart-pointers" ]
82
33
21,017
6
0
2008-10-13T04:42:58.380000
2008-10-13T09:58:40.397000
196,737
196,739
Why not use 'protected' or 'private' in PHP?
I've been working with the Joomla framework and I have noticed that they use a convention to designate private or protected methods (they put an underscore " _ " in front of the method name), but they do not explicitly declare any methods public, private, or protected. Why is this? Does it have to do with portability? ...
public, private and protected are PHP5 keywords. unfortunately, PHP4 still has a very high install base (especially amongst shared hosting services). here's a pretty pic showing july usage rates (text in french). spoiler: php4 still has over a 35% usage rate sadly.
Why not use 'protected' or 'private' in PHP? I've been working with the Joomla framework and I have noticed that they use a convention to designate private or protected methods (they put an underscore " _ " in front of the method name), but they do not explicitly declare any methods public, private, or protected. Why i...
TITLE: Why not use 'protected' or 'private' in PHP? QUESTION: I've been working with the Joomla framework and I have noticed that they use a convention to designate private or protected methods (they put an underscore " _ " in front of the method name), but they do not explicitly declare any methods public, private, o...
[ "php", "encapsulation" ]
7
17
3,302
3
0
2008-10-13T04:44:51.310000
2008-10-13T04:46:06.360000
196,740
196,826
How to add NUnit in Visual Studio
I need to write test cases for my application. I've chosen NUnit. Please let me know how to add NUnit to my Visual Studio IDE. where can I download them?
Your question is a bit ambiguous.. Are you interested in learning nunit (In which case nunit.org would be the place to look along with some books on TDD/UnitTesting) If you're trying to integrate nunit with VisualStudio IDE, I'd go with the external executable approach listed as Option#1 here or TestDriven.net Option#2
How to add NUnit in Visual Studio I need to write test cases for my application. I've chosen NUnit. Please let me know how to add NUnit to my Visual Studio IDE. where can I download them?
TITLE: How to add NUnit in Visual Studio QUESTION: I need to write test cases for my application. I've chosen NUnit. Please let me know how to add NUnit to my Visual Studio IDE. where can I download them? ANSWER: Your question is a bit ambiguous.. Are you interested in learning nunit (In which case nunit.org would be...
[ "asp.net", "visual-studio", "nunit" ]
6
5
12,812
2
0
2008-10-13T04:46:06.643000
2008-10-13T06:08:06.257000
196,741
196,747
How do you slice arrays in D?
How are arrays manipulated in D?
Here you can find a complete reference of array manipulations in D.
How do you slice arrays in D? How are arrays manipulated in D?
TITLE: How do you slice arrays in D? QUESTION: How are arrays manipulated in D? ANSWER: Here you can find a complete reference of array manipulations in D.
[ "arrays", "d" ]
2
4
329
3
0
2008-10-13T04:46:41.447000
2008-10-13T04:54:31.117000
196,754
196,768
What does "select((select(s),$|=1)[0])" do in Perl?
I've seen some horrific code written in Perl, but I can't make head nor tail of this one: select((select(s),$|=1)[0]) It's in some networking code that we use to communicate with a server and I assume it's something to do with buffering (since it sets $| ). But I can't figure out why there's multiple select calls or th...
It's a nasty little idiom for setting autoflush on a filehandle other than STDOUT. select() takes the supplied filehandle and (basically) replaces STDOUT with it, and it returns the old filehandle when it's done. So (select($s),$|=1) redirects the filehandle (remember select returns the old one), and sets autoflush ( $...
What does "select((select(s),$|=1)[0])" do in Perl? I've seen some horrific code written in Perl, but I can't make head nor tail of this one: select((select(s),$|=1)[0]) It's in some networking code that we use to communicate with a server and I assume it's something to do with buffering (since it sets $| ). But I can'...
TITLE: What does "select((select(s),$|=1)[0])" do in Perl? QUESTION: I've seen some horrific code written in Perl, but I can't make head nor tail of this one: select((select(s),$|=1)[0]) It's in some networking code that we use to communicate with a server and I assume it's something to do with buffering (since it set...
[ "perl", "select", "buffering" ]
35
67
12,150
6
0
2008-10-13T05:00:53.507000
2008-10-13T05:14:43.260000
196,755
196,851
How can I search through Stack Overflow questions from a script?
Given a string of keywords, such as "Python best practices", I would like to obtain the first 10 Stack Overflow questions that contain that keywords, sorted by relevance (?), say from a Python script. My goal is to end up with a list of tuples (title, URL). How can I accomplish this? Would you consider querying Google ...
>>> from urllib import urlencode >>> params = urlencode({'q': 'python best practices', 'sort': 'relevance'}) >>> params 'q=python+best+practices&sort=relevance' >>> from urllib2 import urlopen >>> html = urlopen("http://stackoverflow.com/search?%s" % params).read() >>> import re >>> links = re.findall(r' ([^<]*) ', htm...
How can I search through Stack Overflow questions from a script? Given a string of keywords, such as "Python best practices", I would like to obtain the first 10 Stack Overflow questions that contain that keywords, sorted by relevance (?), say from a Python script. My goal is to end up with a list of tuples (title, URL...
TITLE: How can I search through Stack Overflow questions from a script? QUESTION: Given a string of keywords, such as "Python best practices", I would like to obtain the first 10 Stack Overflow questions that contain that keywords, sorted by relevance (?), say from a Python script. My goal is to end up with a list of ...
[ "python", "search", "scripting", "stackexchange-api" ]
5
6
1,819
5
0
2008-10-13T05:03:47.073000
2008-10-13T06:33:02.307000
196,771
200,315
What is the best way to escape Python strings in PHP?
I have a PHP application which needs to output a python script, more specifically a bunch of variable assignment statements, eg. subject_prefix = 'This String From User Input' msg_footer = """This one too.""" The contents of subject_prefix et al need to be written to take user input; as such, I need to escape the conte...
Do not try write this function in PHP. You will inevitably get it wrong and your application will inevitably have an arbitrary remote execution exploit. First, consider what problem you are actually solving. I presume you are just trying to get data from PHP to Python. You might try to write a.ini file rather than a.py...
What is the best way to escape Python strings in PHP? I have a PHP application which needs to output a python script, more specifically a bunch of variable assignment statements, eg. subject_prefix = 'This String From User Input' msg_footer = """This one too.""" The contents of subject_prefix et al need to be written t...
TITLE: What is the best way to escape Python strings in PHP? QUESTION: I have a PHP application which needs to output a python script, more specifically a bunch of variable assignment statements, eg. subject_prefix = 'This String From User Input' msg_footer = """This one too.""" The contents of subject_prefix et al ne...
[ "php", "python", "user-input" ]
2
2
1,881
5
0
2008-10-13T05:20:56.667000
2008-10-14T07:58:38
196,776
196,905
Which AES library to use in Ruby/Python?
I need to be able to send encrypted data between a Ruby client and a Python server (and vice versa) and have been having trouble with the ruby-aes gem/library. The library is very easy to use but we've been having trouble passing data between it and the pyCrypto AES library for Python. These libraries seem to be fine w...
Turns out what happened was that ruby-aes automatically pads data to fill up 16 chars and sticks a null character on the end of the final string as a delimiter. PyCrypto requires you to do multiples of 16 chars so that was how we figured out what ruby-aes was doing.
Which AES library to use in Ruby/Python? I need to be able to send encrypted data between a Ruby client and a Python server (and vice versa) and have been having trouble with the ruby-aes gem/library. The library is very easy to use but we've been having trouble passing data between it and the pyCrypto AES library for ...
TITLE: Which AES library to use in Ruby/Python? QUESTION: I need to be able to send encrypted data between a Ruby client and a Python server (and vice versa) and have been having trouble with the ruby-aes gem/library. The library is very easy to use but we've been having trouble passing data between it and the pyCrypt...
[ "python", "ruby", "encryption", "aes" ]
2
3
5,136
5
0
2008-10-13T05:25:29.963000
2008-10-13T07:17:02.110000
196,788
204,277
How do I get character offset information from a pdf document?
I'm trying to implement search result highlighting for pdfs in a web app. I have the original pdfs, and small png versions that are used in search results. Essentially I'm looking for an api like: pdf_document.find_offsets('somestring') # => { top: 501, left: 100, bottom: 520, right: 150 }, {... another box... },... I ...
Try to look at PdfLib TET http://www.pdflib.com/products/tet/ (it's not free) Fabrizio
How do I get character offset information from a pdf document? I'm trying to implement search result highlighting for pdfs in a web app. I have the original pdfs, and small png versions that are used in search results. Essentially I'm looking for an api like: pdf_document.find_offsets('somestring') # => { top: 501, lef...
TITLE: How do I get character offset information from a pdf document? QUESTION: I'm trying to implement search result highlighting for pdfs in a web app. I have the original pdfs, and small png versions that are used in search results. Essentially I'm looking for an api like: pdf_document.find_offsets('somestring') # ...
[ "search", "pdf" ]
2
1
6,203
3
0
2008-10-13T05:32:11.230000
2008-10-15T10:39:46.537000
196,791
196,957
How do I set up my Ubuntu VPS to send outgoing mail?
My VPS provider (Slicehost) doesn't provide an SMTP server. I use Google Apps to send and receive mail for my domains, but I want to be able to programmatically send e-mail. I've been Googling this issue on and off for many months, and I just can't seem to get a clear picture of what I need to do. Do I just need an MTA...
Have you looked here, seems to me that there is plenty of information to get started. I found mail-server-slice-setup to be quite informative.
How do I set up my Ubuntu VPS to send outgoing mail? My VPS provider (Slicehost) doesn't provide an SMTP server. I use Google Apps to send and receive mail for my domains, but I want to be able to programmatically send e-mail. I've been Googling this issue on and off for many months, and I just can't seem to get a clea...
TITLE: How do I set up my Ubuntu VPS to send outgoing mail? QUESTION: My VPS provider (Slicehost) doesn't provide an SMTP server. I use Google Apps to send and receive mail for my domains, but I want to be able to programmatically send e-mail. I've been Googling this issue on and off for many months, and I just can't ...
[ "email", "ubuntu", "smtp", "postfix-mta", "mta" ]
12
3
15,355
4
0
2008-10-13T05:37:11.797000
2008-10-13T07:53:42.083000
196,795
197,861
Is there a way to control the animation on a UITableView scrollToRowAtIndexPath?
I would like to modify the animation duration and attach a callback to be called when the animation finishes when calling scrollToRowAtIndexPath with animated:YES but I can't find a handle to its animation proxy or any other way to do it. Anyone know if this is possible?
In your TableView delegate, implement -scrollViewDidEndScrollingAnimation: This will get called once the scroll animation has completed.
Is there a way to control the animation on a UITableView scrollToRowAtIndexPath? I would like to modify the animation duration and attach a callback to be called when the animation finishes when calling scrollToRowAtIndexPath with animated:YES but I can't find a handle to its animation proxy or any other way to do it. ...
TITLE: Is there a way to control the animation on a UITableView scrollToRowAtIndexPath? QUESTION: I would like to modify the animation duration and attach a callback to be called when the animation finishes when calling scrollToRowAtIndexPath with animated:YES but I can't find a handle to its animation proxy or any ot...
[ "iphone", "objective-c", "cocoa-touch", "uitableview" ]
7
6
2,745
1
0
2008-10-13T05:42:57.917000
2008-10-13T14:56:32.510000
196,820
196,856
Cross-platform editor control
I need a cross-platform editor control to use as GUI-part in an in-house tool. The control may be commercial, but with reasonable price. Required features: Platforms: Win32, OS X, Linux UTF-8 support Fine-grained run-time control to the text style (or at least color) Nice low-level plain C API without usual horrible bl...
Scintilla and descendants (no OS X) But, scintilla does work on OS X. You could try GTK+ with GtkTextView, or Qt's QTextEdit.
Cross-platform editor control I need a cross-platform editor control to use as GUI-part in an in-house tool. The control may be commercial, but with reasonable price. Required features: Platforms: Win32, OS X, Linux UTF-8 support Fine-grained run-time control to the text style (or at least color) Nice low-level plain C...
TITLE: Cross-platform editor control QUESTION: I need a cross-platform editor control to use as GUI-part in an in-house tool. The control may be commercial, but with reasonable price. Required features: Platforms: Win32, OS X, Linux UTF-8 support Fine-grained run-time control to the text style (or at least color) Nice...
[ "c", "user-interface", "editor", "cross-platform" ]
5
2
1,850
4
0
2008-10-13T06:02:46.377000
2008-10-13T06:34:16.017000
196,828
196,889
ReSharper (or something like it) for Visual C++?
I've seen ReSharper recommended a lot Unfortunately, it doesn't support C++ in Visual Studio. Is there anything out there you can recommend? I already use Visual Assist, and it does its job very well, but it's quite limited in comparison with ReSharper. Any suggestions?
Refactor Pro is available for Visual C++, this will give you some functionality. Also check out CodeRush, I think it also supports C++.
ReSharper (or something like it) for Visual C++? I've seen ReSharper recommended a lot Unfortunately, it doesn't support C++ in Visual Studio. Is there anything out there you can recommend? I already use Visual Assist, and it does its job very well, but it's quite limited in comparison with ReSharper. Any suggestions?
TITLE: ReSharper (or something like it) for Visual C++? QUESTION: I've seen ReSharper recommended a lot Unfortunately, it doesn't support C++ in Visual Studio. Is there anything out there you can recommend? I already use Visual Assist, and it does its job very well, but it's quite limited in comparison with ReSharper....
[ "visual-studio", "visual-c++", "resharper" ]
17
8
14,024
4
0
2008-10-13T06:09:24.367000
2008-10-13T06:56:29.390000
196,830
196,834
What is the easiest/best/most correct way to iterate through the characters of a string in Java?
Some ways to iterate through the characters of a string in Java are: Using StringTokenizer? Converting the String to a char[] and iterating over that. What is the easiest/best/most correct way to iterate?
I use a for loop to iterate the string and use charAt() to get each character to examine it. Since the String is implemented with an array, the charAt() method is a constant time operation. String s = "...stuff..."; for (int i = 0; i < s.length(); i++){ char c = s.charAt(i); //Process char } That's what I would do. It...
What is the easiest/best/most correct way to iterate through the characters of a string in Java? Some ways to iterate through the characters of a string in Java are: Using StringTokenizer? Converting the String to a char[] and iterating over that. What is the easiest/best/most correct way to iterate?
TITLE: What is the easiest/best/most correct way to iterate through the characters of a string in Java? QUESTION: Some ways to iterate through the characters of a string in Java are: Using StringTokenizer? Converting the String to a char[] and iterating over that. What is the easiest/best/most correct way to iterate? ...
[ "java", "string", "iteration", "character", "tokenize" ]
484
480
696,882
17
0
2008-10-13T06:10:15.693000
2008-10-13T06:13:16.530000
196,840
196,873
Drop Down List with WPF Menu Controls
I am looking for a way to add a drop down list in WPF to a menu. This used to be really easy in winforms and so I am expecting you experts to know just now to do it in WPF. Thanks. Sorry if this is a bad question, it is late and I don't want to think.
It is very easy to add any UIElement to any control, You can just add Combobox to a Menu control and create menu as bellow.
Drop Down List with WPF Menu Controls I am looking for a way to add a drop down list in WPF to a menu. This used to be really easy in winforms and so I am expecting you experts to know just now to do it in WPF. Thanks. Sorry if this is a bad question, it is late and I don't want to think.
TITLE: Drop Down List with WPF Menu Controls QUESTION: I am looking for a way to add a drop down list in WPF to a menu. This used to be really easy in winforms and so I am expecting you experts to know just now to do it in WPF. Thanks. Sorry if this is a bad question, it is late and I don't want to think. ANSWER: It ...
[ "c#", ".net", "wpf" ]
12
25
34,853
2
0
2008-10-13T06:23:22.687000
2008-10-13T06:41:53.647000
196,857
197,446
Which Subversion web interfaces have a blame feature?
I'm looking for a subversion web client ala SVN::Web but with a very specific feature I've always thought would be quite useful. What I want is the ability to find which revision was responsible for a certain line (or lines) in a text file. A way to do this via the web would be fantastic. Anybody know of such a tool?
We use Warehouse, and are quite happy with it. It's written in Ruby on Rails, so if you're well versed in that, you're far ahead of the game. They also just went open source.
Which Subversion web interfaces have a blame feature? I'm looking for a subversion web client ala SVN::Web but with a very specific feature I've always thought would be quite useful. What I want is the ability to find which revision was responsible for a certain line (or lines) in a text file. A way to do this via the ...
TITLE: Which Subversion web interfaces have a blame feature? QUESTION: I'm looking for a subversion web client ala SVN::Web but with a very specific feature I've always thought would be quite useful. What I want is the ability to find which revision was responsible for a certain line (or lines) in a text file. A way t...
[ "svn", "version-control", "blame" ]
5
1
1,986
7
0
2008-10-13T06:34:57.670000
2008-10-13T12:39:44.423000
196,876
196,881
Is there a better way to get a named series of constants (enumeration) in Python?
Just looking at ways of getting named constants in python. class constant_list: (A_CONSTANT, B_CONSTANT, C_CONSTANT) = range(3) Then of course you can refer to it like so: constant_list.A_CONSTANT I suppose you could use a dictionary, using strings: constant_dic = { "A_CONSTANT": 1, "B_CONSTANT": 2, "C_CONSTANT": 3,} a...
For 2.3 or after: class Enumerate(object): def __init__(self, names): for number, name in enumerate(names.split()): setattr(self, name, number) To use: codes = Enumerate('FOO BAR BAZ') codes.BAZ will be 2 and so on. If you only have 2.2, precede this with: from __future__ import generators def enumerate(iterable): num...
Is there a better way to get a named series of constants (enumeration) in Python? Just looking at ways of getting named constants in python. class constant_list: (A_CONSTANT, B_CONSTANT, C_CONSTANT) = range(3) Then of course you can refer to it like so: constant_list.A_CONSTANT I suppose you could use a dictionary, usi...
TITLE: Is there a better way to get a named series of constants (enumeration) in Python? QUESTION: Just looking at ways of getting named constants in python. class constant_list: (A_CONSTANT, B_CONSTANT, C_CONSTANT) = range(3) Then of course you can refer to it like so: constant_list.A_CONSTANT I suppose you could use...
[ "python" ]
21
19
5,165
6
0
2008-10-13T06:43:47.230000
2008-10-13T06:48:48.423000
196,883
196,894
ASP.net page life cycle
I am having an ASP.net page in my page i am having this as my code behind files. on first access the page the page preinit, init, load methods are called. on postbacks the preinit, init, load methods are called. My question is LoadViewstate and control state events (Overridden methods) are not firing after postbacks al...
This method is used primarily by the.NET Framework infrastructure and is not intended to be used directly from your code. However, control developers can override this method to specify how a custom server control restores its view state. For more information, see ASP.NET State Management Overview. The LoadViewState me...
ASP.net page life cycle I am having an ASP.net page in my page i am having this as my code behind files. on first access the page the page preinit, init, load methods are called. on postbacks the preinit, init, load methods are called. My question is LoadViewstate and control state events (Overridden methods) are not f...
TITLE: ASP.net page life cycle QUESTION: I am having an ASP.net page in my page i am having this as my code behind files. on first access the page the page preinit, init, load methods are called. on postbacks the preinit, init, load methods are called. My question is LoadViewstate and control state events (Overridden ...
[ "asp.net" ]
1
3
1,654
2
0
2008-10-13T06:50:21.617000
2008-10-13T07:01:52.077000
196,885
377,623
Running on 32 or 64 bit matlab?
How can I determine if I'm running on a 32bit or a 64bit version of matlab? I have some pre-compiled mex-files which need different path's depending on 32/64bit matlab.
Taking up on ScottieT812 and dwj suggestions, I post my own solution to earn some points. The function computer returns the architecture I'm running on. so: switch computer case 'GLNX86' display('32-bit stuff') case 'GLNXA64' display('64-bit stuff') otherwise display('Not supported') end works for me
Running on 32 or 64 bit matlab? How can I determine if I'm running on a 32bit or a 64bit version of matlab? I have some pre-compiled mex-files which need different path's depending on 32/64bit matlab.
TITLE: Running on 32 or 64 bit matlab? QUESTION: How can I determine if I'm running on a 32bit or a 64bit version of matlab? I have some pre-compiled mex-files which need different path's depending on 32/64bit matlab. ANSWER: Taking up on ScottieT812 and dwj suggestions, I post my own solution to earn some points. Th...
[ "matlab", "64-bit", "32-bit" ]
7
5
13,537
3
0
2008-10-13T06:52:36.887000
2008-12-18T11:53:10.120000
196,890
197,060
Java2D Performance Issues
I'm having performance oddities with Java2D. I know of the sun.java2d.opengl VM parameter to enable 3D acceleration for 2D, but even using that has some weird issues. Here are results of tests I ran: Drawing a 25x18 map with 32x32 pixel tiles on a JComponent Image 1 =.bmp format, Image 2 = A.png format Without -Dsun.ja...
I think I found a solution by researching and putting bits and pieces together from too many Google searches. Here it is, comments and all: private BufferedImage toCompatibleImage(BufferedImage image) { // obtain the current system graphical settings GraphicsConfiguration gfxConfig = GraphicsEnvironment. getLocalGraphi...
Java2D Performance Issues I'm having performance oddities with Java2D. I know of the sun.java2d.opengl VM parameter to enable 3D acceleration for 2D, but even using that has some weird issues. Here are results of tests I ran: Drawing a 25x18 map with 32x32 pixel tiles on a JComponent Image 1 =.bmp format, Image 2 = A.p...
TITLE: Java2D Performance Issues QUESTION: I'm having performance oddities with Java2D. I know of the sun.java2d.opengl VM parameter to enable 3D acceleration for 2D, but even using that has some weird issues. Here are results of tests I ran: Drawing a 25x18 map with 32x32 pixel tiles on a JComponent Image 1 =.bmp for...
[ "java", "java-2d" ]
59
71
28,558
3
0
2008-10-13T06:57:08.030000
2008-10-13T09:04:29.147000
196,909
269,852
Editing SQL query with Visual Studio 2008
Would you recommend me the best approach to edit SQL query with Visual Studio 2008 Professional, please? I know I can open Query window from context menu in Server Explorer and edit text in SQL Pane. But unfortunately I am not allowed to save query to a file and Find and Replace commands are not working there. Alternat...
If you create a Database project within your solution in Visual Studio, then you can set up a default database connection for that project. Then any *.sql files that are included in the database project can be executed against that connection. What I usually do is select the text to be exectued and right-click it, then...
Editing SQL query with Visual Studio 2008 Would you recommend me the best approach to edit SQL query with Visual Studio 2008 Professional, please? I know I can open Query window from context menu in Server Explorer and edit text in SQL Pane. But unfortunately I am not allowed to save query to a file and Find and Replac...
TITLE: Editing SQL query with Visual Studio 2008 QUESTION: Would you recommend me the best approach to edit SQL query with Visual Studio 2008 Professional, please? I know I can open Query window from context menu in Server Explorer and edit text in SQL Pane. But unfortunately I am not allowed to save query to a file a...
[ "sql", "visual-studio", "editor" ]
2
1
11,223
3
0
2008-10-13T07:18:18.333000
2008-11-06T18:52:00.873000
196,918
200,669
Open source OCR tool available in the market
Is there any open source OCR library written in.NET, or written in any language but can be used in an ASP.NET application? Or is there any open source OCR API available in the market for image to tabular formats?
Use Tessnet. Tessnet is C++/CLI.NET Wrapper for tessdll (and tesseract ) for.NET 2.0.
Open source OCR tool available in the market Is there any open source OCR library written in.NET, or written in any language but can be used in an ASP.NET application? Or is there any open source OCR API available in the market for image to tabular formats?
TITLE: Open source OCR tool available in the market QUESTION: Is there any open source OCR library written in.NET, or written in any language but can be used in an ASP.NET application? Or is there any open source OCR API available in the market for image to tabular formats? ANSWER: Use Tessnet. Tessnet is C++/CLI.NET...
[ ".net", "ocr" ]
25
15
15,002
5
0
2008-10-13T07:28:38.060000
2008-10-14T10:32:08.563000
196,924
196,950
How to ensure user submit only english text
I am building a project involving natural language processing, since the nlp module currently only deal with english text, so I have to make sure the user submitted content (not long, only several words) is in english. Are there established ways to achieve this? Python or Javascript way preferred.
If the content is long enough I would suggest some frequency analysis on the letters. But for a few words I think your best bet is to compare them to an English dictionary and accept the input if half of them match.
How to ensure user submit only english text I am building a project involving natural language processing, since the nlp module currently only deal with english text, so I have to make sure the user submitted content (not long, only several words) is in english. Are there established ways to achieve this? Python or Jav...
TITLE: How to ensure user submit only english text QUESTION: I am building a project involving natural language processing, since the nlp module currently only deal with english text, so I have to make sure the user submitted content (not long, only several words) is in english. Are there established ways to achieve t...
[ "javascript", "python", "nlp" ]
9
7
1,214
10
0
2008-10-13T07:32:12.953000
2008-10-13T07:47:57.727000
196,930
200,148
How to check if OS is Vista in Python?
How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython? Essentially, I need a function that called will return True iff current OS is Vista: >>> isWindowsVista() True
Python has the lovely 'platform' module to help you out. >>> import platform >>> platform.win32_ver() ('XP', '5.1.2600', 'SP2', 'Multiprocessor Free') >>> platform.system() 'Windows' >>> platform.version() '5.1.2600' >>> platform.release() 'XP' NOTE: As mentioned in the comments proper values may not be returned when u...
How to check if OS is Vista in Python? How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython? Essentially, I need a function that called will return True iff current OS is Vista: >>> isWindowsVista() True
TITLE: How to check if OS is Vista in Python? QUESTION: How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython? Essentially, I need a function that called will return True iff current OS is Vista: >>> isWindowsVista() True ANSWER: Python has the lovel...
[ "python", "windows", "windows-vista", "wxpython", "pywin32" ]
26
43
17,693
5
0
2008-10-13T07:35:14.507000
2008-10-14T06:10:23.367000
196,936
196,945
Reflection and generic types
I'm writing some code for a class constructor which loops through all the properties of the class and calls a generic static method which populates my class with data from an external API. So I've got this as an example class: public class MyClass{ public string Property1 { get; set; } public int Property2 { get; set; ...
Do you want to call DoStuff with T = the type of each property? In which case, "as is" you would need to use reflection and MakeGenericMethod - i.e. var properties = this.GetType().GetProperties(); foreach (PropertyInfo p in properties) { object value = typeof(MyClass).GetMethod("DoStuff").MakeGenericMethod(p.PropertyT...
Reflection and generic types I'm writing some code for a class constructor which loops through all the properties of the class and calls a generic static method which populates my class with data from an external API. So I've got this as an example class: public class MyClass{ public string Property1 { get; set; } publ...
TITLE: Reflection and generic types QUESTION: I'm writing some code for a class constructor which loops through all the properties of the class and calls a generic static method which populates my class with data from an external API. So I've got this as an example class: public class MyClass{ public string Property1 ...
[ "c#", ".net", "generics", "reflection" ]
12
19
17,129
3
0
2008-10-13T07:37:22.460000
2008-10-13T07:44:28.293000
196,946
198,662
Does Android WebView need permissions for opening external URLs?
I was trying the following example, but with external URLs: Using WebViews The example shows how to load an HTML file from assets folder ( file:// url ) and display it in a WebView. But when I try it with external URLs (like http://google.com ), I am always getting a "Website Not Available" error. Android's built-in br...
I found out the answer myself. The permission name is android.permission.INTERNET. Adding following line to the AndroidManifest.xml (nested directly in tag) did the trick: The file can also be edited graphically in Eclipse plugin through permissions tab.
Does Android WebView need permissions for opening external URLs? I was trying the following example, but with external URLs: Using WebViews The example shows how to load an HTML file from assets folder ( file:// url ) and display it in a WebView. But when I try it with external URLs (like http://google.com ), I am alwa...
TITLE: Does Android WebView need permissions for opening external URLs? QUESTION: I was trying the following example, but with external URLs: Using WebViews The example shows how to load an HTML file from assets folder ( file:// url ) and display it in a WebView. But when I try it with external URLs (like http://googl...
[ "android", "http", "webview" ]
24
33
27,613
2
0
2008-10-13T07:44:54.783000
2008-10-13T19:04:01.637000
196,949
287,072
How to run NOT elevated in Vista (.NET)
I have an application that I have to run as Administrator. One small part of that application is to start other applications with Process.Start The started applications will also be run as administrators, but I'd rather see them run as the 'normal' user. How do I accomplish that? /johan/
The WinSafer API's allow a process to be launched as a limited, normal, or elevated user. Sample Usage: CreateSaferProcess(@"calc.exe", "", SaferLevel.NormalUser); Source code: //http://odetocode.com/Blogs/scott/archive/2004/10/28/602.aspx public static void CreateSaferProcess(String fileName, String arguments, SaferLe...
How to run NOT elevated in Vista (.NET) I have an application that I have to run as Administrator. One small part of that application is to start other applications with Process.Start The started applications will also be run as administrators, but I'd rather see them run as the 'normal' user. How do I accomplish that?...
TITLE: How to run NOT elevated in Vista (.NET) QUESTION: I have an application that I have to run as Administrator. One small part of that application is to start other applications with Process.Start The started applications will also be run as administrators, but I'd rather see them run as the 'normal' user. How do ...
[ ".net", "windows-vista", "uac", "elevation" ]
21
13
12,264
4
0
2008-10-13T07:47:53.420000
2008-11-13T14:28:33.113000
196,960
197,053
Can you list the keyword arguments a function receives?
I have a dict, which I need to pass key/values as keyword arguments.. For example.. d_args = {'kw1': 'value1', 'kw2': 'value2'} example(**d_args) This works fine, but if there are values in the d_args dict that are not accepted by the example function, it obviously dies.. Say, if the example function is defined as def ...
A little nicer than inspecting the code object directly and working out the variables is to use the inspect module. >>> import inspect >>> def func(a,b,c=42, *args, **kwargs): pass >>> inspect.getargspec(func) (['a', 'b', 'c'], 'args', 'kwargs', (42,)) If you want to know if its callable with a particular set of args, ...
Can you list the keyword arguments a function receives? I have a dict, which I need to pass key/values as keyword arguments.. For example.. d_args = {'kw1': 'value1', 'kw2': 'value2'} example(**d_args) This works fine, but if there are values in the d_args dict that are not accepted by the example function, it obviousl...
TITLE: Can you list the keyword arguments a function receives? QUESTION: I have a dict, which I need to pass key/values as keyword arguments.. For example.. d_args = {'kw1': 'value1', 'kw2': 'value2'} example(**d_args) This works fine, but if there are values in the d_args dict that are not accepted by the example fun...
[ "python", "arguments", "introspection" ]
124
167
76,846
7
0
2008-10-13T07:55:18.290000
2008-10-13T09:02:23.973000
196,966
200,340
Where does jQuery UI fit in MVC?
I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application I'm building, but I can't figure out how it's supposed to fit, or what the best practice is. I want to do the following: $().ready(function() { $('#searchHolder').customSearch('MyApp.Models.User'); }); As long as I have implemented a...
Just to follow up (I'm very surprised nobody else has had any opinions on this), in an effort to keep best practice I've opted to adopt jTemplates. It enables me to request some Model-style JSON from my server-side Controller and process it using syntax similar to that I would already use in a View, which now keeps any...
Where does jQuery UI fit in MVC? I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application I'm building, but I can't figure out how it's supposed to fit, or what the best practice is. I want to do the following: $().ready(function() { $('#searchHolder').customSearch('MyApp.Models.User'); })...
TITLE: Where does jQuery UI fit in MVC? QUESTION: I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application I'm building, but I can't figure out how it's supposed to fit, or what the best practice is. I want to do the following: $().ready(function() { $('#searchHolder').customSearch('MyApp...
[ "javascript", "model-view-controller", "jquery-plugins" ]
5
2
2,210
5
0
2008-10-13T07:58:20.827000
2008-10-14T08:07:57.513000
196,993
207,140
wordpress - having comments inline ajax like in stackoverflow
i have a wordpress blog and want to give people the same user experience for adding comments that is in stackoverflow. There are a number of comments ajax plugins out there but i can't find a working one that allows you to inline on the main page, go in and add comments without first drilling down into a seperate singl...
I was never able to get AJAXed Wordpress to do what me (and apparently the questioner) want to do. I use a custom solution that makes use of a plug-in called Inline Ajax Comments. I had a heck of a time finding a download link, but here's one that still works: http://kashou.net/files/inline-ajax-comments.zip In WordPre...
wordpress - having comments inline ajax like in stackoverflow i have a wordpress blog and want to give people the same user experience for adding comments that is in stackoverflow. There are a number of comments ajax plugins out there but i can't find a working one that allows you to inline on the main page, go in and ...
TITLE: wordpress - having comments inline ajax like in stackoverflow QUESTION: i have a wordpress blog and want to give people the same user experience for adding comments that is in stackoverflow. There are a number of comments ajax plugins out there but i can't find a working one that allows you to inline on the mai...
[ "php", "ajax", "wordpress", "comments" ]
7
7
5,479
7
0
2008-10-13T08:19:16.603000
2008-10-16T01:35:43.357000
197,009
199,791
How to find out whether subversion working directory is locked by svn?
A python script is running two parallel python processes ( created via os.fork() ) each of which eventually tries to check out a subversion repository leaf into the same working copy dir. Before running 'svn co...' command in a sub-process ( via python subprocess module ) the parent python code checks if the working co...
This sounds like a potential race condition, in that something like the following can happen: Process A checks to see if the directory exists (it doesn't yet). Process B checks to see if the directory exists (it doesn't yet). Process A invokes svn, which creates the directory. Process B invokes svn, which subsequently ...
How to find out whether subversion working directory is locked by svn? A python script is running two parallel python processes ( created via os.fork() ) each of which eventually tries to check out a subversion repository leaf into the same working copy dir. Before running 'svn co...' command in a sub-process ( via pyt...
TITLE: How to find out whether subversion working directory is locked by svn? QUESTION: A python script is running two parallel python processes ( created via os.fork() ) each of which eventually tries to check out a subversion repository leaf into the same working copy dir. Before running 'svn co...' command in a sub...
[ "python", "svn" ]
2
2
3,227
2
0
2008-10-13T08:29:20.030000
2008-10-14T02:09:48.423000