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
65,491
<p>When working with large and/or many Javascript and CSS files, what's the best way to reduce the file sizes?</p>
[ { "answer_id": 65503, "author": "Mark Biek", "author_id": 305, "author_profile": "https://Stackoverflow.com/users/305", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://developer.yahoo.net/blog/archives/2007/07/high_performanc_8.html\" rel=\"nofollow noreferrer\">Minify</a>...
2008/09/15
[ "https://Stackoverflow.com/questions/65491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
When working with large and/or many Javascript and CSS files, what's the best way to reduce the file sizes?
In addition to using server side compression, using intelligent coding is the best way to keep bandwidth costs low. You can always use tools like [Dean Edward's Javascript Packer](http://dean.edwards.name/download/#packer), but for CSS, take the time to learn [CSS Shorthand](http://www.webcredible.co.uk/user-friendly-r...
65,512
<p>I've heard that <code>SELECT *</code> is generally bad practice to use when writing SQL commands because it is more efficient to <code>SELECT</code> columns you specifically need.</p> <p>If I need to <code>SELECT</code> every column in a table, should I use </p> <pre><code>SELECT * FROM TABLE </code></pre> <p>or ...
[ { "answer_id": 65518, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 2, "selected": false, "text": "<p>definitely defining the columns, because SQL Server will not have to do a lookup on the columns to pull them. If you def...
2008/09/15
[ "https://Stackoverflow.com/questions/65512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
I've heard that `SELECT *` is generally bad practice to use when writing SQL commands because it is more efficient to `SELECT` columns you specifically need. If I need to `SELECT` every column in a table, should I use ``` SELECT * FROM TABLE ``` or ``` SELECT column1, colum2, column3, etc. FROM TABLE ``` Does ...
One reason that selecting specific columns is better is that it raises the probability that SQL Server can access the data from indexes rather than querying the table data. Here's a post I wrote about it: [**The real reason select queries are bad index coverage**](http://weblogs.asp.net/jgalloway/archive/2007/07/18/t...
65,524
<p>What is the best way to generate a Unique ID from two (or more) short ints in C++? I am trying to uniquely identify vertices in a graph. The vertices contain two to four short ints as data, and ideally the ID would be some kind of a hash of them. Prefer portability and uniqueness over speed or ease. </p> <p>The...
[ { "answer_id": 65551, "author": "Fire Lancer", "author_id": 6266, "author_profile": "https://Stackoverflow.com/users/6266", "pm_score": 0, "selected": false, "text": "<p>Well the only way to guarantee the ID is unique, is to make have more id combinations than what your gettings ids from...
2008/09/15
[ "https://Stackoverflow.com/questions/65524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8264/" ]
What is the best way to generate a Unique ID from two (or more) short ints in C++? I am trying to uniquely identify vertices in a graph. The vertices contain two to four short ints as data, and ideally the ID would be some kind of a hash of them. Prefer portability and uniqueness over speed or ease. There are a lot o...
A simple solution is to use a 64 bit integer where the lower 16 bits is the first vertex coordinate, next 16 bits is the second, and so on. This will be unique for all your vertices, though not very compact. So here's some half-assed code to do this. Hopefully I got the casts right. ``` uint64_t generateId( uint16_t ...
65,530
<p>In Tomcat 5.5 the server.xml can have many connectors, typically port only 8080, but for my application a user might configure their servlet.xml to also have other ports open (say 8081-8088). I would like for my servlet to figure out what socket connections ports will be vaild (During the Servlet.init() tomcat has ...
[ { "answer_id": 65656, "author": "jrudolph", "author_id": 7647, "author_profile": "https://Stackoverflow.com/users/7647", "pm_score": 3, "selected": true, "text": "<p>In Tomcat 6.0 it should be something like:</p>\n\n<pre><code>org.apache.catalina.ServerFactory.getServer().getServices \n<...
2008/09/15
[ "https://Stackoverflow.com/questions/65530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6580/" ]
In Tomcat 5.5 the server.xml can have many connectors, typically port only 8080, but for my application a user might configure their servlet.xml to also have other ports open (say 8081-8088). I would like for my servlet to figure out what socket connections ports will be vaild (During the Servlet.init() tomcat has not ...
In Tomcat 6.0 it should be something like: ``` org.apache.catalina.ServerFactory.getServer().getServices ``` to get the services. After that you might use ``` Service.findConnectors ``` which returns a Connector which finally has the method ``` Connector.getPort ``` See the [JavaDocs](http://tomcat.apache.or...
65,536
<p>How would I get the <code>here</code> and <code>and here</code> to be on the right, on the same lines as the lorem ipsums? See the following:</p> <pre class="lang-none prettyprint-override"><code>Lorem Ipsum etc........here blah....................... blah blah.................. blah....................... ...
[ { "answer_id": 65572, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>The first line would consist of 3 <code>&lt;div&gt;</code>s. One outer that contains two inner <code>&lt;div&gt;</code>s. Th...
2008/09/15
[ "https://Stackoverflow.com/questions/65536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
How would I get the `here` and `and here` to be on the right, on the same lines as the lorem ipsums? See the following: ```none Lorem Ipsum etc........here blah....................... blah blah.................. blah....................... lorem ipsums.......and here ```
```html <div style="position: relative; width: 250px;"> <div style="position: absolute; top: 0; right: 0; width: 100px; text-align:right;"> here </div> <div style="position: absolute; bottom: 0; right: 0; width: 100px; text-align:right;"> and here </div> Lorem Ipsum etc <br /> blah <br /> ...
65,566
<p>I have a control that, upon postback, saves form results back to the database. It populates the values to be saved by iterating through the querystring. So, for the following SQL statement (vastly simplified for the sake of discussion)...</p> <pre><code>UPDATE MyTable SET MyVal1 = @val1, MyVal2 = @val2 WHERE @i...
[ { "answer_id": 65629, "author": "Sander Rijken", "author_id": 5555, "author_profile": "https://Stackoverflow.com/users/5555", "pm_score": 3, "selected": false, "text": "<p>First of all, I would suggest against adding all entries on the querystring as parameter names, I'm not sure this is...
2008/09/15
[ "https://Stackoverflow.com/questions/65566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1923/" ]
I have a control that, upon postback, saves form results back to the database. It populates the values to be saved by iterating through the querystring. So, for the following SQL statement (vastly simplified for the sake of discussion)... ``` UPDATE MyTable SET MyVal1 = @val1, MyVal2 = @val2 WHERE @id = @id ``` ...
After struggling to find a simpler solution, I gave up and wrote a routine to parse my SQL query for variable names: ``` Dim FieldRegEx As New Regex("@([A-Z_]+)", RegexOptions.IgnoreCase) Dim Fields As Match = FieldRegEx.Match(Query) Dim Processed As New ArrayList While Fields.Success Dim Key As String = Fields.G...
65,607
<p>I've been attempting to write a Lisp macro that would perfom the equivalent of ++ in other programming languages for semantic reasons. I've attempted to do this in several different ways, but none of them seem to work, and all are accepted by the interpreter, so I don't know if I have the correct syntax or not. My...
[ { "answer_id": 65641, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 5, "selected": true, "text": "<p>Remember that a macro returns an expression to be evaluated. In order to do this, you have to backquote:</p>\n\n<pre><cod...
2008/09/15
[ "https://Stackoverflow.com/questions/65607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256/" ]
I've been attempting to write a Lisp macro that would perfom the equivalent of ++ in other programming languages for semantic reasons. I've attempted to do this in several different ways, but none of them seem to work, and all are accepted by the interpreter, so I don't know if I have the correct syntax or not. My idea...
Remember that a macro returns an expression to be evaluated. In order to do this, you have to backquote: ``` (defmacro ++ (variable) `(incf ,variable)) ```
65,627
<p>In a Flex <code>AdvancedDatGrid</code>, we're doing a lot of grouping. Most of the columns are the same for the parents and for the children, so I'd like to show the first value of the group as the summary rather than the MAX, MIN or AVG</p> <p>This code works on numerical but not textual values (without the comme...
[ { "answer_id": 69156, "author": "Raleigh Buckner", "author_id": 1153, "author_profile": "https://Stackoverflow.com/users/1153", "pm_score": 2, "selected": true, "text": "<p>It looks like the summaryFunction has to return a number. According to the <a href=\"https://bugs.adobe.com/jira/br...
2008/09/15
[ "https://Stackoverflow.com/questions/65627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056/" ]
In a Flex `AdvancedDatGrid`, we're doing a lot of grouping. Most of the columns are the same for the parents and for the children, so I'd like to show the first value of the group as the summary rather than the MAX, MIN or AVG This code works on numerical but not textual values (without the commented line you get NaN'...
It looks like the summaryFunction has to return a number. According to the [Adobe bug tracker](https://bugs.adobe.com/jira/browse/FLEXDOCS-431), it is a bug in the documentation: > > Comment from Sameer Bhatt: > > > In the documentation it is mentioned that - > The built-in summary functions for SUM, MIN, MAX, AVG...
65,651
<p>I'm a longtime Java programmer working on a PHP project, and I'm trying to get PHPUnit up and working. When unit testing in Java, it's common to put test case classes and regular classes into separate directories, like this -</p> <pre><code>/src MyClass.java /test MyClassTest.java </code></pre> <p>and so...
[ { "answer_id": 65754, "author": "Brian Phillips", "author_id": 7230, "author_profile": "https://Stackoverflow.com/users/7230", "pm_score": 2, "selected": false, "text": "<p>You need to modify PHP's include_path so that it knows where to find MyClass.php when you <code>include()</code> it...
2008/09/15
[ "https://Stackoverflow.com/questions/65651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8770/" ]
I'm a longtime Java programmer working on a PHP project, and I'm trying to get PHPUnit up and working. When unit testing in Java, it's common to put test case classes and regular classes into separate directories, like this - ``` /src MyClass.java /test MyClassTest.java ``` and so on. When unit testing wit...
I think it's a good idea to keep your files separate. I normally use a folder structure like this: ``` /myapp/src/ <- my classes /myapp/tests/ <- my tests for the classes /myapp/public/ <- document root ``` In your case, for including the class in your test file, why not just pass the the whole pat...
65,668
<p>Someone told me it's more efficient to use <code>StringBuffer</code> to concatenate strings in Java than to use the <code>+</code> operator for <code>String</code>s. What happens under the hood when you do that? What does <code>StringBuffer</code> do differently?</p>
[ { "answer_id": 65677, "author": "André Chalella", "author_id": 4850, "author_profile": "https://Stackoverflow.com/users/4850", "pm_score": 4, "selected": false, "text": "<p>One shouldn't be faster than the other. This wasn't true before Java 1.4.2, because when concatenating more than tw...
2008/09/15
[ "https://Stackoverflow.com/questions/65668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Someone told me it's more efficient to use `StringBuffer` to concatenate strings in Java than to use the `+` operator for `String`s. What happens under the hood when you do that? What does `StringBuffer` do differently?
It's better to use StringBuilder (it's an unsynchronized version; when do you build strings in parallel?) these days, in almost every case, but here's what happens: When you use + with two strings, it compiles code like this: ``` String third = first + second; ``` To something like this: ``` StringBuilder builder ...
65,683
<p>I would like to know how to write PHPUnit tests with Zend_Test and in general with PHP.</p>
[ { "answer_id": 66008, "author": "Sam Corder", "author_id": 2351, "author_profile": "https://Stackoverflow.com/users/2351", "pm_score": 0, "selected": false, "text": "<p>I haven't used Zend_Test but I have written tests against apps using Zend_MVC and the like. The biggest part is gettin...
2008/09/15
[ "https://Stackoverflow.com/questions/65683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to know how to write PHPUnit tests with Zend\_Test and in general with PHP.
I'm using Zend\_Test to completely test all controllers. It's quite simple to set up, as you only have to set up your bootstrap file (the bootstrap file itself should NOT dispatch the front controller!). My base test-case class looks like this: ``` abstract class Controller_TestCase extends Zend_Test_PHPUnit_Controlle...
65,724
<p>As everyone knows, the <a href="http://en.wikipedia.org/wiki/Visual_C%2B%2B" rel="nofollow noreferrer">Visual C++</a> runtime marks uninitialized or just freed memory blocks with special non-zero markers. Is there any way to disable this behavior entirely without manually setting all uninitialized memory to zeros? I...
[ { "answer_id": 65760, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 4, "selected": false, "text": "<p>When you create a pointer, explicity initialize it to <code>NULL</code>. Likewise after a <code>delete</code>. Depending o...
2008/09/15
[ "https://Stackoverflow.com/questions/65724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8844/" ]
As everyone knows, the [Visual C++](http://en.wikipedia.org/wiki/Visual_C%2B%2B) runtime marks uninitialized or just freed memory blocks with special non-zero markers. Is there any way to disable this behavior entirely without manually setting all uninitialized memory to zeros? It's causing havoc with my valid not null...
It is not the responsibility of `delete` to reset all the pointers to the object to `NULL`. Also you shouldn't change the default memory fill for the windows DEBUG runtime and you should use some thing like `boost::shared_ptr<>` for pointers any way. That said, if you really want to **shoot your self in the foot** you...
65,849
<p>I'm writing a web service, and I want to return the data as XHTML. Because it's data, not markup, I want to keep it very clean - no extra <code>&lt;div&gt;</code>s or <code>&lt;span&gt;</code>s. However, as a convenience to developers, I'd also like to make the returned data reasonably readable in a browser. To do s...
[ { "answer_id": 65871, "author": "DamienG", "author_id": 5720, "author_profile": "https://Stackoverflow.com/users/5720", "pm_score": 2, "selected": false, "text": "<p>One option is to specify a XSLT template within your XML that (some) browsers will process allowing you to include present...
2008/09/15
[ "https://Stackoverflow.com/questions/65849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm writing a web service, and I want to return the data as XHTML. Because it's data, not markup, I want to keep it very clean - no extra `<div>`s or `<span>`s. However, as a convenience to developers, I'd also like to make the returned data reasonably readable in a browser. To do so, I'm thinking a good way to go abou...
It'd be best to wrap all of your elements in label elements, then apply css to the labels. The :before and :after pseudo classes are not completely supported in a consistent way. Label tags have a lot of advantages including increased accessibility (on multiple levels) and more. ``` <label> Thingy one: <input typ...
65,925
<p>From time to time am I working in a completely disconnected environment with a Macbook Pro. For testing purposes I need to run a local DNS server in a VMWare session. I've configured the lookup system to use the DNS server (/etc/resolve.conf and through the network configuration panel, which is using configd underne...
[ { "answer_id": 66629, "author": "Mark Regensberg", "author_id": 6735, "author_profile": "https://Stackoverflow.com/users/6735", "pm_score": 0, "selected": false, "text": "<p>I run into this from time to time on different notebooks, and I have found the simplest is a low-tech, non softwar...
2008/09/15
[ "https://Stackoverflow.com/questions/65925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9504/" ]
From time to time am I working in a completely disconnected environment with a Macbook Pro. For testing purposes I need to run a local DNS server in a VMWare session. I've configured the lookup system to use the DNS server (/etc/resolve.conf and through the network configuration panel, which is using configd underneath...
On OS X starting in 10.4, `/etc/resolv.conf` is no longer the canonical location for DNS IP addresses. Some Unix tools such as `dig` and `nslookup` will use it directly, but anything that uses Unix or Mac APIs to do DNS lookups will not. Instead, configd maintains a database which provides many more options, like using...
65,926
<p>When using a browser to transform XML (Google Chrome or IE7) is it possible to pass a parameter to the XSLT stylesheet through the URL?</p> <p>example:</p> <p><strong>data.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;?xml-stylesheet type="text/xsl" href="sample.xsl"?&gt; &lt;root&g...
[ { "answer_id": 66017, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 3, "selected": true, "text": "<p>You can generate the XSLT server-side, even if the transformation is client-side.</p>\n\n<p>This allows you to use a...
2008/09/15
[ "https://Stackoverflow.com/questions/65926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9547/" ]
When using a browser to transform XML (Google Chrome or IE7) is it possible to pass a parameter to the XSLT stylesheet through the URL? example: **data.xml** ``` <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="sample.xsl"?> <root> <document type="resume"> <author>John Doe</a...
You can generate the XSLT server-side, even if the transformation is client-side. This allows you to use a dynamic script to handle the parameter. For example, you might specify: ``` <?xml-stylesheet type="text/xsl"href="/myscript.cfm/sample.xsl?paramter=something" ?> ``` And then in myscript.cfm you would output ...
65,956
<p>Or vice versa.</p> <p>Update:<br> Hmm, let's assume I have a shopping cart app, the user clicks on the Checkout button. The next thing I want to do is send the user to a Invoice.aspx page (or similar). When the user hits checkout, I could <code>Button.PostBackURL = "Invoice.aspx"</code></p> <p>or I could do </p> ...
[ { "answer_id": 65975, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 1, "selected": false, "text": "<p>Server.Transfer is done entirely from the server. Postback is initiated from the client for posting form contents and...
2008/09/15
[ "https://Stackoverflow.com/questions/65956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4298/" ]
Or vice versa. Update: Hmm, let's assume I have a shopping cart app, the user clicks on the Checkout button. The next thing I want to do is send the user to a Invoice.aspx page (or similar). When the user hits checkout, I could `Button.PostBackURL = "Invoice.aspx"` or I could do ``` Server.Transfer("Invoice.aspx...
* Server.TransferURL will not result in a roundtrip of HTTP request/response. The address bar will not update, as far as the browser knows it has received only one document. Server.Transfer also retains execution context, so the script "keeps going" as opposed to "starts anew". * PostbackURL ensures an HTTP request, re...
65,994
<p>I want to use a file to store the current version number for a piece of customer software which can be used by a start-up script to run the binary in the correct directory.</p> <p>For Example, if the run directory looks like this:</p> <pre><code>. .. 1.2.1 1.2.2 1.3.0 run.sh current_version </code></pre> <p>And c...
[ { "answer_id": 66055, "author": "DustinB", "author_id": 7888, "author_profile": "https://Stackoverflow.com/users/7888", "pm_score": 3, "selected": false, "text": "<p>That's a common approach. You can check for dir/file existence using test operators such as \"if [ -d \"somedirectory\" ]...
2008/09/15
[ "https://Stackoverflow.com/questions/65994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7476/" ]
I want to use a file to store the current version number for a piece of customer software which can be used by a start-up script to run the binary in the correct directory. For Example, if the run directory looks like this: ``` . .. 1.2.1 1.2.2 1.3.0 run.sh current_version ``` And current\_version contains: ``` 1....
That's a common approach. You can check for dir/file existence using test operators such as "if [ -d "somedirectory" ]; then" or [ -t "somefile" ] I use symbolic links more often, though. Then, you can just change your symbolic link to use the version you want. For example, ``` $ ln -s 1.2.2 current_version $ ls -a...
66,006
<p>Is it possible to have XML-embedded JavaScript executed to assist in client-side (browser-based) XSL transformations? How is it done and how official is it?</p> <p>Microsoft's XML DOM objects allow this on the server-side (i.e. in ASP/ASP.NET).</p> <p><strong>Clarification:</strong> I do not mean HTML DOM scripti...
[ { "answer_id": 66050, "author": "helios", "author_id": 9686, "author_profile": "https://Stackoverflow.com/users/9686", "pm_score": 1, "selected": false, "text": "<p>Yes. It's browser dependant but you can use Javascript. There is a small but practical tutorial on w3schools.com. It's part...
2008/09/15
[ "https://Stackoverflow.com/questions/66006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
Is it possible to have XML-embedded JavaScript executed to assist in client-side (browser-based) XSL transformations? How is it done and how official is it? Microsoft's XML DOM objects allow this on the server-side (i.e. in ASP/ASP.NET). **Clarification:** I do not mean HTML DOM scripting performed *after* the docume...
To embed JavaScript for the aid of transformation you can use <xsl:script>, but [it is limited](http://www.topxml.com/xsl/tutorials/intro/xsl10.asp) to Microsoft's XML objects implementation. Here's an [example](https://oxampleski.googlecode.com/svn/trunk/XSL): **scripted.xml**: ``` <?xml version="1.0"?> <?xml-styles...
66,009
<p>I know you could make a helper pretty easily given the data. So, if possible, please only submit answers that also include getting the data.</p>
[ { "answer_id": 67644, "author": "Matt Hinze", "author_id": 2676, "author_profile": "https://Stackoverflow.com/users/2676", "pm_score": 5, "selected": true, "text": "<p>We are using an action filter for this. </p>\n\n<p>...</p>\n\n<pre><code> public override void OnActionExecuting(Acti...
2008/09/15
[ "https://Stackoverflow.com/questions/66009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
I know you could make a helper pretty easily given the data. So, if possible, please only submit answers that also include getting the data.
We are using an action filter for this. ... ``` public override void OnActionExecuting(ActionExecutingContext filterContext) { var controller = (Controller) filterContext.Controller; Breadcrumb[] breadcrumbs = _breadcrumbManager.PushBreadcrumb(_breadcrumbLinkText); controller.ViewData...
66,032
<p>The DOM method <code>getChildNodes()</code> returns a <code>NodeList</code> of the children of the current <code>Node</code>. Whilst a <code>NodeList</code> is ordered, is the list guaranteed to be in document order?</p> <p>For example, given <code>&lt;a&gt;&lt;b/&gt;&lt;c/&gt;&lt;d/&gt;&lt;/a&gt;</code> is <code>a...
[ { "answer_id": 66112, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "<p>A document-ordered node list is the behavior in other implementations of the DOM, such as Javascript's or Python's. ...
2008/09/15
[ "https://Stackoverflow.com/questions/66032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4332/" ]
The DOM method `getChildNodes()` returns a `NodeList` of the children of the current `Node`. Whilst a `NodeList` is ordered, is the list guaranteed to be in document order? For example, given `<a><b/><c/><d/></a>` is `a.getChildNodes()` guaranteed to return a `NodeList` with `b`, `c` and `d` *in that order*? The [jav...
In my experience, yes. The [DOM spec](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1451460987) isn't any clearer. If you're paranoid, try something like ``` current = node.firstChild; while(null != current) { ... current = current.nextSibling; } ```
66,066
<p>I've seen examples like this: </p> <pre><code>public class MaxSeconds { public static final int MAX_SECONDS = 25; } </code></pre> <p>and supposed that I could have a Constants class to wrap constants in, declaring them static final. I know practically no Java at all and am wondering if this is the best way to c...
[ { "answer_id": 66076, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 10, "selected": true, "text": "<p>That is perfectly acceptable, probably even the standard.</p>\n\n<pre><code>(public/private) static final TYPE NAME = VALUE...
2008/09/15
[ "https://Stackoverflow.com/questions/66066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1797/" ]
I've seen examples like this: ``` public class MaxSeconds { public static final int MAX_SECONDS = 25; } ``` and supposed that I could have a Constants class to wrap constants in, declaring them static final. I know practically no Java at all and am wondering if this is the best way to create constants.
That is perfectly acceptable, probably even the standard. ``` (public/private) static final TYPE NAME = VALUE; ``` where `TYPE` is the type, `NAME` is the name in all caps with underscores for spaces, and `VALUE` is the constant value; I highly recommend NOT putting your constants in their own classes or interfaces...
66,094
<p>Have been trying out the new Dynamic Data site create tool that shipped with .NET 3.5. The tool uses LINQ Datasources to get the data from the database using a .dmbl context file for a reference. I am interseted in customizing a data grid but I need to show data from more than one table. Does anyone know how to do...
[ { "answer_id": 66119, "author": "Jarrett Meyer", "author_id": 5834, "author_profile": "https://Stackoverflow.com/users/5834", "pm_score": 0, "selected": false, "text": "<p>You cannot put more than one object/datasource on a datagrid. You will have to build a single ConceptObject that com...
2008/09/15
[ "https://Stackoverflow.com/questions/66094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9626/" ]
Have been trying out the new Dynamic Data site create tool that shipped with .NET 3.5. The tool uses LINQ Datasources to get the data from the database using a .dmbl context file for a reference. I am interseted in customizing a data grid but I need to show data from more than one table. Does anyone know how to do this...
If the tables are connected by a foreign key, you can easily reference both tables as they will be joined by linq automatically (you can see easily if you look in your dbml and there is an arrow connecting the tables) - if not, see if you can add one. To do that, you can just use something like this: ``` <%# Bind("un...
66,107
<p>I need to get the number of digits containing the number 1. I know in java I can take the input as a <code>String</code> and use <code>charAt</code>, but I understand there is no implicit String function in C. How can I accomplish this?</p>
[ { "answer_id": 66122, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 3, "selected": false, "text": "<p>Division and modulus are your friends.</p>\n\n<pre><code>#include \"stdio.h\"\n\nint main(){\n int digits[] = {0,...
2008/09/15
[ "https://Stackoverflow.com/questions/66107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628/" ]
I need to get the number of digits containing the number 1. I know in java I can take the input as a `String` and use `charAt`, but I understand there is no implicit String function in C. How can I accomplish this?
Division and modulus are your friends. ``` #include "stdio.h" int main(){ int digits[] = {0,0,0,0,0,0,0,0,0,0}; int i = 11031; while(i > 0){ digits[i % 10]++; i = i / 10; } printf("There are %d ones.\n", digits[1]); } ```
66,164
<p>I'm responsible for some test database servers. Historically, too many other poeple have access to them. They run on <code>SQL Server 2005</code>. </p> <p>I've been writing queries and wrapping them in scripts so I can run a regular audit of rights. Finding out which users had Administrator rights on the server...
[ { "answer_id": 66349, "author": "Jason Punyon", "author_id": 6212, "author_profile": "https://Stackoverflow.com/users/6212", "pm_score": 1, "selected": false, "text": "<pre><code>\nselect * from Master.dbo.syslogins l inner join sys.sysusers u on l.sid = u.sid\n</code></pre>\n\n<p>This w...
2008/09/15
[ "https://Stackoverflow.com/questions/66164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9727/" ]
I'm responsible for some test database servers. Historically, too many other poeple have access to them. They run on `SQL Server 2005`. I've been writing queries and wrapping them in scripts so I can run a regular audit of rights. Finding out which users had Administrator rights on the server itself was fine, as was ...
Here's how to do this. I ended up finding reference to a sproc in the MSDN docs. I pulled this from the sproc and wrapped it in a loop of all the databases known to the instance. ``` select DbRole = g.name, MemberName = u.name from @NAME.sys.database_principals u, @NAME.sys.database_principals g, @NAME.sys.database_...
66,293
<p>I have a Visual Studio application with a splash screen image cut into "slices". The positions are specified in the Form Designer so they line up properly on the screen. However, the images are out of place when the application is run on the Chinese version of Windows XP. It looks as if the image slices were "explod...
[ { "answer_id": 67007, "author": "Benjamin Autin", "author_id": 1440933, "author_profile": "https://Stackoverflow.com/users/1440933", "pm_score": 0, "selected": false, "text": "<p>In the OnLoad event of the form, you could always explicitly set the location of each section. If starting at...
2008/09/15
[ "https://Stackoverflow.com/questions/66293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5626/" ]
I have a Visual Studio application with a splash screen image cut into "slices". The positions are specified in the Form Designer so they line up properly on the screen. However, the images are out of place when the application is run on the Chinese version of Windows XP. It looks as if the image slices were "exploded"...
We found a solution! Apparently the picture boxes stretched out on the Chinese XP PC, but the images they contained did not. The fix was to add code like the following: ``` Me.PictureBoxIcon.Width = Me.PictureBoxIcon.Image.Width Me.PictureBoxIcon.Height = Me.PictureBoxIcon.Image.Height Dim loc As New Point loc.X = Me...
66,363
<p>I need to find out the <strong>external</strong> IP of the computer a C# application is running on. </p> <p>In the application I have a connection (via .NET remoting) to a server. Is there a good way to get the address of the client on the server side?</p> <p><em>(I have edited the question, to be a little more cl...
[ { "answer_id": 66393, "author": "Matt Michielsen", "author_id": 9769, "author_profile": "https://Stackoverflow.com/users/9769", "pm_score": -1, "selected": false, "text": "<p>You can basically parse the page returned by doing a WebRequest of <a href=\"http://whatismyipaddress.com\" rel=\...
2008/09/15
[ "https://Stackoverflow.com/questions/66363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/936/" ]
I need to find out the **external** IP of the computer a C# application is running on. In the application I have a connection (via .NET remoting) to a server. Is there a good way to get the address of the client on the server side? *(I have edited the question, to be a little more clear. I'm apologize to all kind pe...
I found a way that worked great for me. By implementing a custom IServerChannelSinkProvider and IServerChannelSink where I have access to CommonTransportKeys.IPAddress, it's easy to add the client ip on the CallContext. ``` public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage request...
66,382
<p>In the ContainsIngredients method in the following code, is it possible to cache the <em>p.Ingredients</em> value instead of explicitly referencing it several times? This is a fairly trivial example that I just cooked up for illustrative purposes, but the code I'm working on references values deep inside <em>p</em>...
[ { "answer_id": 66710, "author": "Fake Jim", "author_id": 6199, "author_profile": "https://Stackoverflow.com/users/6199", "pm_score": 3, "selected": true, "text": "<p>Can't you simply write your boolean expression in a separate static function which you call from your lambda - passing p.I...
2008/09/15
[ "https://Stackoverflow.com/questions/66382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9825/" ]
In the ContainsIngredients method in the following code, is it possible to cache the *p.Ingredients* value instead of explicitly referencing it several times? This is a fairly trivial example that I just cooked up for illustrative purposes, but the code I'm working on references values deep inside *p* eg. *p.InnerObjec...
Can't you simply write your boolean expression in a separate static function which you call from your lambda - passing p.Ingredients as a parameter... ``` private static bool IsIngredientPresent(IngredientBag i, string ingredientType, string ingredient) { return i != null && i.Contains(ingredientType) && i.Get(ing...
66,422
<p>I need to rotate an image at 12 midnight every day from a group of 5-10 images. How can I go about doing this with JavaScript or jQuery or even PHP?</p>
[ { "answer_id": 66449, "author": "The.Anti.9", "author_id": 2128, "author_profile": "https://Stackoverflow.com/users/2128", "pm_score": 0, "selected": false, "text": "<p>If you are running a linux system you can set a <a href=\"http://www.sitepoint.com/article/introducing-cron/\" rel=\"no...
2008/09/15
[ "https://Stackoverflow.com/questions/66422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9750/" ]
I need to rotate an image at 12 midnight every day from a group of 5-10 images. How can I go about doing this with JavaScript or jQuery or even PHP?
At a basic level what you want to do is define an array of image names then take the number of days from a given point in time then modulo (remainder after division) by the number of images and access that index in the array and set the image, e.g. (untested code) ``` var images = new Array("image1.gif", "image2.jpg",...
66,438
<p>I'm writing a mobile phone game using j2me. In this game, I am using multiple Canvas objects. For example, the game menu is a Canvas object, and the actual game is a Canvas object too. I've noticed that, on some devices, when I switch from one Canvas to another, e.g from the main menu to the game, the screen momenta...
[ { "answer_id": 66742, "author": "Vivek", "author_id": 7418, "author_profile": "https://Stackoverflow.com/users/7418", "pm_score": 0, "selected": false, "text": "<p>Do you use double buffering? If the device itself does not support double buffering you should define a off screen buffer (I...
2008/09/15
[ "https://Stackoverflow.com/questions/66438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9771/" ]
I'm writing a mobile phone game using j2me. In this game, I am using multiple Canvas objects. For example, the game menu is a Canvas object, and the actual game is a Canvas object too. I've noticed that, on some devices, when I switch from one Canvas to another, e.g from the main menu to the game, the screen momentaril...
I would say, that using multiple canvases is generally bad design. On some phones it will even crash. The best way would really be using one canvas with tracking state of the application. And then in paint method you would have ``` protected void paint(final Graphics g) { if(menu) { paintMenu(g); } else if (ga...
66,455
<p>For most GUI's I've used, when a control that contains text gets the focus, the entire contents of the control are selected. This means if you just start typing, you completely replace the former contents.</p> <p>Example: You have spin control that is initialized with the value zero. You tab to it and type "1" ...
[ { "answer_id": 66570, "author": "Alexandre Brasil", "author_id": 8841, "author_profile": "https://Stackoverflow.com/users/8841", "pm_score": 0, "selected": false, "text": "<p>The only way I know is to create a FocusListener and attach it to your component. If you want it this FocusListen...
2008/09/15
[ "https://Stackoverflow.com/questions/66455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/391806/" ]
For most GUI's I've used, when a control that contains text gets the focus, the entire contents of the control are selected. This means if you just start typing, you completely replace the former contents. Example: You have spin control that is initialized with the value zero. You tab to it and type "1" The value in t...
After reading the replies so far (Thanks!) I passed the outermost JPanel to the following method: ``` void addTextFocusSelect(JComponent component){ if(component instanceof JTextComponent){ component.addFocusListener(new FocusAdapter() { @Override public void focusGained(Fo...
66,475
<p>I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does.</p> <p>I know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line?</p> <p>(I really want the Cursor Position on that line, no...
[ { "answer_id": 66500, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>Off the top of my head, I think you want the SelectionStart property.</p>\n" }, { "answer_id": 66561, "a...
2008/09/15
[ "https://Stackoverflow.com/questions/66475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9857/" ]
I've got a multiline textBox that I would like to have a label on the form displaying the current line and column position of, as Visual Studio does. I know I can get the line # with GetLineFromCharIndex, but how can I get the column # on that line? (I really want the Cursor Position on that line, not 'column', per s...
``` int line = textbox.GetLineFromCharIndex(textbox.SelectionStart); int column = textbox.SelectionStart - textbox.GetFirstCharIndexFromLine(line); ```
66,492
<p>Is there a way to check to see if an iPhone is online from a web app. That is, in mobile Safari, can I check the online status of the device to see if I should try an AJAX call or not.</p> <p>In Firefox/regular WebKit, this would be:</p> <pre><code>if(navigator.onLine) { onlineCode() } </code></pre>
[ { "answer_id": 66521, "author": "Loren Segal", "author_id": 6436, "author_profile": "https://Stackoverflow.com/users/6436", "pm_score": 2, "selected": false, "text": "<p>That same code should work in the WebKit nightly build as of May 16th 2008. I guess that means you need to hope the 2....
2008/09/15
[ "https://Stackoverflow.com/questions/66492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6842/" ]
Is there a way to check to see if an iPhone is online from a web app. That is, in mobile Safari, can I check the online status of the device to see if I should try an AJAX call or not. In Firefox/regular WebKit, this would be: ``` if(navigator.onLine) { onlineCode() } ```
That same code should work in the WebKit nightly build as of May 16th 2008. I guess that means you need to hope the 2.1 update included a new build of safari. <https://bugs.webkit.org/show_bug.cgi?id=19105>
66,505
<p>I hit this problem all the time. Suppose I am making a command line interface (Java or C#, the problem is the same I think, I will show C# here).</p> <ol> <li>I define an interface ICommand</li> <li>I create an abstract base class CommandBase which implements ICommand, to contain common code.</li> <li>I create seve...
[ { "answer_id": 66546, "author": "Ewan Makepeace", "author_id": 9731, "author_profile": "https://Stackoverflow.com/users/9731", "pm_score": 0, "selected": false, "text": "<p>[Suggested solution #1 of 3]</p>\n\n<ol>\n<li>Define an abstract property Name in the interface to force all implem...
2008/09/15
[ "https://Stackoverflow.com/questions/66505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9731/" ]
I hit this problem all the time. Suppose I am making a command line interface (Java or C#, the problem is the same I think, I will show C# here). 1. I define an interface ICommand 2. I create an abstract base class CommandBase which implements ICommand, to contain common code. 3. I create several implementation classe...
You may consider to use attributes instead of fields. ``` [Command("HELP")] class HelpCommand : ICommand { } ```
66,518
<p>I need to flip an image so that a character faces in the right direction. This needs to be done "on the fly' as they say. </p> <p>The issue I am having is that with Gif images, I seem to lose the transparency. (The background goes white)</p> <p>Below is the code: (Alternatively someone could send me to a good exam...
[ { "answer_id": 66574, "author": "Alex M", "author_id": 9652, "author_profile": "https://Stackoverflow.com/users/9652", "pm_score": 1, "selected": false, "text": "<p>If you can guarantee the presence of ImageMagick, you can use their <code>mogrify -flop</code> command. It preserves transp...
2008/09/15
[ "https://Stackoverflow.com/questions/66518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2490/" ]
I need to flip an image so that a character faces in the right direction. This needs to be done "on the fly' as they say. The issue I am having is that with Gif images, I seem to lose the transparency. (The background goes white) Below is the code: (Alternatively someone could send me to a good example) ``` $img = ...
Shouldn't this: ``` imagecolortransparent($img, imagecolorallocate($img, 0, 0, 0)); imagealphablending($img, false); imagesavealpha($img, true); ``` ...be this: ``` imagecolortransparent($temp, imagecolorallocate($img, 0, 0, 0)); imagealphablending($temp, false); imagesavealpha($temp, true); ``` Note you should b...
66,528
<p>I have the following Java 6 code:</p> <pre><code> Query q = em.createNativeQuery( "select T.* " + "from Trip T join Itinerary I on (T.itinerary_id=I.id) " + "where I.launchDate between :start and :end " + "or ADDDATE(I.launchDate, I.equipmentPullDayOfTrip) between :start and :end...
[ { "answer_id": 66697, "author": "Jim Kiley", "author_id": 7178, "author_profile": "https://Stackoverflow.com/users/7178", "pm_score": 2, "selected": true, "text": "<p>The Hibernate annotations docs (<a href=\"http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/\" rel=\...
2008/09/15
[ "https://Stackoverflow.com/questions/66528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have the following Java 6 code: ``` Query q = em.createNativeQuery( "select T.* " + "from Trip T join Itinerary I on (T.itinerary_id=I.id) " + "where I.launchDate between :start and :end " + "or ADDDATE(I.launchDate, I.equipmentPullDayOfTrip) between :start and :end", "Tr...
The Hibernate annotations docs (<http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/>) suggest that this should be a class-level annotation rather than occurring inline within your code. And indeed when I paste that code into my IDE and move it around, the compile errors are present when the annotat...
66,542
<p>How do I get started?</p>
[ { "answer_id": 66676, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>You'll need an interface to the Oracle SQL database. As Bob pointed out, Allegro CL has such an interface.</p>\n\n<p><a href...
2008/09/15
[ "https://Stackoverflow.com/questions/66542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9615/" ]
How do I get started?
I have found the easiest way to achieve this by using Clojure. Here is the example code: ``` (ns example (:require [clojure.contrib.sql :as sql]) (:import [java.sql Types])) ``` (def devdb {:classname "oracle.jdbc.driver.OracleDriver" :subprotocol "oracle" :subname "thin:username/password@localhost:1509:devdb...
66,606
<p>I'm trying to find <a href="http://httpd.apache.org/docs/2.0/programs/ab.html" rel="noreferrer">ab - Apache HTTP server benchmarking tool</a> for Ubuntu, I'm hoping there's a package I can install for it. I decided I need to do some simple load testing on my applications.</p>
[ { "answer_id": 66617, "author": "Brian Phillips", "author_id": 7230, "author_profile": "https://Stackoverflow.com/users/7230", "pm_score": 8, "selected": true, "text": "<pre><code>% sudo apt-get install apache2-utils</code></pre>\n\n<p>The command-not-found package in Ubuntu provides som...
2008/09/15
[ "https://Stackoverflow.com/questions/66606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/339/" ]
I'm trying to find [ab - Apache HTTP server benchmarking tool](http://httpd.apache.org/docs/2.0/programs/ab.html) for Ubuntu, I'm hoping there's a package I can install for it. I decided I need to do some simple load testing on my applications.
``` % sudo apt-get install apache2-utils ``` The command-not-found package in Ubuntu provides some slick functionality where if you type a command that can't be resolved to an executable (or bash function or whatever) it will query your apt sources and find a package that contains the binary you tried to execute. So, ...
66,610
<p>For a particular project I have, no server side code is allowed. How can I create the web site in php (with includes, conditionals, etc) and then have that converted into a static html site that I can give to the client?</p> <p>Update: Thanks to everyone who suggested wget. That's what I used. I should have specifi...
[ { "answer_id": 66623, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 1, "selected": false, "text": "<p>Create the site as normal, then use spidering software to generate a HTML copy.</p>\n\n<p><a href=\"http://www.httr...
2008/09/15
[ "https://Stackoverflow.com/questions/66610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3741/" ]
For a particular project I have, no server side code is allowed. How can I create the web site in php (with includes, conditionals, etc) and then have that converted into a static html site that I can give to the client? Update: Thanks to everyone who suggested wget. That's what I used. I should have specified that I ...
If you have a Linux system available to you use [wget](http://www.gnu.org/software/wget/): ``` wget -k -K -E -r -l 10 -p -N -F -nH http://website.com/ ``` Options * -k : convert links to relative * -K : keep an original versions of files without the conversions made by wget * -E : rename html files to .html (if th...
66,635
<p>I am using an ASP.NET MVC project and everytime I add a class to a folder it makes really long namespaces. </p> <p><strong>Example</strong>: </p> <pre><code>Project = Tully.Saps.Data Folder = DataAccess/Interfaces Namespace = Tully.Saps.Data.DataAccess.Interfaces Folder = DataAccess/MbNetRepositories Names...
[ { "answer_id": 66683, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 2, "selected": true, "text": "<p>Leave them alone and add the usings. You're asking for trouble manually changing things like that (harder to debug, inconsistent ...
2008/09/15
[ "https://Stackoverflow.com/questions/66635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9938/" ]
I am using an ASP.NET MVC project and everytime I add a class to a folder it makes really long namespaces. **Example**: ``` Project = Tully.Saps.Data Folder = DataAccess/Interfaces Namespace = Tully.Saps.Data.DataAccess.Interfaces Folder = DataAccess/MbNetRepositories Namespace = Tully.Saps.Data.DataAccess.M...
Leave them alone and add the usings. You're asking for trouble manually changing things like that (harder to debug, inconsistent with other projects, et cetera).
66,636
<p>I would like to make a child class that has a method of the parent class where the method is a 'classmethod' in the child class but <strong>not</strong> in the parent class.</p> <p>Essentially, I am trying to accomplish the following:</p> <pre><code>class foo(Object): def meth1(self, val): self.value =...
[ { "answer_id": 66670, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "<p>What are you trying to accomplish? If I saw such a construct in live Python code, I would consider beating the origi...
2008/09/15
[ "https://Stackoverflow.com/questions/66636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
I would like to make a child class that has a method of the parent class where the method is a 'classmethod' in the child class but **not** in the parent class. Essentially, I am trying to accomplish the following: ``` class foo(Object): def meth1(self, val): self.value = val class bar(foo): meth1 = ...
I'm also not entirely sure what the exact behaviour you want is, but assuming its that you want bar.meth1(42) to be equivalent to foo.meth1 being a classmethod of bar (with "self" being the class), then you can acheive this with: ``` def convert_to_classmethod(method): return classmethod(method.im_func) class bar...
66,643
<p>Is there a way to detect, from within the finally clause, that an exception is in the process of being thrown?</p> <p>See the example below:</p> <pre><code> try { // code that may or may not throw an exception } finally { SomeCleanupFunctionThatThrows(); // if currently executing an exception, exit the...
[ { "answer_id": 66664, "author": "zxcv", "author_id": 9628, "author_profile": "https://Stackoverflow.com/users/9628", "pm_score": -1, "selected": false, "text": "<p>No I do not believe so. The catch block will run to completion before the finally block.</p>\n\n<pre><code>try {\n // co...
2008/09/15
[ "https://Stackoverflow.com/questions/66643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5963/" ]
Is there a way to detect, from within the finally clause, that an exception is in the process of being thrown? See the example below: ``` try { // code that may or may not throw an exception } finally { SomeCleanupFunctionThatThrows(); // if currently executing an exception, exit the program, // othe...
Set a flag variable, then check for it in the finally clause, like so: ``` boolean exceptionThrown = true; try { mightThrowAnException(); exceptionThrown = false; } finally { if (exceptionThrown) { // Whatever you want to do } } ```
66,677
<p>I'm looking for a dead simple mailing list (unix friendly). Robustness, fine-grained configurability, "enterprise-readiness" (whatever that means) are not requirements. I just need to set up a tiny mailing list for a few friends. Rather than hack something up myself, I was wondering if anybody knows of anything alre...
[ { "answer_id": 66775, "author": "rami", "author_id": 9629, "author_profile": "https://Stackoverflow.com/users/9629", "pm_score": 1, "selected": false, "text": "<p>If you're not afraid of perl, give <a href=\"http://www.mml.org.ua/\" rel=\"nofollow noreferrer\">Minimalist</a> a try.</p>\n...
2008/09/15
[ "https://Stackoverflow.com/questions/66677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6436/" ]
I'm looking for a dead simple mailing list (unix friendly). Robustness, fine-grained configurability, "enterprise-readiness" (whatever that means) are not requirements. I just need to set up a tiny mailing list for a few friends. Rather than hack something up myself, I was wondering if anybody knows of anything already...
Mailman is one of the simplest mailing list packages I've come across, so if Mailman is more than you want to deal with I'd suggest just adding an entry into `/etc/aliases` for your mailing list. Of course you have to manage it by hand, but you said it's only for a few friends so that may not be a problem. Just create...
66,727
<p>I have a bunch of legacy documents that are HTML-like. As in, they look like HTML, but have additional made up tags that aren't a part of HTML</p> <pre><code>&lt;strong&gt;This is an example of a &lt;pseud-template&gt;fake tag&lt;/pseud-template&gt;&lt;/strong&gt; </code></pre> <p>I need to parse these files. PHP...
[ { "answer_id": 66811, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 2, "selected": false, "text": "<p>I wonder if passing the \"bad\" HTML through <a href=\"http://www.w3.org/People/Raggett/tidy/\" rel=\"nofollow noreferr...
2008/09/15
[ "https://Stackoverflow.com/questions/66727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4668/" ]
I have a bunch of legacy documents that are HTML-like. As in, they look like HTML, but have additional made up tags that aren't a part of HTML ``` <strong>This is an example of a <pseud-template>fake tag</pseud-template></strong> ``` I need to parse these files. PHP is the only only tool available. The documents don...
You can suppress warnings with [`libxml_use_internal_errors`](http://www.php.net/manual/en/function.libxml-use-internal-errors.php), while loading the document. Eg.: ``` libxml_use_internal_errors(true); $doc = new DomDocument(); $doc->loadHTML("<strong>This is an example of a <pseud-template>fake tag</pseud-template>...
66,730
<p>I've created a python object, but I want to send signals on it. I made it inherit from gobject.GObject, but there doesn't seem to be any way to create a new signal on my object.</p>
[ { "answer_id": 66883, "author": "Sebastian Rittau", "author_id": 7779, "author_profile": "https://Stackoverflow.com/users/7779", "pm_score": 2, "selected": false, "text": "<p>Here is how:</p>\n\n<pre><code>import gobject\n\nclass MyGObjectClass(gobject.GObject):\n ...\n\ngobject.signa...
2008/09/15
[ "https://Stackoverflow.com/questions/66730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8453/" ]
I've created a python object, but I want to send signals on it. I made it inherit from gobject.GObject, but there doesn't seem to be any way to create a new signal on my object.
You can also define signals inside the class definition: ``` class MyGObjectClass(gobject.GObject): __gsignals__ = { "some-signal": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (object, )), } ``` The contents of the tuple are the the same as the three last arguments to `gobject.signal_new`.
66,750
<p>Here is a quick test program:</p> <pre><code> public static void main( String[] args ) { Date date = Calendar.getInstance().getTime(); System.out.println("Months:"); printDate( "MMMM", "en", date ); printDate( "MMMM", "es", date ); printDate( "MMMM", "fr", date ); printDate( "MMMM", "de"...
[ { "answer_id": 66771, "author": "Chris Shaffer", "author_id": 6744, "author_profile": "https://Stackoverflow.com/users/6744", "pm_score": 3, "selected": false, "text": "<p>You may not want to change the capitalization -- different cultures capitalize different words (for example, in Germ...
2008/09/15
[ "https://Stackoverflow.com/questions/66750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9661/" ]
Here is a quick test program: ``` public static void main( String[] args ) { Date date = Calendar.getInstance().getTime(); System.out.println("Months:"); printDate( "MMMM", "en", date ); printDate( "MMMM", "es", date ); printDate( "MMMM", "fr", date ); printDate( "MMMM", "de", date ); ...
Not all languages share english capitalization rules. I guess you'd need to alter the data used by the API, but your non-english clients might not appreciate it... [about.com on french capitalization](http://french.about.com/library/writing/bl-capitalization.htm)
66,819
<p>Are there any good solutions to represent a parameterized enum in <code>C# 3.0</code>? I am looking for something like <a href="http://www.ocaml.org" rel="nofollow noreferrer">OCaml</a> or <a href="http://www.haxe.org" rel="nofollow noreferrer">Haxe</a> has. I can only think of class hierarchy with a simple enum fie...
[ { "answer_id": 66895, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 0, "selected": false, "text": "<p>C# (the .NET framework in general, as far as I know) doesn't support parametrized enums like Java does. That being said,...
2008/09/15
[ "https://Stackoverflow.com/questions/66819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9777/" ]
Are there any good solutions to represent a parameterized enum in `C# 3.0`? I am looking for something like [OCaml](http://www.ocaml.org) or [Haxe](http://www.haxe.org) has. I can only think of class hierarchy with a simple enum field for easy switching for now, maybe there are better ideas? See Ocaml example below in...
Not being familiar with OCaml or Haxe, and not being clever enough to understand the other explanations, I went and looked up the [Haxe enum documentation](https://haxe.org/manual/types-enum-instance.html) - the 'Enum Type Parameters' bit at the bottom seems to be the relevant part. My understanding based on that is a...
66,837
<p>Are <strong>CDATA</strong> tags ever necessary in script tags and if so when?</p> <p>In other words, when and where is this:</p> <pre><code>&lt;script type="text/javascript"&gt; //&lt;![CDATA[ ...code... //]]&gt; &lt;/script&gt; </code></pre> <p>preferable to this:</p> <pre><code>&lt;script type="text/javascript...
[ { "answer_id": 66848, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://javascript.about.com/library/blxhtml.htm\" rel=\"nofollow noreferrer\">When you want it to validat...
2008/09/15
[ "https://Stackoverflow.com/questions/66837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/208/" ]
Are **CDATA** tags ever necessary in script tags and if so when? In other words, when and where is this: ``` <script type="text/javascript"> //<![CDATA[ ...code... //]]> </script> ``` preferable to this: ``` <script type="text/javascript"> ...code... </script> ```
A CDATA section is required if you need your document to parse as XML (e.g. when an XHTML page is interpreted as XML) *and you want to be able to write literal `i<10` and `a && b` instead of `i&lt;10` and `a &amp;&amp; b`*, as XHTML will parse the JavaScript code as parsed character data as opposed to character data by...
66,870
<p>I want a user-privileged (not root) process to launch new processes as user <code>nobody</code>. I've tried a straight call to <code>setuid</code> that fails with -1 <code>EPERM</code> on <code>Ubuntu 8.04</code>:</p> <pre><code>#include &lt;sys/types.h&gt; #include &lt;unistd.h&gt; int main() { setuid(655...
[ { "answer_id": 66887, "author": "zigdon", "author_id": 4913, "author_profile": "https://Stackoverflow.com/users/4913", "pm_score": 1, "selected": false, "text": "<p>As far as I know, you can't unless you're root or have sudo set up to allow you to switch users. Or, you can have your exe...
2008/09/15
[ "https://Stackoverflow.com/questions/66870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9947/" ]
I want a user-privileged (not root) process to launch new processes as user `nobody`. I've tried a straight call to `setuid` that fails with -1 `EPERM` on `Ubuntu 8.04`: ``` #include <sys/types.h> #include <unistd.h> int main() { setuid(65534); while (1); return 0; } ``` How should I do this i...
You *will* require assistance and a lot of trust from your system administrator. Ordinary users are not able to run the executable of their choice on behalf on other users, period. She may add your application to `/etc/sudoers` with proper settings and you'll be able to run it as with `sudo -u nobody`. This will work ...
66,875
<p>We have a case where clients seem to be eternally caching versions of applets. We're making use of the <code>&lt;param name="cache_version"&gt;</code> tag correctly within our <code>&lt;object&gt;</code> tag, or so we think. We went from a version string of <code>7.1.0.40</code> to <code>7.1.0.42</code> and this t...
[ { "answer_id": 66942, "author": "MtotheThird", "author_id": 7069, "author_profile": "https://Stackoverflow.com/users/7069", "pm_score": 4, "selected": true, "text": "<p>Unfortunately, different versions of the Java Plug-In have different caching behaviors. Setting your Cache-Control and ...
2008/09/15
[ "https://Stackoverflow.com/questions/66875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We have a case where clients seem to be eternally caching versions of applets. We're making use of the `<param name="cache_version">` tag correctly within our `<object>` tag, or so we think. We went from a version string of `7.1.0.40` to `7.1.0.42` and this triggered a download for only about half of our clients. It d...
Unfortunately, different versions of the Java Plug-In have different caching behaviors. Setting your Cache-Control and Last-Modified HTTP headers is the ideal solution, but it only works under [the most recent versions](http://java.sun.com/javase/6/docs/technotes/guides/deployment/enhancements.html) of the JRE. The o...
66,880
<p>After reading <a href="https://stackoverflow.com/questions/63668/confessions-of-your-worst-wtf-moment-what-not-to-do#63730">this answer</a>, I wonder if there's a way to get a "testing" credit card number. One that you can experiment with but that doesn't actually charge anything.</p>
[ { "answer_id": 66890, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 1, "selected": false, "text": "<p>Most payment gateways provide such numbers for testing their services, but they will generally only work on the staging...
2008/09/15
[ "https://Stackoverflow.com/questions/66880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5314/" ]
After reading [this answer](https://stackoverflow.com/questions/63668/confessions-of-your-worst-wtf-moment-what-not-to-do#63730), I wonder if there's a way to get a "testing" credit card number. One that you can experiment with but that doesn't actually charge anything.
``` MasterCard: 5431111111111111 Amex: 341111111111111 Discover: 6011601160116611 American Express (15 digits) 378282246310005 American Express (15 digits) 371449635398431 American Express Corporate (15 digits) 378734493671000 Diners Club (14 digits) 30569309025904 Diners Club (14 digits) 38520000023237 Discover (1...
66,882
<p>Which is the simplest way to check if two integers have same sign? Is there any short bitwise trick to do this?</p>
[ { "answer_id": 66892, "author": "Yes - that Jake.", "author_id": 5287, "author_profile": "https://Stackoverflow.com/users/5287", "pm_score": 2, "selected": false, "text": "<p>if (x * y) > 0...</p>\n\n<p>assuming non-zero and such.</p>\n" }, { "answer_id": 66908, "author": "Da...
2008/09/15
[ "https://Stackoverflow.com/questions/66882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Which is the simplest way to check if two integers have same sign? Is there any short bitwise trick to do this?
Here is a version that works in C/C++ that doesn't rely on integer sizes or have the overflow problem (i.e. x\*y>=0 doesn't work) ``` bool SameSign(int x, int y) { return (x >= 0) ^ (y < 0); } ``` Of course, you can geek out and template: ``` template <typename valueType> bool SameSign(typename valueType x, typ...
66,912
<p>In a JSP page, I created a <code>&lt;h:form enctype="multipart/form-data"&gt;</code> with some elements: <code>&lt;t:inputText&gt;</code>, <code>&lt;t:inputDate&gt;</code>, etc. Also, I added some <code>&lt;t:message for="someElement"&gt;</code> And I wanted to allow the user upload several files (one at a time) wit...
[ { "answer_id": 72243, "author": "Kyle Renfro", "author_id": 8187, "author_profile": "https://Stackoverflow.com/users/8187", "pm_score": 1, "selected": false, "text": "<p>The <em>forceId</em> attribute of the tomahawk components should solve this problem.</p>\n\n<p>something like:</p>\n\n...
2008/09/15
[ "https://Stackoverflow.com/questions/66912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9818/" ]
In a JSP page, I created a `<h:form enctype="multipart/form-data">` with some elements: `<t:inputText>`, `<t:inputDate>`, etc. Also, I added some `<t:message for="someElement">` And I wanted to allow the user upload several files (one at a time) within the form (using `<t:inputFileUpload>` ) At this point my code works...
Looks like it may be related a bug in myfaces. There is a newer version of myfaces and tomahawk that you might try. I would remove the subview functionality as a quick test - copy the detail.jsp page back into the main page. <https://issues.apache.org/jira/browse/MYFACES-1807?page=com.atlassian.jira.plugin.system.issu...
66,921
<p>Short version: I want to trigger the Form_Load() event without making the form visible. This doesn't work because Show() ignores the current value of the Visible property:</p> <pre><code>tasksForm.Visible = false; tasksForm.Show(); </code></pre> <p>Long version: I have a WinForms application with two forms: main a...
[ { "answer_id": 66945, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 3, "selected": false, "text": "<p>It sounds to me like you need to sit down and re-think your approach here. I cannot imagine a single reason your public me...
2008/09/15
[ "https://Stackoverflow.com/questions/66921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4794/" ]
Short version: I want to trigger the Form\_Load() event without making the form visible. This doesn't work because Show() ignores the current value of the Visible property: ``` tasksForm.Visible = false; tasksForm.Show(); ``` Long version: I have a WinForms application with two forms: main and tasks. The main form i...
I totally agree with Rich B, you need to look at where you are placing your application logic rather than trying to cludge the WinForms mechanisms. All of those operations and data that your Tasks form is exposing should really be in a separate class say some kind of Application Controller or something held by your mai...
66,923
<p>So you have a String that is retrieved from an admin web UI (so it is definitely a String). How can you find out whether this string is an IP address or a hostname in Java?</p> <p>Update: I think I didn't make myself clear, I was more asking if there is anything in the Java SDK that I can use to distinguish between...
[ { "answer_id": 66944, "author": "Sam", "author_id": 9406, "author_profile": "https://Stackoverflow.com/users/9406", "pm_score": 5, "selected": true, "text": "<p>You can use a regular expression with this pattern:</p>\n\n<pre><code>\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.(25[0-5]|2[...
2008/09/15
[ "https://Stackoverflow.com/questions/66923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10059/" ]
So you have a String that is retrieved from an admin web UI (so it is definitely a String). How can you find out whether this string is an IP address or a hostname in Java? Update: I think I didn't make myself clear, I was more asking if there is anything in the Java SDK that I can use to distinguish between IPs and h...
You can use a regular expression with this pattern: ``` \b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b ``` That will tell you if it's an IPv4 address.
66,934
<p>We are automating Excel using VB.Net, and trying to place multiple lines of text on an Excel worksheet that we can set to not print. Between these we would have printable reports. We can do this if we add textbox objects, and set the print object setting to false. (If you have another way, please direct me)</p> <p>...
[ { "answer_id": 67740, "author": "dreamlax", "author_id": 10320, "author_profile": "https://Stackoverflow.com/users/10320", "pm_score": 4, "selected": true, "text": "<p>If you have the cell name or position, you can do:</p>\n\n<pre><code>With ActiveSheet\n .Shapes.AddTextbox msoTextOrien...
2008/09/15
[ "https://Stackoverflow.com/questions/66934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We are automating Excel using VB.Net, and trying to place multiple lines of text on an Excel worksheet that we can set to not print. Between these we would have printable reports. We can do this if we add textbox objects, and set the print object setting to false. (If you have another way, please direct me) The code t...
If you have the cell name or position, you can do: ``` With ActiveSheet .Shapes.AddTextbox msoTextOrientationHorizontal, .Cells(3,2).Left, .Cells(3,2).Top, .Cells(3,2).Width, .Cells(3,2).Height End With ``` This will add a textbox over cell B3. When B3 is resized, the textbox is also.
66,964
<p>For example:</p> <blockquote> <p>This is main body of my content. I have a footnote link for this line [1]. Then, I have some more content. Some of it is interesting and it has some footnotes as well [2].</p> <p>[1] Here is my first footnote.</p> <p>[2] Another footnote.</p> </blockquote> <p>So, ...
[ { "answer_id": 66977, "author": "Mike Becatti", "author_id": 6617, "author_profile": "https://Stackoverflow.com/users/6617", "pm_score": 0, "selected": false, "text": "<p>anchor tags using named anchors</p>\n\n<p><a href=\"http://www.w3schools.com/HTML/html_links.asp\" rel=\"nofollow nor...
2008/09/15
[ "https://Stackoverflow.com/questions/66964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
For example: > > This is main body of my content. I have a > footnote link for this line [1]. Then, I have some more > content. Some of it is interesting and it > has some footnotes as well [2]. > > > [1] Here is my first footnote. > > > [2] Another footnote. > > > So, if I click on the "[1]" link it direc...
Give a container an id, then use `#` to refer to that Id. e.g. ```html <p>This is main body of my content. I have a footnote link for this line <a href="#footnote-1">[1]</a>. Then, I have some more content. Some of it is interesting and it has some footnotes as well <a href="#footnote-2">[2]</a>.</p> <p id="footnot...
67,021
<p>I'm coding a framework along with a project which uses this framework. The project is a Bazaar repository, with the framework in a subfolder below the project.</p> <p>I want to give the framework a Bazaar repository of its own. How do I do it?</p>
[ { "answer_id": 67126, "author": "jamuraa", "author_id": 9805, "author_profile": "https://Stackoverflow.com/users/9805", "pm_score": 0, "selected": false, "text": "<p>As far as I know, there is not a way to do this easily with bazaar. One possibility is to take the original project, bra...
2008/09/15
[ "https://Stackoverflow.com/questions/67021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6681/" ]
I'm coding a framework along with a project which uses this framework. The project is a Bazaar repository, with the framework in a subfolder below the project. I want to give the framework a Bazaar repository of its own. How do I do it?
You use the split command: ``` bzr split sub_folder ``` This creates an independant tree in the subfolder, which you can now export and work on separately.
67,093
<p>The MySQL manual at <a href="http://web.archive.org/web/20160504181056/https://dev.mysql.com/doc/refman/5.1/en/rename-database.html" rel="noreferrer">MySQL</a> covers this.</p> <p>Usually I just dump the database and reimport it with a new name. This is not an option for very big databases. Apparently <code>RENAME {...
[ { "answer_id": 67123, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 4, "selected": false, "text": "<p>When you rename a database in PHPMyAdmin it creates a dump, then drops and recreates the database with the new name.</p>\n...
2008/09/15
[ "https://Stackoverflow.com/questions/67093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556/" ]
The MySQL manual at [MySQL](http://web.archive.org/web/20160504181056/https://dev.mysql.com/doc/refman/5.1/en/rename-database.html) covers this. Usually I just dump the database and reimport it with a new name. This is not an option for very big databases. Apparently `RENAME {DATABASE | SCHEMA} db_name TO new_db_name;...
For **InnoDB**, the following seems to work: create the new empty database, then rename each table in turn into the new database: ``` RENAME TABLE old_db.table TO new_db.table; ``` You will need to adjust the permissions after that. For scripting in a shell, you can use either of the following: ``` mysql -u userna...
67,141
<p>Does anybody here have positive experience of working with MS SQL Server 2005 from Rails 2.x?</p> <p>Our developers use Mac OS X, and our production runs on Linux. For legacy reasons we should use MS SQL Server 2005.</p> <p>We're using ruby-odbc and are running into various problems, too depressing to list here....
[ { "answer_id": 67962, "author": "Aupajo", "author_id": 10407, "author_profile": "https://Stackoverflow.com/users/10407", "pm_score": 1, "selected": false, "text": "<p>I would strongly suggest you weigh up migrating from the legacy database. You'll probably find yourself in a world of pai...
2008/09/15
[ "https://Stackoverflow.com/questions/67141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7754/" ]
Does anybody here have positive experience of working with MS SQL Server 2005 from Rails 2.x? Our developers use Mac OS X, and our production runs on Linux. For legacy reasons we should use MS SQL Server 2005. We're using ruby-odbc and are running into various problems, too depressing to list here. I get an impressio...
Have you considered using JRuby? Microsoft has a [JDBC driver for SQL Server](http://msdn.microsoft.com/en-us/data/aa937724.aspx) that can be run on UNIX variants (it's pure Java AFAIK). I was able to get the 2.0 technology preview working with JRuby and Rails 2.1 today. I haven't tried migrations yet, but so far the d...
67,219
<p>When I use the PrintOut method to print a Worksheet object to a printer, the "Printing" dialog (showing filename, destination printer, pages printed and a Cancel button) is displayed even though I have set DisplayAlerts = False. The code below works in an Excel macro but the same thing happens if I use this code in...
[ { "answer_id": 69726, "author": "Kevin Haines", "author_id": 10410, "author_profile": "https://Stackoverflow.com/users/10410", "pm_score": 2, "selected": true, "text": "<p>When you say the \"Printing\" Dialog, I assume you mean the \"Now printing xxx on \" dialog rather than standard pri...
2008/09/15
[ "https://Stackoverflow.com/questions/67219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7209/" ]
When I use the PrintOut method to print a Worksheet object to a printer, the "Printing" dialog (showing filename, destination printer, pages printed and a Cancel button) is displayed even though I have set DisplayAlerts = False. The code below works in an Excel macro but the same thing happens if I use this code in a V...
When you say the "Printing" Dialog, I assume you mean the "Now printing xxx on " dialog rather than standard print dialog (select printer, number of copies, etc). Taking your example above & trying it out, that is the behaviour I saw - "Now printing..." was displayed briefly & then auto-closed. What you're trying to c...
67,244
<p>How do I determine using TSQL what roles are granted execute permissions on a specific stored procedure? Is there a system stored procedure or a system view I can use?</p>
[ { "answer_id": 67417, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 0, "selected": false, "text": "<p>You can try something like this. Note, I believe 3 is EXECUTE.</p>\n\n<pre><code>SELECT\ngrantee_principal.name AS [Grant...
2008/09/15
[ "https://Stackoverflow.com/questions/67244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
How do I determine using TSQL what roles are granted execute permissions on a specific stored procedure? Is there a system stored procedure or a system view I can use?
In 7.0 or 2000, you can modify and use the following code: ``` SELECT convert(varchar(100), 'GRANT ' + CASE WHEN actadd & 32 = 32 THEN 'EXECUTE' ELSE CASE WHEN actadd & 1 = 1 THEN 'SELECT' + CASE WHEN actadd & (8|2|16) > 0 THEN ', ' ELSE '' END ELSE ''...
67,273
<p>How do you iterate through every file/directory recursively in standard C++?</p>
[ { "answer_id": 67286, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "<p>You need to call OS-specific functions for filesystem traversal, like <code>open()</code> and <code>readdir()</code>...
2008/09/15
[ "https://Stackoverflow.com/questions/67273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10184/" ]
How do you iterate through every file/directory recursively in standard C++?
In standard C++, technically there is no way to do this since standard C++ has no conception of directories. If you want to expand your net a little bit, you might like to look at using [Boost.FileSystem](http://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/index.htm). This has been accepted for inclusion in TR2, s...
67,275
<p>I am trying to read a single file from a <code>java.util.zip.ZipInputStream</code>, and copy it into a <code>java.io.ByteArrayOutputStream</code> (so that I can then create a <code>java.io.ByteArrayInputStream</code> and hand that to a 3rd party library that will end up closing the stream, and I don't want my <code>...
[ { "answer_id": 67367, "author": "Sunny Milenov", "author_id": 8220, "author_profile": "https://Stackoverflow.com/users/8220", "pm_score": -1, "selected": false, "text": "<p>Check if the input stream is positioned in the begging.</p>\n\n<p>Otherwise, as implementation: I do not think that...
2008/09/15
[ "https://Stackoverflow.com/questions/67275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
I am trying to read a single file from a `java.util.zip.ZipInputStream`, and copy it into a `java.io.ByteArrayOutputStream` (so that I can then create a `java.io.ByteArrayInputStream` and hand that to a 3rd party library that will end up closing the stream, and I don't want my `ZipInputStream` getting closed). I'm pro...
Your loop looks valid - what does the following code (just on it's own) return? ``` zipStream.read(tempBuffer) ``` if it's returning -1, then the zipStream is closed before you get it, and all bets are off. It's time to use your debugger and make sure what's being passed to you is actually valid. When you call getN...
67,300
<p>If you use the standard tab control in .NET for your tab pages and you try to change the look and feel a little bit then you are able to change the back color of the tab pages but not for the tab control. The property is available, you could set it but it has no effect. If you change the back color of the pages and ...
[ { "answer_id": 214082, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>The background color of the tab seems to be controlled by the OS's Display Properties. Specifically the under the appearan...
2008/09/15
[ "https://Stackoverflow.com/questions/67300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9470/" ]
If you use the standard tab control in .NET for your tab pages and you try to change the look and feel a little bit then you are able to change the back color of the tab pages but not for the tab control. The property is available, you could set it but it has no effect. If you change the back color of the pages and not...
The solution in Rajesh's blog is really useful, but it colours the tab part of the control only. In my case I had a tabcontrol on a different coloured background. The tabs themselves were grey which wasn't a problem, but the area to the right of the tabs was displaying as a grey strip. To change this colour to the co...
67,354
<p>I have an iframe. The content is wider than the width I am setting so the iframe gets a horizontal scroll bar. I can't increase the width of the iframe so I want to just remove the scroll bar. I tried setting the scroll property to "no" but that kills both scroll bars and I want the vertical one. I tried setting...
[ { "answer_id": 67568, "author": "Rich Adams", "author_id": 10018, "author_profile": "https://Stackoverflow.com/users/10018", "pm_score": 3, "selected": false, "text": "<p>You could try putting the iframe inside a div and then use the div for the scrolling. You can control the scrolling o...
2008/09/15
[ "https://Stackoverflow.com/questions/67354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5234/" ]
I have an iframe. The content is wider than the width I am setting so the iframe gets a horizontal scroll bar. I can't increase the width of the iframe so I want to just remove the scroll bar. I tried setting the scroll property to "no" but that kills both scroll bars and I want the vertical one. I tried setting overfl...
``` scrolling="yes" horizontalscrolling="no" verticalscrolling="yes" ``` Put that in your iFrame tag. You don't need to mess around with trying to format this in CSS.
67,370
<p>I'm programming WCF using the ChannelFactory which expects a type in order to call the CreateChannel method. For example: </p> <pre><code>IProxy proxy = ChannelFactory&lt;IProxy&gt;.CreateChannel(...); </code></pre> <p>In my case I'm doing routing so I don't know what type my channel factory will be using. I can p...
[ { "answer_id": 67530, "author": "IDisposable", "author_id": 2076, "author_profile": "https://Stackoverflow.com/users/2076", "pm_score": 6, "selected": true, "text": "<p>What you are looking for is MakeGenericType</p>\n\n<pre><code>string elementTypeName = Console.ReadLine();\nType elemen...
2008/09/15
[ "https://Stackoverflow.com/questions/67370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64/" ]
I'm programming WCF using the ChannelFactory which expects a type in order to call the CreateChannel method. For example: ``` IProxy proxy = ChannelFactory<IProxy>.CreateChannel(...); ``` In my case I'm doing routing so I don't know what type my channel factory will be using. I can parse a message header to determi...
What you are looking for is MakeGenericType ``` string elementTypeName = Console.ReadLine(); Type elementType = Type.GetType(elementTypeName); Type[] types = new Type[] { elementType }; Type listType = typeof(List<>); Type genericType = listType.MakeGenericType(types); IProxy proxy = (IProxy)Activator.CreateInstance...
67,410
<p><code>GNU sed version 4.1.5</code> seems to fail with International chars. Here is my input file:</p> <pre><code>Gras Och Stenar Trad - From Moja to Minneapolis DVD [G2007DVD] 7812 | X &lt;br&gt; Gras Och Stenar Trad - From Möja to Minneapolis DVD [G2007DVD] 7812 | Y </code></pre> <p>(Note the umlaut in the second...
[ { "answer_id": 67470, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "<p><code>sed</code> is not very well setup for non-ASCII text. However you can use (almost) the same code in <code>perl</code> ...
2008/09/15
[ "https://Stackoverflow.com/questions/67410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10251/" ]
`GNU sed version 4.1.5` seems to fail with International chars. Here is my input file: ``` Gras Och Stenar Trad - From Moja to Minneapolis DVD [G2007DVD] 7812 | X <br> Gras Och Stenar Trad - From Möja to Minneapolis DVD [G2007DVD] 7812 | Y ``` (Note the umlaut in the second line.) And when I do ``` sed 's/.*| //' ...
I think the error occurs if the input encoding of the file is different from the preferred encoding of your environment. Example: `in` is UTF-8 ``` $ LANG=de_DE.UTF-8 sed 's/.*| //' < in X Y $ LANG=de_DE.iso88591 sed 's/.*| //' < in X Y ``` UTF-8 can safely be interpreted as ISO-8859-1, you'll get strange charact...
67,418
<p>I have a "watcher" module that is currently using global hierarchies inside it. I need to instantiate a second instance of this with a second global hierarchy.</p> <p>Currently:</p> <pre><code>module watcher; wire sig = `HIER.sig; wire bar = `HIER.foo.bar; ... endmodule watcher w; // instantiation </code></pre> ...
[ { "answer_id": 68376, "author": "DMC", "author_id": 3148, "author_profile": "https://Stackoverflow.com/users/3148", "pm_score": 3, "selected": false, "text": "<p>My preference is to have a single module (or a small number of modules) in your testbench that contains all your probes but no...
2008/09/15
[ "https://Stackoverflow.com/questions/67418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8598/" ]
I have a "watcher" module that is currently using global hierarchies inside it. I need to instantiate a second instance of this with a second global hierarchy. Currently: ``` module watcher; wire sig = `HIER.sig; wire bar = `HIER.foo.bar; ... endmodule watcher w; // instantiation ``` Desired: ``` module watcher(i...
My preference is to have a single module (or a small number of modules) in your testbench that contains all your probes but no other functionality. All other modules in your testbench that require probes then connect to that "probe module". Use SystemVerilog interfaces in preference to raw wires if that's an option for...
67,492
<p>Let's say the first N integers divisible by 3 starting with 9.</p> <p>I'm sure there is some one line solution using lambdas, I just don't know it that area of the language well enough yet.</p>
[ { "answer_id": 67552, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 0, "selected": false, "text": "<p>I can't say this is any good, I'm not a C# expert and I just whacked it out, but I think it's probably a canonica...
2008/09/15
[ "https://Stackoverflow.com/questions/67492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
Let's say the first N integers divisible by 3 starting with 9. I'm sure there is some one line solution using lambdas, I just don't know it that area of the language well enough yet.
Just to be different (and to avoid using a where statement) you could also do: ``` var numbers = Enumerable.Range(0, n).Select(i => i * 3 + 9); ``` **Update** This also has the benefit of not running out of numbers.
67,518
<p>I am trying to get the <code>Edit with Vim</code> context menu to open files in a new tab of the previously opened Gvim instance (if any).</p> <p>Currently, using <code>Regedit</code> I have modified this key:</p> <pre><code>\HKEY-LOCAL-MACHINE\SOFTWARE\Vim\Gvim\path = "C:\Programs\Vim\vim72\gvim.exe" -p --remote-...
[ { "answer_id": 69920, "author": "kobusb", "author_id": 1620, "author_profile": "https://Stackoverflow.com/users/1620", "pm_score": 4, "selected": true, "text": "<p>Try setting it to: \"C:\\Programs\\Vim \\vim72\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\"</p>\n\n<p>See: <a href=\"htt...
2008/09/15
[ "https://Stackoverflow.com/questions/67518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10171/" ]
I am trying to get the `Edit with Vim` context menu to open files in a new tab of the previously opened Gvim instance (if any). Currently, using `Regedit` I have modified this key: ``` \HKEY-LOCAL-MACHINE\SOFTWARE\Vim\Gvim\path = "C:\Programs\Vim\vim72\gvim.exe" -p --remote-tab-silent "%*" ``` The registry key type...
Try setting it to: "C:\Programs\Vim \vim72\gvim.exe" -p --remote-tab-silent "%1" "%\*" See: <http://www.vim.org/tips/tip.php?tip_id=1314> EDIT: As pointed out by Thomas, vim.org tips moved to: <http://vim.wikia.com/> See: <http://vim.wikia.com/wiki/Add_open-in-tabs_context_menu_for_Windows>
67,561
<p>The <a href="http://en.wikipedia.org/wiki/Law_Of_Demeter" rel="noreferrer">wikipedia article</a> about <a href="http://c2.com/cgi/wiki?LawOfDemeter" rel="noreferrer">Law of Demeter</a> says:</p> <blockquote> <p>The law can be stated simply as "use only one dot".</p> </blockquote> <p>However a <a href="http://web...
[ { "answer_id": 67593, "author": "Quibblesome", "author_id": 1143, "author_profile": "https://Stackoverflow.com/users/1143", "pm_score": 3, "selected": false, "text": "<p>Yes, although you have to apply some pragmatism to the situation. I always take the Law of Demeter as a guideline as o...
2008/09/15
[ "https://Stackoverflow.com/questions/67561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2361/" ]
The [wikipedia article](http://en.wikipedia.org/wiki/Law_Of_Demeter) about [Law of Demeter](http://c2.com/cgi/wiki?LawOfDemeter) says: > > The law can be stated simply as "use only one dot". > > > However a [simple example](http://weblogs.asp.net/jgalloway/archive/2006/12/06/a-simple-example-of-a-fluent-interface...
Well, the short definition of the law shortens it too much. The real "law" (in reality advice on good API design) basically says: Only access objects you created yourself, or were passed to you as an argument. Do not access objects indirectly through other objects. Methods of fluent interfaces often return the object i...
67,612
<p>In Javascript: How does one find the coordinates (x, y, height, width) of every link in a webpage?</p>
[ { "answer_id": 67642, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 3, "selected": true, "text": "<p>Using jQuery, it's as simple as:</p>\n\n<pre><code>$(\"a\").each(function() {\n var link = $(this);\n var top = link.offs...
2008/09/15
[ "https://Stackoverflow.com/questions/67612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/401774/" ]
In Javascript: How does one find the coordinates (x, y, height, width) of every link in a webpage?
Using jQuery, it's as simple as: ``` $("a").each(function() { var link = $(this); var top = link.offset().top; var left = link.offset().left; var width = link.offset.width(); var height = link.offset.height(); }); ```
67,631
<p>How do I load a Python module given its full path?</p> <p>Note that the file can be anywhere in the filesystem where the user has access rights.</p> <hr /> <p><sub><strong>See also:</strong> <a href="https://stackoverflow.com/questions/301134">How to import a module given its name as string?</a></sub></p>
[ { "answer_id": 67672, "author": "Matt", "author_id": 10035, "author_profile": "https://Stackoverflow.com/users/10035", "pm_score": 3, "selected": false, "text": "<p>I believe you can use <a href=\"https://docs.python.org/2/library/imp.html#imp.find_module\" rel=\"noreferrer\"><code>imp.f...
2008/09/15
[ "https://Stackoverflow.com/questions/67631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10286/" ]
How do I load a Python module given its full path? Note that the file can be anywhere in the filesystem where the user has access rights. --- **See also:** [How to import a module given its name as string?](https://stackoverflow.com/questions/301134)
For Python 3.5+ use ([docs](https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly)): ``` import importlib.util import sys spec = importlib.util.spec_from_file_location("module.name", "/path/to/file.py") foo = importlib.util.module_from_spec(spec) sys.modules["module.name"] = foo spec.loader...
67,676
<p>How can I use .NET DataSet.Select method to search records that match a DateTime? What format should I use to enter my dates in?</p>
[ { "answer_id": 67696, "author": "Leo Moore", "author_id": 6336, "author_profile": "https://Stackoverflow.com/users/6336", "pm_score": 3, "selected": true, "text": "<p>The best method is dd MMM yyyy (ie 15 Sep 2008). This means there is no possiblity of getting it wrong for different Loca...
2008/09/15
[ "https://Stackoverflow.com/questions/67676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7277/" ]
How can I use .NET DataSet.Select method to search records that match a DateTime? What format should I use to enter my dates in?
The best method is dd MMM yyyy (ie 15 Sep 2008). This means there is no possiblity of getting it wrong for different Locals. ``` ds.select(DBDate = '15 Sep 2008') ``` You can use the DateFormat function to convert to long date format as well and this will work fine too.
67,682
<p>I'm trying to make it so when a user scrolls down a page, click a link, do whatever it is they need to do, and then come back to the pages w/ links, they are at the same (x-y) location in the browser they were before. How do I do that?</p> <p>I'm a DOM Newbie so I don't know too much about how to do this. </p> <...
[ { "answer_id": 67697, "author": "YonahW", "author_id": 3821, "author_profile": "https://Stackoverflow.com/users/3821", "pm_score": -1, "selected": false, "text": "<p>you can use offsetLeft and offsetTop</p>\n" }, { "answer_id": 67717, "author": "Lucas Oman", "author_id": ...
2008/09/15
[ "https://Stackoverflow.com/questions/67682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10352/" ]
I'm trying to make it so when a user scrolls down a page, click a link, do whatever it is they need to do, and then come back to the pages w/ links, they are at the same (x-y) location in the browser they were before. How do I do that? I'm a DOM Newbie so I don't know too much about how to do this. Target Browsers: ...
To get the x-y location of where a user clicked on a page, use the following jQuery code: ``` <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> jQuery(document).ready(function(){ $("#special").click(function(e){ ...
67,685
<p>I want my website to join some webcam recordings in FLV files (like this one). This needs to be done on Linux without user input. How do I do this? For simplicity's sake, I'll use the same flv as both inputs in hope of getting a flv that plays the same thing twice in a row.</p> <p>That should be easy enough, right?...
[ { "answer_id": 70991, "author": "Dark Shikari", "author_id": 11206, "author_profile": "https://Stackoverflow.com/users/11206", "pm_score": 0, "selected": false, "text": "<p>You'll encounter a very subtle problem here because most video and audio formats (especially in ordinary containers...
2008/09/15
[ "https://Stackoverflow.com/questions/67685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8279/" ]
I want my website to join some webcam recordings in FLV files (like this one). This needs to be done on Linux without user input. How do I do this? For simplicity's sake, I'll use the same flv as both inputs in hope of getting a flv that plays the same thing twice in a row. That should be easy enough, right? There's e...
I thought it would be a nice learning exercise to rewrite it in Ruby. It was. Six months later and three gems later, [here's the released product](http://github.com/marcandre/flvedit). I'll still be working a bit on it, but it works.
67,699
<p>My <code>master</code> and <code>development</code> branches are tracked remotely on <a href="http://en.wikipedia.org/wiki/GitHub" rel="noreferrer">GitHub</a>. How do I clone both these branches?</p>
[ { "answer_id": 67712, "author": "MattoxBeckman", "author_id": 10354, "author_profile": "https://Stackoverflow.com/users/10354", "pm_score": 5, "selected": false, "text": "<p>A <code>git clone</code> is supposed to copy the entire repository. Try cloning it, and then run <code>git branch...
2008/09/15
[ "https://Stackoverflow.com/questions/67699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/117/" ]
My `master` and `development` branches are tracked remotely on [GitHub](http://en.wikipedia.org/wiki/GitHub). How do I clone both these branches?
First, clone a remote [Git](http://en.wikipedia.org/wiki/Git_%28software%29) repository and [`cd`](http://en.wikipedia.org/wiki/Cd_%28command%29) into it: ``` $ git clone git://example.com/myproject $ cd myproject ``` Next, look at the local branches in your repository: ``` $ git branch * master ``` But there are...
67,713
<p>In Google Reader, you can use a bookmarklet to "note" a page you're visiting. When you press the bookmarklet, a little Google form is displayed on top of the current page. In the form you can enter a description, etc. When you press Submit, the form submits itself without leaving the page, and then the form disappea...
[ { "answer_id": 67897, "author": "Sam Hasler", "author_id": 2541, "author_profile": "https://Stackoverflow.com/users/2541", "pm_score": 0, "selected": false, "text": "<p>At it's very basic level it will be using <code>createElement</code> to create the elements to insert into the page and...
2008/09/15
[ "https://Stackoverflow.com/questions/67713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10155/" ]
In Google Reader, you can use a bookmarklet to "note" a page you're visiting. When you press the bookmarklet, a little Google form is displayed on top of the current page. In the form you can enter a description, etc. When you press Submit, the form submits itself without leaving the page, and then the form disappears....
Aupajo has it right. I will, however, point you towards a bookmarklet framework I worked up for our site ([www.iminta.com](http://www.iminta.com)). The bookmarklet itself reads as follows: ``` javascript:void((function(){ var e=document.createElement('script'); e.setAttribute('type','text/javascript'); e....
67,734
<p>I'd like to execute JavaScript code from within a C# assembly and have the results of the JavaScript code returned to the calling C# code.</p> <p>It's easier to define things that I'm not trying to do:</p> <ul> <li><p>I'm not trying to call a JavaScript function on a web page from my code behind.</p></li> <li><p>I...
[ { "answer_id": 67755, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 2, "selected": false, "text": "<p>You can use the Microsoft Javascript engine for <a href=\"http://www.west-wind.com/WebLog/posts/10688.aspx\" rel=\"no...
2008/09/15
[ "https://Stackoverflow.com/questions/67734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1538/" ]
I'd like to execute JavaScript code from within a C# assembly and have the results of the JavaScript code returned to the calling C# code. It's easier to define things that I'm not trying to do: * I'm not trying to call a JavaScript function on a web page from my code behind. * I'm not trying to load a WebBrowser con...
You can run your JSUnit from inside Nant using the JSUnit server, it's written in java and there is not a Nant task but you can run it from the command prompt, the results are logged as XML and you can them integrate them with your build report process. This won't be part of your Nunit result but an extra report. We fa...
67,760
<p>Has anyone got <a href="http://perldoc.perl.org/Sys/Syslog.html" rel="nofollow noreferrer">Sys::Syslog</a> to work on Solaris? (I'm running Sys::Syslog 0.05 on Perl v5.8.4 on SunOS 5.10 on SPARC). Here's what doesn't work for me:</p> <pre><code>openlog "myprog", "pid", "user" or die; syslog "crit", "%s", "Test fr...
[ { "answer_id": 68121, "author": "rjbs", "author_id": 10478, "author_profile": "https://Stackoverflow.com/users/10478", "pm_score": 2, "selected": false, "text": "<p>By default, Sys::Syslog is going to try to connect with one of the following socket types:</p>\n\n<pre><code>[ 'tcp', 'udp'...
2008/09/15
[ "https://Stackoverflow.com/questions/67760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Has anyone got [Sys::Syslog](http://perldoc.perl.org/Sys/Syslog.html) to work on Solaris? (I'm running Sys::Syslog 0.05 on Perl v5.8.4 on SunOS 5.10 on SPARC). Here's what doesn't work for me: ``` openlog "myprog", "pid", "user" or die; syslog "crit", "%s", "Test from $0" or die; closelog() or warn "Can't close: $!"; ...
By default, Sys::Syslog is going to try to connect with one of the following socket types: ``` [ 'tcp', 'udp', 'unix', 'stream' ] ``` On Solaris, though, you'll need to use an inet socket. Call: ``` setlogsock('inet', $hostname); ``` and things should start working.
67,761
<p>Despite the documentation, NetworkStream.Write does not appear to wait until the data has been sent. Instead, it waits until the data has been copied to a buffer and then returns. That buffer is transmitted in the background.</p> <p>This is the code I have at the moment. Whether I use ns.Write or ns.BeginWrite does...
[ { "answer_id": 67773, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 0, "selected": false, "text": "<p>How about using the Flush() method.</p>\n\n<pre><code>ns.Flush()\n</code></pre>\n\n<p>That should ensure the data is writt...
2008/09/15
[ "https://Stackoverflow.com/questions/67761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4495/" ]
Despite the documentation, NetworkStream.Write does not appear to wait until the data has been sent. Instead, it waits until the data has been copied to a buffer and then returns. That buffer is transmitted in the background. This is the code I have at the moment. Whether I use ns.Write or ns.BeginWrite doesn't matter...
I'm not a C# programmer, but the way you've asked this question is slightly misleading. The only way to know when your data has been "received", for any useful definition of "received", is to have a specific acknowledgment message in your protocol which indicates the data has been fully processed. The data does not "l...
67,790
<p>I have some code with multiple functions very similar to each other to look up an item in a list based on the contents of one field in a structure. The only difference between the functions is the type of the structure that the look up is occurring in. If I could pass in the type, I could remove all the code dupli...
[ { "answer_id": 67809, "author": "JohnnyLambada", "author_id": 9648, "author_profile": "https://Stackoverflow.com/users/9648", "pm_score": 0, "selected": false, "text": "<p>One way to do this is to have a type field as the first byte of the structure. Your receiving function looks at thi...
2008/09/15
[ "https://Stackoverflow.com/questions/67790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10394/" ]
I have some code with multiple functions very similar to each other to look up an item in a list based on the contents of one field in a structure. The only difference between the functions is the type of the structure that the look up is occurring in. If I could pass in the type, I could remove all the code duplicatio...
If you ensure that the field is placed in the same place in each such structure, you can simply cast a pointer to get at the field. This technique is used in lots of low level system libraries e.g. BSD sockets. ``` struct person { int index; }; struct clown { int index; char *hat; }; /* we're not going to defi...
67,798
<p>I'm looking for a multiline regex that will match occurrences after a blank line. For example, given a sample email below, I'd like to match "From: Alex". <code>^From:\s*(.*)$</code> works to match any From line, but I want it to be restricted to lines in the body (anything after the first blank line).</p> <pre> ...
[ { "answer_id": 67840, "author": "Sebastian Redl", "author_id": 8922, "author_profile": "https://Stackoverflow.com/users/8922", "pm_score": 0, "selected": false, "text": "<p>Writing complicated regular expressions for such jobs is a bad idea IMO. It's better to combine several simple quer...
2008/09/15
[ "https://Stackoverflow.com/questions/67798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10392/" ]
I'm looking for a multiline regex that will match occurrences after a blank line. For example, given a sample email below, I'd like to match "From: Alex". `^From:\s*(.*)$` works to match any From line, but I want it to be restricted to lines in the body (anything after the first blank line). ``` Received: from a serv...
I'm not sure of the syntax of C# regular expressions but you should have a way to anchor to the beginning of the string (not the beginning of the line such as ^). I'll call that "\A" in my example: ``` \A.*?\r?\n\r?\n.*?^From:\s*([^\r\n]+)$ ``` Make sure you turn the multiline matching option on, however that works,...
67,819
<p>In php, how can I get the number of apache children that are currently available <br>(<code>status = SERVER_READY</code> in the apache scoreboard)?</p> <p>I'm really hoping there is a simple way to do this in php that I am missing.</p>
[ { "answer_id": 67832, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": 2, "selected": false, "text": "<p>You could execute a shell command of <code>ps aux | grep httpd</code> or <code>ps aux | grep apache</code> and coun...
2008/09/15
[ "https://Stackoverflow.com/questions/67819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In php, how can I get the number of apache children that are currently available (`status = SERVER_READY` in the apache scoreboard)? I'm really hoping there is a simple way to do this in php that I am missing.
You could execute a shell command of `ps aux | grep httpd` or `ps aux | grep apache` and count the number of lines in the output. ``` exec('ps aux | grep apache', $output); $processes = count($output); ``` I'm not sure which status in the status column indicates that it's ready to accept a connection, but you can fi...
67,835
<p>Using VBA, how can I:</p> <ol> <li>test whether a file exists, and if so,</li> <li>delete it?</li> </ol>
[ { "answer_id": 67853, "author": "Leo Moore", "author_id": 6336, "author_profile": "https://Stackoverflow.com/users/6336", "pm_score": 3, "selected": false, "text": "<p>In VB its normally <code>Dir</code> to find the directory of the file. If it's not blank then it exists and then use <co...
2008/09/15
[ "https://Stackoverflow.com/questions/67835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10439/" ]
Using VBA, how can I: 1. test whether a file exists, and if so, 2. delete it?
1.) Check [here](http://www.tek-tips.com/faqs.cfm?fid=1936). Basically do this: ``` Function FileExists(ByVal FileToTest As String) As Boolean FileExists = (Dir(FileToTest) <> "") End Function ``` I'll leave it to you to figure out the various error handling needed but these are among the error handling things I'...
67,859
<p>I am trying to create a query string of variable assignments separated by the <code>&amp;</code> symbol (ex: <code>"var1=x&amp;var2=y&amp;..."</code>). I plan to pass this string into an embedded flash file.</p> <p>I am having trouble getting an <code>&amp;</code> symbol to show up in XSLT. If I just type <code>&am...
[ { "answer_id": 67876, "author": "Thunder3", "author_id": 2832, "author_profile": "https://Stackoverflow.com/users/2832", "pm_score": 3, "selected": false, "text": "<p>Use <code>disable-output-escaping=\"yes\"</code> in your <code>value-of</code> tag</p>\n" }, { "answer_id": 67886...
2008/09/15
[ "https://Stackoverflow.com/questions/67859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to create a query string of variable assignments separated by the `&` symbol (ex: `"var1=x&var2=y&..."`). I plan to pass this string into an embedded flash file. I am having trouble getting an `&` symbol to show up in XSLT. If I just type `&` with no tags around it, there is a problem rendering the XSLT do...
You can combine `disable-output-escaping` with a `CDATA` section. Try this: ``` <xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text> ```
67,890
<p>I'm writing a web app that points to external links. I'm looking to create a non-sequential, non-guessable id for each document that I can use in the URL. I did the obvious thing: treating the url as a string and str#crypt on it, but that seems to choke on any non-alphanumberic characters, like the slashes, dots and...
[ { "answer_id": 67900, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Use <a href=\"http://ruby-doc.org/stdlib/libdoc/digest/rdoc/index.html\" rel=\"nofollow noreferrer\">Digest::MD5</a> from Ru...
2008/09/15
[ "https://Stackoverflow.com/questions/67890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10461/" ]
I'm writing a web app that points to external links. I'm looking to create a non-sequential, non-guessable id for each document that I can use in the URL. I did the obvious thing: treating the url as a string and str#crypt on it, but that seems to choke on any non-alphanumberic characters, like the slashes, dots and un...
Depending on how long a string you would like you can use a few alternatives: ``` require 'digest' Digest.hexencode('http://foo-bar.com/yay/?foo=bar&a=22') # "687474703a2f2f666f6f2d6261722e636f6d2f7961792f3f666f6f3d62617226613d3232" require 'digest/md5' Digest::MD5.hexdigest('http://foo-bar.com/yay/?foo=bar&a=22') # ...
67,894
<p>Why do we need to use:</p> <pre><code>extern "C" { #include &lt;foo.h&gt; } </code></pre> <p><strong>Specifically:</strong> </p> <ul> <li><p>When should we use it?</p></li> <li><p>What is happening at the compiler/linker level that requires us to use it? </p></li> <li><p>How in terms of compilation/linking does...
[ { "answer_id": 67919, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 4, "selected": false, "text": "<p>It has to do with the way the different compilers perform name-mangling. A C++ compiler will mangle the name of a...
2008/09/15
[ "https://Stackoverflow.com/questions/67894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1597/" ]
Why do we need to use: ``` extern "C" { #include <foo.h> } ``` **Specifically:** * When should we use it? * What is happening at the compiler/linker level that requires us to use it? * How in terms of compilation/linking does this solve the problems which require us to use it?
C and C++ are superficially similar, but each compiles into a very different set of code. When you include a header file with a C++ compiler, the compiler is expecting C++ code. If, however, it is a C header, then the compiler expects the data contained in the header file to be compiled to a certain format—the C++ 'ABI...
67,916
<p>I have something that is driving me absolutely crazy...</p> <pre><code> Public Function GetAccountGroups() As IList(Of AccountGroup) Dim raw_account_groups As IList(Of AccountGroup) raw_account_groups = _repository.GetAccountGroups().ToList() Dim parents = (From ag In raw_account_groups _...
[ { "answer_id": 68795, "author": "Jeff Moser", "author_id": 1869, "author_profile": "https://Stackoverflow.com/users/1869", "pm_score": 0, "selected": false, "text": "<p>I haven't used VB.NET since moving to C# 3.0, but it seems like it could be a type inference issue. The error is a bit ...
2008/09/15
[ "https://Stackoverflow.com/questions/67916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10479/" ]
I have something that is driving me absolutely crazy... ``` Public Function GetAccountGroups() As IList(Of AccountGroup) Dim raw_account_groups As IList(Of AccountGroup) raw_account_groups = _repository.GetAccountGroups().ToList() Dim parents = (From ag In raw_account_groups _ ...
Lambda's in VB.Net have to return a value, so your equal sign ('=') is being intepreted as a comparison (so that the lambda returns a boolean), rather than an assignment.
67,959
<p>I've run into a few gotchas when doing C# XML serialization that I thought I'd share:</p> <ul> <li>You can't serialize items that are read-only (like KeyValuePairs)</li> <li>You can't serialize a generic dictionary. Instead, try this wrapper class (from <a href="http://weblogs.asp.net/pwelter34/archive/2006/05/03/4...
[ { "answer_id": 68005, "author": "Charles Graham", "author_id": 7705, "author_profile": "https://Stackoverflow.com/users/7705", "pm_score": 2, "selected": false, "text": "<p>Private variables/properties are not serialized in the default mechanism for XML serialization, but are in binary s...
2008/09/15
[ "https://Stackoverflow.com/questions/67959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109/" ]
I've run into a few gotchas when doing C# XML serialization that I thought I'd share: * You can't serialize items that are read-only (like KeyValuePairs) * You can't serialize a generic dictionary. Instead, try this wrapper class (from <http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx>): --- ``` using...
I can't make comments yet, so I will comment on Dr8k's post and make another observation. Private variables that are exposed as public getter/setter properties, and do get serialized/deserialized as such through those properties. We did it at my old job al the time. One thing to note though is that if you have any log...
68,012
<p>I am relatively new to JavaScript and am trying to understand how to use it correctly.</p> <p>If I wrap JavaScript code in an anonymous function to avoid making variables <code>public</code> the functions within the JavaScript are not available from within the html that includes the JavaScript. </p> <p>On initiall...
[ { "answer_id": 68026, "author": "HitScan", "author_id": 9490, "author_profile": "https://Stackoverflow.com/users/9490", "pm_score": 0, "selected": false, "text": "<p>It might be best not to wrap everything in an anonymous function and just hope that it is executed. You could name the fun...
2008/09/15
[ "https://Stackoverflow.com/questions/68012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am relatively new to JavaScript and am trying to understand how to use it correctly. If I wrap JavaScript code in an anonymous function to avoid making variables `public` the functions within the JavaScript are not available from within the html that includes the JavaScript. On initially loading the page the JavaS...
If you aren't using a javascript framework, I strongly suggest it. I use MooTools, but there are many others that are very solid (Prototype, YUI, jQuery, etc). These include methods for attaching functionality to the DomReady event. The problem with: ``` window.onload = function(){...}; ``` is that you can only ever...
68,018
<p>If I have a Resource bundle property file:</p> <p>A.properties:</p> <pre><code>thekey={0} This is a test </code></pre> <p>And then I have java code that loads the resource bundle:</p> <pre><code>ResourceBundle labels = ResourceBundle.getBundle("A", currentLocale); labels.getString("thekey"); </code></pre> <p>Ho...
[ { "answer_id": 68075, "author": "user10544", "author_id": 10544, "author_profile": "https://Stackoverflow.com/users/10544", "pm_score": 5, "selected": true, "text": "<p>The class you're looking for is java.text.MessageFormat; specifically, calling</p>\n\n<pre><code>MessageFormat.format(\...
2008/09/15
[ "https://Stackoverflow.com/questions/68018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10522/" ]
If I have a Resource bundle property file: A.properties: ``` thekey={0} This is a test ``` And then I have java code that loads the resource bundle: ``` ResourceBundle labels = ResourceBundle.getBundle("A", currentLocale); labels.getString("thekey"); ``` How can I replace the {0} text with some value ``` labels...
The class you're looking for is java.text.MessageFormat; specifically, calling ``` MessageFormat.format("{0} This {1} a test", new Object[] {"Yes!!!", "is"}); ``` or ``` MessageFormat.format("{0} This {1} a test", "Yes!!!", "is"); ``` will return ``` "Yes!!! This is a test" ``` [Unfortunately, I can't help wit...
68,042
<p>Let's say that on the C++ side my function takes a variable of type <code>jstring</code> named <code>myString</code>. I can convert it to an ANSI string as follows:</p> <pre><code>const char* ansiString = env-&gt;GetStringUTFChars(myString, 0); </code></pre> <p>is there a way of getting</p> <p><code>const wchar_t...
[ { "answer_id": 68065, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "<p>A portable and robust solution is to use <a href=\"http://www.gnu.org/software/libiconv/\" rel=\"nofollow noreferrer\">ico...
2008/09/15
[ "https://Stackoverflow.com/questions/68042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Let's say that on the C++ side my function takes a variable of type `jstring` named `myString`. I can convert it to an ANSI string as follows: ``` const char* ansiString = env->GetStringUTFChars(myString, 0); ``` is there a way of getting `const wchar_t* unicodeString =` ...
If this helps someone... I've used this function for an Android project: ``` std::wstring Java_To_WStr(JNIEnv *env, jstring string) { std::wstring value; const jchar *raw = env->GetStringChars(string, 0); jsize len = env->GetStringLength(string); const jchar *temp = raw; while (len > 0) { ...
68,067
<p>I'm using BlogEngine.NET (a fine, fine tool) and I was playing with the TinyMCE editor and noticed that there's a place for me to create a list of external links, but it has to be a javascript file:</p> <p><code>external_link_list_url : "example_link_list.js"</code></p> <p>this is great, of course, but the list of...
[ { "answer_id": 68117, "author": "mjallday", "author_id": 6084, "author_profile": "https://Stackoverflow.com/users/6084", "pm_score": 0, "selected": false, "text": "<p>If you can't change the file extension (and just return plain text, the caller shouldn't care about the file extension, j...
2008/09/15
[ "https://Stackoverflow.com/questions/68067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
I'm using BlogEngine.NET (a fine, fine tool) and I was playing with the TinyMCE editor and noticed that there's a place for me to create a list of external links, but it has to be a javascript file: `external_link_list_url : "example_link_list.js"` this is great, of course, but the list of links I want to use needs t...
I would create an HTTPHandler that responds with the desired data read from the db. Just associate the HTTPHandler with the particular filename 'example\_link\_list.js' in your web-config. Make sure you set ``` context.Response.ContentType = "text/javascript"; ``` then just context.Response.Write(); your list of ex...
68,103
<p>I have a XULRunner application that needs to copy image data to the clipboard. I have figured out how to handle copying text to the clipboard, and I can paste PNG data from the clipboard. What I can't figure out is how to get data from a data URL into the clipboard so that it can be pasted into other applications.</...
[ { "answer_id": 69119, "author": "pc1oad1etter", "author_id": 525, "author_profile": "https://Stackoverflow.com/users/525", "pm_score": 2, "selected": false, "text": "<p>Neal Deakin has an <a href=\"http://developer.mozilla.org/en/Using_the_Clipboard\" rel=\"nofollow noreferrer\">article ...
2008/09/16
[ "https://Stackoverflow.com/questions/68103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7441/" ]
I have a XULRunner application that needs to copy image data to the clipboard. I have figured out how to handle copying text to the clipboard, and I can paste PNG data from the clipboard. What I can't figure out is how to get data from a data URL into the clipboard so that it can be pasted into other applications. Thi...
Here's a workaround that I ended up using that solves the problem pretty well. The variable `dataURL` is the image I was trying to get to the clipboard in the first place. ``` var newImg=document.createElement('img'); newImg.src=dataURL; document.popupNode=newImg; var command='cmd_copyImageContents' var controller=...
68,120
<p>I'm not overly familiar with Tomcat, but my team has inherited a complex project that revolves around a Java Servlet being hosted in Tomcat across many servers. Custom configuration management software is used to write out the server.xml, and various resources (connection pools, beans, server variables, etc) written...
[ { "answer_id": 68140, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 7, "selected": true, "text": "<p>I've had some luck with <a href=\"http://wrapper.tanukisoftware.org/doc/english/introduction.html\" rel=\"noreferrer\">the ...
2008/09/16
[ "https://Stackoverflow.com/questions/68120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10452/" ]
I'm not overly familiar with Tomcat, but my team has inherited a complex project that revolves around a Java Servlet being hosted in Tomcat across many servers. Custom configuration management software is used to write out the server.xml, and various resources (connection pools, beans, server variables, etc) written in...
I've had some luck with [the Java Service Wrapper](http://wrapper.tanukisoftware.org/doc/english/introduction.html)
68,160
<p>Is it possible to get gdb or use some other tools to create a core dump of a running process and it's symbol table? It would be great if there's a way to do this without terminating the process. </p> <p>If this is possible, what commands would you use? (I'm trying to do this on a Linux box)</p>
[ { "answer_id": 68190, "author": "DustinB", "author_id": 7888, "author_profile": "https://Stackoverflow.com/users/7888", "pm_score": 7, "selected": true, "text": "<pre>\n$ gdb --pid=26426\n(gdb) gcore\nSaved corefile core.26426\n(gdb) detach\n</pre>\n" }, { "answer_id": 14279282, ...
2008/09/16
[ "https://Stackoverflow.com/questions/68160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
Is it possible to get gdb or use some other tools to create a core dump of a running process and it's symbol table? It would be great if there's a way to do this without terminating the process. If this is possible, what commands would you use? (I'm trying to do this on a Linux box)
``` $ gdb --pid=26426 (gdb) gcore Saved corefile core.26426 (gdb) detach ```
68,165
<p>I have a link on a long HTML page. When I click it, I wish a <code>div</code> on another part of the page to be visible in the window by scrolling into view.</p> <p>A bit like <code>EnsureVisible</code> in other languages.</p> <p>I've checked out <code>scrollTop</code> and <code>scrollTo</code> but they seem like...
[ { "answer_id": 68168, "author": "Mike Becatti", "author_id": 6617, "author_profile": "https://Stackoverflow.com/users/6617", "pm_score": 2, "selected": false, "text": "<p>Why not a named anchor?</p>\n" }, { "answer_id": 68175, "author": "mjallday", "author_id": 6084, ...
2008/09/16
[ "https://Stackoverflow.com/questions/68165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a link on a long HTML page. When I click it, I wish a `div` on another part of the page to be visible in the window by scrolling into view. A bit like `EnsureVisible` in other languages. I've checked out `scrollTop` and `scrollTo` but they seem like red herrings. Can anyone help?
old question, but if anyone finds this through google (as I did) and who does not want to use anchors or jquery; there's a builtin javascriptfunction to 'jump' to an element; ``` document.getElementById('youridhere').scrollIntoView(); ``` and what's even better; according to the great compatibility-tables on quirksm...
68,234
<p>Let’s say I'm developing a helpdesk application that will be used by multiple departments. Every URL in the application will include a key indicating the specific department. The key will always be the first parameter of every action in the system. For example</p> <pre><code>http://helpdesk/HR/Members http://helpde...
[ { "answer_id": 68348, "author": "Alex Lyman", "author_id": 5897, "author_profile": "https://Stackoverflow.com/users/5897", "pm_score": 0, "selected": false, "text": "<p><em>Disclaimer: I'm currently running MVC Preview 5, so some of this may be new.</em></p>\n\n<p>The best-practices way:...
2008/09/16
[ "https://Stackoverflow.com/questions/68234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Let’s say I'm developing a helpdesk application that will be used by multiple departments. Every URL in the application will include a key indicating the specific department. The key will always be the first parameter of every action in the system. For example ``` http://helpdesk/HR/Members http://helpdesk/HR/Members/...
I have a similar scenario in one of my projects, and I'd tend to use a ModelBinder rather than using a separate inheritance hierarchy. You can make a ModelBinder attribute to fetch the entity/entites from the RouteData: ``` public class HelpdeskDepartmentBinder : CustomModelBinderAttribute, IModelBinder { public ...
68,282
<p>When defining a method on a class in Python, it looks something like this:</p> <pre><code>class MyClass(object): def __init__(self, x, y): self.x = x self.y = y </code></pre> <p>But in some other languages, such as C#, you have a reference to the object that the method is bound to with the "thi...
[ { "answer_id": 68320, "author": "Ryan", "author_id": 8819, "author_profile": "https://Stackoverflow.com/users/8819", "pm_score": 6, "selected": false, "text": "<p>It's to minimize the difference between methods and functions. It allows you to easily generate methods in metaclasses, or ad...
2008/09/16
[ "https://Stackoverflow.com/questions/68282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
When defining a method on a class in Python, it looks something like this: ``` class MyClass(object): def __init__(self, x, y): self.x = x self.y = y ``` But in some other languages, such as C#, you have a reference to the object that the method is bound to with the "this" keyword without declari...
I like to quote Peters' Zen of Python. "Explicit is better than implicit." In Java and C++, '`this.`' can be deduced, except when you have variable names that make it impossible to deduce. So you sometimes need it and sometimes don't. Python elects to make things like this explicit rather than based on a rule. Addi...