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 |
|---|---|---|---|---|---|---|
391,969 | <p>I really like how Consolas looks with ClearType enabled but unfortunately it makes everything else look terrible. Is there any way to enable this on a per app basis? I noticed that putty (the terminal emulator) has options for ClearType separate from the display setting.</p>
| [
{
"answer_id": 392346,
"author": "Mark Heath",
"author_id": 7532,
"author_profile": "https://Stackoverflow.com/users/7532",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not entirely sure if I understood your question right, but why not simply use <code>INotifyPropertyChanged</code> o... | 2008/12/24 | [
"https://Stackoverflow.com/questions/391969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] | I really like how Consolas looks with ClearType enabled but unfortunately it makes everything else look terrible. Is there any way to enable this on a per app basis? I noticed that putty (the terminal emulator) has options for ClearType separate from the display setting. | I'm not entirely sure if I understood your question right, but why not simply use `INotifyPropertyChanged` on your ViewModel?
for example:
```
interface MyInterface : INotifyPropertyChanged
{
string Text { get; set; }
}
class MyViewModel : MyInterface
{
private string text;
public string Text
{
... |
391,979 | <p>I need to somehow retrieve the client's IP address using JavaScript; no server side code, not even SSI.</p>
<p>However, I'm not against using a free 3rd party script/service.</p>
| [
{
"answer_id": 391982,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 7,
"selected": false,
"text": "<p>Most of the answers here \"work around\" the need for server-side code by... Hitting someone else's server. Which is a totall... | 2008/12/24 | [
"https://Stackoverflow.com/questions/391979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I need to somehow retrieve the client's IP address using JavaScript; no server side code, not even SSI.
However, I'm not against using a free 3rd party script/service. | I would use a web service that can return JSON (along with jQuery to make things simpler). Below are all the *active* free IP lookup services I could find and the information they return. If you know of others, then please add a comment and I'll update this answer.
---
[Abstract](https://www.abstractapi.com/ip-geoloc... |
391,991 | <p>Well I am almost done finalizing the auditing portion of my application that I discussed <a href="https://stackoverflow.com/questions/390567/form-level-event-for-when-data-is-changed-on-a-msaccess-form">here</a>. The way I am doing it is looping through all text fields, drop down boxes and checkboxes and storing th... | [
{
"answer_id": 392196,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>I am guessing that AfterUpdate might not be the right event to use.</p>\n\n<p>Also, putting inputbox might be causi... | 2008/12/24 | [
"https://Stackoverflow.com/questions/391991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | Well I am almost done finalizing the auditing portion of my application that I discussed [here](https://stackoverflow.com/questions/390567/form-level-event-for-when-data-is-changed-on-a-msaccess-form). The way I am doing it is looping through all text fields, drop down boxes and checkboxes and storing their values in t... | I'm not sure I have the whole answer, but a couple of observations.
You can eliminate some lines of code by using CurrentDB.Execute strSQL. This elminates the need for the SetWarnings calls. It executes directly against the database without interacting with the usual interface mechanisms.
For debugging purposes, it m... |
392,001 | <p>Does anyone know of a program, a utility, or some programmatic library, preferably for Linux, that takes an unformatted SQL string and pretty prints it?</p>
<p>For example I would like the following</p>
<pre><code>select * from users where name = 'Paul'
</code></pre>
<p>be changed to something like this</p>
<pre... | [
{
"answer_id": 18322855,
"author": "Wayne Walker",
"author_id": 448831,
"author_profile": "https://Stackoverflow.com/users/448831",
"pm_score": 4,
"selected": false,
"text": "<h1>Try fsqlf</h1>\n<p><strong>fsqlf</strong> (<a href=\"http://sourceforge.net/projects/fsqlf/\" rel=\"nofollow ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045/"
] | Does anyone know of a program, a utility, or some programmatic library, preferably for Linux, that takes an unformatted SQL string and pretty prints it?
For example I would like the following
```
select * from users where name = 'Paul'
```
be changed to something like this
```
select *
from users
where
name = ... | Try sqlparse module's sqlformat
===============================
Check out [sqlparse](https://github.com/andialbrecht/sqlparse). It is a Python module that installs the command `sqlformat`. Usage is simple, e.g.:
```
sqlformat --reindent --keywords upper --identifiers lower my_file.sql
```
**Example:**
```
$ echo "... |
392,011 | <p>We use MS Access as a front-end to Oracle tables, via ODBC, and it has been working well.
But we're trying to use the DEFAULT constraint in an Oracle table. When we open the linked table in Access, we see existing data just fine, but when we try to add a row, without keying any value into column(s) that have an Ora... | [
{
"answer_id": 392074,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 1,
"selected": false,
"text": "<p>If you're doing this with the grid view as data entry, I'd think that Access may be explicitly trying to insert an empty stri... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We use MS Access as a front-end to Oracle tables, via ODBC, and it has been working well.
But we're trying to use the DEFAULT constraint in an Oracle table. When we open the linked table in Access, we see existing data just fine, but when we try to add a row, without keying any value into column(s) that have an Oracle ... | If you're doing this with the grid view as data entry, I'd think that Access may be explicitly trying to insert an empty string as that value. Try writing the plain SQL statement for the insert and see what happens.
I'd expect underlying SQL like this (assuming default values set for name="John", balance="0.0")...
Vi... |
392,022 | <p>I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution.</p>
| [
{
"answer_id": 392111,
"author": "brad.lane",
"author_id": 48774,
"author_profile": "https://Stackoverflow.com/users/48774",
"pm_score": 3,
"selected": false,
"text": "<p>if you know pass the pid of the parent process, here's a shell script that should work:</p>\n\n<pre><code>for child i... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26658/"
] | I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution. | You don't say if the tree you want to kill is a single process group. (This is often the case if the tree is the result of forking from a server start or a shell command line.) You can discover process groups using GNU ps as follows:
```
ps x -o "%p %r %y %x %c "
```
If it is a process group you want to kill, just... |
392,034 | <p>I'm going nuts here, trying to get my system configured. </p>
<p>I have a laptop at home and a workstation at work. I use mutt and sendmail. I have a home ISP that is on a lot of blacklists, so that any email I send from my laptop through my ISP is frequently blocked as spam by the receiver. I can SSH to my worksta... | [
{
"answer_id": 392067,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 4,
"selected": true,
"text": "<p>If you run that ssh tunnel, you can't be running sendmail locally because otherwise it will be listening on port 25, ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48915/"
] | I'm going nuts here, trying to get my system configured.
I have a laptop at home and a workstation at work. I use mutt and sendmail. I have a home ISP that is on a lot of blacklists, so that any email I send from my laptop through my ISP is frequently blocked as spam by the receiver. I can SSH to my workstation and u... | If you run that ssh tunnel, you can't be running sendmail locally because otherwise it will be listening on port 25, not your tunnel. And fetchmail by default wants a local mail server to deliver to, although you could configure it to deliver to an mbox file directly if you prefer.
What I do instead is I run postfix o... |
392,041 | <p>I'm using the python optparse module in my program, and I'm having trouble finding an easy way to parse an option that contains a list of values.</p>
<p>For example:</p>
<pre><code>--groups one,two,three.
</code></pre>
<p>I'd like to be able to access these values in a list format as <code>options.groups[]</code... | [
{
"answer_id": 392061,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 6,
"selected": true,
"text": "<p>Look at <a href=\"http://docs.python.org/2/library/optparse#option-callbacks\" rel=\"noreferrer\">option callbacks</a>. ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48810/"
] | I'm using the python optparse module in my program, and I'm having trouble finding an easy way to parse an option that contains a list of values.
For example:
```
--groups one,two,three.
```
I'd like to be able to access these values in a list format as `options.groups[]`. Is there an optparse option to convert co... | Look at [option callbacks](http://docs.python.org/2/library/optparse#option-callbacks). Your callback function can parse the value into a list using a basic `optarg.split(',')` |
392,042 | <p>I'm new to PHP and have installed on Linux to boot (also a newbie).
Anyway, PHP is working...</p>
<pre><code><?
$myVar = "test";
echo($myVar);
?>
</code></pre>
<p>... works just fine.</p>
<p>But...</p>
<pre><code><?
$dbhost = "localhost";
$dbuser = "myuser";
$dbpass = "mypass";
$dbname = "mydb";
echo(... | [
{
"answer_id": 392055,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 1,
"selected": false,
"text": "<p>If it does nothing, doesn't that mean that it connected fine? What output do you expect out of that statement?... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26121/"
] | I'm new to PHP and have installed on Linux to boot (also a newbie).
Anyway, PHP is working...
```
<?
$myVar = "test";
echo($myVar);
?>
```
... works just fine.
But...
```
<?
$dbhost = "localhost";
$dbuser = "myuser";
$dbpass = "mypass";
$dbname = "mydb";
echo($dbhost . "-" . $dbuser . "-" . $dbpass . "-" . $dbna... | Try to do the following:
1. First make sure [display\_errors](http://www.php.net/manual/en/errorfunc.configuration.php) is turned on in your php configuration file. Also set the level of [error\_reporting](http://www.php.net/error_reporting) to show all errors, including strict (error\_reporting = E\_ALL|E\_STRICT). A... |
392,043 | <p>I see on the web there are a lot of questions about caching ASP.Net, but not a lot of discussion on caching options for a Smart Client Application and their databases.</p>
<p>What are the data caching options that are available for Smart Client Application on the .Net framework, and how are any of you using them?</... | [
{
"answer_id": 392050,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 0,
"selected": false,
"text": "<p>Well, if you have a Windows Forms application, you aren't usually concerned with the types of multi-user caching sc... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13502/"
] | I see on the web there are a lot of questions about caching ASP.Net, but not a lot of discussion on caching options for a Smart Client Application and their databases.
What are the data caching options that are available for Smart Client Application on the .Net framework, and how are any of you using them?
---
**Edi... | Caching frequently accessed data is required/desirable in Winforms Smart Client applications. Reading data from cache is often faster than hitting your data providers/web services.
Here are a couple of options with examples
1. Enterprise library's caching application block is a good choice.
2. Also, System.Web.Cachin... |
392,100 | <p>I've been working with python for a while now and am just starting to learn wxPython. After creating a few little programs, I'm having difficulty understanding how to create objects that can be shared between dialogs.</p>
<p>Here's some code as an example (apologies for the length - I've tried to trim):</p>
<pre>... | [
{
"answer_id": 392125,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": true,
"text": "<p>You can pass a gamePlayer object to <code>__init__</code> as another argument.</p>\n\n<pre><code>def __init__(self, paren... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40429/"
] | I've been working with python for a while now and am just starting to learn wxPython. After creating a few little programs, I'm having difficulty understanding how to create objects that can be shared between dialogs.
Here's some code as an example (apologies for the length - I've tried to trim):
```
import wx
class... | You can pass a gamePlayer object to `__init__` as another argument.
```
def __init__(self, parent, id, title, gamePlayer ):
...etc...
```
In the long run, this isn't ideal.
You should separate building an empty panel from loading that panel with data. The empty panel is one thing, populating it with data from ... |
392,120 | <p>Does anyone know why typedefs of class names don't work like class names for the friend declaration?</p>
<pre><code>class A
{
public:
};
class B : public A
{
public:
typedef A SUPERCLASS;
};
typedef A X;
class C
{
public:
friend class A; // OK
friend class X; // fails
friend c... | [
{
"answer_id": 392134,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 1,
"selected": false,
"text": "<p>AFAIK, In C++ typedef does not create a full-fledged synonyms when used in conjuction with classes. In other words, it's no... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48956/"
] | Does anyone know why typedefs of class names don't work like class names for the friend declaration?
```
class A
{
public:
};
class B : public A
{
public:
typedef A SUPERCLASS;
};
typedef A X;
class C
{
public:
friend class A; // OK
friend class X; // fails
friend class B::SUPERC... | It can't, currently. I don't know the reason yet (just looking it up, because i find it interesting). Update: you can find the reason in the first proposal to support typedef-names as friends: <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1520.pdf> . The reason is that the Standard only supported elaborated... |
392,122 | <p>FieldInfo has an IsStatic member, but PropertyInfo doesn't. I assume I'm just overlooking what I need. </p>
<pre><code>Type type = someObject.GetType();
foreach (PropertyInfo pi in type.GetProperties())
{
// umm... Not sure how to tell if this property is static
}
</code></pre>
| [
{
"answer_id": 392130,
"author": "Steven Behnke",
"author_id": 42588,
"author_profile": "https://Stackoverflow.com/users/42588",
"pm_score": 7,
"selected": true,
"text": "<p>To determine whether a property is static, you must obtain the MethodInfo for the get or set accessor, by calling ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16260/"
] | FieldInfo has an IsStatic member, but PropertyInfo doesn't. I assume I'm just overlooking what I need.
```
Type type = someObject.GetType();
foreach (PropertyInfo pi in type.GetProperties())
{
// umm... Not sure how to tell if this property is static
}
``` | To determine whether a property is static, you must obtain the MethodInfo for the get or set accessor, by calling the GetGetMethod or the GetSetMethod method, and examine its IsStatic property.
<http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.aspx> |
392,135 | <p>I understand one uses the "bless" keyword in Perl inside a class's "new" method:</p>
<pre><code>sub new {
my $self = bless { };
return $self;
}
</code></pre>
<p>But what exactly is "bless" doing to that hash reference ? </p>
| [
{
"answer_id": 392143,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 3,
"selected": false,
"text": "<p>Short version: it's marking that hash as attached to the current package namespace (so that that package provides its cla... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47145/"
] | I understand one uses the "bless" keyword in Perl inside a class's "new" method:
```
sub new {
my $self = bless { };
return $self;
}
```
But what exactly is "bless" doing to that hash reference ? | In general, `bless` associates an object with a class.
```
package MyClass;
my $object = { };
bless $object, "MyClass";
```
Now when you invoke a method on `$object`, Perl know which package to search for the method.
If the second argument is omitted, as in your example, the current package/class is used.
For the ... |
392,142 | <p>How do I determine whether a function exists within a library, or list out the functions in a compiled library?</p>
| [
{
"answer_id": 392148,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 6,
"selected": true,
"text": "<p>You can use the <a href=\"http://unixhelp.ed.ac.uk/CGI/man-cgi?nm\" rel=\"noreferrer\">nm</a> command to list the symb... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18352/"
] | How do I determine whether a function exists within a library, or list out the functions in a compiled library? | You can use the [nm](http://unixhelp.ed.ac.uk/CGI/man-cgi?nm) command to list the symbols in static libraries.
```
nm -g -C <libMylib.a>
``` |
392,160 | <p>I have a friend who likes to use metaclasses, and regularly offers them as a solution.</p>
<p>I am of the mind that you almost never need to use metaclasses. Why? because I figure if you are doing something like that to a class, you should probably be doing it to an object. And a small redesign/refactor is in order... | [
{
"answer_id": 392230,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>You never absolutely <em>need</em> to use a metaclass, since you can always construct a class that does what you... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28380/"
] | I have a friend who likes to use metaclasses, and regularly offers them as a solution.
I am of the mind that you almost never need to use metaclasses. Why? because I figure if you are doing something like that to a class, you should probably be doing it to an object. And a small redesign/refactor is in order.
Being a... | I have a class that handles non-interactive plotting, as a frontend to Matplotlib. However, on occasion one wants to do interactive plotting. With only a couple functions I found that I was able to increment the figure count, call draw manually, etc, but I needed to do these before and after every plotting call. So to ... |
392,169 | <p>Is there a way to play a Christmas tune on a PC or Mac without having a pre-recorded sound file? (No .mp3 or .wav or whatever-sound file)</p>
<p>I remember on my TI 99/4A and Apple II sounds (resembling music) could be played. Not sure if modern computers have these abilities (aside from <em>beep</em>).</p>
| [
{
"answer_id": 392177,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 1,
"selected": false,
"text": "<p>MIDI is an option, although on a PC it usually sounds almost as bad as beep.</p>\n"
},
{
"answer_id": 39217... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21826/"
] | Is there a way to play a Christmas tune on a PC or Mac without having a pre-recorded sound file? (No .mp3 or .wav or whatever-sound file)
I remember on my TI 99/4A and Apple II sounds (resembling music) could be played. Not sure if modern computers have these abilities (aside from *beep*). | "Jingle Bells" in java (bloated as usual), using [JFugue](http://www.jfugue.org/), with tubular bells and xylophones (polyphonic!):
```
import org.jfugue.*;
public class JingleBells
{
public static void main(String[] args)
{
Player player = new Player();
player.play("T170 "+
... |
392,176 | <p>I am retrieving three different sets of data (or what should be "unique" rows). In total, I expect 3 different unique sets of rows because I have to complete different operations on each set of data. I am, however, retrieving more rows than there are in total in the table, meaning that I must be retrieving duplica... | [
{
"answer_id": 392184,
"author": "Eric Rosenberger",
"author_id": 41624,
"author_profile": "https://Stackoverflow.com/users/41624",
"pm_score": 1,
"selected": false,
"text": "<p>Are you sure that NAME and ID are unique in both tables?</p>\n\n<p>If not, you could have a situation, for exa... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16631/"
] | I am retrieving three different sets of data (or what should be "unique" rows). In total, I expect 3 different unique sets of rows because I have to complete different operations on each set of data. I am, however, retrieving more rows than there are in total in the table, meaning that I must be retrieving duplicate ro... | Consider if Name is not unique. If you have the following data:
```
Table 1 Table 2
ID Name Address ID Name Address
0 Jim Smith 1111 A St 0 Jim Smith 2222 A St
1 Jim Smith 2222 B St 1 Jim Smith 3333 C St
```
Then Query 1 gives you:
```
0 Ji... |
392,257 | <p>I have a picture box on my form, which I add a picture to. This picture has a transparent background, but unfortunately, it seems lost in the picture box... I'm guessing that's because the picture box's background colour property is set to grey (the default). I can't see any option for "transparent" though.</p>
<p>... | [
{
"answer_id": 392264,
"author": "user21826",
"author_id": 21826,
"author_profile": "https://Stackoverflow.com/users/21826",
"pm_score": 4,
"selected": true,
"text": "<p>Depending on what you are trying to accomplish there's several different ways to go about it.</p>\n\n<p><strong>Some e... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48970/"
] | I have a picture box on my form, which I add a picture to. This picture has a transparent background, but unfortunately, it seems lost in the picture box... I'm guessing that's because the picture box's background colour property is set to grey (the default). I can't see any option for "transparent" though.
Any idea h... | Depending on what you are trying to accomplish there's several different ways to go about it.
**Some examples are -**
Make bitmap transparent
```
Dim bmp As Bitmap = Bitmap.FromFile("test.bmp")
bmp.MakeTransparent(Color.Magenta) ' magenta in bitmap will be transparent
PictureBox1.Image = bmp
```
Make the picture ... |
392,273 | <p>Pursuant to the advice given in <a href="https://stackoverflow.com/questions/385156/how-do-i-retrofit-a-gui-to-an-existing-c-program">this question</a> I have written a little gui to take the options for a command line C program and pass them on to said C program which is already set up to process them. It displays ... | [
{
"answer_id": 392313,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 0,
"selected": false,
"text": "<p>Here's a little tcl snippet - run from tclsh or wish</p>\n\n<pre><code>[nigel@rose ~]$ wish\n% set fo... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30924/"
] | Pursuant to the advice given in [this question](https://stackoverflow.com/questions/385156/how-do-i-retrofit-a-gui-to-an-existing-c-program) I have written a little gui to take the options for a command line C program and pass them on to said C program which is already set up to process them. It displays just like I wa... | Variable Basics
---------------
As others have pointed out, the confusing **to $ or not to $** notation can be simplified by the following rule.
>
> **var** is a reference to the variable itself, not its value
>
>
> **$var** yields the value held in the variable
>
>
>
It can become a little more confusing when... |
392,277 | <p>I'm trying to change the border color of an image using its id with jquery
( photo['id'] is passed in from a previous function )
the ids of the photos are of the form 'photo239839'</p>
<pre><code> $('#photo'+photo['id']+'').click(function(){
$('#photo'+photo['id']+'').css('border-color','#777');
});
<... | [
{
"answer_id": 392293,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 4,
"selected": false,
"text": "<p>This is what you need to do:</p>\n\n<pre><code>$('img.flickr_photo').click(function(){ \n $(this).css('bor... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48973/"
] | I'm trying to change the border color of an image using its id with jquery
( photo['id'] is passed in from a previous function )
the ids of the photos are of the form 'photo239839'
```
$('#photo'+photo['id']+'').click(function(){
$('#photo'+photo['id']+'').css('border-color','#777');
});
```
When I tr... | This is what you need to do:
```
$('img.flickr_photo').click(function(){
$(this).css('border-color','#777');
});
``` |
392,283 | <p>What are your thoughts on using Windows Live Writer communicating with your website as the content editing system?</p>
<p>Windows Live Writer supports multiple category blogs (i.e. can be news, articles, and blogs), multiple category pages, tagging, XHTML WYSIWYG editing, image and file uploading via services or ft... | [
{
"answer_id": 392293,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 4,
"selected": false,
"text": "<p>This is what you need to do:</p>\n\n<pre><code>$('img.flickr_photo').click(function(){ \n $(this).css('bor... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13502/"
] | What are your thoughts on using Windows Live Writer communicating with your website as the content editing system?
Windows Live Writer supports multiple category blogs (i.e. can be news, articles, and blogs), multiple category pages, tagging, XHTML WYSIWYG editing, image and file uploading via services or ftp, and the... | This is what you need to do:
```
$('img.flickr_photo').click(function(){
$(this).css('border-color','#777');
});
``` |
392,315 | <p>I want to use an IFrame in my ASP.Net MVC application, yet I want to retain the layout when the internal pages are navigated via direct access (Search Engine).</p>
<p>How would I switch the master page based on whether the View was in an IFrame, or a top level window?</p>
| [
{
"answer_id": 393814,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 0,
"selected": false,
"text": "<p>One way:</p>\n\n<p>Put the content in a user control. Write a lightweight view which wraps the user control for the ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13502/"
] | I want to use an IFrame in my ASP.Net MVC application, yet I want to retain the layout when the internal pages are navigated via direct access (Search Engine).
How would I switch the master page based on whether the View was in an IFrame, or a top level window? | The ViewResult you return in your controller Action has a MasterName property.
Have your controller action receive a parameter that tells it whether you're in an IFrame or not and then you can do
```
if (isInIFrame)
{
ViewResult result = View();
result.MasterName = "IFrameMaster";
return result;
}
``` |
392,324 | <p>I have an array of <code>int</code> pixels in my C# program and I want to convert it into an image. The problem is I am converting Java source code for a program into equivalent C# code. In java the line reads which displays the array of int pixels into image:</p>
<pre><code>Image output = createImage(new MemoryIma... | [
{
"answer_id": 392335,
"author": "mackenir",
"author_id": 25457,
"author_profile": "https://Stackoverflow.com/users/25457",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <a href=\"http://msdn.microsoft.com/en-us/library/039882h3.aspx\" rel=\"nofollow noreferrer\">Bitmap.LockB... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an array of `int` pixels in my C# program and I want to convert it into an image. The problem is I am converting Java source code for a program into equivalent C# code. In java the line reads which displays the array of int pixels into image:
```
Image output = createImage(new MemoryImageSource(width, height, o... | Using WPF, you can create a bitmap (image) directly from your array. You can then encode this image or display it or play with it:
```
int width = 200;
int height = 200;
//
// Here is the pixel format of your data, set it to the proper value for your data
//
PixelFormat pf = PixelFormats.Bgr32;
int rawStride = (width... |
392,327 | <p>How do I obtain a stack trace of addresses on Windows without using dbghelp.dll?</p>
<p>I don't need to know what the symbols or function names associated with the addresses, I just want the list of addresses -- something similar to <strong><a href="http://www.gnu.org/software/libtool/manual/libc/Backtraces.html" r... | [
{
"answer_id": 392350,
"author": "Kris Kumler",
"author_id": 4281,
"author_profile": "https://Stackoverflow.com/users/4281",
"pm_score": 3,
"selected": false,
"text": "<p>Check out the <a href=\"http://msdn.microsoft.com/en-us/library/bb204633(VS.85).aspx\" rel=\"noreferrer\">CaptureStac... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19129/"
] | How do I obtain a stack trace of addresses on Windows without using dbghelp.dll?
I don't need to know what the symbols or function names associated with the addresses, I just want the list of addresses -- something similar to **[backtrace of \*nix systems](http://www.gnu.org/software/libtool/manual/libc/Backtraces.htm... | Check out the [CaptureStackBackTrace()](http://msdn.microsoft.com/en-us/library/bb204633(VS.85).aspx) function, which is in Kernel32.dll. This should do all that you need.
>
> Captures a stack back trace by walking up the stack and recording the information for each frame.
>
>
>
```
USHORT WINAPI CaptureStackBack... |
392,332 | <p>I have a repository which I have <em>already</em> cloned from Subversion. I've been doing some work in this repository in its Git form and I would hate to lose that structure by cloning again.</p>
<p>However, when I originally cloned the repository, I failed to correctly specify the <code>svn.authors</code> proper... | [
{
"answer_id": 392345,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>You probably want to look into <a href=\"http://git-scm.com/docs/git-filter-branch\" rel=\"nofollow noreferrer\"><code... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9815/"
] | I have a repository which I have *already* cloned from Subversion. I've been doing some work in this repository in its Git form and I would hate to lose that structure by cloning again.
However, when I originally cloned the repository, I failed to correctly specify the `svn.authors` property (or a semantically-similar... | Start out by seeing what you've got to clean up:
```
git shortlog -s
```
For each one of those names, create an entry in a script that looks like this (assuming you want all the authors and committers to be the same):
```
#!/bin/sh
git filter-branch --env-filter '
n=$GIT_AUTHOR_NAME
m=$GIT_AUTHOR_EMAIL
case ${GI... |
392,349 | <p>Is there any way to modify the bound value of one of the variables inside a closure? Look at the example to understand it better.</p>
<pre><code>def foo():
var_a = 2
var_b = 3
def _closure(x):
return var_a + var_b + x
return _closure
localClosure = foo()
# Local closure is now "return 2... | [
{
"answer_id": 392360,
"author": "titaniumdecoy",
"author_id": 18091,
"author_profile": "https://Stackoverflow.com/users/18091",
"pm_score": 0,
"selected": false,
"text": "<p>Why not make var_a and var_b arguments of the function foo?</p>\n\n<pre><code>def foo(var_a = 2, var_b = 3):\n ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/392349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4381/"
] | Is there any way to modify the bound value of one of the variables inside a closure? Look at the example to understand it better.
```
def foo():
var_a = 2
var_b = 3
def _closure(x):
return var_a + var_b + x
return _closure
localClosure = foo()
# Local closure is now "return 2 + 3 + x"
a = l... | I don't think there is any way to do that in Python. When the closure is defined, the current state of variables in the enclosing scope is captured and no longer has a directly referenceable name (from outside the closure). If you were to call `foo()` again, the new closure would have a different set of variables from ... |
392,371 | <p>Hi sorry for being annoying by rephrasing my question but I am just on the point of discovering my answer.</p>
<p>I have an array of <code>int</code> composed of RGB values, I need to decompose that <code>int</code> array into a byte array, but it should be in BGR order.</p>
<p>The array of int composed of RGB val... | [
{
"answer_id": 392379,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 1,
"selected": false,
"text": "<pre><code>#define N something\nunsigned char bytes[N*3];\nunsigned int ints[N];\n\nfor(int i=0; i<N; i++) {\n ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Hi sorry for being annoying by rephrasing my question but I am just on the point of discovering my answer.
I have an array of `int` composed of RGB values, I need to decompose that `int` array into a byte array, but it should be in BGR order.
The array of int composed of RGB values is being created like so:
```
pix[... | C# code
```
// convert integer array representing [argb] values to byte array representing [bgr] values
private byte[] convertArray(int[] array)
{
byte[] newarray = new byte[array.Length * 3];
for (int i = 0; i < array.Length; i++)
{
ne... |
392,375 | <p>I have two simple while loops in my program that I feel ought to be math equations, but I'm struggling to convert them:</p>
<pre><code>float a = someValue;
int b = someOtherValue;
int c = 0;
while (a <= -b / 2) {
c--;
a += b;
}
while (a >= b / 2) {
c++;
a -= b;
}
</code></pre>
<p>This code w... | [
{
"answer_id": 392382,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 1,
"selected": false,
"text": "<p>I think you want something like this:</p>\n\n<pre><code>c = ((int) a + b / 2 * sign(a)) / b\n</code></pre>\n\n<p>That sho... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43496/"
] | I have two simple while loops in my program that I feel ought to be math equations, but I'm struggling to convert them:
```
float a = someValue;
int b = someOtherValue;
int c = 0;
while (a <= -b / 2) {
c--;
a += b;
}
while (a >= b / 2) {
c++;
a -= b;
}
```
This code works as-is, but I feel it could ... | It can be proved that the following is correct:
```
c = floor((a+b/2)/b)
a = a - c*b
```
Note that floor means round down, towards negative infinity: not towards 0. (E.g. floor(-3.1)=-4. The `floor()` library functions will do this; just be sure not to just cast to int, which will usually round towards 0 instead.)
... |
392,376 | <p>I’m trying to publish an InfoPath form to a SharePoint document library, and have the form be viewable in a web browser.</p>
<p>The problem is that in the InfoPath publishing wizard tells me that although the form is browser compatible, that it cannot be browser enabled because of one of the following:</p>
<ul>
<l... | [
{
"answer_id": 392382,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 1,
"selected": false,
"text": "<p>I think you want something like this:</p>\n\n<pre><code>c = ((int) a + b / 2 * sign(a)) / b\n</code></pre>\n\n<p>That sho... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I’m trying to publish an InfoPath form to a SharePoint document library, and have the form be viewable in a web browser.
The problem is that in the InfoPath publishing wizard tells me that although the form is browser compatible, that it cannot be browser enabled because of one of the following:
* The Server is not r... | It can be proved that the following is correct:
```
c = floor((a+b/2)/b)
a = a - c*b
```
Note that floor means round down, towards negative infinity: not towards 0. (E.g. floor(-3.1)=-4. The `floor()` library functions will do this; just be sure not to just cast to int, which will usually round towards 0 instead.)
... |
392,397 | <p>As I was programming, I haven't seen an instance where an array is better for storing information than another form thereof. I had indeed figured the added "features" in programming languages had improved upon this and by that replaced them. I see now that they aren't replaced but rather given new life, so to speak... | [
{
"answer_id": 392403,
"author": "jason",
"author_id": 45914,
"author_profile": "https://Stackoverflow.com/users/45914",
"pm_score": 6,
"selected": false,
"text": "<p>For O(1) random access, which can not be beaten.</p>\n"
},
{
"answer_id": 392426,
"author": "FlySwat",
"a... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48214/"
] | As I was programming, I haven't seen an instance where an array is better for storing information than another form thereof. I had indeed figured the added "features" in programming languages had improved upon this and by that replaced them. I see now that they aren't replaced but rather given new life, so to speak.
S... | Time to go back in time for a lesson. While we don't think about these things much in our fancy managed languages today, they are built on the same foundation, so let's look at how memory is managed in C.
Before I dive in, a quick explanation of what the term "**pointer**" means. A pointer is simply a variable that "p... |
392,416 | <p>When loaded a shared library is opened via the function <code>dlopen()</code>, is there a way for it to call functions in main program?</p>
| [
{
"answer_id": 392419,
"author": "hhafez",
"author_id": 42303,
"author_profile": "https://Stackoverflow.com/users/42303",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, If you provide your library a pointer to that function, I'm sure the library will be able to run/execute the funct... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46431/"
] | When loaded a shared library is opened via the function `dlopen()`, is there a way for it to call functions in main program? | Code of dlo.c (the lib):
```
#include <stdio.h>
// function is defined in main program
void callb(void);
void test(void) {
printf("here, in lib\n");
callb();
}
```
Compile with
```
gcc -shared -olibdlo.so dlo.c
```
Here the code of the main program (copied from dlopen manpage, and adjusted):
```
#incl... |
392,425 | <p>I have got a byte array of pixels in BGR order and I want to create an image out of it in C#. Can anyone offer code or advice?</p>
| [
{
"answer_id": 392445,
"author": "user21826",
"author_id": 21826,
"author_profile": "https://Stackoverflow.com/users/21826",
"pm_score": 1,
"selected": false,
"text": "<p>Something to the effect of (not-tested)</p>\n\n<pre><code>\n private Bitmap createImage(int width, int height,... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have got a byte array of pixels in BGR order and I want to create an image out of it in C#. Can anyone offer code or advice? | Something to the effect of (not-tested)
```
private Bitmap createImage(int width, int height, byte[] image)
{
int index = 0;
byte r, g, b;
Bitmap bmp = new Bitmap(width, height);
for (y as int = 0; y < height; y++)
{
... |
392,438 | <p>i'm relatively new to jquery and javascript and am trying to pass
a unique id (number) into a flickr search function (jquery.flickr-1.0-js) like so, (number is the variable where i'm storing the unique id)</p>
<pre><code><script type="text/javascript" src="javascripts/jquery.flickr-1.0.js"></script>
&... | [
{
"answer_id": 392459,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>Try adjusting your scripts as below:</p>\n\n<pre><code> ...\n jQuery('#gallery_flickr_'+number+'').html(\"... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48973/"
] | i'm relatively new to jquery and javascript and am trying to pass
a unique id (number) into a flickr search function (jquery.flickr-1.0-js) like so, (number is the variable where i'm storing the unique id)
```
<script type="text/javascript" src="javascripts/jquery.flickr-1.0.js"></script>
<script type="text/javascri... | Try adjusting your scripts as below:
```
...
jQuery('#gallery_flickr_'+number+'').html("").flickr({
api_key: "XXXXXXXXXXXXXXXXXXXXXXX",
per_page: 15,
search_text: $('input#flickr_search_'+number+'').val()
});
...
(functi... |
392,455 | <p>Suppose I have a Linked List I created myself. It has its own destructor, which frees the memory. This Linked List does not overload new or delete.</p>
<p>Now, I'm trying to create an array of said linked lists (open hashing, if I understand correctly). Then I allocate the necessary memory inside the constructor of... | [
{
"answer_id": 392457,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "<p>Yeah you are right. A plain </p>\n\n<pre><code>elements = new LinkedList[N];\n</code></pre>\n\n<p>is eno... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Suppose I have a Linked List I created myself. It has its own destructor, which frees the memory. This Linked List does not overload new or delete.
Now, I'm trying to create an array of said linked lists (open hashing, if I understand correctly). Then I allocate the necessary memory inside the constructor of this open... | Yeah you are right. A plain
```
elements = new LinkedList[N];
```
is enough to allocate them. You can then access them
```
elements[i]->push(....);
```
and delete them in your destructor using the way you showed:
```
delete[] elements;
```
The compiler will remember how many elements were allocated, and call... |
392,464 | <p>I'd like to do <code>base64</code> encoding and decoding, but I could not find any support from the iPhone <code>SDK</code>. How can I do <code>base64</code> encoding and decoding with or without a library?</p>
| [
{
"answer_id": 800976,
"author": "Alex Reynolds",
"author_id": 19410,
"author_profile": "https://Stackoverflow.com/users/19410",
"pm_score": 7,
"selected": false,
"text": "<p>This is a good use case for Objective C <a href=\"http://en.wikipedia.org/wiki/Objective-C#Categories\" rel=\"nor... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32096/"
] | I'd like to do `base64` encoding and decoding, but I could not find any support from the iPhone `SDK`. How can I do `base64` encoding and decoding with or without a library? | This is a good use case for Objective C [categories](http://en.wikipedia.org/wiki/Objective-C#Categories).
For Base64 encoding:
```
#import <Foundation/NSString.h>
@interface NSString (NSStringAdditions)
+ (NSString *) base64StringFromData:(NSData *)data length:(int)length;
@end
----------------------------------... |
392,539 | <p>How to download a file via web service ? And how the client application accept this?
I write down the code as below in the client app, it throws an exception "Access Denied"</p>
<pre><code>wsDownload.wsDownloadFile downFile = new wsDownload.wsDownloadFile();
byte[] file = downFile.DownloadFile(strFileName, "", "... | [
{
"answer_id": 392519,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 2,
"selected": false,
"text": "<p>If Google gives back API references for \"Initializable\", it seems to me like a valid name for an interface, even though i... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How to download a file via web service ? And how the client application accept this?
I write down the code as below in the client app, it throws an exception "Access Denied"
```
wsDownload.wsDownloadFile downFile = new wsDownload.wsDownloadFile();
byte[] file = downFile.DownloadFile(strFileName, "", "", "");
MemorySt... | Technical people create new words all the time. (see example below) But this isn't a case of creating a new word. This is a case of a "derivation". You have take a perfectly good word ("initialize") and added a perflecty good [derivative suffix](http://www.prefixsuffix.com/affixes.php) to it ("able"). The resulting wor... |
392,540 | <p>I'm currently trying to make a small application that performs different duties. Right now I have a console app pop up and ask what I want to do, but sometimes I would rather just launch it with something like MyApp.exe -printdocuments or some such thing. </p>
<p>Are there any tutorials out there that can show me a... | [
{
"answer_id": 392548,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": "<p>In C++, your <code>main()</code> function can have <code>argc</code> and <code>argv</code> parameters, which contain th... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49000/"
] | I'm currently trying to make a small application that performs different duties. Right now I have a console app pop up and ask what I want to do, but sometimes I would rather just launch it with something like MyApp.exe -printdocuments or some such thing.
Are there any tutorials out there that can show me a simple ex... | In C++, your `main()` function can have `argc` and `argv` parameters, which contain the arguments passed on the command line. The `argc` is the count of arguments (including the executable name itself), and `argv` is an array of pointers to null-terminated strings of length `argc`.
For example, this program prints its... |
392,550 | <p>I used pole display(E POS) in my POS c# application.I have two major problem in that,
1. I can't clear the display perfectly.
2. I can't set the cursor position.</p>
<pre><code> I used some dirty tricks to do these.But I am not satisfied with that code.The following code i used.
</code></pre>
<p>Code :-</p>
<... | [
{
"answer_id": 392548,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": "<p>In C++, your <code>main()</code> function can have <code>argc</code> and <code>argv</code> parameters, which contain th... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49001/"
] | I used pole display(E POS) in my POS c# application.I have two major problem in that,
1. I can't clear the display perfectly.
2. I can't set the cursor position.
```
I used some dirty tricks to do these.But I am not satisfied with that code.The following code i used.
```
Code :-
```
class PoleDisplay : SerialP... | In C++, your `main()` function can have `argc` and `argv` parameters, which contain the arguments passed on the command line. The `argc` is the count of arguments (including the executable name itself), and `argv` is an array of pointers to null-terminated strings of length `argc`.
For example, this program prints its... |
392,609 | <p>I'm using MySql 5.x and in my environment, I have a table with the name CALLS.</p>
<p>Table CALLS has a column status which takes an enum {inprogress, completed}.</p>
<p>I want reads/updates of the table to be row-locked, so:</p>
<pre><code>SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SET AUTOCOMMIT = 0;
SELECT ... | [
{
"answer_id": 392644,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 0,
"selected": false,
"text": "<p>What you've implemented there--in case you weren't familiar with it--is called <a href=\"http://www.agiledata.org/essays... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24457/"
] | I'm using MySql 5.x and in my environment, I have a table with the name CALLS.
Table CALLS has a column status which takes an enum {inprogress, completed}.
I want reads/updates of the table to be row-locked, so:
```
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SET AUTOCOMMIT = 0;
SELECT amount from CALLS where call... | Disclaimer: MySQL is generally full of surprises, so the following could be untrue.
What you are doing doesn't make any sense to me: You are committing after the SELECT, which should break the lock. So in my opinion, your code shouldn't really incur any significant overhead; but it doesn't give you any consistency imp... |
392,626 | <p>I had a Dataset with some data in it. When I tried to write this DataSet into a file, everything was OK. But When I tried to write it into a MemoryStream, the XML file declaration was lost.
The code looks like:</p>
<pre><code>DataSet dSet = new DataSet();
//load schema, fill data in
dSet.WriteXML("testFile.xml");
M... | [
{
"answer_id": 688487,
"author": "Kenneth Cochran",
"author_id": 71200,
"author_profile": "https://Stackoverflow.com/users/71200",
"pm_score": 3,
"selected": true,
"text": "<p>It wasn't dropped. Simply not included. Though it is highly recommend the xml declaration is not a required elem... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40029/"
] | I had a Dataset with some data in it. When I tried to write this DataSet into a file, everything was OK. But When I tried to write it into a MemoryStream, the XML file declaration was lost.
The code looks like:
```
DataSet dSet = new DataSet();
//load schema, fill data in
dSet.WriteXML("testFile.xml");
MemoryStream st... | It wasn't dropped. Simply not included. Though it is highly recommend the xml declaration is not a required element of the xml specification.
<http://msdn.microsoft.com/en-us/library/ms256048(VS.85).aspx>
You can use XmlWriter.WriteStartDocument to include the xml declaration in the stream like so:
```
MemoryStream ... |
392,630 | <p>one of my php page returns data like this:</p>
<pre><code><?php
//...
echo "json string";
?>
</code></pre>
<p>but someone else use file_get_contents() to get my data and use in other website.</p>
<p>can anybody tell me what can i do to prevent such thing happen. </p>
<p>i consider if i can get the requ... | [
{
"answer_id": 392640,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>You can use $_SERVER['REMOTE_ADDR'] to get the address of the client address. You can also check $_SERVER['HTTP_REFERER'] a... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | one of my php page returns data like this:
```
<?php
//...
echo "json string";
?>
```
but someone else use file\_get\_contents() to get my data and use in other website.
can anybody tell me what can i do to prevent such thing happen.
i consider if i can get the request's domain name to echo something else.but... | you can also use sessions. if somewhere in your application, before the user gets the json data, you start a session, then in this page where you are outputting json data, you can check for the session variable. this way only users that have passed the session generator page, can view your output.
suppose you have page... |
392,643 | <p>I would like to do the following:</p>
<pre><code>$find = "start (.*) end";
$replace = "foo \1 bar";
$var = "start middle end";
$var =~ s/$find/$replace/;
</code></pre>
<p>I would expect $var to contain "foo middle bar", but it does not work. Neither does:</p>
<pre><code>$repl... | [
{
"answer_id": 392649,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": false,
"text": "<p>Deparse tells us this is what is being executed: </p>\n\n<pre><code>$find = 'start (.*) end';\n$replace = \"foo \... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2133/"
] | I would like to do the following:
```
$find = "start (.*) end";
$replace = "foo \1 bar";
$var = "start middle end";
$var =~ s/$find/$replace/;
```
I would expect $var to contain "foo middle bar", but it does not work. Neither does:
```
$replace = 'foo \1 bar';
```
Somehow I am missing something regarding the esc... | On the replacement side, you must use $1, not \1.
And you can only do what you want by making replace an evalable expression that gives the result you want and telling s/// to eval it with the /ee modifier like so:
```
$find="start (.*) end";
$replace='"foo $1 bar"';
$var = "start middle end";
$var =~ s/$find/$repla... |
392,657 | <p>In borland delphi 7 and even in delphi 2007 everything worked, but in delphi 2009 it just returns the wrong hash!</p>
<p>I use wcrypt2 script (<a href="http://pastebin.com/m2f015cfd" rel="noreferrer">http://pastebin.com/m2f015cfd</a>)</p>
<p>Just have a look:</p>
<p>string : "123456"</p>
<p>hash:</p>
<p>Delphi ... | [
{
"answer_id": 392681,
"author": "Mihai Limbășan",
"author_id": 14444,
"author_profile": "https://Stackoverflow.com/users/14444",
"pm_score": 0,
"selected": false,
"text": "<p>Are you perchance casting a generic string (which in Delphi 2009 is a UnicodeString) to a PAnsiChar and passing ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In borland delphi 7 and even in delphi 2007 everything worked, but in delphi 2009 it just returns the wrong hash!
I use wcrypt2 script (<http://pastebin.com/m2f015cfd>)
Just have a look:
string : "123456"
hash:
Delphi 7 : "e10adc3949ba59abbe56e057f20f883e" - real hash.
Delphi 2007 : "e10adc3949ba59abbe56e057f2... | Your library is not Unicode aware. Just passing it an AnsiString won't be enough because it probably uses strings internally to store data.
You could try to update that library, wait for the author to update it, or just use the **MessageDigest\_5.pas** that ships with Delphi 2009. It is in the *source\Win32\soap\wsdli... |
392,668 | <p>I'm trying to model a basic scenario involving a Person and a Seat. A Person has a Status property: Sitting or Standing. A seat has a Seated property that specifies the Person that is currently sitting in it. Also, a Seat is <em>special</em> in that it only "accepts" certain people to sit in it. I know it sounds str... | [
{
"answer_id": 392674,
"author": "diclophis",
"author_id": 32678,
"author_profile": "https://Stackoverflow.com/users/32678",
"pm_score": 2,
"selected": false,
"text": "<p>Introduce a 3rd model... Seatings that has a reference to both the seat, and the person. Then you can create an insta... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49027/"
] | I'm trying to model a basic scenario involving a Person and a Seat. A Person has a Status property: Sitting or Standing. A seat has a Seated property that specifies the Person that is currently sitting in it. Also, a Seat is *special* in that it only "accepts" certain people to sit in it. I know it sounds strange for a... | Introduce a 3rd model... Seatings that has a reference to both the seat, and the person. Then you can create an instance of that model every time someone sits down, throw in some validations for preventing two people sitting in the same seat, and maybe even throw in some timeouts (if your sitting in a seat too long, yo... |
392,721 | <p>What's difference between <strong>shadowing</strong> and <strong>overriding</strong> a method in C#?</p>
| [
{
"answer_id": 392724,
"author": "Matthew Flaschen",
"author_id": 47773,
"author_profile": "https://Stackoverflow.com/users/47773",
"pm_score": 3,
"selected": false,
"text": "<p>I think the main difference is that with shadowing, you're essentially reusing the name, and just ignoring the... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35425/"
] | What's difference between **shadowing** and **overriding** a method in C#? | Well inheritance...
suppose you have this classes:
```
class A {
public int Foo(){ return 5;}
public virtual int Bar(){return 5;}
}
class B : A{
public new int Foo() { return 1;} //shadow
public override int Bar() {return 1;} //override
}
```
then when you call this:
```
A clA = new A();
B clB = ne... |
392,728 | <p>I have a function that returns a float from 0 to 255. I would like to make a gradient in red color from this, but I need a string in "#FFFFFF" format. Is there a function for that?</p>
| [
{
"answer_id": 392732,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": true,
"text": "<p>You could use:</p>\n\n<pre><code>\"#%02X0000\" % x\n</code></pre>\n"
},
{
"answer_id": 392976,
"author": "e... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25459/"
] | I have a function that returns a float from 0 to 255. I would like to make a gradient in red color from this, but I need a string in "#FFFFFF" format. Is there a function for that? | You could use:
```
"#%02X0000" % x
``` |
392,749 | <p>Code auto-generated by Xcode seems to have the opening brace on the same line by default:</p>
<pre><code>@interface Controller : NSObject {
}
</code></pre>
<p>I'd like the opening brace on a line of its own, like this:</p>
<pre><code>@interface Controller : NSObject
{
}
</code></pre>
<p>This applies in genera... | [
{
"answer_id": 393020,
"author": "Mike Shields",
"author_id": 29030,
"author_profile": "https://Stackoverflow.com/users/29030",
"pm_score": 3,
"selected": false,
"text": "<p>Read this: <a href=\"http://developer.apple.com/mac/library/documentation/DeveloperTools/Reference/XcodeUserDefaul... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2288585/"
] | Code auto-generated by Xcode seems to have the opening brace on the same line by default:
```
@interface Controller : NSObject {
}
```
I'd like the opening brace on a line of its own, like this:
```
@interface Controller : NSObject
{
}
```
This applies in general to any method / class auto-generated by Xcode. ... | For Xcode 3.x, you can use the following:
If you open up a terminal session and enter
`defaults write com.apple.Xcode XCCodeSenseFormattingOptions '{ "BlockSeparator" = "\n" ; }'`
it will start new blocks of code on a new line. Note that you will have to restart XCode if you have it opened in order for the new defa... |
392,775 | <p>How can I indicate syntax errors (e.g. an illegal sequence of tokens) in an eclipse editor plugin just like in the eclipse Java editor, i.e. by red wriggly underlines, a red marker on the scrollbar that you can jump to, and an explanatory message when you hover over either one?</p>
<p>I'm writing an eclipse editor ... | [
{
"answer_id": 393326,
"author": "Michael Rutherfurd",
"author_id": 33889,
"author_profile": "https://Stackoverflow.com/users/33889",
"pm_score": 4,
"selected": true,
"text": "<p>You should be using Markers. </p>\n\n<p>An example derived from \"The Java Developer's Guide to Eclipse\" fol... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16883/"
] | How can I indicate syntax errors (e.g. an illegal sequence of tokens) in an eclipse editor plugin just like in the eclipse Java editor, i.e. by red wriggly underlines, a red marker on the scrollbar that you can jump to, and an explanatory message when you hover over either one?
I'm writing an eclipse editor plugin for... | You should be using Markers.
An example derived from "The Java Developer's Guide to Eclipse" follows:
```
<extension point="org.eclipse.core.resources.markers"
id="snakesyntax"
name="Snake syntax error">
<super type="org.eclipse.core.resources.problemmarker" />
<super type="or... |
392,784 | <p>I have two completely different forms in one template. How to process them in one view? How can I distinguish which of the forms was submitted? How can I use prefix to acomplish that? Or maybe it's better to write separate views?<br /><br />
regards<br />
chriss</p>
| [
{
"answer_id": 392801,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 4,
"selected": true,
"text": "<p>Personally, I'd use one view to handle each form's POST.</p>\n\n<p>On the other hand, you could use a hidden input e... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36832/"
] | I have two completely different forms in one template. How to process them in one view? How can I distinguish which of the forms was submitted? How can I use prefix to acomplish that? Or maybe it's better to write separate views?
regards
chriss | Personally, I'd use one view to handle each form's POST.
On the other hand, you could use a hidden input element that indicate which form was used
```
<form action="/blog/" method="POST">
{{ blog_form.as_p }}
<input type="hidden" name="form-type" value"blog-form" /> <!-- set type -->
<input type="submit" ... |
392,789 | <p>I got into Perl years ago and always found it a fun and expressive language to work with.</p>
<p>I found that programming in Perl makes me quite productive thanks to its low overhead and the outstanding amount of ready-made solutions to common problems on CPAN.</p>
<p>If you're new to Perl, what got you into it?</... | [
{
"answer_id": 392869,
"author": "melaos",
"author_id": 38124,
"author_profile": "https://Stackoverflow.com/users/38124",
"pm_score": 2,
"selected": false,
"text": "<p>simple syntax, powerful scripting capabilities for win32 and unix systems, and totally powerful regex!</p>\n\n<p>I picku... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3811/"
] | I got into Perl years ago and always found it a fun and expressive language to work with.
I found that programming in Perl makes me quite productive thanks to its low overhead and the outstanding amount of ready-made solutions to common problems on CPAN.
If you're new to Perl, what got you into it? | With Perl (and the expressive power behind TMTOWTDI), programming becomes a creative task. I can write `if($expr) { $statement; }` if I plan on having many else statements, or I can write `$statement if $expr;` if that makes more sense (for example, I'm fond of writing:
```
sub doSomething {
my($toObject, $argumen... |
392,797 | <p>How do I add a badge to the Dock icon for my app using Cocoa? Is there any roughly "standardized" way to do this? </p>
<p>(I'm referring to the kind of badges that show up in Mail, iChat etc. to indicate the number of unread messages and the like.)</p>
<p>Cocoa Touch does provide one such method, but I haven't bee... | [
{
"answer_id": 392842,
"author": "wfarr",
"author_id": 2286,
"author_profile": "https://Stackoverflow.com/users/2286",
"pm_score": 4,
"selected": false,
"text": "<p>A quick google search turned up the <a href=\"http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/NSDockTile_Class/Ref... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2288585/"
] | How do I add a badge to the Dock icon for my app using Cocoa? Is there any roughly "standardized" way to do this?
(I'm referring to the kind of badges that show up in Mail, iChat etc. to indicate the number of unread messages and the like.)
Cocoa Touch does provide one such method, but I haven't been able to find an... | Use
```
[[[NSApplication sharedApplication] dockTile] setBadgeLabel:@"2234"];
```
This method, and the `NSDockTile` class, has been available since Leopard. |
392,806 | <p>The project currently I am working in requires a lot of searhing/filtering pages. For example I have a comlex search page to get Issues by data,category,unit,...</p>
<p>Issue Domain Class is complex and contains lots of value objects and child objects.</p>
<p>.I am wondering how people deal with Searching/Filterin... | [
{
"answer_id": 486442,
"author": "ssmith",
"author_id": 13729,
"author_profile": "https://Stackoverflow.com/users/13729",
"pm_score": 3,
"selected": true,
"text": "<p>I have a few suggestions, but of course the overall answer is \"it depends\".</p>\n\n<p>First, you should be using an ORM... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36474/"
] | The project currently I am working in requires a lot of searhing/filtering pages. For example I have a comlex search page to get Issues by data,category,unit,...
Issue Domain Class is complex and contains lots of value objects and child objects.
.I am wondering how people deal with Searching/Filtering/Reporting for U... | I have a few suggestions, but of course the overall answer is "it depends".
First, you should be using an ORM tool or you should have a very good reason not to be doing so.
Second, implementing Lazy Loading by hand is relatively simple so in the event that you're not going to use an ORM tool, you can simply create pr... |
392,818 | <p>I use this code to open refresh save and close excel file:</p>
<pre><code>Application excelFile = new Application();
Workbook theWorkbook = excelFile.Workbooks._Open(Environment.CurrentDirectory + "/WebGate", 0, false, 5, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, System... | [
{
"answer_id": 393047,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 2,
"selected": false,
"text": "<p>Eran, I am posting this based on what I understand of documentation.</p>\n\n<p>I assume you are using pivottables &... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I use this code to open refresh save and close excel file:
```
Application excelFile = new Application();
Workbook theWorkbook = excelFile.Workbooks._Open(Environment.CurrentDirectory + "/WebGate", 0, false, 5, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, System.Reflection.Mi... | Eran, I am posting this based on what I understand of documentation.
I assume you are using pivottables & it uses some kind of query.
Try using Workbook object's PivotTableCloseConnection & see if you can call Save inside it.
In Excel 2007, Application object has AfterCalculate event - which could also be of use.
... |
392,832 | <p>I am new to C# and .NET programming. I want to design an application that opens up with a small login screen and when user presses the "Login" button, my program should close the login form and pass to a new form. How can I achieve this simple process? </p>
<p>Thanks.</p>
| [
{
"answer_id": 392854,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 4,
"selected": true,
"text": "<p>This could be a solution;</p>\n\n<p>In LoginForm;</p>\n\n<pre><code>public bool IsLoggedIn { get; private set;}\npublic ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49057/"
] | I am new to C# and .NET programming. I want to design an application that opens up with a small login screen and when user presses the "Login" button, my program should close the login form and pass to a new form. How can I achieve this simple process?
Thanks. | This could be a solution;
In LoginForm;
```
public bool IsLoggedIn { get; private set;}
public void LoginButton_Click(object sender, EventArgs e)
{
IsLoggedIn = DoLogin();
if(IsLoggedIn)
{
this.Close()
}
else
{
DoSomethingElse();
}
}
```
In program.cs
```
static void Main()
{
Application.E... |
392,859 | <p>How to create the condition of stack overflow in GNU/linux?</p>
| [
{
"answer_id": 392865,
"author": "ceejayoz",
"author_id": 1902010,
"author_profile": "https://Stackoverflow.com/users/1902010",
"pm_score": 2,
"selected": false,
"text": "<p>There are <a href=\"http://en.wikipedia.org/wiki/Stack_overflow\" rel=\"nofollow noreferrer\">code samples in the ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How to create the condition of stack overflow in GNU/linux? | a recursive function with no way out should do the trick
pseudo-code, my c is a bit rusty
```
void stack_overflow()
{
stack_overflow();
}
``` |
392,864 | <p>I still have a problem with the splash screen. I don't want to use the property <code>SC.TopMost=true</code>.</p>
<p>Now my application scenario is as follows:</p>
<p><strong>in progeram.cs:</strong></p>
<pre><code>[STAThread]
static void Main()
{
new SplashScreen(_tempAL);// where _tempAL is an arrayList
... | [
{
"answer_id": 392904,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>Following across 2 threads is a bit confusing, but I'm going to take a stab and say this...</p>\n\n<p>I don't fully understa... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42782/"
] | I still have a problem with the splash screen. I don't want to use the property `SC.TopMost=true`.
Now my application scenario is as follows:
**in progeram.cs:**
```
[STAThread]
static void Main()
{
new SplashScreen(_tempAL);// where _tempAL is an arrayList
Application.Run(new Form1(_tempAL));
}
```
**in S... | Following across 2 threads is a bit confusing, but I'm going to take a stab and say this...
I don't fully understand your design here, but if the issue is that when you launch a second application the splash screen form turns white... It's most likely due to the fact that splash screen is busy executing all of that co... |
392,928 | <p>Some applications (or websites) compute a password's complexity as you type.</p>
<p>They typically display a red bar which turns orange, then green, then even greener as your password gets longer, and contains more classes of characters (e.g., lowercase, uppercase, punctuation, digits).</p>
<p><strong>How can I re... | [
{
"answer_id": 392934,
"author": "Jonas Oberschweiber",
"author_id": 1522,
"author_profile": "https://Stackoverflow.com/users/1522",
"pm_score": 2,
"selected": false,
"text": "<p>I would not simply set a flag when you see a digit, capital etc. but give points for them. Something like a s... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47341/"
] | Some applications (or websites) compute a password's complexity as you type.
They typically display a red bar which turns orange, then green, then even greener as your password gets longer, and contains more classes of characters (e.g., lowercase, uppercase, punctuation, digits).
**How can I reliably calculate the co... | Using something like cracklib is very good if you can afford the time of checking against all of the potential rules. If you just want something quick -- say for a javascript-based strength meter -- then consider estimating the number of potential guesses that would be required for a brute force attack. For every chara... |
392,931 | <p>I have a few procedures, for simplicity sake, look like the following:</p>
<pre><code>public string FetchValueAsString(string key)
public int FetchValueAsInteger(string key)
public bool FetchValueAsBoolean(string key)
public DateTime FetchValueAsDateTime(string key)
</code></pre>
<p>I know I could just have one me... | [
{
"answer_id": 392948,
"author": "Corin Blaikie",
"author_id": 1736,
"author_profile": "https://Stackoverflow.com/users/1736",
"pm_score": 5,
"selected": true,
"text": "<pre><code>public static T FetchValue<T>(string key)\n{\n string value; \n // logic to set value here \n ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] | I have a few procedures, for simplicity sake, look like the following:
```
public string FetchValueAsString(string key)
public int FetchValueAsInteger(string key)
public bool FetchValueAsBoolean(string key)
public DateTime FetchValueAsDateTime(string key)
```
I know I could just have one method that returns and obje... | ```
public static T FetchValue<T>(string key)
{
string value;
// logic to set value here
// ...
return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
}
``` |
392,932 | <p>I've always wondered how to write the <strong><code>"A ? B : C"</code></strong> syntax in a C++ compatible language.</p>
<p>I think it works something like: <em>(Pseudo code)</em></p>
<pre><code>If A > B
C = A
Else
C = B
</code></pre>
<p><em>Will any veteran C++ programmer please help me out?</em></p>
| [
{
"answer_id": 392935,
"author": "edef",
"author_id": 49047,
"author_profile": "https://Stackoverflow.com/users/49047",
"pm_score": 2,
"selected": false,
"text": "<p>I assume you mean stuff like a = b ? c : d, where b is the condition, c is the value when b is true, and d is the value wh... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] | I've always wondered how to write the **`"A ? B : C"`** syntax in a C++ compatible language.
I think it works something like: *(Pseudo code)*
```
If A > B
C = A
Else
C = B
```
*Will any veteran C++ programmer please help me out?* | It works like this:
```
(condition) ? true-clause : false-clause
```
It's most commonly used in assignment operations, although it has other uses as well. The ternary operator `?` is a way of shortening an if-else clause, and is also called an immediate-if statement in other languages (`IIf(condition,true-clause,fal... |
392,960 | <p>How can I get my device name (using WinCE) in C# code ?</p>
<p>It gives me only "WindowsCE" how can i get the type on name of the device ? (ex. symbol or datalogic or mio...)</p>
| [
{
"answer_id": 392968,
"author": "edef",
"author_id": 49047,
"author_profile": "https://Stackoverflow.com/users/49047",
"pm_score": 2,
"selected": false,
"text": "<p>The registry value HKEY_LOCAL_MACHINE\\Ident\\Name contains the device name. Use the registry library to read it.</p>\n"
... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43907/"
] | How can I get my device name (using WinCE) in C# code ?
It gives me only "WindowsCE" how can i get the type on name of the device ? (ex. symbol or datalogic or mio...) | I was able to retrieve the device name on Windows CE 5 using
```
System.Net.Dns.GetHostName()
```
Hope this helps. Cheers. |
392,980 | <p>My team at work is considering to use a framework for developing web sites and applications. Some of the seniors are convinced we should use the Zend Framework because it is easier to pick-and-choose the features so the framework we will be light-weight. </p>
<p>I'm afraid however that they are only looking at the ... | [
{
"answer_id": 393022,
"author": "Colonel Sponsz",
"author_id": 11651,
"author_profile": "https://Stackoverflow.com/users/11651",
"pm_score": 1,
"selected": false,
"text": "<p>Symfony is really easy to use and can get a fully functional site with sessions, caching, unit and functional te... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My team at work is considering to use a framework for developing web sites and applications. Some of the seniors are convinced we should use the Zend Framework because it is easier to pick-and-choose the features so the framework we will be light-weight.
I'm afraid however that they are only looking at the technical ... | And why not both? I have been using symfony since 2006, have been a real Doctrine fan for one year, and for a few months, we've reach many steps on the productivity ladder by integrating Zend components directly onto our symfony applications.
The real strength of symfony lies on the decoupling of everything, and the e... |
392,981 | <p>How can I convert string to double in C++?
I want a function that returns 0 when the string is not numerical.</p>
| [
{
"answer_id": 392984,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 0,
"selected": false,
"text": "<p>I think <a href=\"http://www.cplusplus.com/reference/clibrary/cstdlib/atof.html\" rel=\"nofollow noreferrer\">atof</a> ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/392981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I convert string to double in C++?
I want a function that returns 0 when the string is not numerical. | Most simple way is to use [boost::lexical\_cast](http://www.boost.org/doc/libs/1_47_0/libs/conversion/lexical_cast.htm):
```
double value;
try
{
value = boost::lexical_cast<double>(my_string);
}
catch (boost::bad_lexical_cast const&)
{
value = 0;
}
``` |
393,017 | <p>Is there anything like <code>Collections.max</code> which finds the maximal value in an array for regular arrays in the standard java runtime library?</p>
| [
{
"answer_id": 393029,
"author": "Matthew Flaschen",
"author_id": 47773,
"author_profile": "https://Stackoverflow.com/users/47773",
"pm_score": -1,
"selected": false,
"text": "<p>As far as I know, no. You could look at asList (<a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/util/... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there anything like `Collections.max` which finds the maximal value in an array for regular arrays in the standard java runtime library? | No, there is no Arrays.max or a lookalike, at least in Java 6.
If you look at the signature and implementation of Collections.max, it makes quite heavy use of parameterized types. In Java, generic arrays are problematic to say the least, so maybe therefore it is not a good idea to provide a generic max implementation ... |
393,041 | <p>I want to make some variables I generate in b available in c:</p>
<pre><code>a : b c { ...some code...}
</code></pre>
<p>A simple example:</p>
<pre><code>b : X { int result = 0; }
| Y { int result = 1; }
</code></pre>
<p>so I can, later on in c say:</p>
<pre><code>c : D { printf(result + 1); }
| ... | [
{
"answer_id": 393048,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 2,
"selected": true,
"text": "<p><code>result</code> should be a global variable. You can do this by including</p>\n\n<pre><code>%{\n int result;... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] | I want to make some variables I generate in b available in c:
```
a : b c { ...some code...}
```
A simple example:
```
b : X { int result = 0; }
| Y { int result = 1; }
```
so I can, later on in c say:
```
c : D { printf(result + 1); }
| E { printf(result + 2); }
```
Is there any chance to do... | `result` should be a global variable. You can do this by including
```
%{
int result;
%}
```
at the top of your YACC file. Of course, you should also replace `int result = 0` and `int result = 1` with `result = 0` and `result = 1` respectively. |
393,053 | <p>Python provides a nice method for getting length of an eager iterable, <code>len(x)</code> that is. But I couldn't find anything similar for lazy iterables represented by generator comprehensions and functions. Of course, it is not hard to write something like:</p>
<pre><code>def iterlen(x):
n = 0
try:
whil... | [
{
"answer_id": 393059,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 6,
"selected": true,
"text": "<p>There isn't one because you can't do it in the general case - what if you have a lazy infinite generator? For exa... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Python provides a nice method for getting length of an eager iterable, `len(x)` that is. But I couldn't find anything similar for lazy iterables represented by generator comprehensions and functions. Of course, it is not hard to write something like:
```
def iterlen(x):
n = 0
try:
while True:
next(x)
... | There isn't one because you can't do it in the general case - what if you have a lazy infinite generator? For example:
```
def fib():
a, b = 0, 1
while True:
a, b = b, a + b
yield a
```
This never terminates but will generate the Fibonacci numbers. You can get as many Fibonacci numbers as you... |
393,061 | <p>How do I create my own primitive? For example an integer that has a range of to 1-10.</p>
<p>EDIT: This came from a task on Rosetta Code. </p>
<blockquote>
<p>Defining Primitive Data Types: Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value o... | [
{
"answer_id": 393064,
"author": "Jonathan Allen",
"author_id": 5274,
"author_profile": "https://Stackoverflow.com/users/5274",
"pm_score": 4,
"selected": true,
"text": "<pre><code>Structure LimitedInt\n Implements IComparable(Of LimitedInt)\n Implements IEquatable(Of LimitedInt)\n\n ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5274/"
] | How do I create my own primitive? For example an integer that has a range of to 1-10.
EDIT: This came from a task on Rosetta Code.
>
> Defining Primitive Data Types: Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10.
>
>
>
I added it ... | ```
Structure LimitedInt
Implements IComparable(Of LimitedInt)
Implements IEquatable(Of LimitedInt)
Private m_Value As Integer 'treat the default, 0 as being really 1'
Public ReadOnly Property Value() As Integer
Get
Return If(m_Value = 0, 1, m_Value)
End Get
End Property
Public Sub New(ByVal v... |
393,104 | <p>Is there a way to execute code after each Terminal?</p>
<p>So that something like this is possible:</p>
<pre><code>a : B { code } C { some code }
</code></pre>
<p>Any help would really be appreciated!</p>
| [
{
"answer_id": 393116,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 2,
"selected": true,
"text": "<p>The example you gave should work as is.</p>\n"
},
{
"answer_id": 393120,
"author": "Chris",
"author... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] | Is there a way to execute code after each Terminal?
So that something like this is possible:
```
a : B { code } C { some code }
```
Any help would really be appreciated! | The example you gave should work as is. |
393,110 | <p>I'm trying to add a CSS class to the Control that will get the focus, once a page is rendered. While the SetFocus() method of the Page class lets me set the Control, there is no corresponding GetFocus() method.</p>
<p>According to the .Net sources, the information is stored in the private member _focusedControl of ... | [
{
"answer_id": 393125,
"author": "Jason",
"author_id": 10639,
"author_profile": "https://Stackoverflow.com/users/10639",
"pm_score": 1,
"selected": false,
"text": "<p>The control with focus may have changed between post-backs, which is why I don't think you can find it easily. It is pro... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18877/"
] | I'm trying to add a CSS class to the Control that will get the focus, once a page is rendered. While the SetFocus() method of the Page class lets me set the Control, there is no corresponding GetFocus() method.
According to the .Net sources, the information is stored in the private member \_focusedControl of the Page ... | If you are looking for a css solution for highlighting the focused element I believe you can use the ':focus' selector. I haven't tried this, but I believe this is a valid selector. You would use it like so in your css file:
```
:focus{ background-color: yellow;}
``` |
393,121 | <p>I have a file containing several lines similar to:</p>
<pre><code>Name: Peter
Address: St. Serrano número 12, España
Country: Spain
</code></pre>
<p>And I need to extract the address using a regular expression, taking into account that it can contain dots, special characters (ñ, ç), áéíóú...</p>
<p>The current co... | [
{
"answer_id": 393131,
"author": "cnu",
"author_id": 1448,
"author_profile": "https://Stackoverflow.com/users/1448",
"pm_score": 0,
"selected": false,
"text": "<p>Not a Java person, but wouldn't a <code>\"Address: (.*)$\"</code> work? </p>\n\n<p>Edit: Without the Pattern.MULTILINE | Patt... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] | I have a file containing several lines similar to:
```
Name: Peter
Address: St. Serrano número 12, España
Country: Spain
```
And I need to extract the address using a regular expression, taking into account that it can contain dots, special characters (ñ, ç), áéíóú...
The current code works, but it looks quite ugly... | I don't know Java's regex objects that well, but something like this pattern will do it:
```
^Address:\s*((?:(?!^\w+:).)+)$
```
assuming multiline and dotall modes are on.
This will match any line starting with Address, followed by anything until a newline character and a single word followed by a colon.
If you kn... |
393,151 | <p>What's the easiest way to create an array of structs in Cocoa?</p>
| [
{
"answer_id": 393181,
"author": "Rich Catalano",
"author_id": 4103,
"author_profile": "https://Stackoverflow.com/users/4103",
"pm_score": 4,
"selected": false,
"text": "<p>If you're okay with a regular old C array:</p>\n\n<pre><code>struct foo{\n int bar;\n};\n\nint main (int argc, c... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] | What's the easiest way to create an array of structs in Cocoa? | If you want to use an NSArray you'll need to box up your structs. You can use the NSValue class to encode them.
Something like this to encode:
```
struct foo {
int bar;
};
struct foo foobar;
foobar.bar = 3;
NSValue *boxedFoobar = [NSValue valueWithBytes:&foobar objCType:@encode(struct foo)];
```
And then to ge... |
393,166 | <p>I use Javascript to click a link in the webbrowser control. But I don't want to hear IE's "click" sound. </p>
<p>Is there any way to do this?</p>
<p>P.S. </p>
<ul>
<li>I don't want to change system settings.</li>
<li>I've seen this one (<a href="https://stackoverflow.com/q/10456">HowTo Disable WebBrowser 'Cli... | [
{
"answer_id": 393178,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "<p>As noted by the comments, and the answer by <a href=\"https://stackoverflow.com/users/33682/james-crowley\">@James... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40322/"
] | I use Javascript to click a link in the webbrowser control. But I don't want to hear IE's "click" sound.
Is there any way to do this?
P.S.
* I don't want to change system settings.
* I've seen this one ([HowTo Disable WebBrowser 'Click Sound' in your app only](https://stackoverflow.com/q/10456)) but `Document.Writ... | For IE7 and above, you can use this:
```
int feature = FEATURE_DISABLE_NAVIGATION_SOUNDS;
CoInternetSetFeatureEnabled(feature, SET_FEATURE_ON_PROCESS, true);
```
using the following DLL imports
```
private const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21;
private const int SET_FEATURE_ON_THREAD = 0x00000001;
privat... |
393,176 | <p>The (command line) interface I have in mind is like so:</p>
<pre><code>watching FILE+ do COMMAND [ARGS] (and COMMAND [ARGS])*
</code></pre>
<p>Where any occurrence of "<code>{}</code>" in <code>COMMAND</code> is replaced with the name of the file that changed. And note that "<code>do</code>" and "<code>and</code>... | [
{
"answer_id": 393177,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 3,
"selected": true,
"text": "<pre><code>#!/usr/bin/perl\n# Run some commands whenever any of a set of files changes (see USAGE below).\n# Example:\n# ./wa... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | The (command line) interface I have in mind is like so:
```
watching FILE+ do COMMAND [ARGS] (and COMMAND [ARGS])*
```
Where any occurrence of "`{}`" in `COMMAND` is replaced with the name of the file that changed. And note that "`do`" and "`and`" are keywords.
For example:
```
> watching foo.txt bar.txt do scp {}... | ```
#!/usr/bin/perl
# Run some commands whenever any of a set of files changes (see USAGE below).
# Example:
# ./watching.pl foo.txt bar.txt do scp foo.txt remote.com:. and cat bar.txt
# To only do something to the file that changed, refer to it as {}.
$| = 1; # autoflush
my $p = position("do", @ARGV); # position of... |
393,204 | <p>I have 2 classes, main and extended. I need to use main vars in extended class.</p>
<pre><code><?php
class Main {
public $vars = array();
}
$main = new Main;
$main->vars['key'] = 'value';
class Extended extends Main { }
$other = new Extended;
var_dump($other->vars);
?>
</code></pre>
<p>Who I ca... | [
{
"answer_id": 393207,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 3,
"selected": true,
"text": "<p><strong>EDIT</strong>: This can be solved much better with <em>Inversion of Control</em> (IoC) and <em>Dependency Injection<... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49114/"
] | I have 2 classes, main and extended. I need to use main vars in extended class.
```
<?php
class Main {
public $vars = array();
}
$main = new Main;
$main->vars['key'] = 'value';
class Extended extends Main { }
$other = new Extended;
var_dump($other->vars);
?>
```
Who I can do it?
No valid for example:
```
<... | **EDIT**: This can be solved much better with *Inversion of Control* (IoC) and *Dependency Injection* (DI). If you use your own framework or one without *Dependency Injection Container* try [League/Container](http://container.thephpleague.com/)
Answer below left as history of foolish answers.
---
The correct way I ... |
393,208 | <p>When I'm writing C - code I solely use an editor and gcc. I was wondering if anyone could suggest a good and simple tool that will find unused variables, function declarations and possibly make some optimisations.</p>
<p>Does anybody know a good tool?</p>
| [
{
"answer_id": 393216,
"author": "Dan Fego",
"author_id": 34426,
"author_profile": "https://Stackoverflow.com/users/34426",
"pm_score": 3,
"selected": false,
"text": "<p>If you run gcc with -Wall, it'll catch some of the things you mention, such as unused variables (and perhaps unused fu... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] | When I'm writing C - code I solely use an editor and gcc. I was wondering if anyone could suggest a good and simple tool that will find unused variables, function declarations and possibly make some optimisations.
Does anybody know a good tool? | As Dan Fego pointed out, GCC can catch unused variables and unused static functions. It won't normally find unused extern functions as it normally works one source file at a time.
GCC (v4.3.2) has hundreds if not thousands of options. One that might help is '`--combine`' to combine source files (as long as you're not ... |
393,212 | <p>It would seem natural to me that HTML would support this:</p>
<pre><code><div id="comment1">
<div id="helpText">...</div>
</div>
<div id="comment2">
<div id="helpText">...</div>
</div>
<div id="comment3">
<div id="helpText">...</div>
&l... | [
{
"answer_id": 393217,
"author": "stesch",
"author_id": 41860,
"author_profile": "https://Stackoverflow.com/users/41860",
"pm_score": 1,
"selected": false,
"text": "<p>Use classes.</p>\n"
},
{
"answer_id": 393218,
"author": "strager",
"author_id": 39992,
"author_profi... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | It would seem natural to me that HTML would support this:
```
<div id="comment1">
<div id="helpText">...</div>
</div>
<div id="comment2">
<div id="helpText">...</div>
</div>
<div id="comment3">
<div id="helpText">...</div>
</div>
#comment1#helpText
#comment2#helpText
#comment3#helpText
```
But since H... | Use `class`.
An `id` identifies that element and that element alone. It's like a pointer to an object in C++. Elements without an `id` are like objects without named (?) pointers to them.
`Class`es are like attributes. Elements may have zero or more of any combination of `class`es. They give you what you want.
```
/... |
393,234 | <p>Does anybody have a good Ruby script for finding books (or other products) on Amazon using their API?</p>
| [
{
"answer_id": 393246,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "<p>I suppose that kind of script would have to use <a href=\"http://www.caliban.org/ruby/ruby-aws/\" rel=\"noreferrer\">Ruby/AW... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6805/"
] | Does anybody have a good Ruby script for finding books (or other products) on Amazon using their API? | I've been using [Amazon/ECS](http://www.pluitsolutions.com/projects/amazon-ecs) with great success. One important point is that it's not GPLed (whereas Ruby/AWS seems to be), so if it's important in your case, take care.
Here is a sample:
```
require 'amazon/ecs'
# default options; will be camelized and converted
#... |
393,241 | <p>I am continue to build two simple processes throwing class objects one to another (see my previous post) through simple (anonymous) pipes. Now I revealed for myself boost::serialization (thanks answered people) and have tried to make some class be serialized through ::WriteFile::ReadFile. So - what I am doing wrong?... | [
{
"answer_id": 428422,
"author": "Tony",
"author_id": 34101,
"author_profile": "https://Stackoverflow.com/users/34101",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming you're passing a correct value for dwRead, I think the problem is that the stream hasn't been flushed. Make sure ... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7003/"
] | I am continue to build two simple processes throwing class objects one to another (see my previous post) through simple (anonymous) pipes. Now I revealed for myself boost::serialization (thanks answered people) and have tried to make some class be serialized through ::WriteFile::ReadFile. So - what I am doing wrong?
-... | I think the problem here is that you're trying pass a pointer the the archive object in the WriteFile function. What you should do instead is provide a pointer to serialized data.
```
std::stringstream ss;
boost::archive::binary_oarchive oa(ss);
oa << tc;
::WriteFile(hPipe, ss.str().data(), ss.str().data().size(), &dw... |
393,252 | <p>Here's what I've been trying to do, in a nutshell:</p>
<pre><code>class example <T extends Number>
{
private int function(T number)
{
int x = (int) number;
...
}
...
}
</code></pre>
<p>Basically, I'm trying to make it so that T is a number so I can convert it to an int inside ... | [
{
"answer_id": 393257,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 1,
"selected": false,
"text": "<p>Use</p>\n\n<pre><code>x=number.intValue();\n</code></pre>\n"
},
{
"answer_id": 393258,
"author": "VonC",... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Here's what I've been trying to do, in a nutshell:
```
class example <T extends Number>
{
private int function(T number)
{
int x = (int) number;
...
}
...
}
```
Basically, I'm trying to make it so that T is a number so I can convert it to an int inside that function. The problem is th... | Considering that the abstract class `Number` is the superclass of classes
\* `BigDecimal`, `BigInteger`,
\* `Byte`, `Double`, `Float`,
\* `Integer`, `Long`, and `Short`...
if you want to have an int representation, you should use the `.intValue()` function.
If that is what you want to do. |
393,276 | <p>I'm trying to implement a socket with a recv timeout of 1 Second: </p>
<pre><code>int sockfd;
struct sockaddr_in self;
struct sockaddr_in client_addr;
int addrlen=sizeof(client_addr);
ssize_t nBytes;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
self.sin_family = AF_INET;
self.sin_port = htons(PORT);
self.sin_addr.s_... | [
{
"answer_id": 393285,
"author": "Joao da Silva",
"author_id": 46329,
"author_profile": "https://Stackoverflow.com/users/46329",
"pm_score": 0,
"selected": false,
"text": "<p>Try using select() before calling recv() or accept().</p>\n\n<p>select() takes an array of file descriptors (incl... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to implement a socket with a recv timeout of 1 Second:
```
int sockfd;
struct sockaddr_in self;
struct sockaddr_in client_addr;
int addrlen=sizeof(client_addr);
ssize_t nBytes;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
self.sin_family = AF_INET;
self.sin_port = htons(PORT);
self.sin_addr.s_addr = INADDR_... | Which socket do you want to have the one-second timeout on? The one accepting connections, or the one established by `accept()`?
I'd assume the latter - so try setting the receive timeout on `clientfd` AFTER the `accept()` returns. You can also get to where you need to be using `select()`, but you shouldn't need to. |
393,286 | <p>This is what I'm trying to do:</p>
<pre><code>import java.lang.reflect.*;
class exampleOuter <T extends Number>
{
private exampleInner<T>[] elements;
public exampleOuter(Class<T> type, int size)
{
elements = (exampleInner<T>[]) Array.newInstance(type, size);
}
}
</c... | [
{
"answer_id": 393292,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 0,
"selected": false,
"text": "<p>You are creating, for some specific <code>T</code>, an object of type <code>T[]</code> and assigning it to... | 2008/12/25 | [
"https://Stackoverflow.com/questions/393286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This is what I'm trying to do:
```
import java.lang.reflect.*;
class exampleOuter <T extends Number>
{
private exampleInner<T>[] elements;
public exampleOuter(Class<T> type, int size)
{
elements = (exampleInner<T>[]) Array.newInstance(type, size);
}
}
```
I was told that if I wanted to crea... | This is the solution I've come up with:
```
public exampleOuter(Class<T> type, int size)
{
innerClass<T> aux = new innerClass<T>();
elements = (exampleInner<T>[]) Array.newInstance(aux.getClass(), size);
}
```
I thought this would also work:
```
elements = (exampleInner<T>[]) Array.newInstance(innerClass<T... |
393,306 | <p>I am just getting started with NHibernate (for the 15th time it would seem) and am having the following problem.</p>
<p>The following table:</p>
<pre><code>Table Facility
Column FACILITY_ID integer
Column NAME varchar2(50)
Column MONTH varchar2(5)
</code></pre>
<p>For whatever reason, month is a string instead of... | [
{
"answer_id": 393393,
"author": "gcores",
"author_id": 40256,
"author_profile": "https://Stackoverflow.com/users/40256",
"pm_score": 1,
"selected": false,
"text": "<p>I think the best solution may be to use a <a href=\"http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/m... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I am just getting started with NHibernate (for the 15th time it would seem) and am having the following problem.
The following table:
```
Table Facility
Column FACILITY_ID integer
Column NAME varchar2(50)
Column MONTH varchar2(5)
```
For whatever reason, month is a string instead of a native Date type and looks lik... | I think the best solution may be to use a [custom value type](http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mapping-types-custom). |
393,316 | <p>Good evening; I am writing a bit of code that solves the following equation. </p>
<p>X is size of device
Y is quantity of device
A is the denominator
Z is the total diversified value</p>
<p>(X * Y)/A = Z</p>
<p>Here is the part I don't know how to accomplish. The value of A is found by the amount of Y. If Y is be... | [
{
"answer_id": 393320,
"author": "Jules",
"author_id": 40078,
"author_profile": "https://Stackoverflow.com/users/40078",
"pm_score": 1,
"selected": false,
"text": "<p>You can use if and the comparison operators (<=). Homework?</p>\n\n<p>What do you mean by \"and so on\"? If the cases ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45151/"
] | Good evening; I am writing a bit of code that solves the following equation.
X is size of device
Y is quantity of device
A is the denominator
Z is the total diversified value
(X \* Y)/A = Z
Here is the part I don't know how to accomplish. The value of A is found by the amount of Y. If Y is between 3 and 6 than A = ... | There are 3 approaches to this, IMO:
1) Formula calculation. Thus, you want to know what A is given Y which if you have enough data, e.g. taking your .7 for 3<=Y<6, .6 for 6
```
A = .8-(Y/3)/10.0;
```
You may need to use a cast or truncate function on the Y/3 part if Y isn't a multiple of 3, or you could do this to... |
393,322 | <p>I do most of programming work on the Windows terminals in my university. However, my computer is a Mac and, for some reason, the javac command throws up an error when I use UserInput methods. Is there anything to install or an alternative command to use to make this compile properly?</p>
| [
{
"answer_id": 393320,
"author": "Jules",
"author_id": 40078,
"author_profile": "https://Stackoverflow.com/users/40078",
"pm_score": 1,
"selected": false,
"text": "<p>You can use if and the comparison operators (<=). Homework?</p>\n\n<p>What do you mean by \"and so on\"? If the cases ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49128/"
] | I do most of programming work on the Windows terminals in my university. However, my computer is a Mac and, for some reason, the javac command throws up an error when I use UserInput methods. Is there anything to install or an alternative command to use to make this compile properly? | There are 3 approaches to this, IMO:
1) Formula calculation. Thus, you want to know what A is given Y which if you have enough data, e.g. taking your .7 for 3<=Y<6, .6 for 6
```
A = .8-(Y/3)/10.0;
```
You may need to use a cast or truncate function on the Y/3 part if Y isn't a multiple of 3, or you could do this to... |
393,346 | <p>In the Fibonacci sequence, I have seen conventional implementations which recursively call the same method twice:</p>
<pre><code>public void fibonacci(int i)
{
fibonacci(1) + fibonacci(2);
}
</code></pre>
<p>Now this method is not the exact copy of what I have seen or the right way of solving the problem, but I've... | [
{
"answer_id": 393348,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 3,
"selected": false,
"text": "<p>No, they are called one after another. No additional threads are made unless you explicitly ask for it (with System.Threa... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | In the Fibonacci sequence, I have seen conventional implementations which recursively call the same method twice:
```
public void fibonacci(int i)
{
fibonacci(1) + fibonacci(2);
}
```
Now this method is not the exact copy of what I have seen or the right way of solving the problem, but I've seen the two methods adde... | This is one of those times when it's useful to think about the way the computer does it.
Let's start with the function. I'm going to write it in Python flavored pseudocode because I want you to get away from thinking about the LANGUAGE for a second.
```
def fib(n):
if n == 0: return 0
if n == 1: return 1
... |
393,363 | <p>I have some text with the following structure:</p>
<pre><code>Round 1
some multiline text ...
Round 2
some multiline text ...
...
Round N
some multiline text ...
</code></pre>
<p>I'd like to match rounds with their multiline text.</p>
<p>None of the expressions produces correct result:</p>
<p>(Round\s\d+)(... | [
{
"answer_id": 393369,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 1,
"selected": false,
"text": "<p>The dot (<code>.</code>) character matches all characters <strong>except</strong> newlines by default. In many language... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have some text with the following structure:
```
Round 1
some multiline text ...
Round 2
some multiline text ...
...
Round N
some multiline text ...
```
I'd like to match rounds with their multiline text.
None of the expressions produces correct result:
(Round\s\d+)((?!Round).\*?)
(Round\s\d+)(.\*?)
Coul... | The dot (`.`) character matches all characters **except** newlines by default. In many languages you can use the `s` modifier to make the dot match **all** characters, including newlines. It should look something like this:
```
/(Round\s\d+)(.*?)(Round\s\d+|$)/s
```
(Not 100% sure if this regex will work, I'm just s... |
393,366 | <p>I created a Linked List, with insert, search and remove functions. I also created a iterator for it. Now, suppose I do this:</p>
<pre><code>myList<Integer> test = new myList();
test.insert(30);
test.insert(20);
test.insert(10);
myList.iterator it = test.search(20);
if(it.hasNext())
System.out.println(it.n... | [
{
"answer_id": 393374,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 3,
"selected": true,
"text": "<p>You don't want the != operator for this. It comapres references. You want the <code>.equals()</code> method:</p>\n\n<pr... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I created a Linked List, with insert, search and remove functions. I also created a iterator for it. Now, suppose I do this:
```
myList<Integer> test = new myList();
test.insert(30);
test.insert(20);
test.insert(10);
myList.iterator it = test.search(20);
if(it.hasNext())
System.out.println(it.next());
```
And vo... | You don't want the != operator for this. It comapres references. You want the `.equals()` method:
```
public iterator search(T data)
{
no<T> temp = first;
while (!data.equals(temp.data)) {
temp = temp.next;
}
return (new iterator(temp));
}
```
Also, watch out for [auto-boxing](http://java.sun... |
393,376 | <p>Okay so I've read the documentation, and I'm not quite sure what the arguments being passed are. I'm looking at the the listed example request:</p>
<p><code>$facebook->api_client->profile_setFBML(NULL, 128009, 'profile', NULL, 'mobile_profile', 'profile_main');</code></p>
<p>and thinking, where are they getting th... | [
{
"answer_id": 393382,
"author": "Toby Hede",
"author_id": 14971,
"author_profile": "https://Stackoverflow.com/users/14971",
"pm_score": 3,
"selected": true,
"text": "<p>This applies to the PHP library, other libraries may have their own syntax.</p>\n\n<pre><code>$facebook->api_client... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | Okay so I've read the documentation, and I'm not quite sure what the arguments being passed are. I'm looking at the the listed example request:
`$facebook->api_client->profile_setFBML(NULL, 128009, 'profile', NULL, 'mobile_profile', 'profile_main');`
and thinking, where are they getting these arguments and what do th... | This applies to the PHP library, other libraries may have their own syntax.
```
$facebook->api_client->profile_setFBML(session_key, uid, 'profile', 'profile_action', 'mobile_profile', 'profile_main');
```
**session\_key** - The session key of the user whose FBML you are setting. It is required for Web applications o... |
393,378 | <p>I have a servlet S which handles callbacks from a 3rd party site. </p>
<p>The callback invocations happen in a specific order. Thus, I need to queue them. </p>
<p>I propose to use an in-memory queue like </p>
<pre><code>java.util.ConcurrentLinkedQueue
</code></pre>
<p>So the logic looks like this:</p>
<ul>
<li>... | [
{
"answer_id": 393384,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>Remember that while your servlets are in seperate threads, they're in the same VM instance, so they're living in... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24457/"
] | I have a servlet S which handles callbacks from a 3rd party site.
The callback invocations happen in a specific order. Thus, I need to queue them.
I propose to use an in-memory queue like
```
java.util.ConcurrentLinkedQueue
```
So the logic looks like this:
* Servlet S receives a callback & queues the received... | This isn't the sort of thing a servlet container is for. You really need a more full-blown J2EE application server if you're going to use a standards-based approach. What you're going to have are hacks otherwise but they might be sufficient for your task.
What I would probably try is creating a DaemonServlet. This is ... |
393,381 | <p>I'm upsizing an existing MS Access backend to SQL Server 2008 and, because we want to use <a href="http://msdn.microsoft.com/en-us/library/ms151329.aspx" rel="nofollow noreferrer">SQL Server Merge replication</a>, I'll have to change all current primary keys (currently standard autoincrement integers) to GUID.</p>
... | [
{
"answer_id": 393447,
"author": "Chris",
"author_id": 49145,
"author_profile": "https://Stackoverflow.com/users/49145",
"pm_score": 1,
"selected": false,
"text": "<p>This may be slightly off-topic. However, you do not HAVE to use GUIDs to do merge replication. You can still use your aut... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3811/"
] | I'm upsizing an existing MS Access backend to SQL Server 2008 and, because we want to use [SQL Server Merge replication](http://msdn.microsoft.com/en-us/library/ms151329.aspx), I'll have to change all current primary keys (currently standard autoincrement integers) to GUID.
So here are the questions:
* Any recommenda... | [Chris](https://stackoverflow.com/questions/393381/recommendations-on-using-sql-server-guid-from-ms-access#393447) is right when saying that (1) you do not need GUIDS for merge replication and (2) there is only one GUID type, but you have to know that:
1. GUIDS can be generated following different rules. You can check... |
393,395 | <p>I've pretty much tried everything, but it seems impossible to use
expire_fragment from models? I know you're not supposed to and it's
non-MVC, but surely there much be some way to do it. </p>
<p>I created a module in lib/cache_helper.rb with all my expire helpers,
within each are just a bunch of expire_fragment... | [
{
"answer_id": 393425,
"author": "maurycy",
"author_id": 48541,
"author_profile": "https://Stackoverflow.com/users/48541",
"pm_score": 3,
"selected": false,
"text": "<p>In one of my scripts I use the following hack:</p>\n\n<pre><code> require 'action_controller/test_process'\n\n sweepe... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1609611/"
] | I've pretty much tried everything, but it seems impossible to use
expire\_fragment from models? I know you're not supposed to and it's
non-MVC, but surely there much be some way to do it.
I created a module in lib/cache\_helper.rb with all my expire helpers,
within each are just a bunch of expire\_fragment calls. ... | Disclaimer: My rails is a bit rusty, but this or something like it should work
```
ActionController::Base.new.expire_fragment(key, options = nil)
``` |
393,406 | <p>What other caching frameworks are available for .NET besides the project codenamed Velocity. What are the ALT.NET options? </p>
| [
{
"answer_id": 393425,
"author": "maurycy",
"author_id": 48541,
"author_profile": "https://Stackoverflow.com/users/48541",
"pm_score": 3,
"selected": false,
"text": "<p>In one of my scripts I use the following hack:</p>\n\n<pre><code> require 'action_controller/test_process'\n\n sweepe... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | What other caching frameworks are available for .NET besides the project codenamed Velocity. What are the ALT.NET options? | Disclaimer: My rails is a bit rusty, but this or something like it should work
```
ActionController::Base.new.expire_fragment(key, options = nil)
``` |
393,479 | <p>So I have an array of records retreived from a database. The array is in the format;</p>
<pre><code>$rows[0]['id']=1;
$rows[0]['title']='Abc';
$rows[0]['time_left']=200;
$rows[1]['id']=2;
$rows[1]['title']='XYZ';
$rows[1]['time_left']=300;
//And so on upto 10-20 rows
</code></pre>
<p>What's the best way of trans... | [
{
"answer_id": 393497,
"author": "barfoon",
"author_id": 1390354,
"author_profile": "https://Stackoverflow.com/users/1390354",
"pm_score": 6,
"selected": true,
"text": "<p>I tend to use a JSON object for this: </p>\n\n<ul>\n<li>On the server side, JSON encode your data: <code>json_encode... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | So I have an array of records retreived from a database. The array is in the format;
```
$rows[0]['id']=1;
$rows[0]['title']='Abc';
$rows[0]['time_left']=200;
$rows[1]['id']=2;
$rows[1]['title']='XYZ';
$rows[1]['time_left']=300;
//And so on upto 10-20 rows
```
What's the best way of transferring this array over to ... | I tend to use a JSON object for this:
* On the server side, JSON encode your data: `json_encode($data);`
* On the JavaScript side, I write a function that takes a JSON object as a parameter and unpack it.
When you unpack the object, you can print the array's contents into a `<DIV>` tag, or where ever you would like ... |
393,495 | <p>I need to convert the unicode characters to ansi characters</p>
<pre><code>byte[] encode = Encoding.Convert(Encoding.Unicode, Encoding.Default, report);
</code></pre>
<p>I use this piece of code. While I am viewing this I found that extra ? character is added
in the first part</p>
<p>?FF EE 20 12</p>
| [
{
"answer_id": 393506,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "<p>It would be helpful if you posted the input string as well as the output.</p>\n\n<p>Encoding.Convert() will output... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] | I need to convert the unicode characters to ansi characters
```
byte[] encode = Encoding.Convert(Encoding.Unicode, Encoding.Default, report);
```
I use this piece of code. While I am viewing this I found that extra ? character is added
in the first part
?FF EE 20 12 | It would be helpful if you posted the input string as well as the output.
Encoding.Convert() will output a '?' when it tries to convert a character in the source that does not have a corresponding character in the target encoding.
The sequence at the start of your output looks suspiciously close to a Byte Order Mark ... |
393,529 | <p>When using Google Chrome, I receive the following error message:</p>
<p>Error:</p>
<pre><code>Uncaught SyntaxError: Unexpected token <
</code></pre>
<p>It occurs directly after my doctype declaration at the top of my HTML page</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "h... | [
{
"answer_id": 393573,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe the HTTP content type is not <code>text/html</code> or <code>application/xhtml+xml</code>?</p>\n"
},
{
"answ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When using Google Chrome, I receive the following error message:
Error:
```
Uncaught SyntaxError: Unexpected token <
```
It occurs directly after my doctype declaration at the top of my HTML page
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional... | This problem occurred for me when I was using JQuery to load in HTML from an XMLHTTPRequest that was HTML, but the mime type was text/javascript.
So for example, I had some code such as:
```
jQuery.ajax({
data:'params=here',
success:function(request) {
jQuery('#country_list_container').html(request);
... |
393,554 | <p>I have a Python program that uses the "threading" module. Once every second, my program starts a new thread that fetches some data from the web, and stores this data to my hard drive. I would like to use sqlite3 to store these results, but I can't get it to work. The issue seems to be about the following line:</p>
... | [
{
"answer_id": 393576,
"author": "Evgeny Lazin",
"author_id": 42371,
"author_profile": "https://Stackoverflow.com/users/42371",
"pm_score": 7,
"selected": true,
"text": "<p>You can use consumer-producer pattern. For example you can create queue that is shared between threads. First threa... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38146/"
] | I have a Python program that uses the "threading" module. Once every second, my program starts a new thread that fetches some data from the web, and stores this data to my hard drive. I would like to use sqlite3 to store these results, but I can't get it to work. The issue seems to be about the following line:
```
con... | You can use consumer-producer pattern. For example you can create queue that is shared between threads. First thread that fetches data from the web enqueues this data in the shared queue. Another thread that owns database connection dequeues data from the queue and passes it to the database. |
393,595 | <p>I have a query like this - select * from tbl where ... and colname in (2,3,4) </p>
<p>When I prepare the query (... ' colname in (?)' ) using a PreparedStatement in Java, what setter method should I call to set these integers ? The integers are available in an int array and the size varies. If it matters, the datab... | [
{
"answer_id": 393610,
"author": "Learning",
"author_id": 18275,
"author_profile": "https://Stackoverflow.com/users/18275",
"pm_score": 2,
"selected": false,
"text": "<p>you can use another syntax</p>\n\n<pre><code>WHERE colname = ANY (?)\n</code></pre>\n\n<p>and call PreparedStatement.s... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27474/"
] | I have a query like this - select \* from tbl where ... and colname in (2,3,4)
When I prepare the query (... ' colname in (?)' ) using a PreparedStatement in Java, what setter method should I call to set these integers ? The integers are available in an int array and the size varies. If it matters, the database is My... | you can use another syntax
```
WHERE colname = ANY (?)
```
and call PreparedStatement.setArray(). You have to provide an instance of java.sql.Array as parameter.One advantage of ANY instead of IN is, that you can pass an empty array without causing a SQL syntax error. |
393,623 | <p>I'm using FCKEditor in that when "Browse Server" button is clicked the following error is thrown.</p>
<blockquote>
<p>The server didn't send back a proper
XML response. Please contact your
system administrator.</p>
<p>XML Request error: Not Found(404)</p>
<p>Requested URL:</p>
<p>/fckeditor/ed... | [
{
"answer_id": 393628,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 0,
"selected": false,
"text": "<p>Using <a href=\"http://www.getfirebug.com\" rel=\"nofollow noreferrer\">FireBug</a>, check what the response the ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35700/"
] | I'm using FCKEditor in that when "Browse Server" button is clicked the following error is thrown.
>
> The server didn't send back a proper
> XML response. Please contact your
> system administrator.
>
>
> XML Request error: Not Found(404)
>
>
> Requested URL:
>
>
> /fckeditor/editor/filemanager/connectors/asp... | I would imagine that you need to ensure that you've configured FCK to use ASPX for the FileBrowserLanguage and QuickUploadLanguage rather than asp.
I've got this set in the CustomFckConfig.js file, rather than modifying the core FckConfig.js file:
```
// The following value defines which File Browser connector and Qu... |
393,627 | <p>The following snippet of code is used to find the PID of a user's terminal, by using ptree and grabbing the <strong>third</strong> PID from the results it returns. All terminal PID's are stored in a hash with the user's login as the key.</p>
<pre><code> ## If process is a TEMINAL.
## The command ptree is used... | [
{
"answer_id": 393729,
"author": "JoelFan",
"author_id": 16012,
"author_profile": "https://Stackoverflow.com/users/16012",
"pm_score": 3,
"selected": false,
"text": "<p>I think the main problem is that this code is in a loop. You don't need to run ptree and parse the results more than o... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15884/"
] | The following snippet of code is used to find the PID of a user's terminal, by using ptree and grabbing the **third** PID from the results it returns. All terminal PID's are stored in a hash with the user's login as the key.
```
## If process is a TEMINAL.
## The command ptree is used to get the terminal's proce... | I think the main problem is that this code is in a loop. You don't need to run ptree and parse the results more than once! You need to figure out a way to run ptree once and put it into a data structure that you can use later. Probably be some kind of simple hash will suffice. You may even be able to just keep around y... |
393,629 | <p>I'm running a Django app using FastCGI and lighttpd.</p>
<p>Can somebody explain me what I should consider when deciding what value to use for maxrequests, maxspare, minspare, maxchildren?</p>
<p>These options are not too well documented, but seem quite important.</p>
<p>Don't just tell me what they do; I want to... | [
{
"answer_id": 393636,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 5,
"selected": true,
"text": "<p>Let's start with the definition</p>\n\n<pre>\n maxrequests: How many requests does a child server before being ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/393629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5475/"
] | I'm running a Django app using FastCGI and lighttpd.
Can somebody explain me what I should consider when deciding what value to use for maxrequests, maxspare, minspare, maxchildren?
These options are not too well documented, but seem quite important.
Don't just tell me what they do; I want to understand what *implic... | Let's start with the definition
```
maxrequests: How many requests does a child server before being killed
and a new one forked
maxspare : Maximum number of spare processes to keep running
minspare : Minimum number of spare processes to prefork
maxchildren: Hard limit number of p... |