qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
63,632
<p>I'm trying to import an XML file via a web page in a Ruby on Rails application, the code ruby view code is as follows (I've removed HTML layout tags to make reading the code easier)</p> <pre><code>&lt;% form_for( :fmfile, :url =&gt; '/fmfiles', :html =&gt; { :method =&gt; :post, :name =&gt; 'Form_Import_DDR', :enct...
[ { "answer_id": 64068, "author": "tomafro", "author_id": 7126, "author_profile": "https://Stackoverflow.com/users/7126", "pm_score": 1, "selected": false, "text": "<p>Rather than a rails/mongrel problem, it sounds more likely that there's an issue either with your XML file or with the way...
2008/09/15
[ "https://Stackoverflow.com/questions/63632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6106/" ]
I'm trying to import an XML file via a web page in a Ruby on Rails application, the code ruby view code is as follows (I've removed HTML layout tags to make reading the code easier) ``` <% form_for( :fmfile, :url => '/fmfiles', :html => { :method => :post, :name => 'Form_Import_DDR', :enctype => 'multipart/form-data' ...
Rather than a rails/mongrel problem, it sounds more likely that there's an issue either with your XML file or with the way REXML handles it. You can check this by writing a short script to read your XML file directly (rather than within a request) and seeing if it still fails. Assuming it does, there are a couple of t...
63,671
<p>I seem to remember reading something about how it is bad for structs to implement interfaces in CLR via C#, but I can't seem to find anything about it. Is it bad? Are there unintended consequences of doing so?</p> <pre><code>public interface Foo { Bar GetBar(); } public struct Fubar : Foo { public Bar GetBar() { ...
[ { "answer_id": 63709, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": -1, "selected": false, "text": "<p>Structs are just like classes that live in the stack. I see no reason why they should be \"unsafe\".</p>\n" }, { ...
2008/09/15
[ "https://Stackoverflow.com/questions/63671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I seem to remember reading something about how it is bad for structs to implement interfaces in CLR via C#, but I can't seem to find anything about it. Is it bad? Are there unintended consequences of doing so? ``` public interface Foo { Bar GetBar(); } public struct Fubar : Foo { public Bar GetBar() { return new Bar()...
There are several things going on in this question... It is possible for a struct to implement an interface, but there are concerns that come about with casting, mutability, and performance. See this post for more details: <https://learn.microsoft.com/en-us/archive/blogs/abhinaba/c-structs-and-interface> In general, ...
63,687
<p>I would like to save the programs settings every time the user exits the program. So I need a way to call a function when the user quits the program. How do I do that?</p> <p>I am using Java 1.5.</p>
[ { "answer_id": 63701, "author": "Mat Mannion", "author_id": 6282, "author_profile": "https://Stackoverflow.com/users/6282", "pm_score": 6, "selected": true, "text": "<p>You can add a shutdown hook to your application by doing the following:</p>\n\n<pre><code>Runtime.getRuntime().addShutd...
2008/09/15
[ "https://Stackoverflow.com/questions/63687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to save the programs settings every time the user exits the program. So I need a way to call a function when the user quits the program. How do I do that? I am using Java 1.5.
You can add a shutdown hook to your application by doing the following: ``` Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { // what you want to do } })); ``` This is basically equivalent to having a try {} finally {} block around your entire program, and basically...
63,694
<p>Is there any feasible way of using generics to create a Math library that does not depend on the base type chosen to store data?</p> <p>In other words, let's assume I want to write a Fraction class. The fraction can be represented by two ints or two doubles or whatnot. The important thing is that the basic four ari...
[ { "answer_id": 63858, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>First, your class should limit the generic parameter to primitives ( public class Fraction where T : struct, new() ).</p>\n\...
2008/09/15
[ "https://Stackoverflow.com/questions/63694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7028/" ]
Is there any feasible way of using generics to create a Math library that does not depend on the base type chosen to store data? In other words, let's assume I want to write a Fraction class. The fraction can be represented by two ints or two doubles or whatnot. The important thing is that the basic four arithmetic op...
Here is a way to abstract out the operators that is relatively painless. ``` abstract class MathProvider<T> { public abstract T Divide(T a, T b); public abstract T Multiply(T a, T b); public abstract T Add(T a, T b); public abstract T Negate(T a); public virtual T Subtra...
63,741
<p>Why does the default IntelliJ default class javadoc comment use non-standard syntax? Instead of creating a line with "User: jstauffer" it could create a line with "@author jstauffer". The other lines that it creates (Date and Time) probably don't have javadoc syntax to use but why not use the javadoc syntax when ava...
[ { "answer_id": 63922, "author": "Rob Dickerson", "author_id": 7530, "author_profile": "https://Stackoverflow.com/users/7530", "pm_score": 6, "selected": false, "text": "<p>I'm not sure why Idea doesn't use the <code>@author</code> tag by default. </p>\n\n<p>But you can change this behavi...
2008/09/15
[ "https://Stackoverflow.com/questions/63741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6770/" ]
Why does the default IntelliJ default class javadoc comment use non-standard syntax? Instead of creating a line with "User: jstauffer" it could create a line with "@author jstauffer". The other lines that it creates (Date and Time) probably don't have javadoc syntax to use but why not use the javadoc syntax when availa...
I'm not sure why Idea doesn't use the `@author` tag by default. But you can change this behavior by going to `File -> Settings -> File Templates` and editing the `File Header` entry in the `Includes` tab. As of IDEA 14 it's: `File -> Settings -> Editor -> File and Code Templates -> Includes -> File Header`
63,743
<p>I am developing a web page code, which fetches dynamically the content from the server and then places this content to container nodes using something like</p> <pre><code>container.innerHTML = content; </code></pre> <p>Sometimes I have to overwrite some previous content in this node. This works fine, until it happ...
[ { "answer_id": 63811, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 0, "selected": false, "text": "<p>It sounds like you are having a problem with the browser itself. Does this problem only occur in one browser?</p>\n\n<p>O...
2008/09/15
[ "https://Stackoverflow.com/questions/63743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3894/" ]
I am developing a web page code, which fetches dynamically the content from the server and then places this content to container nodes using something like ``` container.innerHTML = content; ``` Sometimes I have to overwrite some previous content in this node. This works fine, until it happens that previous content ...
The easiest solution that I have found would be to place an anchor tag `<a>` at the top of the `div` you are editing: ``` <a name="ajax-div"></a> ``` Then when you change the content of the `div`, you can do this to have the browser jump to your anchor tag: ``` location.hash = 'ajax-div'; ``` Use this to make sur...
63,748
<p>I want to implement in Java a class for handling graph data structures. I have a Node class and an Edge class. The Graph class maintains two list: a list of nodes and a list of edges. Each node must have an unique name. How do I guard against a situation like this: </p> <pre><code>Graph g = new Graph(); Node n1 = ...
[ { "answer_id": 63795, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 1, "selected": false, "text": "<p>In my opinion you should never clone the element unless you explicitly state that your data structure does that.</p>\n\n<p>...
2008/09/15
[ "https://Stackoverflow.com/questions/63748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3885/" ]
I want to implement in Java a class for handling graph data structures. I have a Node class and an Edge class. The Graph class maintains two list: a list of nodes and a list of edges. Each node must have an unique name. How do I guard against a situation like this: ``` Graph g = new Graph(); Node n1 = new Node("#1");...
I work with graph structures in Java a lot, and my advice would be to make any data member of the Node and Edge class that the Graph depends on for maintaining its structure final, with no setters. In fact, if you can, I would make Node and Edge completely immutable, which has [many benefits](http://www.javapractices.c...
63,764
<p>How can I find what databases I have a minimum of read access to in either basic SQL, MySQL specific or in PHP?</p>
[ { "answer_id": 63869, "author": "Jay Shepherd", "author_id": 7511, "author_profile": "https://Stackoverflow.com/users/7511", "pm_score": 1, "selected": false, "text": "<p>In MySQL, you can execute </p>\n\n<p><code>SHOW DATABASES;</code></p>\n\n<p><strong>Description</strong></p>\n\n<p><c...
2008/09/15
[ "https://Stackoverflow.com/questions/63764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
How can I find what databases I have a minimum of read access to in either basic SQL, MySQL specific or in PHP?
There is a command in MySQL which can show you all of the permissions you have. The command is: ``` SHOW GRANTS; ``` It will give you output similar to: ``` root@(none)~> show grants; +---------------------------------------------------------------------+ | Grants for root@localhost ...
63,771
<p>As I build *nix piped commands I find that I want to see the output of one stage to verify correctness before building the next stage but I don't want to re-run each stage. Does anyone know of a program that will help with that? It would keep the output of the last stage automatically to use for any new stages. I us...
[ { "answer_id": 63783, "author": "pjz", "author_id": 8002, "author_profile": "https://Stackoverflow.com/users/8002", "pm_score": 3, "selected": false, "text": "<p>Use 'tee' to copy the intermediate results out to some file as well as pass them on to the next stage of the pipe, like so:</p...
2008/09/15
[ "https://Stackoverflow.com/questions/63771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6770/" ]
As I build \*nix piped commands I find that I want to see the output of one stage to verify correctness before building the next stage but I don't want to re-run each stage. Does anyone know of a program that will help with that? It would keep the output of the last stage automatically to use for any new stages. I usua...
Use 'tee' to copy the intermediate results out to some file as well as pass them on to the next stage of the pipe, like so: ``` cat /var/log/syslog | tee /tmp/syslog.out | grep something | tee /tmp/grep.out | sed 's/foo/bar/g' | tee /tmp/sed.out | cat >>/var/log/syslog.cleaned ```
63,776
<p>Given an integer typedef:</p> <pre><code>typedef unsigned int TYPE; </code></pre> <p>or</p> <pre><code>typedef unsigned long TYPE; </code></pre> <p>I have the following code to reverse the bits of an integer:</p> <pre><code>TYPE max_bit= (TYPE)-1; void reverse_int_setup() { TYPE bits= (TYPE)max_bit; w...
[ { "answer_id": 63854, "author": "TK.", "author_id": 1816, "author_profile": "https://Stackoverflow.com/users/1816", "pm_score": 0, "selected": false, "text": "<p>How about:</p>\n\n<pre><code>long temp = 0;\nint counter = 0;\nint number_of_bits = sizeof(value) * 8; // get the number of bi...
2008/09/15
[ "https://Stackoverflow.com/questions/63776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6899/" ]
Given an integer typedef: ``` typedef unsigned int TYPE; ``` or ``` typedef unsigned long TYPE; ``` I have the following code to reverse the bits of an integer: ``` TYPE max_bit= (TYPE)-1; void reverse_int_setup() { TYPE bits= (TYPE)max_bit; while (bits <<= 1) max_bit= bits; } TYPE reverse_int...
``` #include<stdio.h> #include<limits.h> #define TYPE_BITS sizeof(TYPE)*CHAR_BIT typedef unsigned long TYPE; TYPE reverser(TYPE n) { TYPE nrev = 0, i, bit1, bit2; int count; for(i = 0; i < TYPE_BITS; i += 2) { /*In each iteration, we swap one bit on the 'right half' of the number w...
63,800
<p>Does Java impose any extra restrictions of its own. Windows (upto Vista) does not allow names to include</p> <pre><code>\ / &lt; &gt; ? * : </code></pre> <p>I know HOW to validate names (a regular expression).</p> <p>I need to validate filenames entered by users. </p> <p>My application does not need to run on a...
[ { "answer_id": 63861, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 2, "selected": false, "text": "<p>No, you can escape any character that Java doesn't allow in String literals but the filesystem allows.</p>\n\n<p>Also, if t...
2008/09/15
[ "https://Stackoverflow.com/questions/63800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8118/" ]
Does Java impose any extra restrictions of its own. Windows (upto Vista) does not allow names to include ``` \ / < > ? * : ``` I know HOW to validate names (a regular expression). I need to validate filenames entered by users. My application does not need to run on any other platform, though, of course, I would p...
No, you can escape any character that Java doesn't allow in String literals but the filesystem allows. Also, if trying to port an Windows app to Mac or Unix it is best to use: ``` File.separator ``` To determine the correct file separator to use on each platform.
63,805
<p>How do I ask PowerShell where something is? </p> <p>For instance, "which notepad" and it returns the directory where the notepad.exe is run from according to the current paths.</p>
[ { "answer_id": 63831, "author": "Nicholas", "author_id": 8054, "author_profile": "https://Stackoverflow.com/users/8054", "pm_score": 2, "selected": false, "text": "<p>This seems to do what you want (I found it on <a href=\"http://huddledmasses.org/powershell-find-path/\" rel=\"nofollow n...
2008/09/15
[ "https://Stackoverflow.com/questions/63805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1220/" ]
How do I ask PowerShell where something is? For instance, "which notepad" and it returns the directory where the notepad.exe is run from according to the current paths.
The very first alias I made once I started customizing my profile in PowerShell was 'which'. ```sh New-Alias which get-command ``` To add this to your profile, type this: ```sh "`nNew-Alias which get-command" | add-content $profile ``` The `n at the start of the last line is to ensure it will start as a new line.
63,870
<p>I have a rather large file (150 million lines of 10 chars). I need to split it in 150 files of 2 million lines, with each output line being alternatively the first 5 characters or the last 5 characters of the source line. I could do this in Perl rather quickly, but I was wondering if there was an easy solution using...
[ { "answer_id": 63941, "author": "HD.", "author_id": 6525, "author_profile": "https://Stackoverflow.com/users/6525", "pm_score": 3, "selected": true, "text": "<p>Homework? :-)</p>\n\n<p>I would think that a simple pipe with sed (to split each line into two) and split (to split things up ...
2008/09/15
[ "https://Stackoverflow.com/questions/63870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7028/" ]
I have a rather large file (150 million lines of 10 chars). I need to split it in 150 files of 2 million lines, with each output line being alternatively the first 5 characters or the last 5 characters of the source line. I could do this in Perl rather quickly, but I was wondering if there was an easy solution using ba...
Homework? :-) I would think that a simple pipe with sed (to split each line into two) and split (to split things up into multiple files) would be enough. The man command is your friend. --- Added after confirmation that it is not homework: How about ``` sed 's/\(.....\)\(.....\)/\1\n\2/' input_file | split -l 200...
63,881
<p>I have a strange problem with my cake (cake_1.2.0.7296-rc2). My start()-action runs twice, under certain circumstances, even though only one request is made.</p> <p>The triggers seem to be : - loading an object like: <code>$this-&gt;Questionnaire-&gt;read(null, $questionnaire_id);</code> - accessing $this-data </p>...
[ { "answer_id": 64176, "author": "eelco", "author_id": 8293, "author_profile": "https://Stackoverflow.com/users/8293", "pm_score": 1, "selected": false, "text": "<p>You might want to try and find out where it comes from using the debug_print_backtrace() function. (<a href=\"http://nl.php....
2008/09/15
[ "https://Stackoverflow.com/questions/63881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a strange problem with my cake (cake\_1.2.0.7296-rc2). My start()-action runs twice, under certain circumstances, even though only one request is made. The triggers seem to be : - loading an object like: `$this->Questionnaire->read(null, $questionnaire_id);` - accessing $this-data If I disable the call to `lo...
Check your layout for non-existent links, for example a misconfigured link to favicon.ico will cause the controller action to be triggered for a second time. Make sure favicon.ico points towards the webroot rather than the local directory, or else requests will be generated for /controller/action/favicon.ico rather tha...
63,885
<p>I am trying to create a rather simple effect on a set of images. When an image doesn't have the mouse over it, I'd like it to have a simple, gray border. When it does have an image over it, I'd like it to have a different, "selected", border.</p> <p>The following CSS works great in Firefox:</p> <pre class="lang-...
[ { "answer_id": 64025, "author": "hjdivad", "author_id": 7538, "author_profile": "https://Stackoverflow.com/users/7538", "pm_score": 2, "selected": true, "text": "<p>Try using a different colour. I'm not sure IE understands 'grey' (instead, use 'gray').</p>\n" }, { "answer_id": 6...
2008/09/15
[ "https://Stackoverflow.com/questions/63885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7357/" ]
I am trying to create a rather simple effect on a set of images. When an image doesn't have the mouse over it, I'd like it to have a simple, gray border. When it does have an image over it, I'd like it to have a different, "selected", border. The following CSS works great in Firefox: ```css .myImage a img { borde...
Try using a different colour. I'm not sure IE understands 'grey' (instead, use 'gray').
63,897
<p>I'm testing the VB function below that I got from a Google search. I plan to use it to generate hash codes for quick string comparison. However, there are occasions in which two different strings have the same hash code. For example, these strings</p> <p>"122Gen 1 heap size (.NET CLR Memory w3wp):mccsmtpteweb025.2...
[ { "answer_id": 63929, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 2, "selected": false, "text": "<p>Hash functions do not guarantee uniqueness of hash values. If the input value range (judging your sample strings) is larger t...
2008/09/15
[ "https://Stackoverflow.com/questions/63897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8203/" ]
I'm testing the VB function below that I got from a Google search. I plan to use it to generate hash codes for quick string comparison. However, there are occasions in which two different strings have the same hash code. For example, these strings "122Gen 1 heap size (.NET CLR Memory w3wp):mccsmtpteweb025.208333333333...
I'm betting there are more than just "occasions" when two strings generate the same hash using your function. In fact, it probably happens more often than you think. A few things to realize: First, there will be hash collisions. It happens. Even with really, really big spaces like MD5 (128 bits) there are still two s...
63,950
<p>I program with Emacs on Ubuntu (Hardy Heron at the moment), and I like the default text coloration in the Emacs GUI. However, the default text coloration when Emacs is run in the terminal is different and garish.</p> <p>How do I make the colors in the terminal match the colors in the GUI?</p>
[ { "answer_id": 63965, "author": "HD.", "author_id": 6525, "author_profile": "https://Stackoverflow.com/users/6525", "pm_score": -1, "selected": false, "text": "<p>I don't think that is possible in such a general way. With the terminal you are usually bound to some pre-defined colors (wi...
2008/09/15
[ "https://Stackoverflow.com/questions/63950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I program with Emacs on Ubuntu (Hardy Heron at the moment), and I like the default text coloration in the Emacs GUI. However, the default text coloration when Emacs is run in the terminal is different and garish. How do I make the colors in the terminal match the colors in the GUI?
You don't have to be stuck to your terminal's default 16 (or fewer) colours. Modern terminals will support 256 colours (which will get you pretty close to your GUI look). Unfortunately, getting your terminal to support 256 colours is the tricky part, and varies from term to term. [This page](http://www.xvx.ca/~awg/ema...
63,974
<p>In my application I have a DataGridView control that displays data for the selected object. When I select a different object (in a combobox above), I need to update the grid. Unfortunately different objects have completely different data, even different columns, so I need to clear all the existing data and columns, ...
[ { "answer_id": 63986, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 1, "selected": false, "text": "<p>Sounds like you want double-buffering:</p>\n\n<p><a href=\"http://www.codeproject.com/KB/graphics/DoubleBuffering.a...
2008/09/15
[ "https://Stackoverflow.com/questions/63974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5363/" ]
In my application I have a DataGridView control that displays data for the selected object. When I select a different object (in a combobox above), I need to update the grid. Unfortunately different objects have completely different data, even different columns, so I need to clear all the existing data and columns, cre...
Rather than adding the rows of the data grid one at a time, use the `DataGridView.Rows.AddRange` method to add all the rows at once. That should only update the display once. There's also a `DataGridView.Columns.AddRange` to do the same for the columns.
63,995
<p>I would like to give a class a unique ID every time a new one is instantiated. For example with a class named Foo i would like to be able to do the following</p> <pre><code>dim a as New Foo() dim b as New Foo() </code></pre> <p>and a would get a unique id and b would get a unique ID. The ids only have to be uniq...
[ { "answer_id": 64015, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": -1, "selected": false, "text": "<p>It's likely throwing an error because you're never initializing _nextId to anything. It needs to have an initial v...
2008/09/15
[ "https://Stackoverflow.com/questions/63995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054/" ]
I would like to give a class a unique ID every time a new one is instantiated. For example with a class named Foo i would like to be able to do the following ``` dim a as New Foo() dim b as New Foo() ``` and a would get a unique id and b would get a unique ID. The ids only have to be unique over run time so i would ...
Consider the following code: ``` Public Class Foo Private ReadOnly _fooId As FooId Public Sub New() _fooId = New FooId() End Sub Public ReadOnly Property Id() As Integer Get Return _fooId.Id End Get End Property End Class Public NotInheritable Class...
63,998
<p>Continuing the "Hidden features of ..." meme, let's share the lesser-known but useful features of Ruby programming language.</p> <p>Try to limit this discussion with core Ruby, without any Ruby on Rails stuff.</p> <p>See also:</p> <ul> <li><a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hi...
[ { "answer_id": 64080, "author": "CodingWithoutComments", "author_id": 25, "author_profile": "https://Stackoverflow.com/users/25", "pm_score": 5, "selected": false, "text": "<p>I find using the <strong>define_method</strong> command to dynamically generate methods to be quite interesting ...
2008/09/15
[ "https://Stackoverflow.com/questions/63998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7754/" ]
Continuing the "Hidden features of ..." meme, let's share the lesser-known but useful features of Ruby programming language. Try to limit this discussion with core Ruby, without any Ruby on Rails stuff. See also: * [Hidden features of C#](https://stackoverflow.com/questions/9033/hidden-features-of-c) * [Hidden featu...
Peter Cooper has a [good list](http://www.rubyinside.com/21-ruby-tricks-902.html) of Ruby tricks. Perhaps my favorite of his is allowing both single items and collections to be enumerated. (That is, treat a non-collection object as a collection containing just that object.) It looks like this: ``` [*items].each do |it...
64,000
<p>When launching a process from Java, both stderr and stdout can block on output if I don't read from the pipes. Currently I have a thread that pro-actively reads from one and the main thread blocks on the other.</p> <p>Is there an easy way to join the two streams or otherwise cause the subprocess to continue while ...
[ { "answer_id": 64145, "author": "killdash10", "author_id": 7621, "author_profile": "https://Stackoverflow.com/users/7621", "pm_score": 0, "selected": false, "text": "<p>Just have two threads, one reading from stdout, one from stderr?</p>\n" }, { "answer_id": 64183, "author": ...
2008/09/15
[ "https://Stackoverflow.com/questions/64000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4926/" ]
When launching a process from Java, both stderr and stdout can block on output if I don't read from the pipes. Currently I have a thread that pro-actively reads from one and the main thread blocks on the other. Is there an easy way to join the two streams or otherwise cause the subprocess to continue while not losing ...
Set the redirectErrorStream property on ProcessBuilder to send stderr output to stdout: ``` ProcessBuilder builder = new ProcessBuilder(command); builder.redirectErrorStream(true); ``` You should then create a thread to deal with the process stream, something like the following: ``` Process p = builder.start(); In...
64,003
<p>I want to put a copyright notice in the footer of a web site, but I think it's incredibly tacky for the year to be outdated.</p> <p>How would I make the year update automatically with <a href="http://en.wikipedia.org/wiki/PHP#History" rel="noreferrer">PHP 4</a> or <a href="http://en.wikipedia.org/wiki/PHP#History" r...
[ { "answer_id": 64009, "author": "Daniel Papasian", "author_id": 7548, "author_profile": "https://Stackoverflow.com/users/7548", "pm_score": 9, "selected": false, "text": "<pre><code>&lt;?php echo date(\"Y\"); ?&gt;\n</code></pre>\n" }, { "answer_id": 64011, "author": "Mark Bi...
2008/09/15
[ "https://Stackoverflow.com/questions/64003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1661459/" ]
I want to put a copyright notice in the footer of a web site, but I think it's incredibly tacky for the year to be outdated. How would I make the year update automatically with [PHP 4](http://en.wikipedia.org/wiki/PHP#History) or [PHP 5](http://en.wikipedia.org/wiki/PHP#History)?
You can use either [date](http://php.net/manual/en/function.date.php) or [strftime](http://php.net/manual/en/function.strftime.php). In this case I'd say it doesn't matter as a year is a year, no matter what (unless there's a locale that formats the year differently?) For example: ``` <?php echo date("Y"); ?> ``` O...
64,041
<p>How do I change font size on the DataGridView?</p>
[ { "answer_id": 64052, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 1, "selected": false, "text": "<p>Use the Font-property on the gridview. See MSDN for details and samples:</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/...
2008/09/15
[ "https://Stackoverflow.com/questions/64041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
How do I change font size on the DataGridView?
``` private void UpdateFont() { //Change cell font foreach(DataGridViewColumn c in dgAssets.Columns) { c.DefaultCellStyle.Font = new Font("Arial", 8.5F, GraphicsUnit.Pixel); } } ```
64,059
<p>I have some website which requires a logon and shows sensitive information.</p> <p>The person goes to the page, is prompted to log in, then gets to see the information.</p> <p>The person logs out of the site, and is redirected back to the login page.</p> <p>The person then can hit "back" and go right back to the ...
[ { "answer_id": 64079, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 2, "selected": false, "text": "<p>From <a href=\"http://www.aspdev.org/asp.net/asp.net-disable-caching/\" rel=\"nofollow noreferrer\">aspdev.org</a>:</p>\n\n<p...
2008/09/15
[ "https://Stackoverflow.com/questions/64059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577/" ]
I have some website which requires a logon and shows sensitive information. The person goes to the page, is prompted to log in, then gets to see the information. The person logs out of the site, and is redirected back to the login page. The person then can hit "back" and go right back to the page where the sensitive...
The short answer is that it cannot be done securely. There are, however, a lot of tricks that can be implemented to make it difficult for users to hit back and get sensitive data displayed. ``` Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(Now.AddSeconds(-1)); Response.Cache.SetN...
64,139
<p>I have a usercontrol that has several public properties. These properties automatically show up in the properties window of the VS2005 designer under the "Misc" category. Except two of the properties which are enumerations don't show up correctly.</p> <p>The first on uses the following enum:</p> <pre><code>publi...
[ { "answer_id": 64175, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 1, "selected": true, "text": "<p>For starters, the second enum, AutoSizeMode is declared in System.Windows.Forms. So that might cause the designer some is...
2008/09/15
[ "https://Stackoverflow.com/questions/64139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
I have a usercontrol that has several public properties. These properties automatically show up in the properties window of the VS2005 designer under the "Misc" category. Except two of the properties which are enumerations don't show up correctly. The first on uses the following enum: ``` public enum VerticalControlA...
For starters, the second enum, AutoSizeMode is declared in System.Windows.Forms. So that might cause the designer some issues. Secondly, you might find the following page on MSDN useful: <http://msdn.microsoft.com/en-us/library/tk67c2t8.aspx>
64,141
<p>In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? </p> <p>So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names ...
[ { "answer_id": 64163, "author": "Teifion", "author_id": 1384652, "author_profile": "https://Stackoverflow.com/users/1384652", "pm_score": 4, "selected": true, "text": "<p>A class is a template, it allows you to create a blueprint, you can then have multiple instances of a class each with...
2008/09/15
[ "https://Stackoverflow.com/questions/64141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8324/" ]
In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names for sectio...
A class is a template, it allows you to create a blueprint, you can then have multiple instances of a class each with different numbers, like so. ``` class dog(object): def __init__(self, height, width, lenght): self.height = height self.width = width self.length = length def revert(se...
64,146
<p>When a script is saved as a bundle, it can use the <code>localized string</code> command to find the appropriate string, e.g. in <code>Contents/Resources/English.lproj/Localizable.strings</code>. If this is a format string, what is the best way to fill in the placeholders? In other words, what is the AppleScript equ...
[ { "answer_id": 66899, "author": "nlanza", "author_id": 9373, "author_profile": "https://Stackoverflow.com/users/9373", "pm_score": 0, "selected": false, "text": "<p>As ugly as it is, calling out to <code>printf(1)</code> is the common solution.</p>\n\n<p>A cleaner, though somewhat more c...
2008/09/15
[ "https://Stackoverflow.com/questions/64146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6311/" ]
When a script is saved as a bundle, it can use the `localized string` command to find the appropriate string, e.g. in `Contents/Resources/English.lproj/Localizable.strings`. If this is a format string, what is the best way to fill in the placeholders? In other words, what is the AppleScript equivalent of `+[NSString st...
[Since OS X 10.10](https://developer.apple.com/library/content/releasenotes/AppleScript/RN-AppleScript/RN-10_10/RN-10_10.html), it’s been possible for any AppleScript script to use Objective-C. There are a few ways to call Objective-C methods from within AppleScript, as detailed in [this translation guide](https://deve...
64,193
<p>I am using the AJAX Control Toolkit Popup Calendar Control in a datagrid. When it is in the footer it looks fine. When it is in the edit side of the datagrid it is inheriting the style from the datagrid and looks completely different (i.e. too big). </p> <p>Is there a way to alter the CSS so that it does not inheri...
[ { "answer_id": 64245, "author": "McKay", "author_id": 8384, "author_profile": "https://Stackoverflow.com/users/8384", "pm_score": 0, "selected": false, "text": "<p>It uses the style from the grid, because it's in it. If you want to change it's style, change the style of the control. What...
2008/09/15
[ "https://Stackoverflow.com/questions/64193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7316/" ]
I am using the AJAX Control Toolkit Popup Calendar Control in a datagrid. When it is in the footer it looks fine. When it is in the edit side of the datagrid it is inheriting the style from the datagrid and looks completely different (i.e. too big). Is there a way to alter the CSS so that it does not inherit the styl...
Open the page in firefox. However, first, download the firebug extension. Then, right click on the offending version and go down to inspect element. Firebug is awesome because it let's you navigate the css of any element. You have two options here: 1) Assign the topmost element an css class and work it that way. or ...
64,214
<p>I read everywhere that business logic belongs in the models and not in controller but where is the limit? I am toying with a personnal accounting application. </p> <pre><code>Account Entry Operation </code></pre> <p>When creating an operation it is only valid if the corresponding entries are created and linked to ...
[ { "answer_id": 64389, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>It's easier to think in terms of each entity validating itself, and entities which depend on one another delegating their st...
2008/09/15
[ "https://Stackoverflow.com/questions/64214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7898/" ]
I read everywhere that business logic belongs in the models and not in controller but where is the limit? I am toying with a personnal accounting application. ``` Account Entry Operation ``` When creating an operation it is only valid if the corresponding entries are created and linked to accounts so that the opera...
> > but then the model will create and store instances of other models which is where my problem is. > > > What is wrong with this? If your 'business logic' states that an Operation must have a valid set of Entries, then surely there is nothing wrong for the Operation class to know about, and deal with your Entr...
64,258
<p>I'm using an identical call to "CryptUnprotectData" (exposed from Crypt32.dll) between XP and Vista. Works fine in XP. I get the following exception when I run in Vista:</p> <pre><code>"Decryption failed. Key not valid for use in specified state." </code></pre> <p>As expected, the versions of crypt32.dll are diffe...
[ { "answer_id": 64301, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 3, "selected": true, "text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/aa380882.aspx\" rel=\"nofollow noreferrer\">CryptUnprotectDat...
2008/09/15
[ "https://Stackoverflow.com/questions/64258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1683/" ]
I'm using an identical call to "CryptUnprotectData" (exposed from Crypt32.dll) between XP and Vista. Works fine in XP. I get the following exception when I run in Vista: ``` "Decryption failed. Key not valid for use in specified state." ``` As expected, the versions of crypt32.dll are different between XP and Vista ...
The [CryptUnprotectData function](http://msdn.microsoft.com/en-us/library/aa380882.aspx) documentation states that it usually only works when the user has the same logon credentials as the encrypter. This suggests to me that maybe the key is tied to the user's current token. Since you mention Vista, this makes me thin...
64,272
<p>I want to create a custom control in C#. But every time I have to fully redraw my control, it flickers, even if I use double buffering (drawing to an Image first, and blitting that).</p> <p>How do I eliminate flicker when I have to fully redraw?</p>
[ { "answer_id": 64336, "author": "Grokys", "author_id": 6448, "author_profile": "https://Stackoverflow.com/users/6448", "pm_score": 0, "selected": false, "text": "<p>You say you've tried double buffering, but then you say drawing to an Image first and blitting that. Have you tried setting...
2008/09/15
[ "https://Stackoverflow.com/questions/64272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7305/" ]
I want to create a custom control in C#. But every time I have to fully redraw my control, it flickers, even if I use double buffering (drawing to an Image first, and blitting that). How do I eliminate flicker when I have to fully redraw?
You could try putting the following in your constructor after the InitiliseComponent call. ``` SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); ``` EDIT: If you're giving this a go, if you can, remove your own double buffering co...
64,284
<p>Let's say I have a list of categories for navigation on a web app. Rather than selecting from the database for every user, should I add a function call in the application_onStart of the global.asax to fetch that data into an array or collection that is re-used over and over. If my data does not change at all - (Ed...
[ { "answer_id": 64307, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": 0, "selected": false, "text": "<p>I use a static collection as a private with a public static property that either loads or gets it from the databas...
2008/09/15
[ "https://Stackoverflow.com/questions/64284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1115144/" ]
Let's say I have a list of categories for navigation on a web app. Rather than selecting from the database for every user, should I add a function call in the application\_onStart of the global.asax to fetch that data into an array or collection that is re-used over and over. If my data does not change at all - (Edit -...
You can store the list items in the Application object. You are right about the `application_onStart()`, simply call a method that will read your database and load the data to the Application object. In Global.asax ``` public class Global : System.Web.HttpApplication { // The key to use in the rest of the web sit...
64,291
<p>I'm working on an application that needs to quickly render simple 3D scenes on the server, and then return them as a JPEG via HTTP. Basically, I want to be able to simply include a dynamic 3D scene in an HTML page, by doing something like:</p> <pre><code>&lt;img src="http://www.myserver.com/renderimage?scene=1&amp;...
[ { "answer_id": 64315, "author": "Fire Lancer", "author_id": 6266, "author_profile": "https://Stackoverflow.com/users/6266", "pm_score": 2, "selected": false, "text": "<p>Id say your best bet is have a Direct3D/OpenGL app running on the server (without stopping). THen making the server pa...
2008/09/15
[ "https://Stackoverflow.com/questions/64291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8409/" ]
I'm working on an application that needs to quickly render simple 3D scenes on the server, and then return them as a JPEG via HTTP. Basically, I want to be able to simply include a dynamic 3D scene in an HTML page, by doing something like: ``` <img src="http://www.myserver.com/renderimage?scene=1&x=123&y=123&z=123"> ...
RealityServer by mental images is designed to do precisely what is described here. More details are available on the product page (including a downloadable Developer Edition). [RealityServer docs](http://www.migenius.com/doc/realityserver/latest/)
64,311
<p>The design for the website I am working on calls for a custom image on lists instead of a bullet. Using the image is fine, but I have been having difficulties ensuring that it is centered against the text of the list item across all browsers. Does anyone know of a standard solution for this?</p>
[ { "answer_id": 64340, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 0, "selected": false, "text": "<p>Have you tried adding the following code in your CSS file?</p>\n\n<pre class=\"lang-css prettyprint-override\"><code>li\n{\n ...
2008/09/15
[ "https://Stackoverflow.com/questions/64311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4284/" ]
The design for the website I am working on calls for a custom image on lists instead of a bullet. Using the image is fine, but I have been having difficulties ensuring that it is centered against the text of the list item across all browsers. Does anyone know of a standard solution for this?
If you are referring to using a custom image bullet for your list this is the code you'll want to use, it will be vertically centered. I'm assuming here that the bullet image is 12px by 12px. ```css ul li { background: transparent url(/link/to/custom/bullet.gif) no-repeat 0 50%; padding-left: 18px; } ``` The o...
64,351
<p>I'm trying to load a page that is basically an edit form inside a dialog (ui.dialog). I can load this page fine from an external (I'm using asp.net) page.</p> <p>The problem is that inside of my "popup" form, I need to <code>$(function() {my function here});</code> syntax to do some stuff when the page loads, alon...
[ { "answer_id": 64515, "author": "Alexey Lebedev", "author_id": 8338, "author_profile": "https://Stackoverflow.com/users/8338", "pm_score": 3, "selected": true, "text": "<p>If you really need to load that form via AJAX you could to do all the Javascript stuff in $.ajax callback itself.\n...
2008/09/15
[ "https://Stackoverflow.com/questions/64351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8534/" ]
I'm trying to load a page that is basically an edit form inside a dialog (ui.dialog). I can load this page fine from an external (I'm using asp.net) page. The problem is that inside of my "popup" form, I need to `$(function() {my function here});` syntax to do some stuff when the page loads, along with registering som...
If you really need to load that form via AJAX you could to do all the Javascript stuff in $.ajax callback itself. So, you load the popup form like this: ``` $.ajax({ //... success: function(text) { // insert text into container // the code from $(function() {}); } }); ```
64,360
<p>When I cut (kill) text in Emacs 22.1.1 (in its own window on X, in KDE, on Kubuntu), I can't paste (yank) it in any other application.</p>
[ { "answer_id": 64406, "author": "kfh", "author_id": 6597, "author_profile": "https://Stackoverflow.com/users/6597", "pm_score": 0, "selected": false, "text": "<p>Hmm, what platform and what version of emacs are you using? With GNU Emacs 22.1.1 on Windows Vista, it works fine for me.</p>...
2008/09/15
[ "https://Stackoverflow.com/questions/64360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8522/" ]
When I cut (kill) text in Emacs 22.1.1 (in its own window on X, in KDE, on Kubuntu), I can't paste (yank) it in any other application.
Insert the following into your `.emacs` file: ``` (setq x-select-enable-clipboard t) ```
64,387
<p><strong>Emacs</strong>: <code>C-U (79) #</code> &raquo; a pretty 79 character length divider</p> <p><strong>VIM</strong>: <code>79-i-#</code> &raquo; see above</p> <p><strong><a href="http://macromates.com/" rel="nofollow noreferrer">Textmate</a></strong>: ????</p> <p>Or is it just assumed that we'll make a Rub...
[ { "answer_id": 64975, "author": "pjbeardsley", "author_id": 6812, "author_profile": "https://Stackoverflow.com/users/6812", "pm_score": 2, "selected": false, "text": "<p>I would create a bundle command to do this.</p>\n\n<p>You can take editor selection as input to your script, then repl...
2008/09/15
[ "https://Stackoverflow.com/questions/64387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
**Emacs**: `C-U (79) #` » a pretty 79 character length divider **VIM**: `79-i-#` » see above **[Textmate](http://macromates.com/)**: ???? Or is it just assumed that we'll make a Ruby call or have a snippet somewhere?
I would create a bundle command to do this. You can take editor selection as input to your script, then replace it with the result of execution. This command, for example, will take a selected number and print the character '#' that number of times. ``` python -c "print '#' * $TM_SELECTED_TEXT" ``` Of course this e...
64,388
<p>I'm trying to use Visual Studio 2008's extensibility to write an addin that will create a project folder with various messages in it after parsing an interface. I'm having trouble at the step of creating/adding the folder, however. I've tried using </p> <pre><code>ProjectItem folder = item.ProjectItem.Collection.A...
[ { "answer_id": 64901, "author": "Andrew", "author_id": 8586, "author_profile": "https://Stackoverflow.com/users/8586", "pm_score": 2, "selected": false, "text": "<p>Yup, that was it...</p>\n\n<pre><code>DirectoryInfo dirInfo = new DirectoryInfo(newDirectoryParent + newDirectoryName);\n\n...
2008/09/15
[ "https://Stackoverflow.com/questions/64388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8586/" ]
I'm trying to use Visual Studio 2008's extensibility to write an addin that will create a project folder with various messages in it after parsing an interface. I'm having trouble at the step of creating/adding the folder, however. I've tried using ``` ProjectItem folder = item.ProjectItem.Collection.AddFolder(newDi...
Yup, that was it... ``` DirectoryInfo dirInfo = new DirectoryInfo(newDirectoryParent + newDirectoryName); if (dirInfo.Exists) { dirInfo.Delete(true); item.DTE.ExecuteCommand("View.Refresh", string.Empty); } ProjectItem folder = item.ProjectItem.Collection.AddFolder(newDirectoryName, string.Empty); ``` If t...
64,420
<p>I don't want to take the time to learn Obj-C. I've spent 7+ years doing web application programming. Shouldn't there be a way to use the WebView and just write the whole app in javascript, pulling the files right from the resources of the project?</p>
[ { "answer_id": 64493, "author": "Sergey Mikhanov", "author_id": 3894, "author_profile": "https://Stackoverflow.com/users/3894", "pm_score": 2, "selected": false, "text": "<p>You should have the native wrapper written in Objective C. This wrapper could contain really few lines of code (li...
2008/09/15
[ "https://Stackoverflow.com/questions/64420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8597/" ]
I don't want to take the time to learn Obj-C. I've spent 7+ years doing web application programming. Shouldn't there be a way to use the WebView and just write the whole app in javascript, pulling the files right from the resources of the project?
I found the answer after searching around. Here's what I have done: 1. Create a new project in XCode. I think I used the view-based app. 2. Drag a WebView object onto your interface and resize. 3. Inside of your WebViewController.m (or similarly named file, depending on the name of your view), in the viewDidLoad metho...
64,436
<p>I'm using Excel VBA to a write a UDF. I would like to overload my own UDF with a couple of different versions so that different arguments will call different functions. </p> <p>As VBA doesn't seem to support this, could anyone suggest a good, non-messy way of achieving the same goal? Should I be using Optional argu...
[ { "answer_id": 64494, "author": "theo", "author_id": 7870, "author_profile": "https://Stackoverflow.com/users/7870", "pm_score": 0, "selected": false, "text": "<p>VBA is messy. I'm not sure there is an easy way to do fake overloads:</p>\n\n<p>In the past I've either used lots of Optional...
2008/09/15
[ "https://Stackoverflow.com/questions/64436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/69157/" ]
I'm using Excel VBA to a write a UDF. I would like to overload my own UDF with a couple of different versions so that different arguments will call different functions. As VBA doesn't seem to support this, could anyone suggest a good, non-messy way of achieving the same goal? Should I be using Optional arguments or i...
Declare your arguments as `Optional Variants`, then you can test to see if they're missing using `IsMissing()` or check their type using `TypeName()`, as shown in the following example: ``` Public Function Foo(Optional v As Variant) As Variant If IsMissing(v) Then Foo = "Missing argument" ElseIf TypeN...
64,498
<p>Can you specialize a template method within a template class without specializing the class template parameter?</p> <p>Please note that the specialization is on the <em>value</em> of the template parameter, not its type.</p> <p>This seems to compile under Visual Studio 2008 SP1 complier, but not GCC 4.2.4.</p> <p...
[ { "answer_id": 64824, "author": "moswald", "author_id": 8368, "author_profile": "https://Stackoverflow.com/users/8368", "pm_score": 2, "selected": false, "text": "<p>It is not supported in the standard (and it is apparently a known bug with Visual Studio that you <em>can</em> do it).</p>...
2008/09/15
[ "https://Stackoverflow.com/questions/64498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8524/" ]
Can you specialize a template method within a template class without specializing the class template parameter? Please note that the specialization is on the *value* of the template parameter, not its type. This seems to compile under Visual Studio 2008 SP1 complier, but not GCC 4.2.4. ``` #include <iostream> using ...
Here is another workaround, also useful when you need to partialy specialize a function (which is not allowed). Create a template functor class (ie. class whose sole purpose is to execute a single member function, usually named operator() ), specialize it and then call from within your template function. I think I lea...
64,505
<p>I'm using the following method to send mail from Python using SMTP. Is it the right method to use or are there gotchas I'm missing ?</p> <pre><code>from smtplib import SMTP import datetime debuglevel = 0 smtp = SMTP() smtp.set_debuglevel(debuglevel) smtp.connect('YOUR.MAIL.SERVER', 26) smtp.login('USERNAME@DOMAIN...
[ { "answer_id": 64554, "author": "pjz", "author_id": 8002, "author_profile": "https://Stackoverflow.com/users/8002", "pm_score": 3, "selected": false, "text": "<p>The main gotcha I see is that you're not handling any errors: <code>.login()</code> and <code>.sendmail()</code> both have <a ...
2008/09/15
[ "https://Stackoverflow.com/questions/64505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
I'm using the following method to send mail from Python using SMTP. Is it the right method to use or are there gotchas I'm missing ? ``` from smtplib import SMTP import datetime debuglevel = 0 smtp = SMTP() smtp.set_debuglevel(debuglevel) smtp.connect('YOUR.MAIL.SERVER', 26) smtp.login('USERNAME@DOMAIN', 'PASSWORD')...
The script I use is quite similar; I post it here as an example of how to use the email.\* modules to generate MIME messages; so this script can be easily modified to attach pictures, etc. I rely on my ISP to add the date time header. My ISP requires me to use a secure smtp connection to send mail, I rely on the smtp...
64,508
<p>What does the following Guile scheme code do?</p> <pre><code>(eq? y '.) (cons x '.) </code></pre> <p>The code is not valid in MzScheme, is there a portable equivalent across scheme implementations?</p> <p>I am trying to port this code written by someone else. Guile seems to respond to '. with #{.}#, but I'm not s...
[ { "answer_id": 64530, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 0, "selected": false, "text": "<p>I'm surprised any Scheme system will accept a dot symbol at all. My advice is to use another symbol as (I'm sure you're...
2008/09/15
[ "https://Stackoverflow.com/questions/64508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8689/" ]
What does the following Guile scheme code do? ``` (eq? y '.) (cons x '.) ``` The code is not valid in MzScheme, is there a portable equivalent across scheme implementations? I am trying to port this code written by someone else. Guile seems to respond to '. with #{.}#, but I'm not sure what it means or how to do th...
Okay, it seems that '. is valid syntax for (string->symbol ".") in Guile, whereas MzScheme at least requires |.| for the period as a symbol.
64,559
<p>I've started to work a bit with master pages for an ASP.net mvc site and I've come across a question. When I link in a stylesheet on the master page it seems to update the path to the sheet correctly. That is in the code I have</p> <pre><code>&lt;link href="../../Content/Site.css" rel="stylesheet" type="text/css"...
[ { "answer_id": 64586, "author": "Iain Holder", "author_id": 1122, "author_profile": "https://Stackoverflow.com/users/1122", "pm_score": 0, "selected": false, "text": "<p>Use this instead:</p>\n\n<pre><code>&lt;link href=\"~/Content/Site.css\" rel=\"stylesheet\" type=\"text/css\" /&gt;\n<...
2008/09/15
[ "https://Stackoverflow.com/questions/64559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/361/" ]
I've started to work a bit with master pages for an ASP.net mvc site and I've come across a question. When I link in a stylesheet on the master page it seems to update the path to the sheet correctly. That is in the code I have ``` <link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> ``` but looki...
``` <script src="<%= ResolveClientUrl("~/Content/menu.js") %>" type="text/javascript"></script> ```
64,570
<p>PHP's explode function returns an array of strings split on some provided substring. It will return empty strings when there are leading, trailing, or consecutive delimiters, like this:</p> <pre><code>var_dump(explode('/', '1/2//3/')); array(5) { [0]=&gt; string(1) &quot;1&quot; [1]=&gt; string(1) &quot;2&qu...
[ { "answer_id": 64606, "author": "James Aylett", "author_id": 6302, "author_profile": "https://Stackoverflow.com/users/6302", "pm_score": 2, "selected": false, "text": "<pre><code>function not_empty_string($s) {\n return $s !== \"\";\n}\n\narray_filter(explode('/', '1/2//3/'), 'not_empty...
2008/09/15
[ "https://Stackoverflow.com/questions/64570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5726/" ]
PHP's explode function returns an array of strings split on some provided substring. It will return empty strings when there are leading, trailing, or consecutive delimiters, like this: ``` var_dump(explode('/', '1/2//3/')); array(5) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(0) "" [3]=> st...
Try [preg\_split](http://php.net/preg_split). `$exploded = preg_split('@/@', '1/2//3/', -1, PREG_SPLIT_NO_EMPTY);`
64,581
<p>Any information on how to display the ODBC connections dialog and get the chosen ODBC back?</p>
[ { "answer_id": 64978, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>OK since no one seems to have an answer, how about iterating throught the ODBC connections by DBSource, I.e. SQLServer or My...
2008/09/15
[ "https://Stackoverflow.com/questions/64581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Any information on how to display the ODBC connections dialog and get the chosen ODBC back?
``` // a_RootKey is Microsoft.Win32.RegistryKey // DSN is a class not provided in this code sample - you can see what properties are needed from the usage below. List<DSN> DsnList = new List<DSN>(); Microsoft.Win32.RegistryKey SearchKey = a_RootKey.OpenSubKey("SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources"); if (Sear...
64,602
<p>There are three assembly version attributes. What are differences? Is it ok if I use <code>AssemblyVersion</code> and ignore the rest?</p> <hr> <p>MSDN says:</p> <ul> <li><p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assemblyversionattribute" rel="noreferrer">AssemblyVersion</a>:</p> ...
[ { "answer_id": 64634, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 5, "selected": false, "text": "<p><code>AssemblyVersion</code> pretty much stays internal to .NET, while <code>AssemblyFileVersion</code> is what Windows s...
2008/09/15
[ "https://Stackoverflow.com/questions/64602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2361/" ]
There are three assembly version attributes. What are differences? Is it ok if I use `AssemblyVersion` and ignore the rest? --- MSDN says: * [AssemblyVersion](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assemblyversionattribute): > > Specifies the version of the assembly being attributed. > > ...
**AssemblyVersion** Where other assemblies that reference your assembly will look. If this number changes, other assemblies must update their references to your assembly! Only update this version if it breaks backward compatibility. The `AssemblyVersion` is required. I use the format: *major.minor* (and *major* for v...
64,605
<p>Is it possible to use both JScript and VBScript in the same HTA? Can I call VBScript functions from JScript and vice-versa? Are there any "gotchas," like the JScript running first and the VBScript running second (classic ASP pages have this issue).</p>
[ { "answer_id": 64638, "author": "Mark Brackett", "author_id": 2199, "author_profile": "https://Stackoverflow.com/users/2199", "pm_score": 5, "selected": true, "text": "<p>Yeah, just separate them into different script tags:</p>\n\n<pre><code>&lt;script language=\"javascript\"&gt;\n // ...
2008/09/15
[ "https://Stackoverflow.com/questions/64605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5616/" ]
Is it possible to use both JScript and VBScript in the same HTA? Can I call VBScript functions from JScript and vice-versa? Are there any "gotchas," like the JScript running first and the VBScript running second (classic ASP pages have this issue).
Yeah, just separate them into different script tags: ``` <script language="javascript"> // javascript code </script> <script language="vbscript"> ' vbscript code </script> ``` Edit: And, yeah, you can cross call between Javascript and VBScript with no extra work. Edit: This is also true of ANY Windows Script...
64,639
<p>What's the proper way to convert from a scientific notation string such as "1.234567E-06" to a floating point variable using C#?</p>
[ { "answer_id": 64662, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": true, "text": "<pre><code>Double.Parse(\"1.234567E-06\", System.Globalization.NumberStyles.Float);\n</code></pre>\n" }, { "answer_id": ...
2008/09/15
[ "https://Stackoverflow.com/questions/64639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2488/" ]
What's the proper way to convert from a scientific notation string such as "1.234567E-06" to a floating point variable using C#?
``` Double.Parse("1.234567E-06", System.Globalization.NumberStyles.Float); ```
64,640
<p>Someone please correct me if I'm wrong, but parsing a yyyy/MM/dd (or other specific formats) dates in C# <strong>should</strong> be as easy as </p> <pre><code>DateTime.ParseExact(theDate, "yyyy/MM/dd"); </code></pre> <p>but no, C# forces you to create an IFormatProvider.</p> <p>Is there an app.config friendly way...
[ { "answer_id": 64655, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>The IFormatProvider argument can be null.</p>\n" }, { "answer_id": 64675, "author": "John Sheehan", "author_i...
2008/09/15
[ "https://Stackoverflow.com/questions/64640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7311/" ]
Someone please correct me if I'm wrong, but parsing a yyyy/MM/dd (or other specific formats) dates in C# **should** be as easy as ``` DateTime.ParseExact(theDate, "yyyy/MM/dd"); ``` but no, C# forces you to create an IFormatProvider. Is there an app.config friendly way of setting this so I don't need to do this ea...
The IFormatProvider argument can be null.
64,649
<p>If I issue the <a href="https://en.wikipedia.org/wiki/Find_(Unix)" rel="noreferrer">find</a> command as follows:</p> <pre><code>find . -name *.ear </code></pre> <p>It prints out:</p> <pre><code>./dir1/dir2/earFile1.ear ./dir1/dir2/earFile2.ear ./dir1/dir3/earFile1.ear </code></pre> <p>I want to 'print' the name and ...
[ { "answer_id": 64666, "author": "Jeremy Weathers", "author_id": 8794, "author_profile": "https://Stackoverflow.com/users/8794", "pm_score": 0, "selected": false, "text": "<pre><code>find . -name \"*.ear\" -exec ls -l {} \\;\n</code></pre>\n" }, { "answer_id": 64678, "author":...
2008/09/15
[ "https://Stackoverflow.com/questions/64649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/700/" ]
If I issue the [find](https://en.wikipedia.org/wiki/Find_(Unix)) command as follows: ``` find . -name *.ear ``` It prints out: ``` ./dir1/dir2/earFile1.ear ./dir1/dir2/earFile2.ear ./dir1/dir3/earFile1.ear ``` I want to 'print' the name and the size to the command line: ``` ./dir1/dir2/earFile1.ear 5000 KB ./di...
``` find . -name '*.ear' -exec ls -lh {} \; ``` just the h extra from jer.drab.org's reply. saves time converting to MB mentally ;)
64,653
<p>I am trying to delete several rows from a MySQL 5.0.45 database:</p> <pre><code>delete from bundle_inclusions; </code></pre> <p>The client works for a while and then returns the error:</p> <pre><code>Lock wait timeout exceeded; try restarting transaction </code></pre> <p>It's possible there is some uncommitted t...
[ { "answer_id": 64695, "author": "Erik", "author_id": 6733, "author_profile": "https://Stackoverflow.com/users/6733", "pm_score": 2, "selected": false, "text": "<p>Guessing: truncate table bundle_inclusions</p>\n" }, { "answer_id": 64771, "author": "Matt Solnit", "author_...
2008/09/15
[ "https://Stackoverflow.com/questions/64653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8344/" ]
I am trying to delete several rows from a MySQL 5.0.45 database: ``` delete from bundle_inclusions; ``` The client works for a while and then returns the error: ``` Lock wait timeout exceeded; try restarting transaction ``` It's possible there is some uncommitted transaction out there that has a lock on this tabl...
I agree with Erik; TRUNCATE TABLE is the way to go. However, if you can't use that for some reason (for example, if you don't *really* want to delete every row in the table), you can try the following options: * Delete the rows in smaller batches (e.g. DELETE FROM bundle\_inclusions WHERE id BETWEEN ? and ?) * If it's...
64,689
<p>Is this function declaration in C#:</p> <pre><code>void foo(string mystring) </code></pre> <p>the same as this one in C:</p> <pre><code>void foo(char *) </code></pre> <p>i.e. In C#, does the called function receive a pointer behind the scenes?</p>
[ { "answer_id": 64710, "author": "Nate Kohari", "author_id": 1282, "author_profile": "https://Stackoverflow.com/users/1282", "pm_score": 2, "selected": false, "text": "<p>Essentially, yes. In C#, string (actually System.String) is a reference type, so when foo() is called, it receives a p...
2008/09/15
[ "https://Stackoverflow.com/questions/64689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
Is this function declaration in C#: ``` void foo(string mystring) ``` the same as this one in C: ``` void foo(char *) ``` i.e. In C#, does the called function receive a pointer behind the scenes?
In this specific instance, it is more like: ``` void foo(const char *); ``` .Net strings are immutable and passed by reference. However, in general C# receives a pointer or reference to an object behind the scenes.
64,693
<p>Theres is a little problem I want to solve with Haskell: let substitute a function that change all of the wildcards in a string for one concrete parameter. The function has de signature of:</p> <pre><code>subs :: String -&gt; String -&gt; String -&gt; String -- example: -- subs 'x' "x^3 + x + sin(x)" "6.2" will gen...
[ { "answer_id": 65479, "author": "Dan Dyer", "author_id": 5171, "author_profile": "https://Stackoverflow.com/users/5171", "pm_score": 4, "selected": true, "text": "<p>You could use the <a href=\"http://hackage.haskell.org/package/regex-compat-0.95.1\" rel=\"nofollow noreferrer\">Text.Rege...
2008/09/15
[ "https://Stackoverflow.com/questions/64693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6766/" ]
Theres is a little problem I want to solve with Haskell: let substitute a function that change all of the wildcards in a string for one concrete parameter. The function has de signature of: ``` subs :: String -> String -> String -> String -- example: -- subs 'x' "x^3 + x + sin(x)" "6.2" will generate -- "6.2^...
You could use the [Text.Regex](http://hackage.haskell.org/package/regex-compat-0.95.1) package. Your example might look something like this: ``` import Text.Regex(mkRegex, subRegex) subs :: String -> String -> String -> String subs wildcard input value = subRegex (mkRegex wildcard) input value ```
64,759
<p>I have a pdf file of a logo, about 1"x2" in dimension. Can anybody provide the code snippet to import that PDF logo into another PDF file using the <a href="http://framework.zend.com/manual/en/zend.pdf.html" rel="nofollow noreferrer">Zend_PDF</a> API's? </p> <p>Ideally, I'd like to be able to place it like the PN...
[ { "answer_id": 66011, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 1, "selected": false, "text": "<p>I believe you can <a href=\"http://framework.zend.com/manual/en/zend.pdf.pages.html#zend.pdf.pages.cloning\" rel=\"nofollo...
2008/09/15
[ "https://Stackoverflow.com/questions/64759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6824/" ]
I have a pdf file of a logo, about 1"x2" in dimension. Can anybody provide the code snippet to import that PDF logo into another PDF file using the [Zend\_PDF](http://framework.zend.com/manual/en/zend.pdf.html) API's? Ideally, I'd like to be able to place it like the PNG, TIFF or JPG objects with the Zend\_Pdf\_Image...
It looks like as of this date, there's no way to do it using the Zend\_PDF API's. The Zend\_Pdf\_Page class has a drawContentStream() which looked promising, but when I checked into it, the method body was empty. Maybe a later release of the API will support it. So, if you want place another PDF inside another dynami...
64,781
<p>I have a web application that receives messages through an HTTP interface, e.g.:</p> <pre><code>http://server/application?source=123&amp;destination=234&amp;text=hello </code></pre> <p>This request contains the ID of the sender, the ID of the recipient and the text of the message.</p> <p>This message should be pr...
[ { "answer_id": 65828, "author": "davetron5000", "author_id": 3029, "author_profile": "https://Stackoverflow.com/users/3029", "pm_score": 0, "selected": false, "text": "<p>What is your measure of \"requests/sec\"? In other words, what happens for the 31st request? What resource is being...
2008/09/15
[ "https://Stackoverflow.com/questions/64781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/686/" ]
I have a web application that receives messages through an HTTP interface, e.g.: ``` http://server/application?source=123&destination=234&text=hello ``` This request contains the ID of the sender, the ID of the recipient and the text of the message. This message should be processed like: * finding the matching Use...
You should decouple from the JPA interface and use the bare TopLink API. You can probably chuck the objects you're persisting into a UnitOfWork and commit the UnitOfWork on your schedule (sync or async). Note that one of the costs of em.persist() is the implicit clone that happens of the whole object graph. TopLink wil...
64,782
<pre><code>int i = 4; string text = "Player "; cout &lt;&lt; (text + i); </code></pre> <p>I'd like it to print <code>Player 4</code>.</p> <p>The above is obviously wrong but it shows what I'm trying to do here. Is there an easy way to do this or do I have to start adding new includes?</p>
[ { "answer_id": 64794, "author": "rupello", "author_id": 635, "author_profile": "https://Stackoverflow.com/users/635", "pm_score": 0, "selected": false, "text": "<pre><code>cout &lt;&lt; \"Player\" &lt;&lt; i ;\n</code></pre>\n" }, { "answer_id": 64795, "author": "Community", ...
2008/09/15
[ "https://Stackoverflow.com/questions/64782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` int i = 4; string text = "Player "; cout << (text + i); ``` I'd like it to print `Player 4`. The above is obviously wrong but it shows what I'm trying to do here. Is there an easy way to do this or do I have to start adding new includes?
Well, if you use cout you can just write the integer directly to it, as in ``` std::cout << text << i; ``` The C++ way of converting all kinds of objects to strings is through [string streams](http://en.cppreference.com/w/cpp/io/basic_stringstream). If you don't have one handy, just create one. ``` #include <sstrea...
64,786
<p>What is your favorite method to handle errors in Bash? The best example of handling errors I have found on the web was written by William Shotts, Jr at <a href="http://www.linuxcommand.org" rel="noreferrer">http://www.linuxcommand.org</a>. </p> <p>He suggests using the following function for error handling in Bash...
[ { "answer_id": 64880, "author": "pjz", "author_id": 8002, "author_profile": "https://Stackoverflow.com/users/8002", "pm_score": 2, "selected": false, "text": "<p>I've used</p>\n\n<pre><code>die() {\n echo $1\n kill $$\n}\n</code></pre>\n\n<p>before; i think because 'exit' w...
2008/09/15
[ "https://Stackoverflow.com/questions/64786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is your favorite method to handle errors in Bash? The best example of handling errors I have found on the web was written by William Shotts, Jr at <http://www.linuxcommand.org>. He suggests using the following function for error handling in Bash: ``` #!/bin/bash # A slicker error handling routine # I put a v...
Use a trap! ``` tempfiles=( ) cleanup() { rm -f "${tempfiles[@]}" } trap cleanup 0 error() { local parent_lineno="$1" local message="$2" local code="${3:-1}" if [[ -n "$message" ]] ; then echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}" else echo "Error on or ...
64,813
<p>These days, i came across a problem with Team System Unit Testing. I found that the automatically created accessor class ignores generic constraints - at least in the following case:</p> <p>Assume you have the following class:</p> <pre><code>namespace MyLibrary { public class MyClass { public Nullable&lt;T&gt;...
[ { "answer_id": 64877, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I vote bug. I don't see how this could be by design.</p>\n" }, { "answer_id": 168453, "author": "Zachary Yates"...
2008/09/15
[ "https://Stackoverflow.com/questions/64813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6777/" ]
These days, i came across a problem with Team System Unit Testing. I found that the automatically created accessor class ignores generic constraints - at least in the following case: Assume you have the following class: ``` namespace MyLibrary { public class MyClass { public Nullable<T> MyMethod<T>(string s) wher...
I vote bug. I don't see how this could be by design.
64,820
<p>ASP.NET 2.0 web application, how to implement shortcut key combination of <kbd>CTRL + Letter</kbd>, preferably through JavaScript, to make web application ergonomically better? How to capture multiple-key keyboard events through JavaScript?</p>
[ { "answer_id": 64879, "author": "dawnerd", "author_id": 69503, "author_profile": "https://Stackoverflow.com/users/69503", "pm_score": 2, "selected": false, "text": "<p>Javascript has support for <kbd>ctrl</kbd>+<kbd>alt</kbd>+<kbd>shift</kbd> keys. I assume you can figure out the rest. <...
2008/09/15
[ "https://Stackoverflow.com/questions/64820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8832/" ]
ASP.NET 2.0 web application, how to implement shortcut key combination of `CTRL + Letter`, preferably through JavaScript, to make web application ergonomically better? How to capture multiple-key keyboard events through JavaScript?
Your event listener function, gets passed an Event object. That has a lot of useful information on it, including the properties "altKey", "ctrlKey", "shiftKey" and "metaKey". If any of the modifier keys are being held down when that event fires, the corresponding property is set to true. This applies to keyboard as we...
64,827
<p>I've created a learning application using <a href="http://jimneath.org/2008/09/09/bort-base-rails-application/" rel="noreferrer">Bort</a>, which is a base app that includes Restful Authentication and RSpec. I've got it up and running and added a new object that requires users to be logged in before they can do anyt...
[ { "answer_id": 65748, "author": "TALlama", "author_id": 5657, "author_profile": "https://Stackoverflow.com/users/5657", "pm_score": 4, "selected": true, "text": "<p>I have a very similar setup, and below is the code I'm currently using to test this stuff. In each of the <code>describe</c...
2008/09/15
[ "https://Stackoverflow.com/questions/64827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6805/" ]
I've created a learning application using [Bort](http://jimneath.org/2008/09/09/bort-base-rails-application/), which is a base app that includes Restful Authentication and RSpec. I've got it up and running and added a new object that requires users to be logged in before they can do anything(`before_filter :login_requi...
I have a very similar setup, and below is the code I'm currently using to test this stuff. In each of the `describe`s I put in: ``` it_should_behave_like "login-required object" def attempt_access; do_post; end ``` If all you need is a login, or ``` it_should_behave_like "ownership-required object" def login_as_obj...
64,833
<p>I am writing a C# client that calls a web service written in Java (by another person). I have added a web reference to my client and I'm able to call methods in the web service ok.</p> <p>The service was changed to return an array of objects, and the client does not properly parse the returned SOAP message.</p> <...
[ { "answer_id": 64913, "author": "Xian", "author_id": 4642, "author_profile": "https://Stackoverflow.com/users/4642", "pm_score": 3, "selected": true, "text": "<p>It has been a while, but I seem to remember having trouble with the slight differences in how default namespaces were handled ...
2008/09/15
[ "https://Stackoverflow.com/questions/64833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7475/" ]
I am writing a C# client that calls a web service written in Java (by another person). I have added a web reference to my client and I'm able to call methods in the web service ok. The service was changed to return an array of objects, and the client does not properly parse the returned SOAP message. ``` MyResponse[]...
It has been a while, but I seem to remember having trouble with the slight differences in how default namespaces were handled between .Net and Java web services. Double check the generated c# proxy class and any namespaces declared within (especially the defaults xmlns=""), against what the Java service is expecting. ...
64,841
<p>I believe I need a DTD to define the schema and an XSLT if I want to display it in a browser and have it look "pretty". But I'm not sure what else I would need to have a well-defined XML document that can be queried using XQuery and displayed in a web browser.</p>
[ { "answer_id": 64869, "author": "Sebastian Redl", "author_id": 8922, "author_profile": "https://Stackoverflow.com/users/8922", "pm_score": 2, "selected": false, "text": "<p>Strictly speaking, you need nothing. XML, even without a schema definition, works.</p>\n\n<p>A schema definition (i...
2008/09/15
[ "https://Stackoverflow.com/questions/64841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
I believe I need a DTD to define the schema and an XSLT if I want to display it in a browser and have it look "pretty". But I'm not sure what else I would need to have a well-defined XML document that can be queried using XQuery and displayed in a web browser.
For a XML document to be queryable using XQquery you do not have to define a DTD or XSD. The purpose of DTD or XSD is to define the strict structure of a XML document and to allow validation before usage. Modern browsers interpret XML files very nicely and show a DOM tree. If enhanced formatting of XML for browser dis...
64,851
<p>How would you write (in C/C++) a macro which tests if an integer type (given as a parameter) is signed or unsigned?</p> <pre> #define is_this_type_signed (my_type) ... </pre>
[ { "answer_id": 64908, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 5, "selected": false, "text": "<p>In C++, use <code>std::numeric_limits&lt;type&gt;::is_signed</code>.</p>\n<pre><code>#include &lt;limits&gt;\nstd::numeric_...
2008/09/15
[ "https://Stackoverflow.com/questions/64851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4528/" ]
How would you write (in C/C++) a macro which tests if an integer type (given as a parameter) is signed or unsigned? ``` #define is_this_type_signed (my_type) ... ```
If what you want is a simple macro, this should do the trick: ``` #define is_type_signed(my_type) (((my_type)-1) < 0) ```
64,860
<p>What is the fastest, easiest tool or method to convert text files between character sets?</p> <p>Specifically, I need to convert from UTF-8 to ISO-8859-15 and vice versa.</p> <p>Everything goes: one-liners in your favorite scripting language, command-line tools or other utilities for OS, web sites, etc.</p> <h2>Best...
[ { "answer_id": 64878, "author": "Daniel Papasian", "author_id": 7548, "author_profile": "https://Stackoverflow.com/users/7548", "pm_score": 5, "selected": false, "text": "<p><a href=\"http://linux.die.net/man/1/iconv\" rel=\"noreferrer\">iconv(1)</a></p>\n\n<pre><code>iconv -f FROM-ENCOD...
2008/09/15
[ "https://Stackoverflow.com/questions/64860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2948/" ]
What is the fastest, easiest tool or method to convert text files between character sets? Specifically, I need to convert from UTF-8 to ISO-8859-15 and vice versa. Everything goes: one-liners in your favorite scripting language, command-line tools or other utilities for OS, web sites, etc. Best solutions so far: ---...
[Stand-alone utility](http://linux.die.net/man/1/iconv) approach ```none iconv -f ISO-8859-1 -t UTF-8 in.txt > out.txt ``` ```none -f ENCODING the encoding of the input -t ENCODING the encoding of the output ``` You don't have to specify either of these arguments. They will default to your current locale, which ...
64,894
<p>Is it possible to select from <code>show tables</code> in MySQL?</p> <pre><code>SELECT * FROM (SHOW TABLES) AS `my_tables` </code></pre> <p>Something along these lines, though the above does not work (on 5.0.51a, at least).</p>
[ { "answer_id": 64918, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Have you looked into querying INFORMATION_SCHEMA.Tables? As in</p>\n\n<pre><code>SELECT ic.Table_Name,\n ic.Column_Name,...
2008/09/15
[ "https://Stackoverflow.com/questions/64894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it possible to select from `show tables` in MySQL? ``` SELECT * FROM (SHOW TABLES) AS `my_tables` ``` Something along these lines, though the above does not work (on 5.0.51a, at least).
I think you want `SELECT * FROM INFORMATION_SCHEMA.TABLES` See <http://dev.mysql.com/doc/refman/5.0/en/tables-table.html>
64,904
<p>I need to support exact phrases (enclosed in quotes) in an otherwise space-separated list of terms. Thus splitting the respective string by the space-character is not sufficient anymore.</p> <p>Example:</p> <pre><code>input : 'foo bar "lorem ipsum" baz' output: ['foo', 'bar', 'lorem ipsum', 'baz'] </code></pre> <...
[ { "answer_id": 65033, "author": "shyam", "author_id": 7616, "author_profile": "https://Stackoverflow.com/users/7616", "pm_score": 1, "selected": false, "text": "<pre><code>'foo bar \"lorem ipsum\" baz'.match(/\"[^\"]*\"|\\w+/g);\n</code></pre>\n\n<p>the bounding quotes get included thoug...
2008/09/15
[ "https://Stackoverflow.com/questions/64904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to support exact phrases (enclosed in quotes) in an otherwise space-separated list of terms. Thus splitting the respective string by the space-character is not sufficient anymore. Example: ``` input : 'foo bar "lorem ipsum" baz' output: ['foo', 'bar', 'lorem ipsum', 'baz'] ``` I wonder whether this could be ...
``` var str = 'foo bar "lorem ipsum" baz'; var results = str.match(/("[^"]+"|[^"\s]+)/g); ``` ... returns the array you're looking for. Note, however: * Bounding quotes are included, so can be removed with `replace(/^"([^"]+)"$/,"$1")` on the results. * Spaces between the quotes will stay intact. So, if there a...
64,958
<p>Yacc does not permit objects to be passed around. Because the %union can only contain POD types, complex objects must be new'd and passed around by pointer. If a syntax error occurs, the yacc parser just stops running, and references to all of those created objects are lost.</p> <p>The only solution I've come up wi...
[ { "answer_id": 65096, "author": "Ron", "author_id": 9100, "author_profile": "https://Stackoverflow.com/users/9100", "pm_score": 1, "selected": false, "text": "<p>If it suits your project, consider using the Boehm Garbage collector. That way you can freely allocate new objects and let th...
2008/09/15
[ "https://Stackoverflow.com/questions/64958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8566/" ]
Yacc does not permit objects to be passed around. Because the %union can only contain POD types, complex objects must be new'd and passed around by pointer. If a syntax error occurs, the yacc parser just stops running, and references to all of those created objects are lost. The only solution I've come up with is that...
I love Yacc, but the discriminating union stack does present a challenge. I don't know whether you are using C or C++. I've modified Yacc to generate C++ for my own purposes, but this solution can be adapted to C. My preferred solution is to pass an interface to the owner down the parse tree, rather than constructed ...
64,977
<p>How do you create SQL Server 2005 stored procedure templates in SQL Server 2005 Management Studio?</p>
[ { "answer_id": 64995, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 2, "selected": false, "text": "<p>You bring up <em>Template Explorer</em> using Ctrl+Alt+T or trough <em>View > Template Explorer</em>. Then you can ...
2008/09/15
[ "https://Stackoverflow.com/questions/64977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7001/" ]
How do you create SQL Server 2005 stored procedure templates in SQL Server 2005 Management Studio?
Another little nugget that I think will help people developing and being more productive in their database development. I am a fan of stored procedures and functions when I develop software solutions. I like my actual CRUD methods to be implemented at the database level. It allows me to balance out my work between the ...
64,981
<p>How do I create a unique constraint on an existing table in SQL Server 2005?</p> <p>I am looking for both the TSQL and how to do it in the Database Diagram.</p>
[ { "answer_id": 65003, "author": "Ivan Bosnic", "author_id": 3221, "author_profile": "https://Stackoverflow.com/users/3221", "pm_score": 4, "selected": false, "text": "<pre><code>ALTER TABLE dbo.&lt;tablename&gt; ADD CONSTRAINT\n &lt;namingconventionconstraint&gt; UNIQUE NONCLU...
2008/09/15
[ "https://Stackoverflow.com/questions/64981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469/" ]
How do I create a unique constraint on an existing table in SQL Server 2005? I am looking for both the TSQL and how to do it in the Database Diagram.
The SQL command is: ``` ALTER TABLE <tablename> ADD CONSTRAINT <constraintname> UNIQUE NONCLUSTERED ( <columnname> ) ``` See the full syntax [here](http://msdn.microsoft.com/en-us/library/ms190273.aspx). If you want to do it from a Database Diagram: * right-click on the table an...
64,992
<p>I'm working with a support person who is supposed to be able to install SSL certs on a web server he maintains. He has local admin rights to the server via a domain security group. He also has permissions on our internal CA running Windows 2003 Server Certificate Authority: "Request cert" and "Issue and Manage cer...
[ { "answer_id": 65542, "author": "JWHEAT", "author_id": 7079, "author_profile": "https://Stackoverflow.com/users/7079", "pm_score": 3, "selected": false, "text": "<p>I had this exact same issue a few months ago when I was setting up a cert for a client.</p>\n\n<p>There's a MachineKeys fol...
2008/09/15
[ "https://Stackoverflow.com/questions/64992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3347/" ]
I'm working with a support person who is supposed to be able to install SSL certs on a web server he maintains. He has local admin rights to the server via a domain security group. He also has permissions on our internal CA running Windows 2003 Server Certificate Authority: "Request cert" and "Issue and Manage certs". ...
I had this exact same issue a few months ago when I was setting up a cert for a client. There's a MachineKeys folder that the Administrator need rights - ``` \Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys ``` give **Administrator** (or the Administrator group) **Full Control** o...
65,008
<p>I am experimenting with using the FaultException and FaultException&lt;T&gt; to determine the best usage pattern in our applications. We need to support WCF as well as non-WCF service consumers/clients, including SOAP 1.1 and SOAP 1.2 clients.</p> <p>FYI: using FaultExceptions with wsHttpBinding results in SOAP 1.2...
[ { "answer_id": 69390, "author": "wojo", "author_id": 9022, "author_profile": "https://Stackoverflow.com/users/9022", "pm_score": 4, "selected": true, "text": "<p>This is my current workaround:</p>\n\n<pre><code> /// &lt;summary&gt;\n /// Replacement for the static methods on FaultC...
2008/09/15
[ "https://Stackoverflow.com/questions/65008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9022/" ]
I am experimenting with using the FaultException and FaultException<T> to determine the best usage pattern in our applications. We need to support WCF as well as non-WCF service consumers/clients, including SOAP 1.1 and SOAP 1.2 clients. FYI: using FaultExceptions with wsHttpBinding results in SOAP 1.2 semantics where...
This is my current workaround: ``` /// <summary> /// Replacement for the static methods on FaultCode to generate Sender and Receiver fault codes due /// to what seems like bugs in the implementation for basicHttpBinding (SOAP 1.1). wsHttpBinding /// (SOAP 1.2) seems to work just fine. /// ///...
65,034
<p>How would I remove the border from an iframe embedded in my web app? An example of the iframe is:</p> <pre><code>&lt;iframe src="myURL" width="300" height="300"&gt;Browser not compatible.&lt;/iframe&gt; </code></pre> <p>I would like the transition from the content on my page to the contents of the iframe to be sea...
[ { "answer_id": 65052, "author": "David Basarab", "author_id": 2469, "author_profile": "https://Stackoverflow.com/users/2469", "pm_score": 11, "selected": true, "text": "<p>Add the <code>frameBorder</code> attribute (note the <strong>capital ‘B’</strong>).</p>\n\n<p>So it would look like:...
2008/09/15
[ "https://Stackoverflow.com/questions/65034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2650/" ]
How would I remove the border from an iframe embedded in my web app? An example of the iframe is: ``` <iframe src="myURL" width="300" height="300">Browser not compatible.</iframe> ``` I would like the transition from the content on my page to the contents of the iframe to be seamless, assuming the background colors ...
Add the `frameBorder` attribute (note the **capital ‘B’**). So it would look like: ``` <iframe src="myURL" width="300" height="300" frameBorder="0">Browser not compatible.</iframe> ```
65,035
<p>Considering this code, can I be <em>absolutely sure</em> that the <code>finally</code> block always executes, no matter what <code>something()</code> is?</p> <pre><code>try { something(); return success; } catch (Exception e) { return failure; } finally { System.out.println("I don't...
[ { "answer_id": 65049, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 13, "selected": true, "text": "<p>Yes, <code>finally</code> will be called after the execution of the <code>try</code> or <code>catch</code> code blocks.<...
2008/09/15
[ "https://Stackoverflow.com/questions/65035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/885027/" ]
Considering this code, can I be *absolutely sure* that the `finally` block always executes, no matter what `something()` is? ``` try { something(); return success; } catch (Exception e) { return failure; } finally { System.out.println("I don't know if this will get printed out"); } ``...
Yes, `finally` will be called after the execution of the `try` or `catch` code blocks. The only times `finally` won't be called are: 1. If you invoke `System.exit()` 2. If you invoke `Runtime.getRuntime().halt(exitStatus)` 3. If the JVM crashes first 4. If the JVM reaches an infinite loop (or some other non-interrupt...
65,037
<p>As far as I know, in gcc you can write something like:</p> <pre><code>#define DBGPRINT(fmt...) printf(fmt); </code></pre> <p>Is there a way to do that in VC++?</p>
[ { "answer_id": 65067, "author": "kfh", "author_id": 6597, "author_profile": "https://Stackoverflow.com/users/6597", "pm_score": -1, "selected": false, "text": "<p>Almost. It's uglier than that though (and you probably don't want a trailing semi-colon in the macro itself:</p>\n\n<pre><cod...
2008/09/15
[ "https://Stackoverflow.com/questions/65037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9102/" ]
As far as I know, in gcc you can write something like: ``` #define DBGPRINT(fmt...) printf(fmt); ``` Is there a way to do that in VC++?
Yes but only since VC++ 2005. The syntax for your example would be: ``` #define DBGPRINT(fmt, ...) printf(fmt, __VA_ARGS__) ``` A full reference is [here](http://msdn.microsoft.com/en-us/library/ms177415(VS.80).aspx).
65,039
<p>I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional HTML IDs in the code. </p> <p>There is heavy use of <code>CssClass='&amp;hellip;'</code>, or sometimes just <code>class='&amp;hellip;'</code>, but I can't seem to find a way to say id='&hellip;' and not have it sw...
[ { "answer_id": 65051, "author": "Matt Dawdy", "author_id": 232, "author_profile": "https://Stackoverflow.com/users/232", "pm_score": 0, "selected": false, "text": "<p>.Net will always replace your id values with some mangled (every so slightly predictable, but still don't count on it) va...
2008/09/15
[ "https://Stackoverflow.com/questions/65039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am refactoring some CSS on a website. I have been working on, and noticed the absence of traditional HTML IDs in the code. There is heavy use of `CssClass='&hellip;'`, or sometimes just `class='&hellip;'`, but I can't seem to find a way to say id='…' and not have it swapped out by the server. Here is an example: ...
The 'crap' placed in front of the id is related to the container(s) of the control and there is no way (as far as I know) to prevent this behavior, other than not putting it in any container. If you need to refer to the id in script, you can use the ClientID of the control, like so: ``` <script type="text/javascript...
65,060
<p>If i have a simple named query defined, the preforms a count function, on one column:</p> <pre><code> &lt;query name="Activity.GetAllMiles"&gt; &lt;![CDATA[ select sum(Distance) from Activity ]]&gt; &lt;/query&gt; </code></pre> <p>How do I get the result of a sum or any query that dont return of ...
[ { "answer_id": 67675, "author": "Matt Hinze", "author_id": 2676, "author_profile": "https://Stackoverflow.com/users/2676", "pm_score": 2, "selected": false, "text": "<p>As an indirect answer to your question, here is how I do it without a named query.</p>\n\n<pre><code>var session = GetS...
2008/09/15
[ "https://Stackoverflow.com/questions/65060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/230/" ]
If i have a simple named query defined, the preforms a count function, on one column: ``` <query name="Activity.GetAllMiles"> <![CDATA[ select sum(Distance) from Activity ]]> </query> ``` How do I get the result of a sum or any query that dont return of one the mapped entities, with NHibernate usi...
Sorry! I actually wanted a sum, not a count, which explains alot. Iv edited the post accordingly This works fine: ``` var criteria = session.CreateCriteria(typeof(Activity)) .SetProjection(Projections.Sum("Distance")); return (double)criteria.UniqueResult(); ``` The named query approach...
65,071
<p>Is there a performant equivalent to the isnull function for DB2?</p> <p>Imagine some of our products are internal, so they don't have names:</p> <pre><code>Select product.id, isnull(product.name, "Internal) From product </code></pre> <p>Might return:</p> <pre><code>1 Socks 2 Shoes 3 Internal 4 Pants </code><...
[ { "answer_id": 65111, "author": "Chris Shaffer", "author_id": 6744, "author_profile": "https://Stackoverflow.com/users/6744", "pm_score": 2, "selected": false, "text": "<p>I'm not familiar with DB2, but have you tried COALESCE?</p>\n\n<p>ie:</p>\n\n<pre><code>\nSELECT Product.ID, COALESC...
2008/09/15
[ "https://Stackoverflow.com/questions/65071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056/" ]
Is there a performant equivalent to the isnull function for DB2? Imagine some of our products are internal, so they don't have names: ``` Select product.id, isnull(product.name, "Internal) From product ``` Might return: ``` 1 Socks 2 Shoes 3 Internal 4 Pants ```
For what its worth, COALESCE is similiar but ``` IFNULL(expr1, default) ``` is the exact match you're looking for in DB2. COALESCE allows multiple arguments, returning the first NON NULL expression, whereas IFNULL only permits the expression and the default. Thus ``` SELECT product.ID, IFNULL(product.Name, "Int...
65,074
<p>I've just started writing unit tests for a legacy code module with large physical dependencies using the #include directive. I've been dealing with them a few ways that felt overly tedious (providing empty headers to break long #include dependency lists, and using #define to prevent classes from being compiled) and ...
[ { "answer_id": 65121, "author": "Pieter", "author_id": 5822, "author_profile": "https://Stackoverflow.com/users/5822", "pm_score": 1, "selected": false, "text": "<p>Since you're testing legacy code I'm assuming you can't refactor said code to have less dependencies (e.g. by using the <a ...
2008/09/15
[ "https://Stackoverflow.com/questions/65074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8908/" ]
I've just started writing unit tests for a legacy code module with large physical dependencies using the #include directive. I've been dealing with them a few ways that felt overly tedious (providing empty headers to break long #include dependency lists, and using #define to prevent classes from being compiled) and was...
The depression in the responses is overwhelming... But don't fear, we've got [the holy book to exorcise the demons of legacy C++ code](https://rads.stackoverflow.com/amzn/click/com/0131177052). Seriously just buy the book if you are in line for more than a week of jousting with legacy C++ code. Turn to page 127: **The...
65,076
<p>I've trouble setting up Vim (7.1.xxx) for editing Python files (*.py). Indenting seems to be broken (optimal 4 spaces). I've followed some tutorials I found via Google. Still no effect :/ Please help.</p>
[ { "answer_id": 65122, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://Stackoverflow.com/users/2260", "pm_score": 6, "selected": false, "text": "<p>I use this on my macbook:</p>\n\n<pre><code>\" configure expanding of tabs for various file types\nau BufRead,BufNewF...
2008/09/15
[ "https://Stackoverflow.com/questions/65076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9099/" ]
I've trouble setting up Vim (7.1.xxx) for editing Python files (\*.py). Indenting seems to be broken (optimal 4 spaces). I've followed some tutorials I found via Google. Still no effect :/ Please help.
I use this on my macbook: ``` " configure expanding of tabs for various file types au BufRead,BufNewFile *.py set expandtab au BufRead,BufNewFile *.c set expandtab au BufRead,BufNewFile *.h set expandtab au BufRead,BufNewFile Makefile* set noexpandtab " ----------------------------------------------------------------...
65,091
<p>I'd like to be able to write a PHP class that behaves like an array and uses normal array syntax for getting &amp; setting.</p> <p>For example (where Foo is a PHP class of my making):</p> <pre><code>$foo = new Foo(); $foo['fooKey'] = 'foo value'; echo $foo['fooKey']; </code></pre> <p>I know that PHP has the _ge...
[ { "answer_id": 65136, "author": "Mat Mannion", "author_id": 6282, "author_profile": "https://Stackoverflow.com/users/6282", "pm_score": 6, "selected": true, "text": "<p>If you extend <code>ArrayObject</code> or implement <code>ArrayAccess</code> then you can do what you want.</p>\n\n<ul>...
2008/09/15
[ "https://Stackoverflow.com/questions/65091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305/" ]
I'd like to be able to write a PHP class that behaves like an array and uses normal array syntax for getting & setting. For example (where Foo is a PHP class of my making): ``` $foo = new Foo(); $foo['fooKey'] = 'foo value'; echo $foo['fooKey']; ``` I know that PHP has the \_get and \_set magic methods but those ...
If you extend `ArrayObject` or implement `ArrayAccess` then you can do what you want. * [ArrayObject](http://php.net/arrayobject) * [ArrayAccess](http://php.net/arrayaccess)
65,095
<p>What are the common algorithms being used to measure the processor frequency?</p>
[ { "answer_id": 65159, "author": "Todd Gamblin", "author_id": 9122, "author_profile": "https://Stackoverflow.com/users/9122", "pm_score": 0, "selected": false, "text": "<p>I'm not sure why you need assembly for this. If you're on a machine that has the /proc filesystem, then running:</p>...
2008/09/15
[ "https://Stackoverflow.com/questions/65095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What are the common algorithms being used to measure the processor frequency?
Intel CPUs after Core Duo support two Model-Specific registers called IA32\_MPERF and IA32\_APERF. MPERF counts at the maximum frequency the CPU supports, while APERF counts at the actual current frequency. The actual frequency is given by: ![freq = max_frequency * APERF / MPERF](https://chart.apis.google.com/char...
65,097
<p>I'm evaluating Server 2008. My C++ executable is getting this error. I've seen this error on MSDN that seems to have required a hot-fix for several previous OSes. Anyone else seen this? I get the same results for the 32 &amp; 64 bit OS.</p> <p>Code snippet:</p> <pre><code>HRESULT GroupStart([in] short iClientId, [...
[ { "answer_id": 66322, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 2, "selected": false, "text": "<p>We ran into the same error recently with a client/server app communicating via DCOM. It turned out that the size ...
2008/09/15
[ "https://Stackoverflow.com/questions/65097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9111/" ]
I'm evaluating Server 2008. My C++ executable is getting this error. I've seen this error on MSDN that seems to have required a hot-fix for several previous OSes. Anyone else seen this? I get the same results for the 32 & 64 bit OS. Code snippet: ``` HRESULT GroupStart([in] short iClientId, [in] VARIANT GroupDataArra...
We ran into the same error recently with a client/server app communicating via DCOM. It turned out that the size of a marshalled interface pointer going across the wire (i.e., not local) had changed (gotten bigger). You might like to check whether your code is doing any special marshalling via CoMarshalInterface or the...
65,170
<p>What's the easiest way to get the filename associated with an open HANDLE in Win32?</p>
[ { "answer_id": 65252, "author": "Daniel Papasian", "author_id": 7548, "author_profile": "https://Stackoverflow.com/users/7548", "pm_score": 0, "selected": false, "text": "<p>On unixes there is no real way of reliably doing this. In unix with the traditional unix filesystem, you can open...
2008/09/15
[ "https://Stackoverflow.com/questions/65170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4842/" ]
What's the easiest way to get the filename associated with an open HANDLE in Win32?
There is a correct (although undocumented) way to do this on Windows XP **which also works with directories** -- the same method [GetFinalPathNameByHandle](http://msdn.microsoft.com/en-us/library/aa364962.aspx) uses on Windows Vista and later. Here are the eneded declarations. Some of these are already in `WInternl.h`...
65,173
<p>I'm trying to run PHP from the command line under <a href="https://en.wikipedia.org/wiki/Windows_XP" rel="nofollow noreferrer">Windows XP</a>.</p> <p>That works, except for the fact that I am not able to provide parameters to my PHP script.</p> <p>My test case:</p> <pre><code>echo &quot;param = &quot; . $param . &qu...
[ { "answer_id": 65233, "author": "Adam Wright", "author_id": 1200, "author_profile": "https://Stackoverflow.com/users/1200", "pm_score": 3, "selected": false, "text": "<p>Why do you have any expectation that <em>param</em> will be set to the value?</p>\n<p>You're responsible for parsing t...
2008/09/15
[ "https://Stackoverflow.com/questions/65173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to run PHP from the command line under [Windows XP](https://en.wikipedia.org/wiki/Windows_XP). That works, except for the fact that I am not able to provide parameters to my PHP script. My test case: ``` echo "param = " . $param . "\n"; var_dump($argv); ``` I want to call this as: ``` php.exe -f test.p...
Why do you have any expectation that *param* will be set to the value? You're responsible for parsing the command line in the fashion you desire, from the *$argv* array.
65,205
<p>What's the best way to store a linked list in a MySQL database so that inserts are simple (i.e. you don't have to re-index a bunch of stuff every time) and such that the list can easily be pulled out in order?</p>
[ { "answer_id": 65229, "author": "Daniel Papasian", "author_id": 7548, "author_profile": "https://Stackoverflow.com/users/7548", "pm_score": -1, "selected": false, "text": "<p>A list can be stored by having a column contain the offset (list index position) -- an insert in the middle is th...
2008/09/15
[ "https://Stackoverflow.com/questions/65205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What's the best way to store a linked list in a MySQL database so that inserts are simple (i.e. you don't have to re-index a bunch of stuff every time) and such that the list can easily be pulled out in order?
Store an integer column in your table called 'position'. Record a 0 for the first item in your list, a 1 for the second item, etc. Index that column in your database, and when you want to pull your values out, sort by that column. ``` alter table linked_list add column position integer not null default 0; alter tabl...
65,206
<p>Using <a href="http://en.wikipedia.org/wiki/JQuery" rel="noreferrer">jQuery</a>, how can I dynamically set the size attribute of a select box?</p> <p>I would like to include it in this code:</p> <pre><code>$("#mySelect").bind("click", function() { $("#myOtherSelect").children().remove(); var op...
[ { "answer_id": 65239, "author": "Loren Segal", "author_id": 6436, "author_profile": "https://Stackoverflow.com/users/6436", "pm_score": 6, "selected": true, "text": "<p>Oops, it's</p>\n\n<pre><code>$('#mySelect').attr('size', value)\n</code></pre>\n" }, { "answer_id": 65261, ...
2008/09/15
[ "https://Stackoverflow.com/questions/65206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
Using [jQuery](http://en.wikipedia.org/wiki/JQuery), how can I dynamically set the size attribute of a select box? I would like to include it in this code: ``` $("#mySelect").bind("click", function() { $("#myOtherSelect").children().remove(); var options = '' ; for (var i = 0; i < myArray[...
Oops, it's ``` $('#mySelect').attr('size', value) ```
65,209
<p>I was recently asked to come up with a script that will allow the end user to upload a PSD (Photoshop) file, and split it up and create images from each of the layers.</p> <p>I would love to stay with PHP for this, but I am open to Python or Perl as well.</p> <p>Any ideas would be greatly appreciated.</p>
[ { "answer_id": 65239, "author": "Loren Segal", "author_id": 6436, "author_profile": "https://Stackoverflow.com/users/6436", "pm_score": 6, "selected": true, "text": "<p>Oops, it's</p>\n\n<pre><code>$('#mySelect').attr('size', value)\n</code></pre>\n" }, { "answer_id": 65261, ...
2008/09/15
[ "https://Stackoverflow.com/questions/65209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9176/" ]
I was recently asked to come up with a script that will allow the end user to upload a PSD (Photoshop) file, and split it up and create images from each of the layers. I would love to stay with PHP for this, but I am open to Python or Perl as well. Any ideas would be greatly appreciated.
Oops, it's ``` $('#mySelect').attr('size', value) ```
65,250
<p>Convert a .doc or .pdf to an image and display a thumbnail in Ruby?<br> Does anyone know how to generate document thumbnails in Ruby (or C, python...)</p>
[ { "answer_id": 65287, "author": "Loren Segal", "author_id": 6436, "author_profile": "https://Stackoverflow.com/users/6436", "pm_score": 0, "selected": false, "text": "<p>Not sure about .doc support in any open source library but ImageMagick (and the RMagick gem) can be compiled with pdf ...
2008/09/15
[ "https://Stackoverflow.com/questions/65250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Convert a .doc or .pdf to an image and display a thumbnail in Ruby? Does anyone know how to generate document thumbnails in Ruby (or C, python...)
A simple RMagick example to convert a PDF to a PNG would be: ``` require 'RMagick' pdf = Magick::ImageList.new("doc.pdf") thumb = pdf.scale(300, 300) thumb.write "doc.png" ``` To convert a MS Word document, it won't be as easy. Your best option may be to first convert it to a PDF before generating the thumbnail. You...
65,266
<p>Each time a python file is imported that contains a large quantity of static regular expressions, cpu cycles are spent compiling the strings into their representative state machines in memory.</p> <pre><code>a = re.compile("a.*b") b = re.compile("c.*d") ... </code></pre> <p>Question: Is it possible to store these ...
[ { "answer_id": 65333, "author": "Toni Ruža", "author_id": 6267, "author_profile": "https://Stackoverflow.com/users/6267", "pm_score": 2, "selected": false, "text": "<p>Note that each module initializes itself only once during the life of an app, no matter how many times you import it. So...
2008/09/15
[ "https://Stackoverflow.com/questions/65266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9241/" ]
Each time a python file is imported that contains a large quantity of static regular expressions, cpu cycles are spent compiling the strings into their representative state machines in memory. ``` a = re.compile("a.*b") b = re.compile("c.*d") ... ``` Question: Is it possible to store these regular expressions in a c...
> > Is it possible to store these regular expressions in a cache on disk in a pre-compiled manner to avoid having to execute the regex compilations on each import? > > > Not easily. You'd have to write a custom serializer that hooks into the C `sre` implementation of the Python regex engine. Any performance benefi...
65,310
<p>I am using Apache Axis to connect my Java app to a web server. I used wsdl2java to create the stubs for me, but when I try to use the stubs, I get the following exception:</p> <blockquote> <p>org.apache.axis.ConfigurationException: No service named <code>&lt;web service name&gt;</code> is available</p> </blockquo...
[ { "answer_id": 65575, "author": "ScArcher2", "author_id": 1310, "author_profile": "https://Stackoverflow.com/users/1310", "pm_score": 0, "selected": false, "text": "<p>This is what my code looks like. It seems to work fine.\nAre you using a service locator or just creating your service?<...
2008/09/15
[ "https://Stackoverflow.com/questions/65310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2328/" ]
I am using Apache Axis to connect my Java app to a web server. I used wsdl2java to create the stubs for me, but when I try to use the stubs, I get the following exception: > > org.apache.axis.ConfigurationException: No service named `<web service name>` is available > > > any idea?
Just a guess, but it looks like that error message is reporting that you've left the service name blank. I imagine the code that generates that error message looks like this: ``` throw new ConfigurationException("No service named" + serviceName + " is available"); ```
65,351
<p>I have a generic method defined like this:</p> <pre><code>public void MyMethod&lt;T&gt;(T myArgument) </code></pre> <p>The first thing I want to do is check if the value of myArgument is the default value for that type, something like this:</p> <pre><code>if (myArgument == default(T)) </code></pre> <p>But this d...
[ { "answer_id": 65423, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 5, "selected": false, "text": "<p>I was able to locate a <a href=\"http://msdn.microsoft.com/en-us/library/system.icomparable.compareto.aspx\" rel=\...
2008/09/15
[ "https://Stackoverflow.com/questions/65351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8739/" ]
I have a generic method defined like this: ``` public void MyMethod<T>(T myArgument) ``` The first thing I want to do is check if the value of myArgument is the default value for that type, something like this: ``` if (myArgument == default(T)) ``` But this doesn't compile because I haven't guaranteed that T will...
To avoid boxing, the best way to compare generics for equality is with `EqualityComparer<T>.Default`. This respects `IEquatable<T>` (without boxing) as well as `object.Equals`, and handles all the `Nullable<T>` "lifted" nuances. Hence: ``` if(EqualityComparer<T>.Default.Equals(obj, default(T))) { return obj; } ``...
65,364
<p>I've created a seperate assembly with a class that is intended to be published through wmi. Then I've created a windows forms app that references that assembly and attempts to publish the class. When I try to publish the class, I get an exception of type System.Management.Instrumentation.WmiProviderInstallation...
[ { "answer_id": 69618, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": true, "text": "<p>I used gacutil - installutil to to test your class (as a dll). The gacutil part worked, but installutil (actually mofcomp) co...
2008/09/15
[ "https://Stackoverflow.com/questions/65364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
I've created a seperate assembly with a class that is intended to be published through wmi. Then I've created a windows forms app that references that assembly and attempts to publish the class. When I try to publish the class, I get an exception of type System.Management.Instrumentation.WmiProviderInstallationExce...
I used gacutil - installutil to to test your class (as a dll). The gacutil part worked, but installutil (actually mofcomp) complained about a syntax error: ... error SYNTAX 0X80044014: Unexpected character in class name (must be an identifier) Compiler returned error 0x80044014 ... So I changed the class name to '...
65,400
<p>How do I add an instance method to a class using a metaclass (yes I do need to use a metaclass)? The following kind of works, but the func_name will still be "foo":</p> <pre><code>def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): dict["foobar"] = bar retur...
[ { "answer_id": 65682, "author": "Nathan Shively-Sanders", "author_id": 7851, "author_profile": "https://Stackoverflow.com/users/7851", "pm_score": 2, "selected": false, "text": "<p>I think what you want to do is this:</p>\n\n<pre><code>&gt;&gt;&gt; class Foo():\n... def __init__(self, ...
2008/09/15
[ "https://Stackoverflow.com/questions/65400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5179/" ]
How do I add an instance method to a class using a metaclass (yes I do need to use a metaclass)? The following kind of works, but the func\_name will still be "foo": ``` def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): dict["foobar"] = bar return type(name, ...
Try dynamically extending the bases that way you can take advantage of the mro and the methods are actual methods: ``` class Parent(object): def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): return type(name, (Parent,) + bases, dict) class Foo(object): _...
65,427
<p>As I understand it, anything created with an <strong>alloc</strong>, <strong>new</strong>, or <strong>copy</strong> needs to be manually released. For example:</p> <pre><code>int main(void) { NSString *string; string = [[NSString alloc] init]; /* use the string */ [string release]; } </code></pre> ...
[ { "answer_id": 65483, "author": "kperryua", "author_id": 72126, "author_profile": "https://Stackoverflow.com/users/72126", "pm_score": 7, "selected": true, "text": "<p>Yes, your second code snippit is perfectly valid.</p>\n\n<p>Every time -autorelease is sent to an object, it is added to...
2008/09/15
[ "https://Stackoverflow.com/questions/65427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7979/" ]
As I understand it, anything created with an **alloc**, **new**, or **copy** needs to be manually released. For example: ``` int main(void) { NSString *string; string = [[NSString alloc] init]; /* use the string */ [string release]; } ``` My question, though, is wouldn't this be just as valid?: ``` ...
Yes, your second code snippit is perfectly valid. Every time -autorelease is sent to an object, it is added to the inner-most autorelease pool. When the pool is drained, it simply sends -release to all the objects in the pool. Autorelease pools are simply a convenience that allows you to defer sending -release until ...
65,431
<p>Is there a reliable way to detect whether or not WinHelp is installed on Windows Vista or newer versions of Windows? If possible, I'd like a solution that's not specific to any particular version of Windows.</p> <p>I've posted this question to other message boards and got back answers regarding the size of Winhlp32...
[ { "answer_id": 65672, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 0, "selected": false, "text": "<p>I hate to say it, but move on from WinHelp. It's been deprecated for a reason. We were able to migrate to a .chm in only ...
2008/09/15
[ "https://Stackoverflow.com/questions/65431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a reliable way to detect whether or not WinHelp is installed on Windows Vista or newer versions of Windows? If possible, I'd like a solution that's not specific to any particular version of Windows. I've posted this question to other message boards and got back answers regarding the size of Winhlp32.exe befor...
The download for WinHelp from Microsoft appears to be a hotfix (.msu) that enables the WinHelp program. This would explain why the size/registry keys don't change as the hotfix is just a "delta" change from the orginal file. Since it's a hotfix, this means that you should be able to query the installed hotfixes for y...
65,434
<p>I know there are some ways to get notified when the page body has loaded (before all the images and 3rd party resources load which fires the <strong>window.onload</strong> event), but it's different for every browser.</p> <p>Is there a definitive way to do this on all the browsers?</p> <p>So far I know of:</p> <u...
[ { "answer_id": 65455, "author": "Sijin", "author_id": 8884, "author_profile": "https://Stackoverflow.com/users/8884", "pm_score": 1, "selected": false, "text": "<p>Just take the relevant piece of code from jQuery, John Resig has covered most of the bases on this issue already in jQuery.<...
2008/09/15
[ "https://Stackoverflow.com/questions/65434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4465/" ]
I know there are some ways to get notified when the page body has loaded (before all the images and 3rd party resources load which fires the **window.onload** event), but it's different for every browser. Is there a definitive way to do this on all the browsers? So far I know of: * **DOMContentLoaded** : On Mozilla,...
There's no cross-browser method for checking when the DOM is ready -- this is why libraries like jQuery exist, to abstract away nasty little bits of incompatibility. Mozilla, Opera, and modern WebKit support the `DOMContentLoaded` event. IE and Safari need weird hacks like scrolling the window or checking stylesheets....
65,447
<p>A sample perl script that connects to an oracle database, does a simple SELECT query, and spits the results to stdout in CSV format would be great. Python or any other language available in a typical unix distribution would be fine too. </p> <p>Note that I'm starting from scratch with nothing but a username/passw...
[ { "answer_id": 65568, "author": "Jumpy", "author_id": 9416, "author_profile": "https://Stackoverflow.com/users/9416", "pm_score": 3, "selected": true, "text": "<p>In perl you could do something like this, leaving out all the my local variable declarations and ... or die \"failmessage\" e...
2008/09/15
[ "https://Stackoverflow.com/questions/65447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
A sample perl script that connects to an oracle database, does a simple SELECT query, and spits the results to stdout in CSV format would be great. Python or any other language available in a typical unix distribution would be fine too. Note that I'm starting from scratch with nothing but a username/password for a re...
In perl you could do something like this, leaving out all the my local variable declarations and ... or die "failmessage" error handling for brevity. ``` use DBI; use DBD::Oracle; $dbh = DBI->connect( "dbi:Oracle:host=127.0.0.1;sid=XE", "username", "password" ); # some settings that you usually want for oracle 10 $...
65,452
<p>This morning I ran into an issue with returning back a text string as result from a Web Service call. the Error I was getting is below</p> <pre><code>************** Exception Text ************** System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'GetFilingTreeXML'...
[ { "answer_id": 65499, "author": "MikeScott8", "author_id": 1889, "author_profile": "https://Stackoverflow.com/users/1889", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://joewirtley.blogspot.com/2007/08/maximum-string-content-length-and.html\" rel=\"nofollow noreferrer\">J...
2008/09/15
[ "https://Stackoverflow.com/questions/65452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1889/" ]
This morning I ran into an issue with returning back a text string as result from a Web Service call. the Error I was getting is below ``` ************** Exception Text ************** System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'GetFilingTreeXML'. ---> System....
Try this blog post [here](https://web.archive.org/web/20210128000850/http://geekswithblogs.net/niemguy/archive/2007/12/11/wcf-maxstringcontentlength-maxbuffersize-and-maxreceivedmessagesize.aspx). You can modify the MaxStringContentLength property in the Binding configuration.
65,456
<p>I'm specifically interested in tools that can be plugged into Vim to allow CScope-style source browsing (1-2 keystroke commands to locate function definitions, callers, global symbols and so on) for languages besides C/C++ such as Java and C# (since Vim and Cscope already integrate very well for browsing C/C++). I'm...
[ { "answer_id": 65544, "author": "Lucas Oman", "author_id": 6726, "author_profile": "https://Stackoverflow.com/users/6726", "pm_score": -1, "selected": false, "text": "<p>This may be what you're looking for:</p>\n\n<p><a href=\"http://www.vim.org/scripts/script.php?script_id=1783\" rel=\"...
2008/09/15
[ "https://Stackoverflow.com/questions/65456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8998/" ]
I'm specifically interested in tools that can be plugged into Vim to allow CScope-style source browsing (1-2 keystroke commands to locate function definitions, callers, global symbols and so on) for languages besides C/C++ such as Java and C# (since Vim and Cscope already integrate very well for browsing C/C++). I'm no...
CScope does work for Java. From <http://cscope.sourceforge.net/cscope_vim_tutorial.html>: > > Although Cscope was originally intended only for use with C code, it's > actually a very flexible tool that works well with languages like C++ > and Java. You can think of it as a generic 'grep' database, with the > abil...