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 |
|---|---|---|---|---|---|---|
279,572 | <p>I have a database where one of the common queries is has a "where blobCol is null", I think that this is getting bad performance (as in a full table scan). I have no need to index the contents of the blobCol. </p>
<p>What indexes would improve this? Can an index be built on an expression (blobCol is not null) rathe... | [
{
"answer_id": 279578,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 1,
"selected": false,
"text": "<p>Some databases allow indexes on expressions but a plain index should reduce the running time of your query signif... | 2008/11/10 | [
"https://Stackoverflow.com/questions/279572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | I have a database where one of the common queries is has a "where blobCol is null", I think that this is getting bad performance (as in a full table scan). I have no need to index the contents of the blobCol.
What indexes would improve this? Can an index be built on an expression (blobCol is not null) rather than jus... | Yes, most DBMSs support it, for instance in [PostgreSQL](http://www.postgresql.org/docs/8.2/static/sql-createindex.html) it is
```
CREATE INDEX notNullblob ON myTable (blobCol is not NULL);
```
It seems that the best you could do on SQL Server though is to create a [computed column](http://msdn.microsoft.com/en-us/l... |
279,575 | <p>HI All,</p>
<p>I have a piece of javaScript that removes commas from a provided string (in my case currency values)</p>
<p>It is:</p>
<pre><code> function replaceCommaInCurrency(myField, val)
{
var re = /,/g;
document.net1003Form.myField.value=val.replace(re, '');
}
</code></pre>
<p>'... | [
{
"answer_id": 279604,
"author": "flatline",
"author_id": 20846,
"author_profile": "https://Stackoverflow.com/users/20846",
"pm_score": 2,
"selected": false,
"text": "<p>If you code it right into the markup like that, e.g. onblur=\"replaceCommaInCurrency(this)\", the control originating ... | 2008/11/10 | [
"https://Stackoverflow.com/questions/279575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | HI All,
I have a piece of javaScript that removes commas from a provided string (in my case currency values)
It is:
```
function replaceCommaInCurrency(myField, val)
{
var re = /,/g;
document.net1003Form.myField.value=val.replace(re, '');
}
```
'MyField' was my attempt to dynamically h... | You can use eval to make your code snippet work:
```
eval("document.net1003Form." + myField + ".value=val.replace(re, '');");
```
As mentioned below, the square brackets work (and don't suck like eval), stupid me for forgetting about those:
```
document.net1003Form[myField].value=val.replace(re, '');
```
Alternat... |
279,583 | <p>I have a very basic app that I believe should change the width of an image, but it does nothing... can anyone tell me why, when I click on the image, nothing happens to the image? </p>
<p><em>(note, the image itself doesnt really matter, Im just trying to figure out how to shrink and grow and image in JavaFX)</em><... | [
{
"answer_id": 279604,
"author": "flatline",
"author_id": 20846,
"author_profile": "https://Stackoverflow.com/users/20846",
"pm_score": 2,
"selected": false,
"text": "<p>If you code it right into the markup like that, e.g. onblur=\"replaceCommaInCurrency(this)\", the control originating ... | 2008/11/10 | [
"https://Stackoverflow.com/questions/279583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26310/"
] | I have a very basic app that I believe should change the width of an image, but it does nothing... can anyone tell me why, when I click on the image, nothing happens to the image?
*(note, the image itself doesnt really matter, Im just trying to figure out how to shrink and grow and image in JavaFX)*
```
import javaf... | You can use eval to make your code snippet work:
```
eval("document.net1003Form." + myField + ".value=val.replace(re, '');");
```
As mentioned below, the square brackets work (and don't suck like eval), stupid me for forgetting about those:
```
document.net1003Form[myField].value=val.replace(re, '');
```
Alternat... |
279,601 | <p>I have a <code>vector</code> that I want to insert into a <code>set</code>. This is one of three different calls (the other two are more complex, involving <code>boost::lambda::if_()</code>), but solving this simple case will help me solve the others.</p>
<pre><code>std::vector<std::string> s_vector;
std::set... | [
{
"answer_id": 279649,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 1,
"selected": false,
"text": "<p>I think part of the problem is that <code>for_each()</code> is expecting a functor and you're passing it the result of ... | 2008/11/10 | [
"https://Stackoverflow.com/questions/279601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36378/"
] | I have a `vector` that I want to insert into a `set`. This is one of three different calls (the other two are more complex, involving `boost::lambda::if_()`), but solving this simple case will help me solve the others.
```
std::vector<std::string> s_vector;
std::set<std::string> s_set;
std::for_each(s_vector.begin(), ... | >
> The error is really nasty, but boils down to the fact that it can't figure out which set::insert to use, since there's three overloads.
>
>
>
You can work around the ambiguity by giving bind a helpful hand, by specifying a pointer to the function you wish to use:
```
typedef std::set<std::string> s_type;
type... |
279,610 | <p>I want to create a history table to track field changes across a number of tables in DB2. </p>
<p>I know history is usually done with copying an entire table's structure and giving it a suffixed name (e.g. user --> user_history). Then you can use a pretty simple trigger to copy the old record into the history table... | [
{
"answer_id": 279649,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 1,
"selected": false,
"text": "<p>I think part of the problem is that <code>for_each()</code> is expecting a functor and you're passing it the result of ... | 2008/11/10 | [
"https://Stackoverflow.com/questions/279610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to create a history table to track field changes across a number of tables in DB2.
I know history is usually done with copying an entire table's structure and giving it a suffixed name (e.g. user --> user\_history). Then you can use a pretty simple trigger to copy the old record into the history table on an UP... | >
> The error is really nasty, but boils down to the fact that it can't figure out which set::insert to use, since there's three overloads.
>
>
>
You can work around the ambiguity by giving bind a helpful hand, by specifying a pointer to the function you wish to use:
```
typedef std::set<std::string> s_type;
type... |
279,631 | <p>I'm trying to load an external swf movie then adding the ability to drag it around the stage, however whenever I try to do this I just hit a dead end. Are there any limitations on what you can set be draggable or clickable? An example of what I'm doing is below:</p>
<pre><code>public function loadSwf(url:String, sw... | [
{
"answer_id": 281754,
"author": "mgbennet",
"author_id": 32139,
"author_profile": "https://Stackoverflow.com/users/32139",
"pm_score": 1,
"selected": false,
"text": "<p>Something of a shot in the dark, but could you make a transparent movie clip on top of the movie that's loaded that is... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26081/"
] | I'm trying to load an external swf movie then adding the ability to drag it around the stage, however whenever I try to do this I just hit a dead end. Are there any limitations on what you can set be draggable or clickable? An example of what I'm doing is below:
```
public function loadSwf(url:String, swfUniqueName:St... | If there is empty space in your content, Flash will treat it like you have clicked THROUGH the clip to the stage below. Try adding a transparent square to the bottom layer of the content you're loading.
Also try setting:
`ldr.content.mouseChildren = false;` |
279,634 | <p>I have this piece of Javascript and it just won't work. I allready checked JSlint but that said everything works. Still doesn't work. The javascript is located not in the HTML but is linked in the <code><head></code></p>
<p>note: I am working with a local server, so pageload in instant.</p>
<pre><code>functi... | [
{
"answer_id": 279637,
"author": "mercutio",
"author_id": 1951,
"author_profile": "https://Stackoverflow.com/users/1951",
"pm_score": 4,
"selected": true,
"text": "<p>This sounds like the DOM object doesn't exist at the time of referencing it. Perhaps change your code to execute once the... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] | I have this piece of Javascript and it just won't work. I allready checked JSlint but that said everything works. Still doesn't work. The javascript is located not in the HTML but is linked in the `<head>`
note: I am working with a local server, so pageload in instant.
```
function changeVisibility() {
var a = do... | This sounds like the DOM object doesn't exist at the time of referencing it. Perhaps change your code to execute once the document has fully loaded (or place the javascript at the bottom of your page)
>
> note: I am working with a local server, so pageload in instant.
>
>
>
that's not the issue - the constituent ... |
279,665 | <p>How can I return the result of a different action or move the user to a different action if there is an error in my <code>ModelState</code> without losing my <code>ModelState</code> information?</p>
<p>The scenario is; <code>Delete</code> action accepts a POST from a DELETE form rendered by my <code>Index</code> Act... | [
{
"answer_id": 279680,
"author": "Ty.",
"author_id": 16948,
"author_profile": "https://Stackoverflow.com/users/16948",
"pm_score": -1,
"selected": false,
"text": "<p>Maybe try</p>\n\n<pre><code>return View(\"Index\");\n</code></pre>\n\n<p>instead of</p>\n\n<pre><code>return Index();\n</c... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | How can I return the result of a different action or move the user to a different action if there is an error in my `ModelState` without losing my `ModelState` information?
The scenario is; `Delete` action accepts a POST from a DELETE form rendered by my `Index` Action/View. If there is an error in the `Delete` I want... | Store your view data in `TempData` and retrieve it from there in your `Index` action, if it exists.
```
...
if (!ModelState.IsValid)
TempData["ViewData"] = ViewData;
RedirectToAction( "Index" );
}
public ActionResult Index()
{
if (TempData["ViewData"] != null)
{
ViewData = (ViewD... |
279,673 | <p>I wonder if it's possible to save all files in a Visual Studio 2008 project into a specific character encoding. I got a solution with mixed encodings and I want to make them all the same (UTF-8 with signature).</p>
<p>I know how to save single files, but how about all files in a project?</p>
| [
{
"answer_id": 279706,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": -1,
"selected": false,
"text": "<p>I'm only offering this suggestion in case there's no way to automatically do this in Visual Studio (I'm not even s... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33349/"
] | I wonder if it's possible to save all files in a Visual Studio 2008 project into a specific character encoding. I got a solution with mixed encodings and I want to make them all the same (UTF-8 with signature).
I know how to save single files, but how about all files in a project? | Since you're already in Visual Studio, why not just simply write the code?
```cs
foreach (var f in new DirectoryInfo(@"...").GetFiles("*.cs", SearchOption.AllDirectories)) {
string s = File.ReadAllText(f.FullName);
File.WriteAllText (f.FullName, s, Encoding.UTF8);
}
```
Only three lines of code! I'm sure you can... |
279,696 | <p>Still struggling to understand what best practices are with respect to macros. I'm attempting to write a macro which defines packages on the fly.</p>
<pre><code>(defmacro def-dynamic-package (name)
`(defpackage ,(intern (string-upcase name) "KEYWORD")
(:use :common-lisp)))
</code></pre>
<p>This works fine ... | [
{
"answer_id": 279725,
"author": "Nowhere man",
"author_id": 400277,
"author_profile": "https://Stackoverflow.com/users/400277",
"pm_score": 0,
"selected": false,
"text": "<p>Failure is to be expected here, because a macro is used when its argument should not be evaluated.</p>\n\n<p>In y... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32797/"
] | Still struggling to understand what best practices are with respect to macros. I'm attempting to write a macro which defines packages on the fly.
```
(defmacro def-dynamic-package (name)
`(defpackage ,(intern (string-upcase name) "KEYWORD")
(:use :common-lisp)))
```
This works fine only for expressions such a... | **defpackage** is a macro. As such, it's expanded at compile-time, not run-time. What you want is something that is called at run-time in order to make a new package. Therefore, **defpackage** can't do anything for you.
Fortunately, there's also **[make-package](http://www.lispworks.com/documentation/HyperSpec/Body/f_... |
279,701 | <p>I'm trying to get a handle on if there's a good time to use standard linq keywords or linq extension methods with lambda expressions. They seems to do the same thing, just are written differently. Is it purely a matter of style?</p>
<pre><code>var query = from p in Products
where p.Name.Contains("foo")
or... | [
{
"answer_id": 279719,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 3,
"selected": false,
"text": "<p>They compile the same, and are equivalent. Personally, I prefer the lambda (extension) methods for most things, onl... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26931/"
] | I'm trying to get a handle on if there's a good time to use standard linq keywords or linq extension methods with lambda expressions. They seems to do the same thing, just are written differently. Is it purely a matter of style?
```
var query = from p in Products
where p.Name.Contains("foo")
orderby c.Name
... | Honestly, sometimes it can be situational once you start using Funcs and Actions. Say you are using these three funcs:
```
Func<DataClasses.User, String> userName = user => user.UserName;
Func<DataClasses.User, Boolean> userIDOverTen = user => user.UserID < 10;
Func<DataClasses.User, Boolean> userIDUnderTen = us... |
279,729 | <p>I am forking a number of processes and I want to measure how long it takes to complete the whole task, that is when all processes forked are completed. Please advise how to make the parent process wait until all child processes are terminated? I want to make sure that I stop the timer at the right moment.</p>
<p>He... | [
{
"answer_id": 279736,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 2,
"selected": false,
"text": "<p>I believe the <a href=\"http://linux.die.net/man/2/wait\" rel=\"nofollow noreferrer\">wait system call</a> will accompl... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3515/"
] | I am forking a number of processes and I want to measure how long it takes to complete the whole task, that is when all processes forked are completed. Please advise how to make the parent process wait until all child processes are terminated? I want to make sure that I stop the timer at the right moment.
Here is as a... | I'd move everything after the line "else //parent" down, outside the for loop. After the loop of forks, do another for loop with waitpid, then stop the clock and do the rest:
```
for (int i = 0; i < pidCount; ++i) {
int status;
while (-1 == waitpid(pids[i], &status, 0));
if (!WIFEXITED(status) || WEXITSTAT... |
279,748 | <p>I have some code like this:</p>
<pre><code>[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Save([Bind(Prefix="")]Person person)
{
String s = person.property;
/* ... */
}
</code></pre>
<p>But it throws the error: "Cannot use local variable 'person' before it is declared".</p>
<p>What simple thing am I mi... | [
{
"answer_id": 279829,
"author": "Matt Mitchell",
"author_id": 364,
"author_profile": "https://Stackoverflow.com/users/364",
"pm_score": 3,
"selected": true,
"text": "<p>Okay, this is just some really bizarre error - if the variable is named a particular name it does not work, for any ot... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | I have some code like this:
```
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Save([Bind(Prefix="")]Person person)
{
String s = person.property;
/* ... */
}
```
But it throws the error: "Cannot use local variable 'person' before it is declared".
What simple thing am I missing? | Okay, this is just some really bizarre error - if the variable is named a particular name it does not work, for any other name it does work... |
279,769 | <p>How do you convert between a DateTime and a Time object in Ruby?</p>
| [
{
"answer_id": 279785,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 7,
"selected": true,
"text": "<p>You'll need two slightly different conversions.</p>\n\n<p>To convert from <code> Time </code> to <code> DateTime</... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | How do you convert between a DateTime and a Time object in Ruby? | You'll need two slightly different conversions.
To convert from `Time` to `DateTime` you can amend the Time class as follows:
```
require 'date'
class Time
def to_datetime
# Convert seconds + microseconds into a fractional number of seconds
seconds = sec + Rational(usec, 10**6)
# Convert a UTC offse... |
279,779 | <p>I know in the MVC Framework, you have the Html Class to create URLs:</p>
<pre><code>Html.ActionLink("About us", "about", "home");
</code></pre>
<p>But what if you want to generate Urls in Webforms?</p>
<p>I haven't found a really good resource on the details on generating URLs with Webf... | [
{
"answer_id": 279980,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": -1,
"selected": false,
"text": "<p>Hyperlink hl = new Hyperlink();\nhl.Text = \"click here\";\nhl.NavigateUrl=\"~/Forms/Article.aspx\";\nMostlyAnyControl.C... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26931/"
] | I know in the MVC Framework, you have the Html Class to create URLs:
```
Html.ActionLink("About us", "about", "home");
```
But what if you want to generate Urls in Webforms?
I haven't found a really good resource on the details on generating URLs with Webforms.
For example, if I'm generating routes like so:
```
R... | As you say, ASP.NET MVC offers you a set of helper methods to "reverse lookup" the RouteTable and generate a URL for you. I've not played with this much yet but as far as I can see you need to call the GetVirtualPath method on a RouteCollection (most likely RouteTable.Routes). So something like:
```
Dim routedurl = Ro... |
279,781 | <p>Hey everyone, I am trying to run the following program, but am getting a NullPointerException. I am new to the Java swing library so I could be doing something very dumb. Either way here are my two classes I am just playing around for now and all i want to do is draw a damn circle (ill want to draw a gallow, with a ... | [
{
"answer_id": 279798,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 3,
"selected": true,
"text": "<p>You're getting NPE because <code>g</code> is not set, therefore, it's <code>null</code>. Furthermore, you shouldn't be doi... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29326/"
] | Hey everyone, I am trying to run the following program, but am getting a NullPointerException. I am new to the Java swing library so I could be doing something very dumb. Either way here are my two classes I am just playing around for now and all i want to do is draw a damn circle (ill want to draw a gallow, with a han... | You're getting NPE because `g` is not set, therefore, it's `null`. Furthermore, you shouldn't be doing the drawing in the constructor. Overload [`paintComponent(Graphics g)`](http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JComponent.html#paintComponent(java.awt.Graphics)) instead.
```
public class Gallow extends ... |
279,782 | <p>Given:</p>
<pre><code>from django.db import models
class Food(models.Model):
"""Food, by name."""
name = models.CharField(max_length=25)
class Cat(models.Model):
"""A cat eats one type of food"""
food = models.ForeignKey(Food)
class Cow(models.Model):
"""A cow eats one type of food"""
... | [
{
"answer_id": 279809,
"author": "Brian M. Hunt",
"author_id": 19212,
"author_profile": "https://Stackoverflow.com/users/19212",
"pm_score": 4,
"selected": false,
"text": "<p>Some digging in the source code revealed:</p>\n\n<p>django/db/models/options.py:</p>\n\n<pre><code>def get_all_re... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19212/"
] | Given:
```
from django.db import models
class Food(models.Model):
"""Food, by name."""
name = models.CharField(max_length=25)
class Cat(models.Model):
"""A cat eats one type of food"""
food = models.ForeignKey(Food)
class Cow(models.Model):
"""A cow eats one type of food"""
food = mode... | Either
A) Use [multiple table inheritance](http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance) and create a "Eater" base class, that Cat, Cow and Human inherit from.
B) Use a [Generic Relation](http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1), where Food could be linked... |
279,791 | <p>Suppose the following data schema:</p>
<pre><code>Usage
======
client_id
resource
type
amount
Billing
======
client_id
usage_resource
usage_type
rate
</code></pre>
<p>In this example, suppose I have multiple resources, each of which can be used in many ways. For example, one resource is a <code>widget</code>. <... | [
{
"answer_id": 279838,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "<p>There is apparently an project at sourceforge to extend Rails' ActiveRecord with support for <a href=\"http://compos... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4257/"
] | Suppose the following data schema:
```
Usage
======
client_id
resource
type
amount
Billing
======
client_id
usage_resource
usage_type
rate
```
In this example, suppose I have multiple resources, each of which can be used in many ways. For example, one resource is a `widget`. `Widgets` can be `foo`ed and they can be... | There is apparently an project at sourceforge to extend Rails' ActiveRecord with support for [Composite Primary Keys](http://compositekeys.rubyforge.org/). I haven't used this extension, but it might help you. It's also a gem at rubyforge.
Plain Ruby on Rails, as of version 2.0, does not support compound primary keys ... |
279,822 | <p>I'm looking for a (preferably free) component for Delphi for users to easily select about 100 different colours.</p>
<p>I've currently got one as part of DevExpress's editors, but it only has about 20 proper colours to choose, with a bunch of other 'Windows' colours like clHighlight, clBtnFace, etc.</p>
<p>It's fo... | [
{
"answer_id": 279864,
"author": "moobaa",
"author_id": 3569,
"author_profile": "https://Stackoverflow.com/users/3569",
"pm_score": 4,
"selected": false,
"text": "<p>Delphi Gems' Color Picker control, maybe?</p>\n\n<p><a href=\"http://www.soft-gems.net/index.php/controls/color-picker-con... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26305/"
] | I'm looking for a (preferably free) component for Delphi for users to easily select about 100 different colours.
I've currently got one as part of DevExpress's editors, but it only has about 20 proper colours to choose, with a bunch of other 'Windows' colours like clHighlight, clBtnFace, etc.
It's for regular users, ... | What's wrong with the TColorDialog?
It gives you the standard Windows color dialog, exactly the same as in MSPaint...
Add these options to show it directly expanded and with all colors available.
```
object ColorDialog1: TColorDialog
Options = [cdFullOpen, cdAnyColor]
end
``` |
279,833 | <p>I am not looking for links to information on hashing.</p>
<p>I am not looking for the worlds greatest hash function.</p>
<p>I am interested in mini-stories describing</p>
<ul>
<li>The problem domain you were working in</li>
<li>The nature of the data you were working with</li>
<li>What your thought process was in... | [
{
"answer_id": 279877,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 3,
"selected": false,
"text": "<p>The first issue I consider is whether an established algorithm will suit my requirements.</p>\n"
},
{
"answer... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | I am not looking for links to information on hashing.
I am not looking for the worlds greatest hash function.
I am interested in mini-stories describing
* The problem domain you were working in
* The nature of the data you were working with
* What your thought process was in designing a hash function for your data.
... | Doing data warehouse development. We had a dimension with about 9,000 rows. The queries that were being developed included some really ugly queries.
So, I started analyzing the dimension rows. Dimension rows were clustered based on various combinations of columns. The clustering was a map from some key to a list of di... |
279,837 | <p>It's kind of a C puzzle. You have to tell if the program finish its execution, if so, how much time it takes to run and what it returns to the OS.</p>
<pre><code>static unsigned char buffer[256];
int main(void)
{
unsigned char *p, *q;
q = (p = buffer) + sizeof(buffer);
while (q - p)
{
p = buffer... | [
{
"answer_id": 279855,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 4,
"selected": false,
"text": "<p>this code is garbage, see comments</p>\n\n<pre><code>static unsigned char buffer[256];\nint main(void)\n{\n unsig... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1876/"
] | It's kind of a C puzzle. You have to tell if the program finish its execution, if so, how much time it takes to run and what it returns to the OS.
```
static unsigned char buffer[256];
int main(void)
{
unsigned char *p, *q;
q = (p = buffer) + sizeof(buffer);
while (q - p)
{
p = buffer;
while ... | Despite the fact that this is a horrible interview question, it is actually quite interesting:
```
static unsigned char buffer[256];
int main(void)
{
unsigned char *p, *q;
q = (p = buffer) + sizeof(buffer);
/* This statement will set p to point to the beginning of buffer and will
set q to point to one past... |
279,854 | <p>If I have a vector of pairs:</p>
<pre><code>std::vector<std::pair<int, int> > vec;
</code></pre>
<p>Is there and easy way to sort the list in <strong>increasing</strong> order based on the second element of the pair?</p>
<p>I know I can write a little function object that will do the work, but is there a... | [
{
"answer_id": 279863,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 1,
"selected": false,
"text": "<p>You'd have to rely on a non standard <a href=\"http://www.sgi.com/tech/stl/select2nd.html\" rel=\"nofollow noreferrer... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34502/"
] | If I have a vector of pairs:
```
std::vector<std::pair<int, int> > vec;
```
Is there and easy way to sort the list in **increasing** order based on the second element of the pair?
I know I can write a little function object that will do the work, but is there a way to use existing parts of the *STL* and `std::less`... | **EDIT**: using c++14, the best solution is very easy to write thanks to lambdas that can now have parameters of type `auto`. **This is my current favorite solution**
```
std::sort(v.begin(), v.end(), [](auto &left, auto &right) {
return left.second < right.second;
});
```
---
**ORIGINAL ANSWER**:
Just use a c... |
279,860 | <h2>Background</h2>
<p>I'm trying out Scons by setting up a basic C++ sample project that has two sub-projects: </p>
<ul>
<li>Prj1 is an EXE that depends on Prj2</li>
<li>Prj2 is a DLL that exports some functions</li>
</ul>
<p>The problem I'm running into is that the library builds its .obj, .pdb, .lib, .dll, etc. f... | [
{
"answer_id": 279883,
"author": "grieve",
"author_id": 34329,
"author_profile": "https://Stackoverflow.com/users/34329",
"pm_score": 2,
"selected": false,
"text": "<p>VariantDir is the way to do this. How does your Sconstruct call your Sconscript files? Also have you read this section o... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2233/"
] | Background
----------
I'm trying out Scons by setting up a basic C++ sample project that has two sub-projects:
* Prj1 is an EXE that depends on Prj2
* Prj2 is a DLL that exports some functions
The problem I'm running into is that the library builds its .obj, .pdb, .lib, .dll, etc. files in the same directory as it'... | Ok Third try is a charm. I am just placing this in a new answer to keep it cleaner. I talked with my local scons guru, and he stated that the install method should work, but there is a much easier way.
Simply define the full path where you want the executable (or dll) to go. So:
```
prj2_env.Program(target = os.path.... |
279,907 | <p>What is the best way to display a checkbox in a Crystal Report?</p>
<p>Example: My report has a box for "Male" and "Female", and one should be checked.</p>
<p>My current workaround is to draw a small graphical square, and line it up with a formula which goes like this:</p>
<pre><code>if {table.gender} = "M" then ... | [
{
"answer_id": 279929,
"author": "Mark Bostleman",
"author_id": 22355,
"author_profile": "https://Stackoverflow.com/users/22355",
"pm_score": 3,
"selected": true,
"text": "<p>Try a pair of images with a conditional formula for visibility</p>\n"
},
{
"answer_id": 279932,
"auth... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | What is the best way to display a checkbox in a Crystal Report?
Example: My report has a box for "Male" and "Female", and one should be checked.
My current workaround is to draw a small graphical square, and line it up with a formula which goes like this:
```
if {table.gender} = "M" then "X" else " "
```
This is ... | Try a pair of images with a conditional formula for visibility |
279,919 | <p>Is there a C function call that can change the last modified date of a file or directory in Windows?</p>
| [
{
"answer_id": 279930,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 1,
"selected": false,
"text": "<p>Yes. You can use the <a href=\"http://msdn.microsoft.com/en-us/library/ms724933.aspx\" rel=\"nofollow noreferrer\">... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a C function call that can change the last modified date of a file or directory in Windows? | You can use the [SetFileTime](http://msdn.microsoft.com/en-us/library/ms724933(VS.85).aspx) function, for the directories, you have to use the [CreateFile](http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx) function with the FILE\_FLAG\_BACKUP\_SEMANTICS flag to get the directory handle and use it as the fil... |
279,945 | <p>I have a file <code>test.txt</code> that is inside a zip archive <code>test.zip</code>. The permissions on <code>test.txt</code> are out of my control when it's compressed, but now I want them to be group-writeable. I am extracting the file with Python, and don't want to escape out to the shell.</p>
<p><strong>ED... | [
{
"answer_id": 279975,
"author": "Chris",
"author_id": 15578,
"author_profile": "https://Stackoverflow.com/users/15578",
"pm_score": 1,
"selected": false,
"text": "<p>Per the documentation, unzip sets the permissions to those stored, under unix. Also, the shell umask is not used. Your ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1057/"
] | I have a file `test.txt` that is inside a zip archive `test.zip`. The permissions on `test.txt` are out of my control when it's compressed, but now I want them to be group-writeable. I am extracting the file with Python, and don't want to escape out to the shell.
**EDIT:**
Here's what I've got so far:
```
import zipf... | I had a similar problem to you, so here is the code spinet from my stuff, this I believe should help here.
```
# extract all of the zip
for file in zf.filelist:
name = file.filename
perm = ((file.external_attr >> 16L) & 0777)
if name.endswith('/'):
outfile = os.path.join(dir, name)
os.mkdir... |
279,953 | <p>I am using a service component through ASP.NET MVC.
I would like to send the email in a asynchronous way to let the user do other stuff without having to wait for the sending.</p>
<p>When I send a message without attachments it works fine.
When I send a message with at least one in-memory attachment it fails.</p>
... | [
{
"answer_id": 280316,
"author": "Robert Vuković",
"author_id": 438025,
"author_profile": "https://Stackoverflow.com/users/438025",
"pm_score": 0,
"selected": false,
"text": "<p>I have tried your function and it works even for email with in memory attachments. But here are some remarks:<... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1195872/"
] | I am using a service component through ASP.NET MVC.
I would like to send the email in a asynchronous way to let the user do other stuff without having to wait for the sending.
When I send a message without attachments it works fine.
When I send a message with at least one in-memory attachment it fails.
So, I would li... | Don't use "using" here. You are destroying the memory stream immediately after calling SendAsync, e.g. probably before SMTP gets to read it (since it's async). Destroy your stream in the callback. |
279,959 | <p>I have an entry in my .vimrc which makes it page down the viewport when I hit the spacebar. It looks like this:</p>
<pre><code>map <Space> <PageDown>
</code></pre>
<p>I want to create another key mapping which pages the viewport up when holding shift and hitting the spacebar. I have tried the following... | [
{
"answer_id": 279973,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": false,
"text": "<p>Use this:</p>\n\n<pre><code>map <Space> ^D \" Pagedown when press Space\nmap <S-Space> ^U \" P... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476/"
] | I have an entry in my .vimrc which makes it page down the viewport when I hit the spacebar. It looks like this:
```
map <Space> <PageDown>
```
I want to create another key mapping which pages the viewport up when holding shift and hitting the spacebar. I have tried the following entries:
```
map <Shift><Space> <Pag... | You cannot. CMS's solution will work for gVim, but not in vim because terminals cannot distinguish between <Space> and <S-Space> because curses sees them the same. It might be possible in the future if vim gains libtermkey support and your terminal supports the proper <CSI> sequences (xterm does if properly configured;... |
279,966 | <p>I am building a PHP application in CodeIgniter. CodeIgniter sends all requests to the main controller: <code>index.php</code>. However, I don't like to see <code>index.php</code> in the URI. For example, <code>http://www.example.com/faq/whatever</code> will route to <code>http://www.example.com/index.php/faq/whateve... | [
{
"answer_id": 279986,
"author": "Xenph Yan",
"author_id": 264,
"author_profile": "https://Stackoverflow.com/users/264",
"pm_score": 2,
"selected": false,
"text": "<p>Personally I use the <code>$REQUEST_URI</code> as it references the URI entered and not the location on the server's disc... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] | I am building a PHP application in CodeIgniter. CodeIgniter sends all requests to the main controller: `index.php`. However, I don't like to see `index.php` in the URI. For example, `http://www.example.com/faq/whatever` will route to `http://www.example.com/index.php/faq/whatever`. I need a reliable way for a script to... | The [PHP documentation](http://ca.php.net/manual/en/reserved.variables.server.php) can tell you the difference:
>
> *'PHP\_SELF'*
>
>
>
> >
> > The filename of the currently executing script, relative to the document root. For instance, *$\_SERVER['PHP\_SELF']* in a script at the address *<http://example.com/test... |
279,974 | <p>I'm finding myself writing a bunch of related functions dealing with different nouns (clusters, sql servers, servers in general, files, etc.) and put each of these groups of functions in separate files (say cluster_utils.ps1, for example). I want to be able to "import" some of these libraries in my profile and othe... | [
{
"answer_id": 282098,
"author": "Steven Murawski",
"author_id": 1233,
"author_profile": "https://Stackoverflow.com/users/1233",
"pm_score": 2,
"selected": false,
"text": "<p>Mike, I think those scripts are awesome. Parceling out your functions into libraries is very useful, but I think... | 2008/11/11 | [
"https://Stackoverflow.com/questions/279974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36429/"
] | I'm finding myself writing a bunch of related functions dealing with different nouns (clusters, sql servers, servers in general, files, etc.) and put each of these groups of functions in separate files (say cluster\_utils.ps1, for example). I want to be able to "import" some of these libraries in my profile and others ... | Building on [Steven's answer](https://stackoverflow.com/questions/279974/importing-libraries-in-powershell#282098), another improvement might be to allow loading multiple files at once:
```
$global:scriptdirectory = 'C:\powershellscripts'
$global:loaded_scripts = @{}
function require {
param(
[string[]]$filenam... |
280,014 | <p>I have a script which logs on to a remote server and tries to rename files, using PHP.</p>
<p>The code currently looks something like this example from the php.net website:</p>
<pre><code>if (ftp_rename($conn_id, $old_file, $new_file)) {
echo "successfully renamed $old_file to $new_file\n";
} else {
echo "There ... | [
{
"answer_id": 280022,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 5,
"selected": true,
"text": "<p>Looking at the FTP API here:</p>\n\n<p><a href=\"http://us.php.net/manual/en/function.ftp-rename.php\" rel=\"noreferrer\">... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/242241/"
] | I have a script which logs on to a remote server and tries to rename files, using PHP.
The code currently looks something like this example from the php.net website:
```
if (ftp_rename($conn_id, $old_file, $new_file)) {
echo "successfully renamed $old_file to $new_file\n";
} else {
echo "There was a problem while r... | Looking at the FTP API here:
<http://us.php.net/manual/en/function.ftp-rename.php>
There doesn't seem to be any way to get anything but true or false.
However, you could use ftp\_raw to send a raw RENAME command, and then parse the returned message. |
280,017 | <p>I'm trying to wrap my head around the roles of UIViews and UIViewControllers. If I'm creating and inserting subviews programmatically, is it typical to do this from the view or the controller?</p>
<p>I'm really just wondering if there's a convention/pattern for this. In my sample application, I'm loading 50 image... | [
{
"answer_id": 280046,
"author": "Jim Puls",
"author_id": 6010,
"author_profile": "https://Stackoverflow.com/users/6010",
"pm_score": 4,
"selected": true,
"text": "<p>It depends on what you're doing. If the view represents something \"packaged\", then you create subviews from the view it... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2773/"
] | I'm trying to wrap my head around the roles of UIViews and UIViewControllers. If I'm creating and inserting subviews programmatically, is it typical to do this from the view or the controller?
I'm really just wondering if there's a convention/pattern for this. In my sample application, I'm loading 50 images at runtime... | It depends on what you're doing. If the view represents something "packaged", then you create subviews from the view itself. If you're merely aggregating views together, then you should do it from the view controller.
Think about traditional encapsulation. Is your subview conceptually "part" of its superview, or does ... |
280,033 | <p>I am new to C++ and I had a few general questions about code separation. I have currently built a small application, all in one file. What I want to do now is convert this into separate files such that they contain similar code or whatnot. My real question right now is, how do I know how to separate things? What i... | [
{
"answer_id": 280048,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 5,
"selected": false,
"text": "<p>Header files should contain class and function declarations.</p>\n<p>Source files contain class and function defini... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am new to C++ and I had a few general questions about code separation. I have currently built a small application, all in one file. What I want to do now is convert this into separate files such that they contain similar code or whatnot. My real question right now is, how do I know how to separate things? What is the... | Header files should contain class and function declarations.
Source files contain class and function definitions.
It is standard practice (i.e. read easier) to have one declaration per header file and one definition per source file, though for small (read simpler helper) objects you sometimes group them with related ... |
280,049 | <p>I want to know when an image has finished loading. Is there a way to do it with a callback?</p>
<p>If not, is there a way to do it at all?</p>
| [
{
"answer_id": 280087,
"author": "keparo",
"author_id": 19468,
"author_profile": "https://Stackoverflow.com/users/19468",
"pm_score": 6,
"selected": false,
"text": "<p><strong>Image.onload()</strong> will often work. </p>\n\n<p>To use it, you'll need to be sure to bind the event handler... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to know when an image has finished loading. Is there a way to do it with a callback?
If not, is there a way to do it at all? | **`.complete` + callback**
This is a standards compliant method without extra dependencies, and waits no longer than necessary:
```
var img = document.querySelector('img')
function loaded() {
alert('loaded')
}
if (img.complete) {
loaded()
} else {
img.addEventListener('load', loaded)
img.addEventListener('e... |
280,053 | <p>Please help! Have been staring at this for 12 hours; and have looked online and can't find solution.</p>
<p>In my application, I use 2 UIView controls in separate pages/controllers:</p>
<ul>
<li>UIImageView (retrieve data via
NSData dataWithContentsOfUrl)</li>
<li>UIWebView</li>
</ul>
<p>Just to isolate my code, ... | [
{
"answer_id": 280064,
"author": "Justin Weiss",
"author_id": 33821,
"author_profile": "https://Stackoverflow.com/users/33821",
"pm_score": 2,
"selected": false,
"text": "<p>I think this is what's happening: </p>\n\n<p>When ViewController.xib is loaded, an instance of UIWebView is alloca... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Please help! Have been staring at this for 12 hours; and have looked online and can't find solution.
In my application, I use 2 UIView controls in separate pages/controllers:
* UIImageView (retrieve data via
NSData dataWithContentsOfUrl)
* UIWebView
Just to isolate my code, and make it easier to explain, I created a... | I was also having trouble with leaks from NSData's `dataWithContentsOfURL:` in the iPhone simulator. I found that when I used the other convenience method (`dataWithContentsOfURL:options:error:`) I would not get the memory leak.
My code looked something like this:
```
NSURL *url = [NSURL URLWithString:urlString];
NSE... |
280,058 | <p>Basically I need to insert a bunch of data to an Excel file. Creating an OleDB connection appears to be the fastest way but I've seen to have run into memory issues. The memory used by the process seems to keep growing as I execute INSERT queries. I've narrowed them down to only happen when I output to the Excel ... | [
{
"answer_id": 280078,
"author": "Charles Graham",
"author_id": 7705,
"author_profile": "https://Stackoverflow.com/users/7705",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of writing one record at a time, can you find a way to insert in a Bulk capacity? I try not to use crazy ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1469014/"
] | Basically I need to insert a bunch of data to an Excel file. Creating an OleDB connection appears to be the fastest way but I've seen to have run into memory issues. The memory used by the process seems to keep growing as I execute INSERT queries. I've narrowed them down to only happen when I output to the Excel file (... | The answer is **Yes**, the formula you describe *does* equal a bad time.
If you have a database handy (SQL Server or Access are good for this), you can do all of your inserts into a database table, and then export the table all at once into an Excel spreadsheet.
Generally speaking, databases are good at handling lots... |
280,069 | <p>I'm writing a C++ program that doesn't work (I get a segmentation fault) when I compile it with optimizations (options -O1, -O2, -O3, etc.), but it works just fine when I compile it without optimizations.</p>
<p>Is there any chance that the error is in my code? or should I assume that this is a bug in GCC?</p>
<p>... | [
{
"answer_id": 280079,
"author": "Patrick_O",
"author_id": 11084,
"author_profile": "https://Stackoverflow.com/users/11084",
"pm_score": 2,
"selected": false,
"text": "<p>You may be running into an aliasing problem (or it could be a million other things). Look up the -fstrict-aliasing op... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25700/"
] | I'm writing a C++ program that doesn't work (I get a segmentation fault) when I compile it with optimizations (options -O1, -O2, -O3, etc.), but it works just fine when I compile it without optimizations.
Is there any chance that the error is in my code? or should I assume that this is a bug in GCC?
My GCC version is... | Now that you posted the code fragment and a working workaround was found (@Windows programmer's answer), I can say that perhaps what you are looking for is `-ffloat-store`.
>
> -ffloat-store
>
>
> Do not store floating point variables in registers, and inhibit other options that might change whether a floating poin... |
280,075 | <p>I'm trying to implement (what I think is) a pretty simple data model for a counter:</p>
<pre><code>class VisitorDayTypeCounter(models.Model):
visitType = models.CharField(max_length=60)
visitDate = models.DateField('Visit Date')
counter = models.IntegerField()
</code></pre>
<p>When someone comes throug... | [
{
"answer_id": 280125,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "https://Stackoverflow.com/users/32638",
"pm_score": 3,
"selected": false,
"text": "<p>Two suggestions:</p>\n\n<p>Add a unique_together to your model, and wrap the creation in an exception handler to ca... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13868/"
] | I'm trying to implement (what I think is) a pretty simple data model for a counter:
```
class VisitorDayTypeCounter(models.Model):
visitType = models.CharField(max_length=60)
visitDate = models.DateField('Visit Date')
counter = models.IntegerField()
```
When someone comes through, it will look for a row ... | This is a bit of a hack. The raw SQL will make your code less portable, but it'll get rid of the race condition on the counter increment. In theory, this should increment the counter any time you do a query. I haven't tested this, so you should make sure the list gets interpolated in the query properly.
```
class Visi... |
280,106 | <p>I am implementing a Comment box facility in my application which user can resize using mouse. This comment box contains a scrollpane which instead contains a <code>JEditorPane</code> in which user can insert comment. I have added the editor pane inside a scroll pane for the following reason:</p>
<p><a href="https:/... | [
{
"answer_id": 281769,
"author": "luiscubal",
"author_id": 32775,
"author_profile": "https://Stackoverflow.com/users/32775",
"pm_score": -1,
"selected": false,
"text": "<p>Decreasing the size of a JEditorPane in a JScrollPane and then reducing it, is not possible.\nYou may want to use a ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22550/"
] | I am implementing a Comment box facility in my application which user can resize using mouse. This comment box contains a scrollpane which instead contains a `JEditorPane` in which user can insert comment. I have added the editor pane inside a scroll pane for the following reason:
[auto scolling of jeditorpane](https:... | I realise this is long since answered, but for future reference all you need to do is override the `getScrollableTracksViewportWidth()` to always return true, eg.
```
JEditorPane pane = new JEditorPane() {
public boolean getScrollableTracksViewportWidth() {
return true;
}
};
panel.add(new JScrollPane(p... |
280,114 | <p>I'm new to C# and .Net in general so this may be a naive thing to ask. But anyway, consider this C# code:</p>
<pre><code>class A {
public int Data {get; set;}
}
class B {
public A Aval {get; set;}
}
</code></pre>
<p>The B.Aval property above is returning a reference to its internal A object. As a former C... | [
{
"answer_id": 280133,
"author": "stephbu",
"author_id": 12702,
"author_profile": "https://Stackoverflow.com/users/12702",
"pm_score": 1,
"selected": false,
"text": "<p>This isn't encapsulation - it's an act of abstraction through object composition or aggregation depending on how the in... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32688/"
] | I'm new to C# and .Net in general so this may be a naive thing to ask. But anyway, consider this C# code:
```
class A {
public int Data {get; set;}
}
class B {
public A Aval {get; set;}
}
```
The B.Aval property above is returning a reference to its internal A object. As a former C++ programmer, I find this... | You're absolutely right - you should only return objects from properties where either the object is immutable, or you're happy for the caller to modify it to whatever extent they can. A classic example of this is returning collections - often it's much better to return a read-only wrapper round a collection than to ret... |
280,115 | <p>I am creating menus in WPF programatically using vb.net. Can someone show me how I can add separator bar to a menu in code? No xaml please.</p>
| [
{
"answer_id": 280194,
"author": "Jeff Donnici",
"author_id": 821,
"author_profile": "https://Stackoverflow.com/users/821",
"pm_score": 7,
"selected": true,
"text": "<p>WPF has a <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.separator.aspx\" rel=\"noreferrer\"... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3566/"
] | I am creating menus in WPF programatically using vb.net. Can someone show me how I can add separator bar to a menu in code? No xaml please. | WPF has a [Separator](http://msdn.microsoft.com/en-us/library/system.windows.controls.separator.aspx) control for just that purpose and it also separates your menu items when the appear on a toolbar. From the MSDN docs:
>
> A Separator control draws a line,
> horizontal or vertical, between items
> in controls, suc... |
280,127 | <p>I'm bored with surrounding code with try catch like this..</p>
<pre><code>try
{
//some boring stuff
}
catch(Exception ex)
{
//something even more boring stuff
}
</code></pre>
<p>I would like something like</p>
<pre><code>SurroundWithTryCatch(MyMethod)
</code></pre>
<p>I know I can accomplish this behavio... | [
{
"answer_id": 280132,
"author": "stiduck",
"author_id": 35398,
"author_profile": "https://Stackoverflow.com/users/35398",
"pm_score": 2,
"selected": false,
"text": "<p>You can try to use some null validiation instead. I can take a LINQ to SQL example:</p>\n\n<pre><code>var user = db.Use... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34296/"
] | I'm bored with surrounding code with try catch like this..
```
try
{
//some boring stuff
}
catch(Exception ex)
{
//something even more boring stuff
}
```
I would like something like
```
SurroundWithTryCatch(MyMethod)
```
I know I can accomplish this behaviour by creating a delegate with the exact signatur... | Firstly, it sounds like you may be using try/catch too often - particularly if you're catching `Exception`. try/catch blocks should be relatively rare; unless you can really "handle" the exception, you should just let it bubble up to the next layer of the stack.
Now, assuming you really *do* want all of these try/catc... |
280,143 | <p>Well I would like to make a custom run dialog within my program so that the user can test commands without opening it themselves. The only problem is, msdn does not provide any coverage on this. If I cannot make my own custom run dialog and send the data to shell32.dll (where the run dialog is stored) I will settle ... | [
{
"answer_id": 280447,
"author": "OJ.",
"author_id": 611,
"author_profile": "https://Stackoverflow.com/users/611",
"pm_score": 2,
"selected": true,
"text": "<p>VBScript's CreateObject() function just creates an instance of a COM object. You can do exactly the same thing in C++, you just ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36457/"
] | Well I would like to make a custom run dialog within my program so that the user can test commands without opening it themselves. The only problem is, msdn does not provide any coverage on this. If I cannot make my own custom run dialog and send the data to shell32.dll (where the run dialog is stored) I will settle for... | VBScript's CreateObject() function just creates an instance of a COM object. You can do exactly the same thing in C++, you just need to read a [tutorial on how to access COM objects using C++](http://progtutorials.tripod.com/COM.htm) first. |
280,162 | <p>I have some low level serialization code that is templated, and I need to know the system's endianness at compiletime obviously (because the templates specializes based on the system's endianness). </p>
<p>Right now I have a header with some platform defines, but I'd rather have someway to make assertions about en... | [
{
"answer_id": 280164,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "<p>Hmm, that's an interesting Question. My bet is that this is not possible. I think you have to continue u... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] | I have some low level serialization code that is templated, and I need to know the system's endianness at compiletime obviously (because the templates specializes based on the system's endianness).
Right now I have a header with some platform defines, but I'd rather have someway to make assertions about endianness wi... | If you're using autoconf, you can use the `AC_C_BIGENDIAN` macro, which is fairly guaranteed to work (setting the `WORDS_BIGENDIAN` define by default)
alternately, you could try something like the following (taken from autoconf) to get a test that will probably be optimized away (GCC, at least, removes the other branc... |
280,201 | <p>In a html page we use the head tag to add reference to our external .js files .. we can also include script tags in the body .. But how do we include our external .js file in a web user control?</p>
<p>After little googling I got this. It works but is this the only way?</p>
<pre><code>ScriptManager.RegisterStartup... | [
{
"answer_id": 280338,
"author": "Phil Jenkins",
"author_id": 35496,
"author_profile": "https://Stackoverflow.com/users/35496",
"pm_score": 3,
"selected": true,
"text": "<p>You can also use</p>\n\n<pre><code>Page.ClientScript.RegisterClientScriptInclude(\"key\", \"path/to/script.js\");\n... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25138/"
] | In a html page we use the head tag to add reference to our external .js files .. we can also include script tags in the body .. But how do we include our external .js file in a web user control?
After little googling I got this. It works but is this the only way?
```
ScriptManager.RegisterStartupScript(this.Page, Pag... | You can also use
```
Page.ClientScript.RegisterClientScriptInclude("key", "path/to/script.js");
```
That's the way I always do it anyway |
280,207 | <p>I have an object.</p>
<pre><code> fp = open(self.currentEmailPath, "rb")
p = email.Parser.Parser()
self._currentEmailParsedInstance= p.parse(fp)
fp.close()
</code></pre>
<p>self.currentEmailParsedInstance, from this object I want to get the body of an email, text only no HTML....</p>
<p>How do I do... | [
{
"answer_id": 280238,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": true,
"text": "<p>This will get you the contents of the message</p>\n\n<pre><code>self.currentEmailParsedInstance.get_payload()\n</c... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21537/"
] | I have an object.
```
fp = open(self.currentEmailPath, "rb")
p = email.Parser.Parser()
self._currentEmailParsedInstance= p.parse(fp)
fp.close()
```
self.currentEmailParsedInstance, from this object I want to get the body of an email, text only no HTML....
How do I do it?
---
something like this?
... | This will get you the contents of the message
```
self.currentEmailParsedInstance.get_payload()
```
As for the text only part you will have to strip HTML on your own, for example using BeautifulSoup.
Check [this link](http://www.python.org/doc/2.2.3/lib/module-email.Message.html) for more information about the Mess... |
280,222 | <p>I have input consisting of a list of nested lists like this:</p>
<pre><code>l = [[[[[39]]]], [1, 2, 3], [4, [5, 3], 1], [[[[8, 9], 10], 11], 12]]
</code></pre>
<p>I want to sort this list based on the sum of all the numbers in the nested lists... so, the values I want to sort by of l would look like this:</p>
<pr... | [
{
"answer_id": 280224,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 3,
"selected": false,
"text": "<pre><code>l.sort(key=sum_nested)\n</code></pre>\n\n<p>Where <code>sum_nested()</code> is:</p>\n\n<pre><code>def sum_nested(astr... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | I have input consisting of a list of nested lists like this:
```
l = [[[[[39]]]], [1, 2, 3], [4, [5, 3], 1], [[[[8, 9], 10], 11], 12]]
```
I want to sort this list based on the sum of all the numbers in the nested lists... so, the values I want to sort by of l would look like this:
```
[39, 6, 13, 50]
```
Then I ... | A slight simplification and generalization to the answers provided so far, using a recent addition to python's syntax:
```
>>> l = [[[[[39]]]], [1, 2, 3], [4, [5, 3], 1], [[[[8, 9], 10], 11], 12]]
>>> def asum(t): return sum(map(asum, t)) if hasattr(t, '__iter__') else t
...
>>> sorted(l, key=asum)
[[1, 2, 3], [4, [5,... |
280,229 | <p>I want to add an item to an ASP.Net combobox using Javascript. I can retrieve the ID (No Masterpage). How can I add values to the combobox from Javascript? My present code looks like this.</p>
<pre><code> //Fill the years (counting 100 from the first)
function fillvarYear() {
var dt = $('#txtBDate').... | [
{
"answer_id": 280241,
"author": "Cyril Gupta",
"author_id": 33052,
"author_profile": "https://Stackoverflow.com/users/33052",
"pm_score": 0,
"selected": false,
"text": "<p>I found a possible solution. I don't know why the earlier code didn't work for me, but the line below </p>\n\n<p>do... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33052/"
] | I want to add an item to an ASP.Net combobox using Javascript. I can retrieve the ID (No Masterpage). How can I add values to the combobox from Javascript? My present code looks like this.
```
//Fill the years (counting 100 from the first)
function fillvarYear() {
var dt = $('#txtBDate').val();
... | To see the value on postback:
```
string selectedValue = Request.Params[combobox.UniqueId]
```
Remember, changing the values in a combobox with javascript will cause an Event Validation exception to be thrown, and is generally a bad idea, as you'll have to explicitly disabled event validation.
I'd recommend placing... |
280,243 | <p>What's the easiest way to use a linked list in python? In scheme, a linked list is defined simply by <code>'(1 2 3 4 5)</code>. Python's lists, <code>[1, 2, 3, 4, 5]</code>, and tuples, <code>(1, 2, 3, 4, 5)</code>, are not, in fact, linked lists, and linked lists have some nice properties such as constant-time conc... | [
{
"answer_id": 280284,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 4,
"selected": false,
"text": "<p>Immutable lists are best represented through two-tuples, with None representing NIL. To allow simple formulatio... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | What's the easiest way to use a linked list in python? In scheme, a linked list is defined simply by `'(1 2 3 4 5)`. Python's lists, `[1, 2, 3, 4, 5]`, and tuples, `(1, 2, 3, 4, 5)`, are not, in fact, linked lists, and linked lists have some nice properties such as constant-time concatenation, and being able to referen... | Here is some list functions based on [Martin v. Löwis's representation](https://stackoverflow.com/questions/280243/python-linked-list#280284):
```
cons = lambda el, lst: (el, lst)
mklist = lambda *args: reduce(lambda lst, el: cons(el, lst), reversed(args), None)
car = lambda lst: lst[0] if lst else lst
cdr = lambda ... |
280,247 | <p>I've tried my best and cannot figure out what happened here. It worked fine in Delphi 4. After upgrading to Delphi 2009, I don't know if this is the way it is supposed to work, or if it's a problem:</p>
<p>This is what my program's menu looks like in Design Mode under Delphi 2009:</p>
<p><a href="https://i.stack.i... | [
{
"answer_id": 280275,
"author": "Francesca",
"author_id": 9842,
"author_profile": "https://Stackoverflow.com/users/9842",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think it is a Delphi generated bug as you have the same behavior with Notepad on Vista. Also in Delphi itself B... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30176/"
] | I've tried my best and cannot figure out what happened here. It worked fine in Delphi 4. After upgrading to Delphi 2009, I don't know if this is the way it is supposed to work, or if it's a problem:
This is what my program's menu looks like in Design Mode under Delphi 2009:
[ to normally hide those accelerators unless the Alt key is held down. That would explain why opening the menu with Alt+F10 shows them for you. Maybe that's the cause?
[EDIT]: No, it's not. I just tried, and a simple TForm with a menu item shows the accelera... |
280,298 | <p>A complicated-sounding term with no good explanations from a simple google search... are there any more academically-oriented folk who could explain this one?</p>
| [
{
"answer_id": 280384,
"author": "Duncan",
"author_id": 7140,
"author_profile": "https://Stackoverflow.com/users/7140",
"pm_score": 1,
"selected": false,
"text": "<p>Okay, just going to hazard a COMPLETE guess here, based on this</p>\n\n<p><a href=\"http://ieeexplore.ieee.org/xpl/freeabs... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | A complicated-sounding term with no good explanations from a simple google search... are there any more academically-oriented folk who could explain this one? | Relational parametricity seems to be the property that a function abstracted over types (like a generic in Java) can have. If it has this property, it means it never inspects its type argument or deconstructs it / uses it in some special way. For example, the function "id or inc" here is not relationally parametric:
`... |
280,313 | <p>I am trying to merge several XML files in a single XDocument object.</p>
<p>Merge does not exist in XDocument object. I miss this.</p>
<p>Has anyone already implemented a Merge extension method for XDocument, or something similar ?</p>
| [
{
"answer_id": 280319,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 0,
"selected": false,
"text": "<p>As a workaround, you could use a XSL file to merge the XML files and then transform it to a XDocument object.</p>\n"
... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24472/"
] | I am trying to merge several XML files in a single XDocument object.
Merge does not exist in XDocument object. I miss this.
Has anyone already implemented a Merge extension method for XDocument, or something similar ? | I tried a bit myself :
```
var MyDoc = XDocument.Load("File1.xml");
MyDoc.Root.Add(XDocument.Load("File2.xml").Root.Elements());
```
I dont know whether it is good or bad, but it works fine to me :-) |
280,324 | <p>I have been using classes for only a short while and when I write a method, I make all variables reference self, e.g. self.foo.</p>
<p>However, I'm looking through the <em>wxPython in Action</em> book and notice that "self" isn't used all the time. For example:</p>
<pre><code> import wx
class TextFrame(wx.Frame):... | [
{
"answer_id": 280332,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>In those instances, if you do not use <code>self</code> then you will create only a local variable of that name. In th... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18676/"
] | I have been using classes for only a short while and when I write a method, I make all variables reference self, e.g. self.foo.
However, I'm looking through the *wxPython in Action* book and notice that "self" isn't used all the time. For example:
```
import wx
class TextFrame(wx.Frame):
def __init__(self):
... | You use `self.attribute` to reference an attribute of your current instance.
You use `wx.Frame.__init__()` to reference a method of the parent class.
You don't use `self` if you only reference a local name (variable) of the method (function) you are in.
These are not "rules of thumb," because there are no exceptions... |
280,331 | <p>This seems like it should be easy but I'm stumped. In WPF, I'd like a TextBox that stretches to the width of it's parent, but only to a maximum width. The problem is that I want it to be left justified within its parent. To get it to stretch you have to use HorizontalAlignment="Stretch", but then the result is cente... | [
{
"answer_id": 280402,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 6,
"selected": false,
"text": "<pre><code><Grid>\n <Grid.ColumnDefinitions>\n <ColumnDefinition Width=\"*\" MaxWidth=\"200\"... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9045/"
] | This seems like it should be easy but I'm stumped. In WPF, I'd like a TextBox that stretches to the width of it's parent, but only to a maximum width. The problem is that I want it to be left justified within its parent. To get it to stretch you have to use HorizontalAlignment="Stretch", but then the result is centered... | You can set `HorizontalAlignment` to Left, set your `MaxWidth` and then bind `Width` to the `ActualWidth` of the parent element:
```
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Name="Container">
<TextBox Backgr... |
280,345 | <p>I'm trying to start <code>iexplore.exe</code> let it run for 5 seconds and then close it again.</p>
<p><code>iexplore</code> opens just fine however it doesn't close when I call the PostThreadMessage.
Can anyone see what I'm doing wrong? Here is my code:</p>
<pre><code>CString IEPath = "C:\\Program Files\\Interne... | [
{
"answer_id": 280364,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>if you can enumerate the windows on the desktop and send a WM_CLOSE to the IE window , it might work .. you can use the spy ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36476/"
] | I'm trying to start `iexplore.exe` let it run for 5 seconds and then close it again.
`iexplore` opens just fine however it doesn't close when I call the PostThreadMessage.
Can anyone see what I'm doing wrong? Here is my code:
```
CString IEPath = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";//GetIEPath();
//... | if you can enumerate the windows on the desktop and send a WM\_CLOSE to the IE window , it might work .. you can use the spy programme to get the window class of the IE window |
280,347 | <p>How to convert Unicode string into a utf-8 or utf-16 string?
My VS2005 project is using Unicode char set, while sqlite in cpp provide </p>
<pre><code>int sqlite3_open(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb /* OUT: SQLite db handle */
);
int sqlite3_open16(
const void ... | [
{
"answer_id": 280358,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 3,
"selected": false,
"text": "<p>Use the <a href=\"http://msdn.microsoft.com/en-us/library/ms776420(VS.85).aspx\" rel=\"noreferrer\">WideCharToMu... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25749/"
] | How to convert Unicode string into a utf-8 or utf-16 string?
My VS2005 project is using Unicode char set, while sqlite in cpp provide
```
int sqlite3_open(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb /* OUT: SQLite db handle */
);
int sqlite3_open16(
const void *filename, /... | Short answer:
No conversion required if you use Unicode strings such as CString or wstring. Use sqlite3\_open16().
You will have to make sure you pass a WCHAR pointer (casted to `void *`. Seems lame! Even if this lib is cross platform, I guess they could have defined a wide char type that depends on the platform and ... |
280,356 | <p>In my webpage, I want the website to greet the user, but the username is surrounded by 'single quotations'. Since this isn't to prevent MySQL injection, i just want to remove quotes around my name on the display page.</p>
<p>Ex: Welcome 'user'!
I'm trying to find the way where i can strip the quotations around the ... | [
{
"answer_id": 280366,
"author": "davil",
"author_id": 22592,
"author_profile": "https://Stackoverflow.com/users/22592",
"pm_score": 1,
"selected": false,
"text": "<p>I think the easiest way would be to use the trim() function. It usually trims whitespace characters, but you may pass it ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In my webpage, I want the website to greet the user, but the username is surrounded by 'single quotations'. Since this isn't to prevent MySQL injection, i just want to remove quotes around my name on the display page.
Ex: Welcome 'user'!
I'm trying to find the way where i can strip the quotations around the user and h... | If you're sure that the first and last characters of `$login` are always a `'` you can use [`substr()`](http://de3.php.net/manual/en/function.substr.php) to do something like
```
$login = substr($_SESSION['login'], 1, -1); // example 1
```
You can strip all `'` from the string with [`str_replace()`](http://de3.php.n... |
280,378 | <p>I read a little of the help for my advanced installer 6.5.1 and couldn't find a way to change the version string except by hand.</p>
| [
{
"answer_id": 280458,
"author": "Rob Stevenson-Leggett",
"author_id": 4950,
"author_profile": "https://Stackoverflow.com/users/4950",
"pm_score": 1,
"selected": false,
"text": "<p>The files for creating an MSI are usually in XML format, we've created a little tool that runs as part of o... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30324/"
] | I read a little of the help for my advanced installer 6.5.1 and couldn't find a way to change the version string except by hand. | Here is a snippet from one of our push scripts. Rob, maybe you'll find this useful too- Advanced installer provides the ability to set the ProductVersion of your installation package based on an existing compiled EXE. We use a custom build task in TFS to increment our build number and set our AssemblyInfo.cs files, the... |
280,385 | <p>Let's say we have a method signature like </p>
<pre><code>public static function explodeDn($dn, array &$keys = null, array &$vals = null,
$caseFold = self::ATTR_CASEFOLD_NONE)
</code></pre>
<p>we can easily call the method by omitting all parameters after <code>$dn</code>:</p>
<pre><code>$dn=Zend_Ldap... | [
{
"answer_id": 280397,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 6,
"selected": true,
"text": "<p>It's because you can't have a reference to null.</p>\n\n<p>You can have a reference to a variable that contains null - t... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11354/"
] | Let's say we have a method signature like
```
public static function explodeDn($dn, array &$keys = null, array &$vals = null,
$caseFold = self::ATTR_CASEFOLD_NONE)
```
we can easily call the method by omitting all parameters after `$dn`:
```
$dn=Zend_Ldap_Dn::explodeDn('CN=Alice Baker,CN=Users,DC=example,DC=co... | It's because you can't have a reference to null.
You can have a reference to a variable that contains null - that is exactly what the default value does. Or you can pass in null as a literal value - but since you want an out parameter this is not possible here. |
280,389 | <pre><code>function main()
{
Hello();
}
function Hello()
{
// How do you find out the caller function is 'main'?
}
</code></pre>
<p>Is there a way to find out the call stack?</p>
| [
{
"answer_id": 280396,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 11,
"selected": true,
"text": "<p><strong>Note that this solution is deprecated and should no longer be used according to MDN documentation</strong></p>... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11413/"
] | ```
function main()
{
Hello();
}
function Hello()
{
// How do you find out the caller function is 'main'?
}
```
Is there a way to find out the call stack? | **Note that this solution is deprecated and should no longer be used according to MDN documentation**
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller>
---
```
function Hello()
{
alert("caller is " + Hello.caller);
}
```
Note that this feature is **non-standard*... |
280,399 | <p>I have an sp with the following pseudo code... </p>
<pre><code> BEGIN TRANSACTION
set @errorLocation='Deleting Permissions'
DELETE [tblUsrPermissions]
WHERE
lngUserID = @lngUserID
if @@error>0
begin
goto roll_back
... | [
{
"answer_id": 280420,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": 1,
"selected": false,
"text": "<p>use raiserror to thorw your error to the client.\nnote that depending on the severity of the erorr your raiserro... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13370/"
] | I have an sp with the following pseudo code...
```
BEGIN TRANSACTION
set @errorLocation='Deleting Permissions'
DELETE [tblUsrPermissions]
WHERE
lngUserID = @lngUserID
if @@error>0
begin
goto roll_back
end
... | use raiserror to thorw your error to the client.
note that depending on the severity of the erorr your raiserror message might never be hit.
so for more complete answer provide the original error you get and where do you get it. |
280,406 | <p>I have problems with bringing a windows mobile 6 form to the front.
I tried things like this already</p>
<pre><code>Form1 testForm = new Form1();
testForm.Show();
testForm.BringToFront();
testForm.Focus();
</code></pre>
<p>But it's always behind the form that includes that code.
The only things that have worked fo... | [
{
"answer_id": 280478,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 3,
"selected": true,
"text": "<p>I haven't tried it in WM6, but you can use some pinvoke to call Win32 functions:</p>\n\n<pre><code>[DllImport(\"cor... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36481/"
] | I have problems with bringing a windows mobile 6 form to the front.
I tried things like this already
```
Form1 testForm = new Form1();
testForm.Show();
testForm.BringToFront();
testForm.Focus();
```
But it's always behind the form that includes that code.
The only things that have worked for me are
```
testForm.Top... | I haven't tried it in WM6, but you can use some pinvoke to call Win32 functions:
```
[DllImport("coredll.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("coredll.dll", EntryPoint="SetForegroundWindow")]
private static extern int SetForegroundWindow(IntPtr hWnd);
``... |
280,413 | <p><strong>Closed as exact duplicate of <a href="https://stackoverflow.com/questions/171970/how-can-i-find-the-method-that-called-the-current-method">"How can I find the method that called the current method?"</a></strong></p>
<p>Is <a href="https://stackoverflow.com/questions/280389/javascript-how-do-you-find-the-cal... | [
{
"answer_id": 280425,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<pre><code>Console.WriteLine(new StackFrame(1).GetMethod().Name);\n</code></pre>\n\n<p>However, this is not robust, es... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | **Closed as exact duplicate of ["How can I find the method that called the current method?"](https://stackoverflow.com/questions/171970/how-can-i-find-the-method-that-called-the-current-method)**
Is [this](https://stackoverflow.com/questions/280389/javascript-how-do-you-find-the-caller-function) possible with c#?
```... | ```
Console.WriteLine(new StackFrame(1).GetMethod().Name);
```
However, this is not robust, especially as optimisations (such as JIT inlining) can monkey with the perceived stack frames. |
280,421 | <p>It seems that when I have one mysql_real_query() function in a continuous while loop, the query will get executed OK.</p>
<p>However, if multiple mysql_real_query() are inside the while loop, one right after the other. Depending on the query, sometimes neither the first query nor second query will execute properly... | [
{
"answer_id": 280456,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 0,
"selected": false,
"text": "<p>OK, For test purposes, take your <code>tagBuffer</code> variable out of the first <code>mysql_real_query</code> call and ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28462/"
] | It seems that when I have one mysql\_real\_query() function in a continuous while loop, the query will get executed OK.
However, if multiple mysql\_real\_query() are inside the while loop, one right after the other. Depending on the query, sometimes neither the first query nor second query will execute properly.
This... | Always check the return value of an API call.
[`mysql_real_query()`](http://dev.mysql.com/doc/refman/5.0/en/mysql-real-query.html) returns an integer. The value is zero if the call worked, and nonzero if there's an error.
Check the return value and report it if it's nonzero:
```
if ((err = mysql_real_query(&mysql,"i... |
280,426 | <p>We've got a fairly complex httphandler for handling images. Basically it streams any part of the image at any size that is requested. Some clients use this handler without any problems. But we've got one location that gives us problems, and now it also gives problems on my development environment.</p>
<p>What happe... | [
{
"answer_id": 280436,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>First off, there are better ways of dealing with streams that using an array for the entire thing (i.e. <code>Memo... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5043/"
] | We've got a fairly complex httphandler for handling images. Basically it streams any part of the image at any size that is requested. Some clients use this handler without any problems. But we've got one location that gives us problems, and now it also gives problems on my development environment.
What happens is that... | A client will limit the number of simultaneous requests it will make to any one server. Furthermore when requesting from a resource that requires session state (the default) other requests for resources requiring session state will block.
When using `HttpWebResponse` you must dispose either that object or the stream r... |
280,428 | <p>I have one autocomplete search, in which by typing few characters it will show all the names, which matches the entered character. I am populating this data in the jsp using DIV tag, by using mouse I'm able to select the names. But I want to select the names in the DIV tag to be selected using the keyboard up and do... | [
{
"answer_id": 280450,
"author": "jishi",
"author_id": 33663,
"author_profile": "https://Stackoverflow.com/users/33663",
"pm_score": 0,
"selected": false,
"text": "<p>I assume that you have an input which handles the input. </p>\n\n<p>map onkeyup-eventhandler for that input in which you ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have one autocomplete search, in which by typing few characters it will show all the names, which matches the entered character. I am populating this data in the jsp using DIV tag, by using mouse I'm able to select the names. But I want to select the names in the DIV tag to be selected using the keyboard up and down ... | Use the `onkeydown` and `onkeyup` events to check for key press events in your results div:
```
var UP = 38;
var DOWN = 40;
var ENTER = 13;
var getKey = function(e) {
if(window.event) { return e.keyCode; } // IE
else if(e.which) { return e.which; } // Netscape/Firefox/Opera
};
var keynum = getKey(e);
if(key... |
280,435 | <p>I want to use input from a user as a regex pattern for a search over some text. It works, but how I can handle cases where user puts characters that have meaning in regex?</p>
<p>For example, the user wants to search for Word <code>(s)</code>: regex engine will take the <code>(s)</code> as a group. I want it to tr... | [
{
"answer_id": 280441,
"author": "ddaa",
"author_id": 11549,
"author_profile": "https://Stackoverflow.com/users/11549",
"pm_score": 10,
"selected": true,
"text": "<p>Use the <code>re.escape()</code> function for this:</p>\n\n<p><a href=\"http://docs.python.org/library/re.html#re.escape\"... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/288629/"
] | I want to use input from a user as a regex pattern for a search over some text. It works, but how I can handle cases where user puts characters that have meaning in regex?
For example, the user wants to search for Word `(s)`: regex engine will take the `(s)` as a group. I want it to treat it like a string `"(s)"` . I ... | Use the `re.escape()` function for this:
[4.2.3 `re` Module Contents](http://docs.python.org/library/re.html#re.escape)
>
> **escape(string)**
>
>
> Return string with all non-alphanumerics backslashed; this is useful if you want to match an arbitrary literal string that may have regular expression metacharacters ... |
280,449 | <p>I have a page on which I must load controls dynamically based on the user selection.
Let's say that I have something like this:</p>
<pre><code>public static readonly Dictionary<string, string> DynamicControls = new Dictionary<string, string>
{
{ "UserCtrl1", "~/Controls/UserCtrl1.as... | [
{
"answer_id": 280460,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 0,
"selected": false,
"text": "<p>Can you not just use foreach on your dictionary and do your test and LoadControl in there?</p>\n"
},
{
"answer_id... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2099426/"
] | I have a page on which I must load controls dynamically based on the user selection.
Let's say that I have something like this:
```
public static readonly Dictionary<string, string> DynamicControls = new Dictionary<string, string>
{
{ "UserCtrl1", "~/Controls/UserCtrl1.ascx" },
{ "User... | You don't need to cast the result from LoadControl.
This should do:
```
private Control GetControl()
{
string dynamicCtrl = CurrentItem.DynamicControl;
string path = SomeClass.DynamicControls[dynamicCtrl];
Control ctrl = LoadControl(path);
return ctrl;
}
``` |
280,480 | <p>I have some code to enable/disable the Windows Aero service in Vista, and I would like to run it in a Windows Service. The code works in a standalone application, but when I run it from a Service, nothing happens. No errors or exceptions are thrown.</p>
<p>I realise that running code in a service is a different sco... | [
{
"answer_id": 280498,
"author": "OJ.",
"author_id": 611,
"author_profile": "https://Stackoverflow.com/users/611",
"pm_score": 1,
"selected": false,
"text": "<p>I dont know for certain, but perhaps you need to associate your service's process with the current desktop before that will wor... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21593/"
] | I have some code to enable/disable the Windows Aero service in Vista, and I would like to run it in a Windows Service. The code works in a standalone application, but when I run it from a Service, nothing happens. No errors or exceptions are thrown.
I realise that running code in a service is a different scope than ru... | I had the same error code, when creating WPF FlowDocuments through a service running under 64-bit Vista. After digging around I can accross [this post on Microsoft Connect](https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361469), which points out that
>
> "... The problem is caused b... |
280,485 | <p>We have a DLL which is produced in house, and for which we have the associated static LIB of stubs.</p>
<p>We also have an EXE which uses this DLL using the simple method of statically linking to the DLL's LIB file (ie, not manually using LoadLibrary).</p>
<p>When we deploy the EXE we'd like the DLL file name to b... | [
{
"answer_id": 280522,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": -1,
"selected": false,
"text": "<p>you'll have to use Assembly.Load and have the obfuscated assembly name saved in the app.config.</p>\n\n<p>eithe... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/755/"
] | We have a DLL which is produced in house, and for which we have the associated static LIB of stubs.
We also have an EXE which uses this DLL using the simple method of statically linking to the DLL's LIB file (ie, not manually using LoadLibrary).
When we deploy the EXE we'd like the DLL file name to be changed for obf... | Using the LIB tool (included with visual studio) you can generate a lib file from a def file. Asuming your dll source does not include a def file, you have to create one first. You can use dumpbin to assist you. For example: `dumpbin /exports ws2_32.dll`
In the output you see the names of the functions exported. Now c... |
280,488 | <p>I'm looking to convert the following <code>mod_rewrite</code> rule to the <a href="http://wiki.codemongers.com/NginxHttpRewriteModule" rel="noreferrer">Nginx equivalent</a>:</p>
<pre><code>RewriteRule ^foo/(.*)$ /bar/index.php?title=$1 [PT,L,QSA]
RewriteRule ^foo/*$ /bar/index.php [L,QSA]
</code></pre>
<p>So far I... | [
{
"answer_id": 282437,
"author": "jumoel",
"author_id": 1555170,
"author_profile": "https://Stackoverflow.com/users/1555170",
"pm_score": 4,
"selected": true,
"text": "<p>These rewrite rules made the scripts work:</p>\n\n<pre><code>rewrite ^/foo/([^?]*)(?:\\?(.*))? /bar/index.php?title=$... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1555170/"
] | I'm looking to convert the following `mod_rewrite` rule to the [Nginx equivalent](http://wiki.codemongers.com/NginxHttpRewriteModule):
```
RewriteRule ^foo/(.*)$ /bar/index.php?title=$1 [PT,L,QSA]
RewriteRule ^foo/*$ /bar/index.php [L,QSA]
```
So far I have:
```
rewrite ^foo/(.*)$ /bar/index.php?title=$1&$query_str... | These rewrite rules made the scripts work:
```
rewrite ^/foo/([^?]*)(?:\?(.*))? /bar/index.php?title=$1&$2;
rewrite ^/foo /bar/index.php;
``` |
280,494 | <p>I have a group by clause in a sql statement and need to use an aggregate function to minus all the values in each group instead of adding like the Sum() function.</p>
<p>i.e. </p>
<pre><code>SELECT Sum(A)
FROM (
SELECT 2 AS A
UNION
SELECT 1) AS t1
</code></pre>
<p>..so will evaluate 2+1 and return 3.</... | [
{
"answer_id": 280496,
"author": "Unsliced",
"author_id": 2902,
"author_profile": "https://Stackoverflow.com/users/2902",
"pm_score": 2,
"selected": false,
"text": "<p>How will you identify the item to be subtracted from? </p>\n\n<p>Once that's been identified it's a <code>SUM()</code> m... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11989/"
] | I have a group by clause in a sql statement and need to use an aggregate function to minus all the values in each group instead of adding like the Sum() function.
i.e.
```
SELECT Sum(A)
FROM (
SELECT 2 AS A
UNION
SELECT 1) AS t1
```
..so will evaluate 2+1 and return 3.
I need some way of doing 2-1 to re... | How will you identify the item to be subtracted from?
Once that's been identified it's a `SUM()` multiplied by `-1` and then added to that value.
**Edit:**
If it's the first value to be taken as the subtracted from then take that value, double it, then take away the sum of all the values. (Doubling it cancels out ... |
280,495 | <p>When browsing ASP.NET MVC source code in <a href="http://www.codeplex.com/aspnet/SourceControl/FileView.aspx?itemId=266503&changeSetId=17272" rel="noreferrer">codeplex</a>, I found it is common to have a class explicitly implementing interface. The explicitly implemented method/property then invoke another "prot... | [
{
"answer_id": 280505,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>Well, not specific to MVC, but this approach allows you to <strong>keep the core public API clean</strong>. It is a... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] | When browsing ASP.NET MVC source code in [codeplex](http://www.codeplex.com/aspnet/SourceControl/FileView.aspx?itemId=266503&changeSetId=17272), I found it is common to have a class explicitly implementing interface. The explicitly implemented method/property then invoke another "protected virtual" method/property with... | Well, not specific to MVC, but this approach allows you to **keep the core public API clean**. It is also useful if there is ever a risk of different interfaces / etc having the same name & signature, but different meaning. In reality this is rare.
It also allows you to provide an implementation where you want the ret... |
280,497 | <p>I am having a peculiar problem with the order in which FlowLayoutPanels are added in to the form's <strong>controls</strong> property. This is what I tried,</p>
<p>I added 7 FlowLayoutPanels in to a C# window application from left to right in vertical strips. Then I tagged the flow layouts as 1, 2, 3, ... 7 again f... | [
{
"answer_id": 280513,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": 3,
"selected": true,
"text": "<p>look at the order in which they are added to the form in the yourForm.designer.cs</p>\n"
},
{
"answer_id"... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am having a peculiar problem with the order in which FlowLayoutPanels are added in to the form's **controls** property. This is what I tried,
I added 7 FlowLayoutPanels in to a C# window application from left to right in vertical strips. Then I tagged the flow layouts as 1, 2, 3, ... 7 again from left to right. Now ... | look at the order in which they are added to the form in the yourForm.designer.cs |
280,542 | <p>I'm regularly creating an XSD schema by transforming a proprietary data model of a legacy system. This works out pretty good. However, the legacy system only allows me to specify very basic attributes of a parameter, such as the data type (<code>int</code>, <code>string</code> etc.).</p>
<p>I would like to enhance ... | [
{
"answer_id": 280728,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "<p>\"What do you think of that?\"</p>\n\n<p><strike>Two</strike>Three things.</p>\n\n<ol>\n<li><p>Fix the legacy metadata. ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25842/"
] | I'm regularly creating an XSD schema by transforming a proprietary data model of a legacy system. This works out pretty good. However, the legacy system only allows me to specify very basic attributes of a parameter, such as the data type (`int`, `string` etc.).
I would like to enhance the XSL transformation with a me... | The best solution would be to modify the legacy data by adding the missing metadata.
An instance of the modified "datamodel" vocabulary may be something like this:
```
<datamodel xmlns:nm="my:new.meta">
<customer>
<firstName type="string"
nm:nillable="false"
nm:minOc... |
280,551 | <p>I try get the <a href="http://flash-mp3-player.net/players/js/" rel="nofollow noreferrer">mp3 flash player</a> to work with my javascript on all browsers. All went well for first, but fast realized that my code doesn't work on MSIE.</p>
<p>After trying to find out I found this in the reference code:</p>
<pre><cod... | [
{
"answer_id": 281941,
"author": "Ben Combee",
"author_id": 1323,
"author_profile": "https://Stackoverflow.com/users/1323",
"pm_score": 3,
"selected": true,
"text": "<p>That syntax, with the <script> tag with the \"event\" and \"for\" attributes is an Internet Explorer-only way of set... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21711/"
] | I try get the [mp3 flash player](http://flash-mp3-player.net/players/js/) to work with my javascript on all browsers. All went well for first, but fast realized that my code doesn't work on MSIE.
After trying to find out I found this in the reference code:
```
<!--[if IE]>
<script type="text/javascript" event="FSComm... | That syntax, with the <script> tag with the "event" and "for" attributes is an Internet Explorer-only way of setting up an event handler on an DOM object. Here, it adds a FSCommand event handler to the myFlash object. This is needed because code running inside the Flash object may want to run JavaScript in the browser.... |
280,559 | <p>This is probably easy but I am getting stuck: when I build a solution in Visual Studio - how do extract the exact cmd line for the current build command in order to be able to do the same build from VisualStudio console? </p>
<p>In the output window I can see the single projects in the solution build commands but n... | [
{
"answer_id": 280568,
"author": "Mendelt",
"author_id": 3320,
"author_profile": "https://Stackoverflow.com/users/3320",
"pm_score": 2,
"selected": false,
"text": "<p>You can start msbuild from the command line. msbuild understands .sln (solution) files. You can specify the .sln file and... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | This is probably easy but I am getting stuck: when I build a solution in Visual Studio - how do extract the exact cmd line for the current build command in order to be able to do the same build from VisualStudio console?
In the output window I can see the single projects in the solution build commands but not the one... | In addition to what @JohnIdol says correctly, I've found that you need to setup a number VS environment variables. I don't have the name of the batch file in front of me, but you can modify or 'I think' use it. It is in VS program files tree somewhere. Also, as I remember you don't want to be in a standard shell but a ... |
280,563 | <p>Has anybody got any real world stories build mobile web sites with NetBiscuits?</p>
<p>Someone told me it was the next big thing in mobile development (<a href="http://www.netbiscuits.com/home" rel="nofollow noreferrer">http://www.netbiscuits.com/home</a>) and it looks pretty good from their site. Just wondered if ... | [
{
"answer_id": 280568,
"author": "Mendelt",
"author_id": 3320,
"author_profile": "https://Stackoverflow.com/users/3320",
"pm_score": 2,
"selected": false,
"text": "<p>You can start msbuild from the command line. msbuild understands .sln (solution) files. You can specify the .sln file and... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36503/"
] | Has anybody got any real world stories build mobile web sites with NetBiscuits?
Someone told me it was the next big thing in mobile development (<http://www.netbiscuits.com/home>) and it looks pretty good from their site. Just wondered if anybody (besides them) has actually used it. | In addition to what @JohnIdol says correctly, I've found that you need to setup a number VS environment variables. I don't have the name of the batch file in front of me, but you can modify or 'I think' use it. It is in VS program files tree somewhere. Also, as I remember you don't want to be in a standard shell but a ... |
280,571 | <p>I am confused about how popen() redirects stdin, stdout and stderr of the child process in unix. The man page on popen() is not very clear in this regard. The call</p>
<pre><code>FILE *p = popen("/usr/bin/foo", "w");
</code></pre>
<p>forks a child process and executes a shell with arguments "-c", "/usr/bin/foo", a... | [
{
"answer_id": 280587,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n <p>The return value from popen() is a normal standard I/O stream in all\n respects save ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31330/"
] | I am confused about how popen() redirects stdin, stdout and stderr of the child process in unix. The man page on popen() is not very clear in this regard. The call
```
FILE *p = popen("/usr/bin/foo", "w");
```
forks a child process and executes a shell with arguments "-c", "/usr/bin/foo", and redirects stdin of this... | `popen(3)` is just a library function, which relies on `fork(2)` and `pipe(2)` to do the real work.
However `pipe(2)` can only create unidirectional pipes. To send the child process input, and also capture the output, you need to open two pipes.
If you want to capture the `stderr` too, that's possible, but then you'l... |
280,578 | <p>I have got some code to load an assembly and get all types, which implement a certain interface, like this (assume asm is a valid and loaded assembly).</p>
<pre><code>var results = from type in asm.GetTypes()
where typeof(IServiceJob).IsAssignableFrom(type)
select type;
</code></pre>
<p>Now I'm stuck: I need t... | [
{
"answer_id": 280591,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 5,
"selected": true,
"text": "<p>Oh wow - I only <a href=\"http://www.madprops.org/blog/linq-with-reflection-part-2/\" rel=\"noreferrer\">blogged about... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] | I have got some code to load an assembly and get all types, which implement a certain interface, like this (assume asm is a valid and loaded assembly).
```
var results = from type in asm.GetTypes()
where typeof(IServiceJob).IsAssignableFrom(type)
select type;
```
Now I'm stuck: I need to create instances of thes... | Oh wow - I only [blogged about this](http://www.madprops.org/blog/linq-with-reflection-part-2/) a few days ago. Here's my method to return instances of all the types that implement a given interface:
```
private static IEnumerable<T> InstancesOf<T>() where T : class
{
var type = typeof(T);
return from t in typ... |
280,579 | <p>How do I pass a value from a child back to the parent form? I have a string that I would like to pass back to the parent.</p>
<p>I launched the child using:</p>
<pre><code>FormOptions formOptions = new FormOptions();
formOptions.ShowDialog();
</code></pre>
| [
{
"answer_id": 280586,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 6,
"selected": false,
"text": "<p>Create a property (or method) on <code>FormOptions</code>, say <code>GetMyResult</code>:</p>\n\n<pre><code>using (F... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I pass a value from a child back to the parent form? I have a string that I would like to pass back to the parent.
I launched the child using:
```
FormOptions formOptions = new FormOptions();
formOptions.ShowDialog();
``` | Create a property (or method) on `FormOptions`, say `GetMyResult`:
```
using (FormOptions formOptions = new FormOptions())
{
formOptions.ShowDialog();
string result = formOptions.GetMyResult;
// do what ever with result...
}
``` |
280,600 | <p>I have some code that effectively does this :</p>
<pre><code>File file = new File("C:\\Program Files (x86)\\Something\\fred.txt");
System.out.println("file.canWrite() = " + file.canWrite());
</code></pre>
<p>It prints true.
Now the odd thing is, I can create the file without any exceptions. Furthermore, another pr... | [
{
"answer_id": 280609,
"author": "Michael Madsen",
"author_id": 27528,
"author_profile": "https://Stackoverflow.com/users/27528",
"pm_score": 4,
"selected": true,
"text": "<p>You are most likely a \"victim\" of folder redirection. When UAC is enabled, any writes to Program Files is redir... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36510/"
] | I have some code that effectively does this :
```
File file = new File("C:\\Program Files (x86)\\Something\\fred.txt");
System.out.println("file.canWrite() = " + file.canWrite());
```
It prints true.
Now the odd thing is, I can create the file without any exceptions. Furthermore, another program can read the file I'... | You are most likely a "victim" of folder redirection. When UAC is enabled, any writes to Program Files is redirected to somewhere else when you're not running the program as an administrator.
You should find your file in C:\Users\<username>\AppData\Local\VirtualStore\<insert>\<expected>\<path>\<here>.
The proper fix,... |
280,634 | <p>How can I check if a string ends with a particular character in JavaScript?</p>
<p>Example: I have a string </p>
<pre><code>var str = "mystring#";
</code></pre>
<p>I want to know if that string is ending with <code>#</code>. How can I check it?</p>
<ol>
<li><p>Is there a <code>endsWith()</code> method in JavaScr... | [
{
"answer_id": 280644,
"author": "Phillip B Oldham",
"author_id": 30478,
"author_profile": "https://Stackoverflow.com/users/30478",
"pm_score": 7,
"selected": false,
"text": "<ol>\n<li>Unfortunately not.</li>\n<li><code>if( \"mystring#\".substr(-1) === \"#\" ) {}</code></li>\n</ol>\n"
... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15177/"
] | How can I check if a string ends with a particular character in JavaScript?
Example: I have a string
```
var str = "mystring#";
```
I want to know if that string is ending with `#`. How can I check it?
1. Is there a `endsWith()` method in JavaScript?
2. One solution I have is take the length of the string and get... | **UPDATE (Nov 24th, 2015):**
This answer is originally posted in the year 2010 (SIX years back.) so please take note of these insightful comments:
* [Shauna](https://stackoverflow.com/users/570040/shauna) -
>
> Update for Googlers - Looks like ECMA6 adds this function. The MDN article also shows a polyfill. <https:... |
280,672 | <p>I have let's say two pc's.PC-a and PC-b which both have the same application installed with java db support.I want from time to time to copy the data from the database on PC-a to database to PC-b and vice-versa so the two PC's to have the same data all the time.
Is there an already implemented API in the database la... | [
{
"answer_id": 280717,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 1,
"selected": false,
"text": "<p>I guess you are using <a href=\"http://developers.sun.com/javadb/\" rel=\"nofollow noreferrer\">Java DB (aka Derb... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36525/"
] | I have let's say two pc's.PC-a and PC-b which both have the same application installed with java db support.I want from time to time to copy the data from the database on PC-a to database to PC-b and vice-versa so the two PC's to have the same data all the time.
Is there an already implemented API in the database layer... | In short: You can't do this without some work on your side. SalesLogix fixed this problem by giving everything a site code, so here's how your table looked:
```
Customer:
SiteCode varchar,
CustomerID varchar,
....
primary key(siteCode, CustomerID)
```
So now you would take your databases, and match ... |
280,680 | <pre><code>$images = array();
$images[0][0] = "boxes/blue.jpg";
$images[0][1] = "blah.html";
$images[1][0] = "boxes/green.jpg";
$images[1][1] = "blah.html";
$images[2][0] = "boxes/orange.jpg";
$images[2][1] = "blah.html";
$images[3][0] = "boxes/pink.jpg";
$images[3][1] = "blah.html";
$images[4][0] = "boxes/purple.jpg";... | [
{
"answer_id": 280686,
"author": "Davide Gualano",
"author_id": 28582,
"author_profile": "https://Stackoverflow.com/users/28582",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://it.php.net/manual/en/function.array-splice.php\" rel=\"nofollow noreferrer\">array_splice()</a>... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] | ```
$images = array();
$images[0][0] = "boxes/blue.jpg";
$images[0][1] = "blah.html";
$images[1][0] = "boxes/green.jpg";
$images[1][1] = "blah.html";
$images[2][0] = "boxes/orange.jpg";
$images[2][1] = "blah.html";
$images[3][0] = "boxes/pink.jpg";
$images[3][1] = "blah.html";
$images[4][0] = "boxes/purple.jpg";
$image... | Slightly off topic, but wouldn't it be easier in this case (picking 5 items from a list of 6) just to pick one element and discard it from the original array, and then use the original? This will also ensure you do not get duplicates in the resultant array.
I realise that you may have more than 6 items in the original... |
280,687 | <p>I am trying to change the rows output by PHP in a table to links. I have added the a href tags to the example below, however it results in an unexpected <code>T_VARIABLE</code>. I have tried it without the extra quotes, but this displays a blank table. I am not sure what the flaw in the logic is.</p>
<pre><code>whi... | [
{
"answer_id": 280691,
"author": "Tom Haigh",
"author_id": 22224,
"author_profile": "https://Stackoverflow.com/users/22224",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li><p>I'm not sure, but you should not really trust anything sent in the header, as it could be faked by the user... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I am trying to change the rows output by PHP in a table to links. I have added the a href tags to the example below, however it results in an unexpected `T_VARIABLE`. I have tried it without the extra quotes, but this displays a blank table. I am not sure what the flaw in the logic is.
```
while($row = mysql_fetch_row... | <http://www.faqs.org/rfcs/rfc1867.html>
*HTTP clients are
encouraged to supply content-length for overall file input so that a
busy server could detect if the proposed file data is too large to be
processed reasonably*
But the content-length is not required, so you cannot rely on it. Also, an attacker can forge a ... |
280,706 | <p>I've been thinking of ways of providing syntactic sugar for a framework I have been working on. I want to deal with Immitable objects exclusively.</p>
<h3>Say I have an immutable object and wish to create a modified version of it. Would, in your view, a non-instantiable class with a single static factory method brea... | [
{
"answer_id": 280718,
"author": "Erik Hesselink",
"author_id": 8071,
"author_profile": "https://Stackoverflow.com/users/8071",
"pm_score": 1,
"selected": false,
"text": "<p>Usually on immutable objects, I would have a method returning a modified version of the object. So if you have som... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] | I've been thinking of ways of providing syntactic sugar for a framework I have been working on. I want to deal with Immitable objects exclusively.
### Say I have an immutable object and wish to create a modified version of it. Would, in your view, a non-instantiable class with a single static factory method break OO p... | I don't think it's a good idea to create one class per method. You could instead create a static only methods class, named e.g StringUtils and implement the methods. This way you would call:
String lowerCaseString = StringUtils.lowercase( targetString );
This would also offer you intellisense help while you are typin... |
280,712 | <p>There should be something akin to <code>\w</code> that can match any code-point in Letters or Marks category (not just the ASCII ones), and hopefully have filters like [[P*]] for punctuation, etc.</p>
| [
{
"answer_id": 280762,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 8,
"selected": false,
"text": "<h2>Situation for ES 6</h2>\n<p>The ECMAScript language specification, edition 6 (also commonly known as ES2015), includes... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There should be something akin to `\w` that can match any code-point in Letters or Marks category (not just the ASCII ones), and hopefully have filters like [[P\*]] for punctuation, etc. | Situation for ES 6
------------------
The ECMAScript language specification, edition 6 (also commonly known as ES2015), includes Unicode-aware regular expressions. Support must be enabled with the `u` modifier on the regex. See [*Unicode-aware regular expressions in ES6*](https://mathiasbynens.be/notes/es6-unicode-reg... |
280,713 | <p>Does the "for…in" loop in Javascript loop through the hashtables/elements in the order they are declared? Is there a browser which doesn't do it in order?<br>
The object I wish to use will be declared <em>once</em> and will never be modified.</p>
<p>Suppose I have:</p>
<pre><code>var myObject = { A: "Hello", B: "W... | [
{
"answer_id": 280733,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 3,
"selected": false,
"text": "<p>The elements of an object that for/in enumerates are the properties that don't have the DontEnum flag set. The ECMASc... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3055/"
] | Does the "for…in" loop in Javascript loop through the hashtables/elements in the order they are declared? Is there a browser which doesn't do it in order?
The object I wish to use will be declared *once* and will never be modified.
Suppose I have:
```
var myObject = { A: "Hello", B: "World" };
```
And I further ... | [Quoting John Resig](http://ejohn.org/blog/javascript-in-chrome/):
>
> Currently all major browsers loop over the properties of an object in the order in
> which they were defined. Chrome does this as well, except for a couple cases. [...]
> This behavior is explicitly left undefined by the ECMAScript specification.
... |
280,729 | <p>I am trying to use the following code to write data into an excel file</p>
<pre><code> Dim objexcel As Excel.Application
Dim wbexcel As Excel.Workbook
Dim wbExists As Boolean
Set objexcel = CreateObject("excel.Application")
obje... | [
{
"answer_id": 280758,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 4,
"selected": true,
"text": "<p>You will need to change this line:</p>\n\n<pre><code> Set wbexcel = objexcel.WorkBooks.Open( _\n \"C:\\Documents and ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31132/"
] | I am trying to use the following code to write data into an excel file
```
Dim objexcel As Excel.Application
Dim wbexcel As Excel.Workbook
Dim wbExists As Boolean
Set objexcel = CreateObject("excel.Application")
objexcel.Visible =... | You will need to change this line:
```
Set wbexcel = objexcel.WorkBooks.Open( _
"C:\Documents and Settings\TAYYAPP\Desktop\test folder\ERROR REPORT2.xls")
```
Note WorkBooks, not Documents
As For this line Set wbexcel = objexcel.Workbook.Add, wbexcel is defined as a workbook, but the line is an action, s... |
280,749 | <p>I have some directories that are bundled with my installer and I need to access them from within a custom action. I have done some research and seen that the SourceDir can be used to obtain the currently executing dir location. However I cannot find any examples of how to obtain this property? Or another way to o... | [
{
"answer_id": 282465,
"author": "w4g3n3r",
"author_id": 36745,
"author_profile": "https://Stackoverflow.com/users/36745",
"pm_score": 1,
"selected": false,
"text": "<p>I'm assuming you're using vbscript for the custom action. If so, properties can be accessed via the Session object. See... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have some directories that are bundled with my installer and I need to access them from within a custom action. I have done some research and seen that the SourceDir can be used to obtain the currently executing dir location. However I cannot find any examples of how to obtain this property? Or another way to obtain ... | I'm assuming you're using vbscript for the custom action. If so, properties can be accessed via the Session object. See below:
```
strSourceDir = Session.Property("SourceDir")
```
Be aware that the SourceDir property is only available at [specific times during the installation](http://msdn.microsoft.com/en-us/librar... |
280,751 | <p>I have a large c# solution file (~100 projects), and I am trying to improve build times. I think that "Copy Local" is wasteful in many cases for us, but I am wondering about best practices.</p>
<p>In our .sln, we have application A depending on assembly B which depends on assembly C. In our case, there are dozens... | [
{
"answer_id": 280770,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 2,
"selected": false,
"text": "<p>our \"best practise\" is to avoid solutions with many projects.\nWe have a directory named \"matrix\" with current version... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6996/"
] | I have a large c# solution file (~100 projects), and I am trying to improve build times. I think that "Copy Local" is wasteful in many cases for us, but I am wondering about best practices.
In our .sln, we have application A depending on assembly B which depends on assembly C. In our case, there are dozens of "B" and ... | In a previous project I worked with one big solution with project references and bumped into a performance problem as well. The solution was three fold:
1. Always set the Copy Local property to false and enforce this via a custom msbuild step
2. Set the output directory for each project to the same directory (preferab... |
280,759 | <p>I am using the <strong><a href="http://en.wikipedia.org/wiki/JQuery" rel="noreferrer">jQuery</a> validation plugin</strong>. Great stuff! I want to migrate my existing ASP.NET solution to use jQuery instead of the ASP.NET validators. I am missing a replacement for the <strong>regular expression</strong> validator. I... | [
{
"answer_id": 280952,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 6,
"selected": false,
"text": "<p>You can use the addMethod()</p>\n\n<p>e.g </p>\n\n<pre><code>$.validator.addMethod('postalCode', function (value) { \n ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36546/"
] | I am using the **[jQuery](http://en.wikipedia.org/wiki/JQuery) validation plugin**. Great stuff! I want to migrate my existing ASP.NET solution to use jQuery instead of the ASP.NET validators. I am missing a replacement for the **regular expression** validator. I want to be able to do something like this:
```
$("Textb... | Thanks to the answer of redsquare I added a method like this:
```js
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
},
"Please check your input."
);
```
Now all you need to do to validate against any rege... |
280,769 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/2246772/whats-the-difference-between-not-exists-vs-not-in-vs-left-join-where-is-null">What's the difference between NOT EXISTS vs. NOT IN vs. LEFT JOIN WHERE IS NULL?</a> </p>
</blockquote>
<p>I need to wit... | [
{
"answer_id": 280775,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": 3,
"selected": true,
"text": "<pre><code>SELECT *\nFROM A\nWHERE ID NOT IN\n (SELECT ID FROM B)\n</code></pre>\n"
},
{
"answer_id": 280778,
... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> **Possible Duplicate:**
>
> [What's the difference between NOT EXISTS vs. NOT IN vs. LEFT JOIN WHERE IS NULL?](https://stackoverflow.com/questions/2246772/whats-the-difference-between-not-exists-vs-not-in-vs-left-join-where-is-null)
>
>
>
I need to wite a query that will retrieve the records from Table A ,... | ```
SELECT *
FROM A
WHERE ID NOT IN
(SELECT ID FROM B)
``` |
280,793 | <p>I need to highlight, case insensitively, given keywords in a JavaScript string.</p>
<p>For example:</p>
<ul>
<li><code>highlight("foobar Foo bar FOO", "foo")</code> should return <code>"<b>foo</b>bar <b>Foo</b> bar <b>FOO</b>"</code></li>
</ul>
<p>I need the code to work for an... | [
{
"answer_id": 280805,
"author": "okoman",
"author_id": 35903,
"author_profile": "https://Stackoverflow.com/users/35903",
"pm_score": 7,
"selected": true,
"text": "<p>You <em>can</em> use regular expressions if you prepare the search string. In PHP e.g. there is a function preg_quote, wh... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to highlight, case insensitively, given keywords in a JavaScript string.
For example:
* `highlight("foobar Foo bar FOO", "foo")` should return `"<b>foo</b>bar <b>Foo</b> bar <b>FOO</b>"`
I need the code to work for any keyword, and therefore using a hardcoded regular expression like `/foo/i` is not a sufficie... | You *can* use regular expressions if you prepare the search string. In PHP e.g. there is a function preg\_quote, which replaces all regex-chars in a string with their escaped versions.
Here is such a function for javascript ([source](https://locutus.io/php/pcre/preg_quote/)):
```
function preg_quote (str, delimiter) ... |
280,797 | <p>When you use the POISSON function in Excel (or in OpenOffice Calc), it takes two arguments:</p>
<ul>
<li>an integer</li>
<li>an 'average' number</li>
</ul>
<p>and returns a float.</p>
<p>In Python (I tried RandomArray and NumPy) it returns an array of random poisson numbers.
What I really want is the percentage t... | [
{
"answer_id": 280831,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://numpy.sourceforge.net/numdoc/HTML/numdoc.htm#pgfId-305426\" rel=\"nofollow noreferrer\">This page</a> e... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When you use the POISSON function in Excel (or in OpenOffice Calc), it takes two arguments:
* an integer
* an 'average' number
and returns a float.
In Python (I tried RandomArray and NumPy) it returns an array of random poisson numbers.
What I really want is the percentage that this event will occur (it is a constan... | It is easy to do by hand, but you can overflow doing it that way. You can do the exponent and factorial in a loop to avoid the overflow:
```
def poisson_probability(actual, mean):
# naive: math.exp(-mean) * mean**actual / factorial(actual)
# iterative, to keep the components from getting too large or small:... |
280,798 | <p>I'm trying to make a class that will execute any one of a number of stored procedures with any amount of variables</p>
<p>Im using php and mysqli</p>
<ul>
<li>My class enumerates an array and constructs a string based on the number of elements if any</li>
<li>giving something like this <code>CALL spTestLogin(?,?)<... | [
{
"answer_id": 280829,
"author": "Stefan Gehrig",
"author_id": 11354,
"author_profile": "https://Stackoverflow.com/users/11354",
"pm_score": 2,
"selected": false,
"text": "<p>You have to do something like this:</p>\n\n<pre><code>$params=array_merge(\n array($this->paramTypes), \n ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11394/"
] | I'm trying to make a class that will execute any one of a number of stored procedures with any amount of variables
Im using php and mysqli
* My class enumerates an array and constructs a string based on the number of elements if any
* giving something like this `CALL spTestLogin(?,?)` for example
* I now need to bind... | You have to do something like this:
```
$params=array_merge(
array($this->paramTypes),
$this->paramValues
);
call_user_func_array(array($stmt, 'bind_param'), $params);
```
given that `$this->paramTypes` is a string in the format required by `mysqli_stmt::bind_param` - if not, you have to create this `string... |
280,801 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/16991/what-ruby-ide-do-you-prefer">What Ruby IDE do you prefer?</a> </p>
</blockquote>
<p>I'm making a <strong>simple</strong> script using ruby on a Windows 2003 Server.
My questions are:</p>
<ul>
<li>How can... | [
{
"answer_id": 280857,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "<p>There is an ODBC package for the <a href=\"http://ruby-dbi.rubyforge.org/\" rel=\"nofollow noreferrer\">Ruby DBI module... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15884/"
] | >
> **Possible Duplicate:**
>
> [What Ruby IDE do you prefer?](https://stackoverflow.com/questions/16991/what-ruby-ide-do-you-prefer)
>
>
>
I'm making a **simple** script using ruby on a Windows 2003 Server.
My questions are:
* How can I connect to a database through ODBC? I will be connecting to both **Sybas... | There is an ODBC package for the [Ruby DBI module](http://ruby-dbi.rubyforge.org/) available, or you can try to use the [ODBC binding for Ruby](http://www.ch-werner.de/rubyodbc/), which also includes a Win32 binary.
Here an example that uses RDI (stolen from [here](http://www.ruby-forum.com/topic/64065)):
```
require... |
280,818 | <p>I'm developing a small utility application that needs to detect whether another one has one of its MDI child windows open (it's an off-the-shelf Win32 business application over which I have neither source code nor control).
From my app, I would like to be able to poll or detect when a particular MDI Child window is... | [
{
"answer_id": 280866,
"author": "Juanma",
"author_id": 3730,
"author_profile": "https://Stackoverflow.com/users/3730",
"pm_score": 1,
"selected": false,
"text": "<p>You can use P/Invoke to access EnumWindows and EnumChidWindows to itereate through the subwindows/controls of any window.<... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3811/"
] | I'm developing a small utility application that needs to detect whether another one has one of its MDI child windows open (it's an off-the-shelf Win32 business application over which I have neither source code nor control).
From my app, I would like to be able to poll or detect when a particular MDI Child window is op... | You must use native Win32 API.
[EnumChildWindows (user32)](http://www.pinvoke.net/default.aspx/user32/EnumChildWindows.html)
```
[DllImport("user32")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr i);
/// <summary>
/// Returns a lis... |
280,819 | <p>My WCF service involves the sending of a dataset (in csv format) data between client and service. This dataset must be encrypted so that the data cannot be intercepted. I'm using wshttpbinding and trying to encrypt the message by using the following settings in web.config:</p>
<pre><code><wsHttpBinding>
<... | [
{
"answer_id": 280890,
"author": "Martin",
"author_id": 1529,
"author_profile": "https://Stackoverflow.com/users/1529",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, your service needs a certificate so that your encryption keys can be exchanged securely. You can create a test servic... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445/"
] | My WCF service involves the sending of a dataset (in csv format) data between client and service. This dataset must be encrypted so that the data cannot be intercepted. I'm using wshttpbinding and trying to encrypt the message by using the following settings in web.config:
```
<wsHttpBinding>
<binding name="wsHttp">... | Yes, your service needs a certificate so that your encryption keys can be exchanged securely. You can create a test service authentication certificate with makecert.exe. See [this entry in my blog](http://web.archive.org/web/20070306040207/http://martinparry.com/cs/blogs/mparry_software/archive/2006/10/30/97.aspx) for ... |