qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
249,372 | <p>Given two integers <code>a</code> and <code>b</code>, how would I go about calculating the repeating decimal of <code>a / b</code>? This can be in any language; whatever it's easiest for you to express it in.</p>
| [
{
"answer_id": 251597,
"author": "ShreevatsaR",
"author_id": 4958,
"author_profile": "https://Stackoverflow.com/users/4958",
"pm_score": 3,
"selected": false,
"text": "a / b"
},
{
"answer_id": 15230863,
"author": "Harit Vishwakarma",
"author_id": 569161,
"author_profi... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
249,374 | <p>Is anyone familiar with this?</p>
<blockquote>
<p>Write a procedure that takes as inputs
a procedure that computes f and a
positive integer n and returns the
procedure that computes the nth
repeated application of f. The
procedure should be able to be used as
follows:</p>
<pre><code>((repeated square 2) 5)
625
</code></pre>
</blockquote>
<p>I know that the following code I've created for the composition of functions will help make the solution simpler, but I'm not sure where to go from here:</p>
<pre><code>(define (compose f g) (lambda (x) (f (g x))))
</code></pre>
| [
{
"answer_id": 249490,
"author": "Matthias Benkard",
"author_id": 15517,
"author_profile": "https://Stackoverflow.com/users/15517",
"pm_score": 1,
"selected": false,
"text": "((repeated square 3) 5)\n-> (square ((repeated square 2) 5))\n-> (square (square ((repeated square 1) 5)))\n-> (s... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30622/"
] |
249,375 | <p>How do you programmatically set a DataContext that specifies the selected item of a list? </p>
<p>More simply, how do you reproduce this type of binding in code?</p>
<pre><code><StackPanel>
<ListBox Name="listBox1" />
<TextBox Name="textBox1" DataContext="{Binding ElementName=listBox1, Path=SelectedItem}" />
</StackPanel>
</code></pre>
| [
{
"answer_id": 249378,
"author": "Ty.",
"author_id": 16948,
"author_profile": "https://Stackoverflow.com/users/16948",
"pm_score": 4,
"selected": true,
"text": "Binding binding = new Binding();\nbinding.ElementName = \"listBox1\";\nbinding.Path = new PropertyPath(\"SelectedItem\");\nbind... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25968/"
] |
249,388 | <p>I'm having trouble getting pictures supported with PIL - it throws me this:</p>
<pre><code>IOError: decoder jpeg not available
</code></pre>
<p>I installed PIL from binary, not realizing I needed libjpeg.</p>
<p>I installed libjpeg and freetype2 through fink. </p>
<p>I tried to reinstall PIL using instructions from <a href="http://timhatch.com/" rel="nofollow noreferrer">http://timhatch.com/</a> (bottom of the page)</p>
<ul>
<li>Download PIL 1.1.6 source package and have the Developer Tools already installed</li>
<li><p>Patch setup.py with this patch so it can find the Freetype you already have.</p>
<p><code>patch -p0 < leopard_freetype2.diff</code></p></li>
<li>sudo apt-get install libjpeg if you have fink (otherwise, build by hand and adjust paths)</li>
</ul>
<p>But I'm still getting the same error. </p>
<p>I'm on Leopard PPC. </p>
| [
{
"answer_id": 4533995,
"author": "Walty Yeung",
"author_id": 176423,
"author_profile": "https://Stackoverflow.com/users/176423",
"pm_score": 0,
"selected": false,
"text": "file /usr/local/lib/libjpeg.7.dylib \n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20824/"
] |
249,392 | <p>How would I implement a binary search using just an array? </p>
| [
{
"answer_id": 249404,
"author": "mmcdole",
"author_id": 2635,
"author_profile": "https://Stackoverflow.com/users/2635",
"pm_score": 6,
"selected": true,
"text": "BinarySearch(A[0..N-1], value, low, high) { \n if (high < low) \n return -1 // not found \n mid = low + ((hig... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
249,423 | <p>Can someone explain to me how XOR swapping of two variables with no temp variable works?</p>
<pre><code>void xorSwap (int *x, int *y)
{
if (x != y) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
}
</code></pre>
<p>I understand WHAT it does, but can someone walk me through the logic of how it works? </p>
| [
{
"answer_id": 249427,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": false,
"text": "tmp = x\nx = y\ny = tmp\n"
},
{
"answer_id": 249431,
"author": "Greg Hewgill",
"author_id": 893,
"author_pr... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] |
249,448 | <p>I have a textbox with the <strong>Text</strong> property bound to a dataset column with the DataType set to System.DateTime.<br>
The FormatString on the Binding is set to <strong>dd-MM-yyyy</strong>.</p>
<p>When the user enters a date it attempts to convert it to a date but can come up with some strange values for a seemingly invalid date.</p>
<p>For example:</p>
<pre><code>textBox1.Text = "01-02-200";
</code></pre>
<p>Should be an invalid date but it formats it as <strong>01-02-0200</strong>.</p>
<p>Is there an easy way to catch these out-of-bounds values either through setting a valid range or overriding an event on the binding/textbox?</p>
| [
{
"answer_id": 249519,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 3,
"selected": true,
"text": "private void textBox1_Validating(object sender, CancelEventArgs e)\n{\n DateTime date;\n if (!DateTime.TryParseExact(text... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4490/"
] |
249,452 | <p>How to add new item in existing string array in C#.net?</p>
<p>I need to preserve the existing data.</p>
| [
{
"answer_id": 249455,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 7,
"selected": false,
"text": "List<string> ls = new List<string>();\nls.Add(\"Hello\");\n"
},
{
"answer_id": 249486,
"author": "Ali Ersöz",
... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
249,460 | <p>On Windows Mobile, I am displaying my output in HTML. This includes lots of user-generated strings. Occasionally there are situations where a really large string is part of the output that has no whitespaces or punctuation. </p>
<p>Unfortunately the Windows Mobile's HTML view (htmlview.dll, based on Pocket Internet Explorer) does not break these long words down so they fit on screen. Instead a horizontal scrollbar is added and the user has to scroll sideways to see the whole word. This also affects other output which now also is spread along this larger screen width.</p>
<p>Is there any possibility to either make the htmlview behave differently, or to force the word to break? CSS can be used. Regarding the forcing: The &shy; tag is ALWAYS inserting a "-" character and never causes a breaks, the <WBR> tag is not doing anything at all, &8203; is output as &8203:, empty tags like <B></B> also do nothing. Also it should be noted that this code is running on multiple screen sizes and due to other parts of the HTML output I am not 100% sure how much screen width I have left.</p>
<p>P.S.: My app is compiled using the WM 5.0 SDK and is written in C++/Win32/MFC.</p>
| [
{
"answer_id": 249455,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 7,
"selected": false,
"text": "List<string> ls = new List<string>();\nls.Add(\"Hello\");\n"
},
{
"answer_id": 249486,
"author": "Ali Ersöz",
... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27101/"
] |
249,461 | <p>I want to compute for month difference of 2 dates which will return a float value.</p>
<p>example:</p>
<p>date1='4/23/2008'
date2='12/31/2008'</p>
<p>that will be 7.y months. I want to find the y value. can someone give me the formula to make this in sql codes? tnx..</p>
| [
{
"answer_id": 249477,
"author": "a2800276",
"author_id": 27408,
"author_profile": "https://Stackoverflow.com/users/27408",
"pm_score": 1,
"selected": false,
"text": "to_date()"
},
{
"answer_id": 249481,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "htt... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21963/"
] |
249,467 | <p>I've heard of "error" when using floating point variables. Now I'm trying to solve this puzzle and I think I'm getting some rounding/floating point error. So I'm finally going to figure out the basics of floating point error.</p>
<p>What is a simple example of floating point/rounding error (preferably in C++) ?</p>
<p>Edit: For example say I have an event that has probability p of succeeding. I do this event 10 times (p does not change and all trials are independent). What is the probability of exactly 2 successful trials? I have this coded as:</p>
<pre><code>double p_2x_success = pow(1-p, (double)8) * pow(p, (double)2) * (double)choose(8, 2);
</code></pre>
<p>Is this an opportunity for floating point error?</p>
| [
{
"answer_id": 249498,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 4,
"selected": false,
"text": "Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) \n[GCC 4.0.1 (Apple Inc. build 5465)] on darwin\nType \"help\", \"c... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] |
249,468 | <p>I'm looking at stdint.h and given that it has uint16_t and uint_fast16_t, what is the use for uint_least16_t what might you want that couldn't be done equally well with one of the other two?</p>
| [
{
"answer_id": 249482,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 5,
"selected": true,
"text": "unsigned char"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10471/"
] |
249,470 | <p>What would be a simple implementation of a method to convert a String like "Hello there everyone" to "helloThereEveryone". In JavaME support for String and StringBuffer utility operations are quite limited.</p>
| [
{
"answer_id": 249512,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 3,
"selected": true,
"text": "String str = \"Hello, there, everyone?\";\n\nStringBuffer result = new StringBuffer(str.length());\nString strl = str.toLowe... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22012/"
] |
249,489 | <p>I hope someone will be able to answer my question.</p>
<p>I have Subversion set up, served by Apache2+SSL, doing web development.</p>
<p>I want a post-commit hook that runs svn update on my testing server, so when someone commits, it will automatically update the testing site. The hook doesn't work because the certificate is a self generated one and it's not trusted.</p>
<p>I've tried to accept (p)ermanently, but it doesn't. </p>
<p>Any ideas?</p>
| [
{
"answer_id": 6049056,
"author": "ownking",
"author_id": 275443,
"author_profile": "https://Stackoverflow.com/users/275443",
"pm_score": 0,
"selected": false,
"text": "svn co file:///path_to/your/repo\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
249,499 | <p>Evaluate:</p>
<pre><code>((((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4) 5)
</code></pre>
<p>This is what I did:</p>
<ul>
<li><p>evaluate <code>((((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4) 5)</code></p>
<ul>
<li>evaluate <code>5 -> 5</code></li>
</ul></li>
<li><p>evaluate <code>(((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4)</code></p>
<ul>
<li>evaluate <code>4 -> 4</code></li>
</ul></li>
<li><p>evaluate <code>((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3)</code></p>
<ul>
<li>evaluate <code>3 -> 3</code></li>
</ul></li>
<li><p><code>(lambda (x) (lambda (y) (lambda (x) (+ x y))))</code> -> <code>(lambda (x) (lambda (y) (lambda (x) (+ x y))))</code></p></li>
<li><p>apply <code>(lambda (x) (lambda (y) (lambda (x) (+ x y))))</code> to <code>3</code></p>
<ul>
<li><p>substitute <code>3</code> -> <code>x</code> in <code>(lambda (y) (lambda (x) (+ x y))</code></p></li>
<li><p><code>(lambda (y) (lambda (x) (+ 3 y))</code></p></li>
<li><p>evaluate <code>(lambda (y) (lambda (x) (+ 3 y)) -> (lambda (y) (lambda (x) (+ 3 y))</code></p></li>
<li><p><code>apply (lambda (y) (lambda (x) (+ 3 y))</code> to <code>4</code></p></li>
<li><p>subsitute <code>4 -> y</code> in <code>(lambda (y) (lambda (x) (+ 3 y))</code></p></li>
<li><p><code>(lambda (y) (+ 3 4))</code></p></li>
<li><p>evaluate <code>(lambda (y) (+ 3 4)) -> (lambda (y) (7))</code></p>
<ul>
<li>subsitute <code>5</code> -> ?</li>
</ul></li>
</ul></li>
</ul>
<p>And then I'm stuck.</p>
| [
{
"answer_id": 249520,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 2,
"selected": false,
"text": "(define part1 (lambda (y) (lambda (x) (+ x y)))) ; basically an adder\n(define part2 (lambda (x) part1)) ; just return par... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30622/"
] |
249,500 | <p>OK, I have a somewhat complicated system in C++. In a nutshell, I need to add a method to a third party abstract base class. The third party also provides a ton of derived classes that also need the new functionality.</p>
<p>I'm using a library that provides a standard Shape interface, as well as some common shapes.</p>
<pre><code>class Shape
{
public:
Shape(position);
virtual ~Shape();
virtual position GetPosition() const;
virtual void SetPosition(position);
virtual double GetPerimeter() const = 0;
private: ...
};
class Square : public Shape
{
public:
Square(position, side_length);
...
};
class Circle, Rectangle, Hexagon, etc
</code></pre>
<p>Now, here's my problem. I want the Shape class to also include a GetArea() function. So it seems like I should just do a:</p>
<pre><code>class ImprovedShape : public virtual Shape
{
virtual double GetArea() const = 0;
};
class ImprovedSquare : public Square, public ImprovedShape
{
...
}
</code></pre>
<p>And then I go and make an ImprovedSquare that inherits from ImprovedShape and Square. Well, as you can see, I have now created the dreaded <a href="http://en.wikipedia.org/wiki/Diamond_problem" rel="nofollow noreferrer">diamond inheritance problem</a>. This would easily be fixed if the third party library used <a href="http://en.wikipedia.org/wiki/Virtual_inheritance" rel="nofollow noreferrer">virtual inheritance</a> for their Square, Circle, etc. However, getting them to do that isn't a reasonable option.</p>
<p>So, what do you do when you need to add a little functionality to an interface defined in a library? Is there a good answer?</p>
<p>Thanks!</p>
| [
{
"answer_id": 249666,
"author": "Dave Hillier",
"author_id": 1575281,
"author_profile": "https://Stackoverflow.com/users/1575281",
"pm_score": 3,
"selected": false,
"text": "class ImprovedShape : public virtual Shape\n{\n virtual double GetArea() const = 0;\n};\n"
},
{
"answe... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] |
249,536 | <p>FindBugs has found a potential bug in my code. But it is not a bug.</p>
<p>Is it possible to mark this occurrence as 'not a bug' AND have it removed from the bug list?</p>
<p>I have documented quite clearly why for each case it is not a bug.</p>
<p>For example. A class implements the comparable interface. it has the compareTo method. I have however not overridden the equals method.</p>
<p>FindBugs does not like this as the JavaDocs state that it is recommended that</p>
<pre><code>(x.compareTo(y)==0) == (x.equals(y))
</code></pre>
<p>Although in my case the above condition is and always will be true.</p>
| [
{
"answer_id": 249543,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "<Match>\n <Class name=\"com.foobar.MyClass\" />\n <Method name=\"myMethod\" />\n <Bug pattern=\"EQ_COMPARETO_USE_OBJECT_E... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/939/"
] |
249,540 | <p>How do I specify the username and password in order for my program to open
a file for reading?
The program that needs to access the file is running from an account that
does not have read access to the folder the file is in.
Program is written in C# and .NET 2, running under XP and file is on a Windows Server 2003 machine.</p>
| [
{
"answer_id": 249594,
"author": "James Newton-King",
"author_id": 11829,
"author_profile": "https://Stackoverflow.com/users/11829",
"pm_score": 4,
"selected": false,
"text": "using (new Impersonator(\"myUsername\", \"myDomainname\", \"myPassword\"))\n{\n string fileText = File.ReadAllT... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
249,557 | <blockquote>
<p>If f is a numerical function and n is a positive integer, then we can form the nth repeated application of f, which is defined to be the function whose value at x is f(f(...(f(x))...)). For example, if f is the function x + 1, then the nth repeated application of f is the function x + n. If f is the operation of squaring a number, then the nth repeated application of f is the function that raises its argument to the 2^nth power. Write a procedure that takes as inputs a procedure that computes f and a positive integer n and returns the procedure that computes the nth repeated application of f. Your procedure should be able to be used as follows:</p>
<pre><code>((repeated square 2) 5)
625
</code></pre>
<p>You can use this to simplify the answer:</p>
<pre><code> (define (compose f g) (lambda (x) (f (g x))))
</code></pre>
</blockquote>
| [
{
"answer_id": 249564,
"author": "Matthias Benkard",
"author_id": 15517,
"author_profile": "https://Stackoverflow.com/users/15517",
"pm_score": 1,
"selected": false,
"text": "((repeated square 3) 5)\n-> (square ((repeated square 2) 5))\n-> (square (square ((repeated square 1) 5)))\n-> (s... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30622/"
] |
249,567 | <p>What would be the best way to avoid SQL injection on the C#.net platform.</p>
<p>Please post an C# implementation if you have any.</p>
| [
{
"answer_id": 249582,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 5,
"selected": false,
"text": "'"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11135/"
] |
249,570 | <p>On a particular Debian server, iostat (and similar) report an unexpectedly high volume (in bytes) of disk writes going on. I am having trouble working out which process is doing these writes.</p>
<p>Two interesting points:</p>
<ol>
<li><p>Tried turning off system services one at a time to no avail. Disk activity remains fairly constant and unexpectedly high.</p></li>
<li><p>Despite the writing, do not seem to be consuming more overall space on the disk.</p></li>
</ol>
<p>Both of those make me think that the writing may be something that the kernel is doing, but I'm not swapping, so it's not clear to me what Linux might try to write.</p>
<p>Could try out atop:</p>
<p><a href="http://www.atcomputing.nl/Tools/atop/" rel="noreferrer">http://www.atcomputing.nl/Tools/atop/</a></p>
<p>but would like to avoid patching my kernel.</p>
<p>Any ideas on how to track this down?</p>
| [
{
"answer_id": 395362,
"author": "Igor Pozgaj",
"author_id": 19777,
"author_profile": "https://Stackoverflow.com/users/19777",
"pm_score": 2,
"selected": false,
"text": "CONFIG_TASKSTATS=y\nCONFIG_TASK_IO_ACCOUNTING=y\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
249,573 | <p>There is small system, where a database table as queue on MSSQL 2005. Several applications are writing to this table, and one application is reading and processing in a FIFO manner.</p>
<p>I have to make it a little bit more advanced to be able to create a distributed system, where several processing application can run. The result should be that 2-10 processing application should be able to run and they should not interfere each other during work.</p>
<p>My idea is to extend the queue table with a row showing that a process is already working on it. The processing application will first update the table with it's idetifyer, and then asks for the updated records.</p>
<p>So something like this:</p>
<pre><code>start transaction
update top(10) queue set processing = 'myid' where processing is null
select * from processing where processing = 'myid'
end transaction
</code></pre>
<p>After processing, it sets the processing column of the table to something else, like 'done', or whatever.</p>
<p>I have three questions about this approach.</p>
<p>First: can this work in this form?</p>
<p>Second: if it is working, is it effective? Do you have any other ideas to create such a distribution?</p>
<p>Third: In MSSQL the locking is row based, but after an amount of rows are locked, the lock is extended to the whole table. So the second application cannot access it, until the first application does not release the transaction. How big can be the selection (top x) in order to not lock the whole table, only create row locks?</p>
| [
{
"answer_id": 249688,
"author": "mjallday",
"author_id": 6084,
"author_profile": "https://Stackoverflow.com/users/6084",
"pm_score": 1,
"selected": false,
"text": "update mytable with (rowlock) set x=y where a=b\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/968/"
] |
249,578 | <p>I'm writing a bash script that needs to delete old files.</p>
<p>It's currently implemented using :</p>
<pre><code>find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete
</code></pre>
<p>This will delete of the files older than 1 day.</p>
<p>However, what if I need a finer resolution that 1 day, say like 6 hours old? Is there a nice clean way to do it, like there is using find and -mtime?</p>
| [
{
"answer_id": 249584,
"author": "GavinCattell",
"author_id": 21644,
"author_profile": "https://Stackoverflow.com/users/21644",
"pm_score": 2,
"selected": false,
"text": "man find\n"
},
{
"answer_id": 249591,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile"... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] |
249,580 | <p>What is the recommended practice? Should I add the my sub-folder under the fitnesse folder to version control? </p>
<p><em>Context: working on a single developer rails pet project. I've my rails project under version-control (Subversion) however my fitnesse wiki pages lie under the fitnesse program folder.</em></p>
<p>Fitnesse seems to have its own version-control... (I see numbered zips along with each of my wiki pages) Is it reliable? Where does it store the revisions?</p>
| [
{
"answer_id": 446230,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 6,
"selected": true,
"text": "-d"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] |
249,581 | <p>I have checked with the <a href="http://en.wikipedia.org/wiki/Facade_pattern" rel="noreferrer">wikipedia article</a>, and it seems like it is missing the c++ version of a code example. I am not able to fully appreciate the Facade pattern without this, can you please help explain it to me using C++?</p>
| [
{
"answer_id": 249656,
"author": "Dave Hillier",
"author_id": 1575281,
"author_profile": "https://Stackoverflow.com/users/1575281",
"pm_score": 3,
"selected": false,
"text": "// \"Subsystem ClassA\" \n#include <iostream>\nclass SubSystemOne\n{\npublic:\n void MethodOne()\n {\n ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] |
249,587 | <p>I want to scale an image in C# with quality level as good as Photoshop does. Is there any C# image processing library available to do this thing?</p>
| [
{
"answer_id": 249601,
"author": "Hallgrim",
"author_id": 15454,
"author_profile": "https://Stackoverflow.com/users/15454",
"pm_score": 4,
"selected": false,
"text": "Bitmap original = ...\nBitmap scaled = new Bitmap(new Size(original.Width * 4, original.Height * 4));\nusing (Graphics gr... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191/"
] |
249,607 | <p>I am using Visual C++ 2005 Express Edition and get the following linker errors:</p>
<pre><code>19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ) referenced in function "protected: static void __cdecl std::vector<class mytype,class std::allocator<class mytype> >::_Xlen(void)" (?_Xlen@?$vector@Vmytype@@V?$allocator@Vmytype@@@std@@@std@@KAXXZ)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ)
19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z)
</code></pre>
<p>I turned off exceptions in generated code, and I am using before including the vector header file:</p>
<pre><code>#define _HAS_EXCEPTIONS 0
</code></pre>
<p>A few Google results turned up some stuff, but no "aha!" solutions that worked for me.</p>
<p>EDIT:</p>
<p>As noted "_HAS_EXCEPTIONS 0" doesn't turn off exceptions, per se. What it does is, at least in the vector header file, is call _Raise on an exception object instead of calling the C++ "throw". In my case, it can't link to the exception object's _Raise function since I am not including the correct library. What that library is, though, is not obvious.</p>
| [
{
"answer_id": 249685,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 0,
"selected": false,
"text": "#define the _HAS_EXCEPTIONS 0"
},
{
"answer_id": 254069,
"author": "Jim Buck",
"author_id": 2666,
"au... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2666/"
] |
249,618 | <p>Can anyone explain to me how to get the visual state manager to work with a WPF application? It's just been added to the new wpftoolkit. I installed it as told, but even the sample doesn't show the VSM. In silverlight it work, but not in WPF. If installed the latest Blend 2 and updated with the SP1. </p>
| [
{
"answer_id": 249833,
"author": "Sorskoot",
"author_id": 31722,
"author_profile": "https://Stackoverflow.com/users/31722",
"pm_score": 2,
"selected": false,
"text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Expression\\Blend\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31722/"
] |
249,637 | <p>Let's suppose I have an applet running within a page in a browser.
What happens when the browser is closed by the user?</p>
<p>Is the applet notified so that it can perform some kind of close action on its side (closing connections opened to a server, cleaning static variables, ...)?</p>
<p>Also, I assume the same behavior would apply for a page refresh or page navigation (instead of browser close). The browser remains opened but the applet is gone. Although when you close the browser you also close the JVM so I'm unsure at this point.</p>
<p>Thanks,
JB</p>
| [
{
"answer_id": 249643,
"author": "keparo",
"author_id": 19468,
"author_profile": "https://Stackoverflow.com/users/19468",
"pm_score": 3,
"selected": true,
"text": "public void finalize () {\n destroy();\n}\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7218/"
] |
249,655 | <p>I work on a large project in Delphi 5.
Today, after merging two branches of the app together, one of the hundreds of units, UnitMain (the main form's unit, would you guess) stopped recognizing the Application global.</p>
<p>This is a rather bizarre problem - I could get the program to compile by defining Application: TApplication in UnitMain, and setting that to the Application from our .dpr project file, but that leads to an access violation, which isn't much of a surprise with Application being the special thing it is.</p>
<p>I'm hoping someone has faced the same problem before, or knows enough of Delphi VCL's inner workings to help me out here.</p>
<pre><code>unit UnitMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ComCtrls, StdCtrls, cxButtons, ExtCtrls, IniFiles, ShellAPI,
LMDControl, LMDBaseControl, LMDBaseGraphicControl, LMDGraphicControl,
LMDScrollText, cxControls, cxContainer, cxListBox, Psock, NMFtp, db, DBTables,
FileCtrl, Configs, cxHint, DSetFunc, OleCtrls, DsInformation,
InterAppComm, ActnList, ADODB, OleServer, CRAXDRT_TLB;
</code></pre>
<p>The exact error is that the compiler does not recognize Application in this unit.
For example, for a Application.ProcessMessages; call, the error is "Object or class type required".
None of the other units has this problem.</p>
| [
{
"answer_id": 249669,
"author": "Re0sless",
"author_id": 2098,
"author_profile": "https://Stackoverflow.com/users/2098",
"pm_score": 2,
"selected": false,
"text": "unit MyUnit;\n\ninterface\n\nuses\n Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;\n"
},
{... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15477/"
] |
249,657 | <p>could someone provide working example (full maven plugin configuration) how to copy built jar file to a specific server(s) at the time of deploy phase?</p>
<p>I have tried to look at wagon plugin, but it is hugely undocumented and I was not able to set it up. The build produces standard jar that is being deployed to Nexus, but I need to put the jar also to the test server automatically over local network (\someserver\testapp\bin).</p>
<p>I will be grateful for any hints.</p>
<p>Thank you</p>
| [
{
"answer_id": 250021,
"author": "Petr Macek",
"author_id": 15045,
"author_profile": "https://Stackoverflow.com/users/15045",
"pm_score": 3,
"selected": false,
"text": "<plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-dependency-plugin</artifactId>\n <executi... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15045/"
] |
249,664 | <p>I found the discussion on <a href="https://stackoverflow.com/questions/105007/do-you-test-private-method">Do you test private method</a> informative.</p>
<p>I have decided, that in some classes, I want to have protected methods, but test them.
Some of these methods are static and short. Because most of the public methods make use of them, I will probably be able to safely remove the tests later. But for starting with a TDD approach and avoid debugging, I really want to test them.</p>
<p>I thought of the following:</p>
<ul>
<li><a href="http://www.refactoring.com/catalog/replaceMethodWithMethodObject.html" rel="noreferrer">Method Object</a> as adviced in <a href="https://stackoverflow.com/questions/105007/do-you-test-private-method#105021">an answer</a> seems to be overkill for this.</li>
<li>Start with public methods and when code coverage is given by higher level tests, turn them protected and remove the tests.</li>
<li>Inherit a class with a testable interface making protected methods public</li>
</ul>
<p>Which is best practice? Is there anything else?</p>
<p>It seems, that JUnit automatically changes protected methods to be public, but I did not have a deeper look at it. PHP does not allow this via <a href="http://php.net/language.oop5.reflection" rel="noreferrer">reflection</a>.</p>
| [
{
"answer_id": 249776,
"author": "troelskn",
"author_id": 18180,
"author_profile": "https://Stackoverflow.com/users/18180",
"pm_score": 6,
"selected": false,
"text": "class Foo {\n protected function stuff() {\n // secret stuff, you want to test\n }\n}\n\nclass SubFoo extends Foo {\... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32679/"
] |
249,667 | <p>Say you get a recordset like the following:</p>
<pre><code>| ID | Foo | Bar | Red |
|-----|------|------|------|
| 1 | 100 | NULL | NULL |
| 1 | NULL | 200 | NULL |
| 1 | NULL | NULL | 300 |
| 2 | 400 | NULL | NULL |
| ... | ... | ... | ... | -- etc.
</code></pre>
<p>And you want:</p>
<pre><code>| ID | Foo | Bar | Red |
|-----|-----|-----|-----|
| 1 | 100 | 200 | 300 |
| 2 | 400 | ... | ... |
| ... | ... | ... | ... | -- etc.
</code></pre>
<p>You could use something like:</p>
<pre><code>SELECT
ID,
MAX(Foo) AS Foo,
MAX(Bar) AS Bar,
MAX(Red) AS Red
FROM foobarred
GROUP BY ID
</code></pre>
<hr>
<p>Now, how might you accomplish similar when Foo, Bar, and Red are VARCHAR?</p>
<pre><code>| ID | Foo | Bar | Red |
|-----|----------|---------|---------|
| 1 | 'Text1' | NULL | NULL |
| 1 | NULL | 'Text2' | NULL |
| 1 | NULL | NULL | 'Text3' |
| 2 | 'Test4' | NULL | NULL |
| ... | ... | ... | ... | -- etc.
</code></pre>
<p>To:</p>
<pre><code>| ID | Foo | Bar | Red |
|-----|----------|---------|---------|
| 1 | 'Text1' | 'Text2' | 'Text3' |
| 2 | 'Text4' | ... | ... |
| ... | ... | ... | ... | -- etc.
</code></pre>
<hr>
<p>Currently working primarily with SQL Server 2000; but have access to 2005 servers.</p>
| [
{
"answer_id": 249719,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 1,
"selected": true,
"text": "CREATE TABLE Flatten (\n id int not null,\n foo Nvarchar(10) null,\n bar Nvarchar(10) null,\n red Nvarcha... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15031/"
] |
249,671 | <p>I have created the following style for a listbox that will have an image displayed next to some text:</p>
<pre><code><Style x:Key="ImageListBoxStyle" TargetType="{x:Type ListBox}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<!-- Simple ListBoxItem - This is used for each Item in a ListBox. The item's content is placed in the ContentPresenter -->
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid SnapsToDevicePixels="true">
<Border x:Name="Border">
<Grid Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image
x:Name="DisplayImage"
Source="{Binding Path=ThumbnailImage}"
Height="30"
Width="30"
Grid.Column="0"/>
<ContentPresenter
x:Name="DisplayText"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Grid.Column="1"/>
<!--<ContentPresenter.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="Black"/>
</Style>
</ContentPresenter.Resources>-->
<!--Content="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListBox}, Path=DisplayMemberPath, Converter={StaticResource myDisplayMemberConverter}}"-->
<!--<Label
x:Name="Text"
Content="{Binding Path=FullNameAndTitle}"
Foreground="Black"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
VerticalContentAlignment="Center"
HorizontalAlignment="Stretch"
Grid.Column="1"
Height="40"/>-->
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<!--<Setter Property="FontWeight" Value="Bold" TargetName="DisplayText"/>-->
<!--<Setter Property="Style" Value="{StaticResource SelectedTextStyle}" TargetName="DisplayText"/>-->
<Setter Property="Background" Value="DarkBlue" TargetName="Border"/>
<Setter Property="Width" Value="40" TargetName="DisplayImage"/>
<Setter Property="Height" Value="40" TargetName="DisplayImage"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBox}">
<Grid>
<Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="Black" BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<ScrollViewer Margin="1,1,1,1" Focusable="false" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<StackPanel IsItemsHost="true"/>
</ScrollViewer>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</code></pre>
<p>I have to use the contentpresenter as I am filtering what is displayed (text wise) using the DisplayMemberPath of the ListBox itself.</p>
<p>All I want to do is set the FontWeight to Bold and the Foreground to White when an item is selected in the ListBox.</p>
<p>Has anyone encountered a problem like this? I have looked at some related questions but people have been able to use a TextBlock to get around their issues I can't unfortunately.</p>
<p>Any info ppl can give will be appreciated.</p>
<p>Cheers</p>
| [
{
"answer_id": 258612,
"author": "Bijington",
"author_id": 32348,
"author_profile": "https://Stackoverflow.com/users/32348",
"pm_score": 5,
"selected": false,
"text": "<Setter Property=\"FontWeight\" Value=\"Bold\"/>\n<Setter Property=\"Foreground\" Value=\"White\"/>\n"
},
{
"ans... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32348/"
] |
249,692 | <p>I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax()</p>
<p>To perform the AJAX I'm using:</p>
<pre><code>$.ajax({
url: myUrl,
cache: false,
dataType: "json",
success: function(data){
...
},
error: function(e, xhr){
...
}
});
</code></pre>
<p>And if I return an array of items then it works fine:</p>
<pre><code>[ { title: "One", key: "1" }, { title: "Two", key: "2" } ]
</code></pre>
<p>The success function is called and receives the correct object.</p>
<p>However, when I'm trying to return a single object:</p>
<pre><code>{ title: "One", key: "1" }
</code></pre>
<p>The error function is called and xhr contains 'parsererror'. I've tried wrapping the JSON in parenthesis on the server before sending it down the wire, but it makes no difference. Yet if I paste the content into a string in Javascript and then use the eval() function, it evaluates it perfectly.</p>
<p>Any ideas what I'm doing wrong?</p>
<p>Anthony</p>
| [
{
"answer_id": 249758,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 7,
"selected": true,
"text": "\"*/json\""
},
{
"answer_id": 250245,
"author": "Josh",
"author_id": 2204759,
"author_profile": "https:... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/366/"
] |
249,701 | <p>I have a header file x.h which is included by more than one *.c source files.
This header file has some structure variables defined.</p>
<p>I have put multiple inclusion prevention guard at the beginning of the header file as:</p>
<pre><code>#ifndef X_H
#define X_H
...
..
//header file declarations and definitons.
#endif//X_H
</code></pre>
<p>On building I get linker errors related to multiple definitions. I understand the problem.</p>
<ol>
<li><p>Won't a multiple inclusion prevention guard at the top of header file as I have, prevent multiple inclusions of the header file x.h and thereby avoid multiple definitions of the variables that are there in x.h?</p></li>
<li><p><code>#pragma</code> once does not work on this particular compiler, so what is the solution?
Someone had posted <a href="https://stackoverflow.com/questions/223771/repeated-multiple-definition-errors-from-including-same-header-in-multiple-cpps#223798">this</a> answer to a similar question. It doesn't seem to work for me. How does this solution work?</p></li>
</ol>
| [
{
"answer_id": 249707,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "extern"
},
{
"answer_id": 249745,
"author": "Roddy",
"author_id": 1737,
"author_profile": "https://St... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759376/"
] |
249,703 | <p>I have some scripts that ought to have stopped running but hang around forever. Is there some way I can figure out what they're writing to STDOUT and STDERR in a readable way?</p>
<p>I tried, for example, to do:</p>
<pre><code>$ tail -f /proc/(pid)/fd/1
</code></pre>
<p>but that doesn't really work. It was a long shot anyway.</p>
<p>Any other ideas? </p>
<p><code>strace</code> on its own is quite verbose and unreadable for seeing this.</p>
<p>Note: I am <em>only</em> interested in their output, not in anything else. I'm capable of figuring out the other things on my own; this question is only focused on getting access to stdout and stderr of the running process <em>after</em> starting it.</p>
| [
{
"answer_id": 249932,
"author": "Thomas Vander Stichele",
"author_id": 2900,
"author_profile": "https://Stackoverflow.com/users/2900",
"pm_score": 6,
"selected": false,
"text": "creat"
},
{
"answer_id": 251429,
"author": "Community",
"author_id": -1,
"author_profile"... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2900/"
] |
249,704 | <p>Has anyone tested sorting with Selenium? I'd like to verify that sorting a table in different ways work (a-z, z-a, state, date, etc.). Any help would be very much appreciated.</p>
<p>/Göran</p>
| [
{
"answer_id": 296686,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 0,
"selected": false,
"text": " //div[@id='sortResult']/div[1]/div (this'd be row 1 of the search result)\n //div[@id='sortResult']/div[2]/div ( ro... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
249,709 | <p>How can i, in a bash script, execute a command when the user stops the script (with ctrl - c)?</p>
<p>Currently, i have this:</p>
<pre><code>afplay file.mp3
while true:
do osascript -e "set volume 10"
end
</code></pre>
<p>But i would like it to execute <code>killall afplay</code> when the user is finished with it, regardless if it is command-c or another keypress.</p>
| [
{
"answer_id": 249733,
"author": "Vebjorn Ljosa",
"author_id": 17498,
"author_profile": "https://Stackoverflow.com/users/17498",
"pm_score": 4,
"selected": true,
"text": "trap 'killall afplay' EXIT"
},
{
"answer_id": 249736,
"author": "CesarB",
"author_id": 28258,
"au... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] |
249,718 | <p>Already implemented performance boosters :
- Get compatible image of GraphicsConfiguration to draw on
- Enable OpenGL pipeline in 1.5: Not possible due to severe artifacts</p>
<p>So far I am fine, the main profiled bottleneck of the program is drawing an image with several thousand tiles. Unfortunately it is not regular, else I simply could set pixels
and scale them.
I accerelated the image with VolatileImages and own rendering routines (ignore repaint and draw it itself with a timer). The result was pleasing and would suffice, BUT:
Choosing a JMenu which hovers normally over the part of the image is severely disturbed because the JMenu is overdrawn. Inacceptable and the layout couldn't be changed.</p>
<p>I tried the GLJPanel of JOGL, but there is no visible performance improvement.
So is there a possibitlity to use VolatileImages (or other accerelated lightweighted components like GLCanvas) and still get normal JMenu display and if yes, how ? </p>
| [
{
"answer_id": 249920,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "import javax.swing.*;\nimport java.awt.*;\nimport java.awt.event.WindowAdapter;\nimport java.awt.event.WindowEvent;\nimport ja... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
249,720 | <p>I'm using the Lengauer and Tarjan algorithm with path compression to calculate the dominator tree for a graph where there are millions of nodes. The algorithm is quite complex and I have to admit I haven't taken the time to fully understand it, I'm just using it. Now I have a need to calculate the dominator trees of the direct children of the root node and possibly recurse down the graph to a certain depth repeating this operation. I.e. when I calculate the dominator tree for a child of the root node I want to pretend that the root node has been removed from the graph.</p>
<p>My question is whether there is an efficient solution to this that makes use of immediate dominator information already calculated in the initial dominator tree for the root node? In other words I don't want to start from scratch for each of the children because the whole process is quite time consuming.</p>
<p>Naively it seems it must be possible since there will be plenty of nodes deep down in the graph that have idoms just a little way above them and are unaffected by changes at the top of the graph.</p>
<p>BTW just as aside: it's bizarre that the subject of dominator trees is "owned" by compiler people and there is no mention of it in books on classic graph theory. The application I'm using it for - my FindRoots java heap analyzer - is not related to compiler theory.</p>
<p>Clarification: I'm talking about directed graphs here. The "root" I refer to is actually the node with the greatest reachability. I've updated the text above replacing references to "tree" with "graph". I tend to think of them as trees because the shape is <em>mainly</em> tree-like. The graph is actually of the objects in a java heap and as you can imagine is reasonably hierarchical. I have found the dominator tree useful when doing OOM leak analysis because what you are interested in is "what keeps this object alive?" and the answer ultimately is its dominator. Dominator trees allow you to <ahem> see the wood rather than the trees. But sometimes lots of junk floats to the top of the tree so you have a root with thousands of children directly below it. For such cases I would like to experiment with calculating the dominator trees rooted at each of the direct children (in the original graph) of the root and then maybe go to the next level down and so on. (I'm trying not to worry about the possibility of back links for the time being :)</p>
| [
{
"answer_id": 252927,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 4,
"selected": true,
"text": "boost::lengauer_tarjan_dominator_tree_without_dfs"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15379/"
] |
249,721 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/249760/how-to-convert-unix-timestamp-to-datetime-and-vice-versa">How to convert UNIX timestamp to DateTime and vice versa?</a> </p>
</blockquote>
<p>I've got the following class:</p>
<pre><code>[DataContractAttribute]
public class TestClass
{
[DataMemberAttribute]
public DateTime MyDateTime { get; set; }
}
</code></pre>
<p>Here's the JSON:</p>
<pre><code>{ "MyDateTime":"1221818565" }
</code></pre>
<p>The JSON is being returned from a PHP webservice.</p>
<p>What I need to do, is convert that epoch string into a valid C# DateTime. What's the best way of doing this?</p>
<p>I can do this:</p>
<pre><code>[IgnoreDataMemberAttribute]
public DateTime MyDateTime { get; set; }
[DataMemberAttribute(Name = "MyDateTime")]
public Int32 MyDateTimeTicks
{
get { return this.MyDateTime.Convert(...); }
set { this.Created = new DateTime(...); }
}
</code></pre>
<p>But the trouble with this is, the MyDateTimeTicks is public (changing it to private causes an exception in the serialization process)</p>
| [
{
"answer_id": 251804,
"author": "Dan Esparza",
"author_id": 19020,
"author_profile": "https://Stackoverflow.com/users/19020",
"pm_score": 2,
"selected": false,
"text": "new System.DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(1221818565);\n"
},
{
"answer_id": 251845,
"author":... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] |
249,724 | <p>How can I customise the Site Actions menu to remove or rename 'standard' menu items? Where are the site actions menu items defined? </p>
| [
{
"answer_id": 257789,
"author": "Lachlan Wetherall",
"author_id": 32701,
"author_profile": "https://Stackoverflow.com/users/32701",
"pm_score": 2,
"selected": false,
"text": "ConfigMenu=\"Delete\""
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32701/"
] |
249,729 | <p>I am writing a Jython script to sort a list of URLs.</p>
<p>I have a list that looks like this:</p>
<p><a href="http://www.domain.com/folder1/folder2/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/|,1</a><br />
<a href="http://www.domain.com/folder1/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/folder3/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/folder3/|,1</a><br />
<a href="http://www.domain.com/folder1/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/folder3/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/folder3/|,1</a><br /></p>
<p>The pipe and the comma separates the path from the amount of files that are under that path.
Is it possible some how use Jython to order the URLs by length, so it would end up look like the below list:</p>
<p><a href="http://www.domain.com/folder1/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/|,1</a><br />
<a href="http://www.domain.com/folder1/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/folder3/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/folder3/|,1</a><br />
<a href="http://www.domain.com/folder1/folder2/folder3/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/folder3/|,1</a><br /></p>
<p>Hope you guys get what I mean, any help would be appreciated. Cheers</p>
| [
{
"answer_id": 249754,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 3,
"selected": true,
"text": "urls.sort(lambda a, b: cmp(len(a), len(b)))\n"
},
{
"answer_id": 249766,
"author": "gimel",
"author_id": 64... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30786/"
] |
249,760 | <p>There is this example code, but then it starts talking about millisecond / nanosecond problems.</p>
<p>The same question is on MSDN, <em><a href="https://learn.microsoft.com/archive/blogs/brada/seconds-since-the-unix-epoch-in-c" rel="noreferrer">Seconds since the Unix epoch in C#</a></em>.</p>
<p>This is what I've got so far:</p>
<pre><code>public Double CreatedEpoch
{
get
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();
TimeSpan span = (this.Created.ToLocalTime() - epoch);
return span.TotalSeconds;
}
set
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();
this.Created = epoch.AddSeconds(value);
}
}
</code></pre>
| [
{
"answer_id": 250400,
"author": "ScottCher",
"author_id": 24179,
"author_profile": "https://Stackoverflow.com/users/24179",
"pm_score": 11,
"selected": true,
"text": "public static DateTime UnixTimeStampToDateTime( double unixTimeStamp )\n{\n // Unix timestamp is seconds past epoch\n... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] |
249,775 | <p>Say I have an input file, and a target directory. How do I determine if the input file is on the same hard-drive (or partition) as the target directory?</p>
<p>What I want to do is the copy a file if it's on a different, but move it if it's the same. For example:</p>
<pre><code>target_directory = "/Volumes/externalDrive/something/"
input_foldername, input_filename = os.path.split(input_file)
if same_partition(input_foldername, target_directory):
copy(input_file, target_directory)
else:
move(input_file, target_directory)
</code></pre>
| [
{
"answer_id": 249796,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 5,
"selected": true,
"text": "stat()"
},
{
"answer_id": 250149,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stack... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] |
249,779 | <p>I'm using a <code>BindingList<T></code> in my Windows Forms that contains a list of "<code>IComparable<Contact></code>" Contact-objects. Now I'd like the user to be able to sort by any column displayed in the grid.</p>
<p>There is a way described on MSDN online which shows how to implement a custom collection based on <code>BindingList<T></code> which allows sorting. But isn't there a Sort-event or something that could be caught in the DataGridView (or, even nicer, on the BindingSource) to sort the underlying collection using custom code?</p>
<p>I don't really like the way described by MSDN. The other way I could easily apply a LINQ query to the collection.</p>
| [
{
"answer_id": 281324,
"author": "Matthias Meid",
"author_id": 17713,
"author_profile": "https://Stackoverflow.com/users/17713",
"pm_score": 5,
"selected": false,
"text": "BindingList<T>"
},
{
"answer_id": 1178144,
"author": "Sorin Comanescu",
"author_id": 117290,
"au... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17713/"
] |
249,780 | <p>I have a really simple search form with the following</p>
<ul>
<li>Label ("Search")</li>
<li>Textbox (fixed width)</li>
<li>Submit button</li>
<li>"Advanced" link</li>
</ul>
<p>Label, textbox and submit are all on one horizontal line and centered.
Now I would like my advanced link to be under the submit button.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 249790,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": true,
"text": " Search [xxxxxxxxxxxxxxxx] [Submit]\n Advanced\n"
},
{
"answer_id"... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
249,785 | <p>Simply moving the file to <code>~/.Trash/</code> will not work, as if the file os on an external drive, it will move the file to the main system drive..</p>
<p>Also, there are other conditions, like files on external drives get moved to <code>/Volumes/.Trash/501/</code> (or whatever the current user's ID is)</p>
<p>Given a file or folder path, what is the correct way to determine the trash folder? I imagine the language is pretty irrelevant, but I intend to use Python</p>
| [
{
"answer_id": 251566,
"author": "Dave Dribin",
"author_id": 26825,
"author_profile": "https://Stackoverflow.com/users/26825",
"pm_score": 4,
"selected": true,
"text": "url = NSURL.fileURLWithPath(path)\nfinder = SBApplication.applicationWithBundleIdentifier(\"com.apple.Finder\")\nitem =... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] |
249,786 | <p>I'm at a client doing some quick fixes to their access application. It was a while I had a go with access, but I'm recovering quickly. However, I've discovered an interesting problem:</p>
<p>For some reports, I get a "Record is deleted" error. I've checked the reports, and it seems like there's a problem with one table. When opening that table, I find a record where all columns are marked "#deleted". So obviously, this row seems to be the culprit. However, when I try to delete that row, nothing really happens. If I re-open the table, the row still exists. </p>
<p>Is there a corruption in the db? How can I remove this record for good?</p>
<p><strong>Edit:</strong> It's a MS2000-version</p>
<p><strong>Solution:</strong> Simply compress/repair did not work. I converted the database to the 2003 file format instead, which did the trick. I've marked the first answer suggesting compress/repair, since it pointed me in the right direction. Thanks!</p>
| [
{
"answer_id": 252357,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 2,
"selected": false,
"text": " Me!txtMyMemo = Me!MyMemo\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17436/"
] |
249,791 | <p>How do I get the substring <code>" It's big \"problem "</code> using a regular expression?</p>
<pre><code>s = ' function(){ return " It\'s big \"problem "; }';
</code></pre>
| [
{
"answer_id": 249804,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "/([\"\\']).*?(?<!\\\\)(\\\\\\\\)*\\1/is\n"
},
{
"answer_id": 249937,
"author": "PhiLho",
"author_id": 15459,
... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
249,794 | <p>I'me looking for a function that would receive a time and would round it to the next/previous hour / half-hour / quarter / minute.</p>
| [
{
"answer_id": 249828,
"author": "IAdapter",
"author_id": 30453,
"author_profile": "https://Stackoverflow.com/users/30453",
"pm_score": 6,
"selected": true,
"text": "CREATE FUNCTION [dbo].[RoundTime] (@Time datetime, @RoundTo float)\nRETURNS datetime\nAS\nBEGIN\n DECLARE @RoundedTime s... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1842864/"
] |
249,797 | <p>I'm currently using the ActiveRecord-based session store for my Rails app and I have a background process which clears out inactive sessions every 30 minutes.</p>
<p>I'd like to switch to Rails' new cookie-based session store but how do I set the expiry time of the session to 30 minutes, as opposed to the default 'at end of session' value?</p>
| [
{
"answer_id": 249966,
"author": "Codebeef",
"author_id": 12037,
"author_profile": "https://Stackoverflow.com/users/12037",
"pm_score": -1,
"selected": false,
"text": "session :session_key => 'my_session_key'\nsession :session_expires => 1.day.from_now\n"
},
{
"answer_id": 251123... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1174/"
] |
249,819 | <p>I have the following sql query for transforming data but is it possible to save the value of the int in some variable to avoid casting multiple times?</p>
<pre><code>update prospekts set sni_kod = case
when
cast(sni_kod as int) >= 1000 and cast(sni_kod as int) <= 1499
or cast(sni_kod as int) >= 1600 and cast(sni_kod as int) <= 2439
then '1'
when
cast(sni_kod as int) >= 7000 and cast(sni_kod as int) <= 7499
then 'W'
else
sni_kod
end
</code></pre>
<p>There are a lot more when-cases in the script, just showing the first one. I cannot use anything other than a simple text-script.</p>
<p><strong>Update</strong>
Using SQL Server 2000</p>
<p>Thanks</p>
<p>Anders</p>
| [
{
"answer_id": 249836,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 1,
"selected": false,
"text": "With xxx AS (\n i_sni_kod = cast(sni_kod as int)\n ...)\nUPDATE prospekts set sni_kod = case \n when i_sni_... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22092/"
] |
249,847 | <p>I am wondering how to use NUnit correctly. First, I created a separate test project that uses my main project as reference. But in that case, I am not able to test private methods. My guess was that I need to include my test code into my main code?! - That doesn't seem to be the correct way to do it. (I dislike the idea of shipping code with tests in it.)</p>
<p>How do you test private methods with NUnit?</p>
| [
{
"answer_id": 9035421,
"author": "user1039513",
"author_id": 1039513,
"author_profile": "https://Stackoverflow.com/users/1039513",
"pm_score": 6,
"selected": false,
"text": "private MethodInfo GetMethod(string methodName)\n{\n if (string.IsNullOrWhiteSpace(methodName))\n Asser... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32726/"
] |
249,860 | <p>How can i restrict adding controls in Panel in C# window controls? I have to restrict user to add controls in a panel at design time.</p>
| [
{
"answer_id": 249934,
"author": "Rune Grimstad",
"author_id": 30366,
"author_profile": "https://Stackoverflow.com/users/30366",
"pm_score": 1,
"selected": false,
"text": "class MyPanel : Panel\n{\n\n public MyPanel()\n { }\n\n protected override void OnControlAdded(ControlEvent... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31159/"
] |
249,865 | <p>We're seeing the error message ORA-00936 Missing Expression for the following SQL:</p>
<p>Note that this is just a cut-down version of a much bigger SQL so rewriting it to a inner join or similar is not really in the scope of this:</p>
<p>This is the SQL that fails:</p>
<pre><code>select (select count(*) from gt_roster where ROS_ROSTERPLAN_ID = RPL_ID)
from gt_rosterplan
where RPL_ID = 432065061
</code></pre>
<p>What I've tried:
* Extracting the innermost SQL and substituting the ID from the outer SQL gives me the number 12.
* Aliasing both the sub-query, and the count(*) individually and both at the same time does not change the outcome (ie. still an error)</p>
<p>What else do I need to look at?</p>
<p>The above are only tables, no views, RPL_ID is primary key of gt_rosterplan, and ROS_ROSTERPLAN_ID is a foreign key to this column, there is basically no magic or hidden information here.</p>
<hr>
<p><strong>Edit:</strong> In response to answer, no, you do not need the aliases here as the columns are uniquely named across the tables.</p>
<hr>
<p><strong>Solved:</strong> The problem was that the client was running the wrong client driver version, 9.2.0.1, and there are known problems with that version.</p>
| [
{
"answer_id": 249915,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 2,
"selected": true,
"text": "SQL> select (select count(*) from emp2 where empdeptno = deptno)\n 2 from dept\n 3 where deptno=10\n 4 /\n\n(SEL... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267/"
] |
249,866 | <p>I'm creating a <code>Path</code> in <em>Silverlight</em>, and adding elements to it on mouse events. But, although the elements are there in memory, the screen doesn't get updated until something else causes a screen repaint to happen.</p>
<p>Here's the relevant code - I'm responding to a mouse event, and I keep a class member of the path I'm editing.</p>
<pre><code>Path path = null;
private void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Point thisPoint = e.GetPosition(LayoutRoot);
if (path == null)
{
CreateNewPath(thisPoint);
path.LayoutUpdated += new EventHandler(path_LayoutUpdated);
}
else
{
path.AddLineElement(thisPoint);
}
}
private void CreateNewPath(Point startPoint)
{
path = new Path();
PathGeometry geometry = new PathGeometry();
path.Data = geometry;
PathFigureCollection figures = new PathFigureCollection();
geometry.Figures = figures;
PathFigure figure = new PathFigure();
figures.Add(figure);
figure.StartPoint = startPoint;
figure.Segments = new PathSegmentCollection();
path.Stroke = new SolidColorBrush(Colors.Red);
path.StrokeThickness = 2;
path.Stretch = Stretch.None;
LayoutRoot.Children.Add(path);
}
</code></pre>
<p><code>AddLineElement</code> is an extension method for the path class just to simplify:</p>
<pre><code>public static class PathHelper
{
public static void AddLineElement(this Path thePath, Point newPoint)
{
PathGeometry geometry = thePath.Data as PathGeometry;
geometry.Figures[0].Segments.Add(new LineSegment { Point = newPoint });
}
}
</code></pre>
<p>This is the minimum needed to reproduce the problem. If you run this code in a full WPF app it all works as expected. Mouse clicks add line elements which appear immediately. However, in <em>Silverlight</em> it's a different matter. The clicks appear to do nothing, even though stepping through the code shows that the data is getting added. But if you click a few times, then resize the browser, for example, the path elements appear. If you happen to have a button on the page as well, and move the mouse over, the path will appear.</p>
<p>I've tried all the obvious things, like calling <code>InvalidateMeasure</code> and <code>InvalidateArrange</code> on the <code>Path</code> (and on the parent grid) to no avail. </p>
<p>The only workaround I've got is to change a property on the path then change it back, which seems to be enough to get the rendering engine to draw the new path elements. I use <code>Opacity</code>. You have to set it to a different value, otherwise (I presume) the <code>PropertyChanged</code> event won't fire. It's a kludge, though.</p>
<p>Has anyone else played with paths in this way? I guess if I were putting other graphical elements on screen at the same time this wouldn't be an issue, so it's probably not something which will affect may people, but it would be good to know if there's a more correct way to do it.</p>
| [
{
"answer_id": 250873,
"author": "Bryant",
"author_id": 10893,
"author_profile": "https://Stackoverflow.com/users/10893",
"pm_score": 0,
"selected": false,
"text": "<UserControl x:Class=\"SilverlightTesting.Page\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" \... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6483/"
] |
249,867 | <p>I was wondering if in Java I would get any odd behaviour if I synchronise twice on the same object?</p>
<p>The scenario is as follows</p>
<pre><code>pulbic class SillyClassName {
object moo;
...
public void method1(){
synchronized(moo)
{
....
method2();
....
}
}
public void method2(){
synchronized(moo)
{
doStuff();
}
}
}
</code></pre>
<p>Both methods use the object and are synchronised on it. Will the second method when called by the first method stop because it's locked?</p>
<p>I don't think so because it's the same thread but I'm unsure of any other odd results that might occur.</p>
| [
{
"answer_id": 249888,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "synchronized"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] |
249,868 | <p>I'd like to have a page in php that normally displays information based on the GET request sent to it. However, I'd like for it to also be able to process certain POST requests. So, how can I tell if any data was sent by POST so I can act on it?</p>
| [
{
"answer_id": 249873,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": true,
"text": "$_SERVER['REQUEST_METHOD']"
},
{
"answer_id": 249879,
"author": "moo",
"author_id": 23107,
"author_profile"... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25680/"
] |
249,878 | <p>If it said "oneword", then I could write "#oneword", but what do I write when there is a space in the word?</p>
| [
{
"answer_id": 249887,
"author": "Philip Morton",
"author_id": 21709,
"author_profile": "https://Stackoverflow.com/users/21709",
"pm_score": 5,
"selected": false,
"text": "<p class=\"one two\">lalala</p>\n\n.one {\n color: black;\n}\n\n.two {\n font-weight: bold;\n} \n"
},
{... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] |
249,883 | <p>I have two XML files with two different XSD schemas and different namespaces. They have both an identical substructure. And now i need to copy that node (and all childs) from one XML document to the other one. </p>
<p>Clone would do, if the namespaces were the same. Is there a nice way to do it?
(The substructure will change later on - but will be kept identical.)</p>
| [
{
"answer_id": 250057,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": true,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test xmlns=\"http://tempuri.org/ns_old\">\n <child attrib=\"value\">text</c... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32726/"
] |
249,901 | <p>What is the equivalent to web controls in frameworks other than ASP.Net?</p>
<p>Specifically I'd like to know about Java, PHP and Ruby on Rails.</p>
<p>What are the relative merits/faults of each of these frameworks for web development?</p>
<p>I've had some exposure to ASP.Net and have been asked to look into developing an app that will have configurable controls on it. I know how I'd do this in ASP.Net, but it's to run on a linux box and in my experience Mono is not mature/stable when running ASP.Net.</p>
<p><strong>Clarification</strong></p>
<p>Basicly what I mean by webcontrols is a set of reusable componenet that I can initialize with various values.</p>
<p>So if for example I want to have a reusable component which draws a graph of some kind on the page. and i want to lay out several of these to graph different things.</p>
| [
{
"answer_id": 249949,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 1,
"selected": false,
"text": "<input>"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] |
249,916 | <p>The <code>java.net.InetAddress.GetByName(String host)</code> method can only return <code>A</code> records so to lookup other record types I need to be able to send DNS queries using the <code>dnsjava</code> library.</p>
<p>However that normally relies on being able to parse <code>/etc/resolv.conf</code> or similar to find the DNS server addresses and that doesn't work on Android.</p>
<p>The current DNS settings on Android can apparently only be obtained from within a shell by using the <code>getprop</code> command.</p>
<p>Can anyone tell me how to get those settings from Java other than by spawning a shell with <code>Runtime.exec()</code> and parsing the output from <code>getprop</code>?</p>
| [
{
"answer_id": 385806,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 3,
"selected": false,
"text": "WiFiManager wifi = (WifiManager) getSystemService(WIFI_SERVICE); \nDhcpInfo info = wifi.getDhcpInfo(); \n"
},
{
... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6782/"
] |
249,926 | <pre><code><a id="lblShowTimings"
runat="server"
title='<%# Eval("SHOW_Name") %>'
onclick='PopulateTicketDiv(<%#Eval("SHOW_ID") %>)'> <-- this is the problem
%#Eval("SHOW_Time") %>
</a>
</code></pre>
<p>Can Eval be passed as an argument to a javascript function?
If so whats the syntax?</p>
| [
{
"answer_id": 249986,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 6,
"selected": true,
"text": "onclick='<%# \"PopulateTicketDiv(\" +Eval(\"SHOW_ID\") + \" );\" %>'\n"
},
{
"answer_id": 250004,
"author": ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17447/"
] |
249,927 | <p>How can I restart(recycle) IIS Application Pool from C# (.net 2)?</p>
<p>Appreciate if you post sample code?</p>
| [
{
"answer_id": 249942,
"author": "dove",
"author_id": 30913,
"author_profile": "https://Stackoverflow.com/users/30913",
"pm_score": 7,
"selected": true,
"text": "// Gets the application pool collection from the server.\n[ModuleServiceMethod(PassThrough = true)]\npublic ArrayList GetAppli... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
249,928 | <p>I have an executable that is started by a windows service, this program will be run on a customers machine and will need to connect to a remote share to perform a particular task. This share is specified by the customer via a UI, so we do not know this in advance meaning it can't be "hard-coded", or the share mapped in advance.</p>
<p>Previously we required the customer to log on to their machine and run the executable on log-on , but we have always wanted to allow our program to run within a service and not require a log-in, primarily to make it easier for the customer and prevent any accidental log-outs shutting down our software. So this also means we don't know what local user accounts exist on a customers machine, so we have to start the service using the local system account.</p>
<p>We now have, as mentioned above, a wrapper service to start the executable and perform various tasks. This appears to work fine in most cases and accesses the underlying network fine - our software's purpose mainly involves capturing packets etc.</p>
<p>However, when the software tries to connect to a windows share (UNC name) it cannot connect. Whereas if the executable was started manually it connects fine.</p>
<p>The suggestions I have generally seen to resolve these kind of issues appear to all say use a user account as the system account cannot access network shares, but in our case this isn't possible. Is there any other way we could get this to work?</p>
<p><strong>Edit: I forgot to mention that this application could (and most commonly will be) run on Win2K not XP, and I think I'm right in saying that the Local Network account is not available before XP?</strong></p>
| [
{
"answer_id": 249951,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 0,
"selected": false,
"text": "cmd.exe"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15297/"
] |
249,968 | <p>I have written a web app in PHP which makes use of Ajax requests (made using YUI.util.Connect.asyncRequest).</p>
<p>Most of the time, this works fine. The request is sent with an <strong>X-Requested-With</strong> value of <strong>XMLHttpRequest</strong>. My PHP controller code uses apache_request_headers() to check whether an incoming request is Ajax or not and all works well.</p>
<p>But not always. Intermittently, I'm getting a situation where the Ajax request is sent (and Firebug confirms for me that the headers on the request include an X-Requested-With of XMLHttpRequest) but apache_request_headers() is not returning that header in its list.</p>
<p>The output from when I var_dump the apache_request_headers() is as follows (note the lack of X-</p>
<pre><code>'Host' => string 'peterh.labs.example.com' (length=26)
'User-Agent' => string 'Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3' (length=105)
'Accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' (length=63)
'Accept-Language' => string 'en-gb,en;q=0.5' (length=14)
'Accept-Encoding' => string 'gzip,deflate' (length=12)
'Accept-Charset' => string 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' (length=30)
'Keep-Alive' => string '300' (length=3)
'Connection' => string 'keep-alive' (length=10)
'Referer' => string 'http://peterh.labs.example.com/qmail/' (length=40)
'Cookie' => string 'WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6' (length=57)
'Pragma' => string 'no-cache' (length=8)
'Cache-Control' => string 'no-cache' (length=8)
</code></pre>
<p>But Firebug tells me:</p>
<pre><code>Request Headers:
Host peterh.labs.example.com
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3
Accept text/html,application/xhtml+xml,application/xml;q=0.9,**;q=0.8
Accept-Language en-gb,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
X-Requested-With XMLHttpRequest
Referer http://peterh.labs.example.com/qmail/
Cookie WORKFLOW_SESSION=55f9aff2051746851de453c1f776ad10745354f6
</code></pre>
<p>This mismatch is (apparently) intermittent when executing the same code. But I don't believe in "intermittent" when it comes to software! Help!</p>
| [
{
"answer_id": 250242,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 0,
"selected": false,
"text": "$_SERVER"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24106/"
] |
249,971 | <p>Having some Geometry data and a Transform how can the transform be applied to the Geometry to get a new Geometry with it's data transformed ?</p>
<p>Ex: I Have a Path object that has it's Path.Data set to a PathGeometry object, I want to tranform <strong>the points</strong> of the PathGeometry object <strong>in place</strong> using a transform, and not apply a transform to the PathGeometry that will be used at render time.</p>
<p>P.S. I know that the Transform class has a method <code>Point Transform.Transform(Point p)</code> that can be used to transform a Point but...is there a way to transform a arbitrary geometry at once?</p>
<p>Edit:
See my repply for a currently found <a href="https://stackoverflow.com/questions/249971/wpf-how-to-apply-a-generaltransform-to-a-geometry-data-and-return-the-new-geome#250913">solution</a></p>
| [
{
"answer_id": 250587,
"author": "Todd White",
"author_id": 30833,
"author_profile": "https://Stackoverflow.com/users/30833",
"pm_score": 5,
"selected": true,
"text": "PathGeometry geometry = new PathGeometry();\ngeometry.Figures.Add(new PathFigure(new Point(10, 10), new PathSegment[] { ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4685/"
] |
249,979 | <p>In the below code snippet can i replace char * to const char * and remove the strdup() function call and directly take the optarg value set by getopt()? I am advised to use const char * to skip the strdup function usage. Appreciate the help in advance.</p>
<pre><code>/* Code Snippet */
char *dir = NULL;
char *bld = NULL;
int chr;
while ( ( chr = getopt( argc, argv, "d:a:b:f:" ) ) != -1 ) {
switch ( chr ) {
case 'd': //Directory parameter
dir = strdup( optarg );
if (dir == NULL) { /*Error*/ }
case 'b': //Build parameter
bld = strdup( optarg );
if (bld == NULL) { /*Error*/ }
...other code...
}
}
</code></pre>
<p>I really don't understand the need for doing so.</p>
<p>Edit: Thanks for the answers. It was really helpful. I modified the code to const char * and skipped the strdup call.</p>
<p>Thanks,
Liju</p>
| [
{
"answer_id": 250587,
"author": "Todd White",
"author_id": 30833,
"author_profile": "https://Stackoverflow.com/users/30833",
"pm_score": 5,
"selected": true,
"text": "PathGeometry geometry = new PathGeometry();\ngeometry.Figures.Add(new PathFigure(new Point(10, 10), new PathSegment[] { ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18657/"
] |
249,987 | <p>We'd like to start our bug numbers to something other than 1 for a new Bugzilla installation. Is there a way to do this?</p>
| [
{
"answer_id": 250130,
"author": "Richard Morgan",
"author_id": 2258,
"author_profile": "https://Stackoverflow.com/users/2258",
"pm_score": 3,
"selected": false,
"text": "ALTER TABLE bugs AUTO_INCREMENT = 100;\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/249987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2258/"
] |
249,991 | <p>I am trying to read a custom (non-standard) CSS property, set in a stylesheet (not the inline style attribute) and get its value. Take this CSS for example:</p>
<pre><code>#someElement {
foo: 'bar';
}
</code></pre>
<p>I have managed to get its value with the currentStyle property in IE7:</p>
<pre><code>var element = document.getElementById('someElement');
var val = element.currentStyle.foo;
</code></pre>
<p>But currentStyle is MS-specific. So I tried getComputedStyle() in Firefox 3 and Safari 3:</p>
<pre><code>var val = getComputedStyle(element,null).foo;
</code></pre>
<p>...and it returns undefined. <strong>Does anyone know a cross-browser way of retreiving a custom CSS property value?</strong></p>
<p><em>(As you might have noticed, this isn't valid CSS. But it should work as long as the value follows the correct syntax. A better property name would be "-myNameSpace-foo" or something.)</em></p>
| [
{
"answer_id": 265566,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 2,
"selected": false,
"text": "var firstSS = document.styleSheets[0];\nvar firstSSRule = firstSS.rules[0];\nif(typeof(firstSSRule.style.bar) != 'undefine... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27741/"
] |
249,994 | <p>I have a dump of a windows service i made. The exception is that my code can't move a file (for some reason). Now, in my code there's a number of places where i move files around the filesystem. So, using Windbg, i'm trying to see the code where the exception occurs.</p>
<p>here's my !clrstack dump..</p>
<pre><code>0:016> !clrstack -p
OS Thread Id: 0xdf8 (16)
Child-SP RetAddr Call Site
0000000019edea70 0000064278a15e4f System.IO.__Error.WinIOError(Int32, System.String)
PARAMETERS:
errorCode = <no data>
maybeFullPath = <no data>
0000000019edead0 0000064280181ce5 System.IO.File.Move(System.String, System.String)
PARAMETERS:
sourceFileName = <no data>
destFileName = <no data>
0000000019edeb50 0000064280196532 MyClass.Foo.DoSomeStuffInHere(System.String)
PARAMETERS:
this = 0x0000000000c30aa8
filePathAndName = 0x0000000000d1aad0
</code></pre>
<p>now, this helps a lot...</p>
<pre><code>0:016> !do 0x0000000000d1aad0
Name: System.String
MethodTable: 00000642784365e8
EEClass: 000006427803e4f0
Size: 88(0x58) bytes
(C:\WINDOWS\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: C:\BlahBlahFolder\FooFolder\4469.jpg
Fields:
-snipped-
</code></pre>
<p>So i've figured out the file which failed to be moved. kewl. But i just want to see the code in this method MyClass.Foo.DoSomeStuffInHere(System.String) which calls File.Move(..). That method has lots of File.Move .. so i could put try / catches / debug / trace information .. but i'm hoping to be more efficient by using Windbg to help find this problem.</p>
<p>Any thoughts?</p>
| [
{
"answer_id": 265566,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 2,
"selected": false,
"text": "var firstSS = document.styleSheets[0];\nvar firstSSRule = firstSS.rules[0];\nif(typeof(firstSSRule.style.bar) != 'undefine... | 2008/10/30 | [
"https://Stackoverflow.com/questions/249994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
250,000 | <p>We all know that alerts are bad. If you didn't know it read <a href="http://www.codinghorror.com/blog/archives/000114.html" rel="nofollow noreferrer">this</a></p>
<p>Alerts are used to communicate with the user. So if we don't use them what is a good alternative? </p>
<p>I'd like to get a nice list of good alternatives to choose from when implementing something that requires user communications.</p>
<p>I'll give one myself as an example and for everyone to use:</p>
<p><strong>Case:</strong> we need to validate user input before we can proceed.</p>
<p><strong>Solution:</strong> instead of showing an alert box when user clicks ok/next/submit show a clearly styled (eg. red on a white bg) "frame" around/next to the user input that has the invalid input with an informative text on what is wrong. To make it easier on the user the input in question should gain focus and if necessary moved back into view.</p>
| [
{
"answer_id": 250181,
"author": "John Rudy",
"author_id": 14048,
"author_profile": "https://Stackoverflow.com/users/14048",
"pm_score": 0,
"selected": false,
"text": "Text"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/250000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22673/"
] |
250,001 | <p>Can someone define what exactly 'POCO' means? I am encountering the term more and more often, and I'm wondering if it is only about plain classes or it means something more?</p>
| [
{
"answer_id": 250006,
"author": "David Mohundro",
"author_id": 4570,
"author_profile": "https://Stackoverflow.com/users/4570",
"pm_score": 9,
"selected": true,
"text": "public class Person\n{\n public string Name { get; set; }\n\n public int Age { get; set; }\n}\n"
},
{
"a... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30726/"
] |
250,033 | <p>C++: Since a struct is a class with everything "public", are default -ctors created and called?</p>
<p>The reason I ask is to understand the overhead, if any, that C++ may have over C, when structs are used. An opinion I have heard is that classes have some overhead that structs don't, in C++, but I question this.</p>
| [
{
"answer_id": 250426,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 4,
"selected": false,
"text": "struct sPOD {\n int foo;\n float bar;\n char baz[23];\n};\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/250033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
250,037 | <p>I have a gridview and I need to sort its elements when the user clicks on the header.<br>
Its datasource is a List object.</p>
<p>The aspx is defined this way :</p>
<pre><code><asp:GridView ID="grdHeader" AllowSorting="true" AllowPaging="false"
AutoGenerateColumns="false" Width="780" runat="server" OnSorting="grdHeader_OnSorting" EnableViewState="true">
<Columns>
<asp:BoundField DataField="Entitycode" HeaderText="Entity" SortExpression="Entitycode" />
<asp:BoundField DataField="Statusname" HeaderText="Status" SortExpression="Statusname" />
<asp:BoundField DataField="Username" HeaderText="User" SortExpression="Username" />
</Columns>
</asp:GridView>
</code></pre>
<p>The code behind is defined this way :<br>
First load :</p>
<pre><code>protected void btnSearch_Click(object sender, EventArgs e)
{
List<V_ReportPeriodStatusEntity> items = GetPeriodStatusesForScreenSelection();
this.grdHeader.DataSource = items;
this.grdHeader.DataBind();
}
</code></pre>
<p>when the user clicks on headers :</p>
<pre><code>protected void grdHeader_OnSorting(object sender, GridViewSortEventArgs e)
{
List<V_ReportPeriodStatusEntity> items = GetPeriodStatusesForScreenSelection();
items.Sort(new Helpers.GenericComparer<V_ReportPeriodStatusEntity>(e.SortExpression, e.SortDirection));
grdHeader.DataSource = items;
grdHeader.DataBind();
}
</code></pre>
<p>My problem is that e.SortDirection is always set to Ascending.<br>
I have webpage with a similar code and it works well, e.SortDirection alternates between Ascending and Descending.</p>
<p>What did I do wrong ?</p>
| [
{
"answer_id": 250571,
"author": "Michael DeLorenzo",
"author_id": 1383003,
"author_profile": "https://Stackoverflow.com/users/1383003",
"pm_score": 1,
"selected": false,
"text": "List<V_ReportPeriodStatusEntity> items = GetPeriodStatusesForScreenSelection();"
},
{
"answer_id": 3... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28544/"
] |
250,055 | <p>I'd like to warn users when they <strong>try to close a browser window</strong> if they <strong>didn't save</strong> the changes they made in the web form.</p>
<p>I'm using ASP.NET 3.5 (with ASP.NET Ajax).</p>
<p>Is there a common solution which I could easily implement?</p>
<p><em>EDIT: maybe my question wasn't clear:</em> I am specifically looking for a way which integrates gracefully in the <strong>ASP.NET</strong> Server Controls methodology.</p>
| [
{
"answer_id": 250078,
"author": "Anders",
"author_id": 25515,
"author_profile": "https://Stackoverflow.com/users/25515",
"pm_score": 0,
"selected": false,
"text": "<body onunload=\"onPageUnload();\">"
},
{
"answer_id": 250086,
"author": "Eoin Campbell",
"author_id": 3015... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6461/"
] |
250,062 | <p>I have been hearing a lot about Ruby and possibly even Javascript being "true" object oriented languages as opposed to C++ and C# which are class oriented (or template based) languages. What is meant by true OO and what are the advantages of this over the class/template approach?</p>
| [
{
"answer_id": 250098,
"author": "Firas Assaad",
"author_id": 23153,
"author_profile": "https://Stackoverflow.com/users/23153",
"pm_score": 5,
"selected": true,
"text": "1.to_s"
},
{
"answer_id": 277066,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31188/"
] |
250,082 | <p>I have a makefile template to compile a single DLL (for a plugin system).
The makefile of the user looks like this:</p>
<pre><code>EXTRA_SRCS=file1 file2
include makefile.in
</code></pre>
<p>In the <code>makefile.in</code> I have:</p>
<pre><code>plugin.dll: plugin.os $(patsubst %,%.os,$(EXTRA_SRCS))
</code></pre>
<p>Where <code>plugin.os</code> is the main C++ file to be compiled. Btw, the files ending is <code>.os</code> are the object files compiled for shared library (i.e. using the <code>-fpic</code> option with <code>gcc</code>)</p>
<p>Now, the problem is that the extra sources will probably (but not necessarily) be header files. Ideally I would like to add them as dependencies for the target <code>plugin.os</code> and the <code>file.cpp</code>, but only if they exist.</p>
<p>The method should work for both windows and linux, or at least be adaptable to each. However, I only use the GNU version of make.</p>
| [
{
"answer_id": 250163,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 5,
"selected": true,
"text": "$(wildcard *.h)\n"
},
{
"answer_id": 250795,
"author": "m0j0",
"author_id": 31319,
"author_profile": "h... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7136/"
] |
250,096 | <p>I'm trying to code opposite action to this:</p>
<pre><code>std::ostream outs; // properly initialized of course
std::set<int> my_set; // ditto
outs << my_set.size();
std::copy( my_set.begin(), my_set.end(), std::ostream_iterator<int>( outs ) );
</code></pre>
<p>it should be something like this:</p>
<pre><code>std::istream ins;
std::set<int>::size_type size;
ins >> size;
std::copy( std::istream_iterator<int>( ins ), std::istream_iterator<int>( ins ) ???, std::inserter( my_set, my_set.end() ) );
</code></pre>
<p>But I'm stuck with the 'end' iterator -- input interators can't use std::advance and neither I can use two streams with the same source...</p>
<p>Is there any elegant way how to solve this? Of course I can use for loop, but maybe there's something nicer :)</p>
| [
{
"answer_id": 250380,
"author": "Dominik Grabiec",
"author_id": 3719,
"author_profile": "https://Stackoverflow.com/users/3719",
"pm_score": 2,
"selected": false,
"text": "std::istream ins;\nstd::set<int> my_set;\nstd::vector<int> my_vec;\n\nstruct read_functor\n{\n read_functor(std::... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21009/"
] |
250,134 | <p>What is the difference between <code>int *a[3]</code> and <code>int (*a)[3]</code>?</p>
| [
{
"answer_id": 250164,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 4,
"selected": false,
"text": "int a[3]"
},
{
"answer_id": 250174,
"author": "CAdaker",
"author_id": 30579,
"author_profile": "... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
250,137 | <p>I have the following legacy code:</p>
<pre><code>public class MyLegacyClass
{
private static final String jndiName = "java:comp/env/jdbc/LegacyDataSource"
public static SomeLegacyClass doSomeLegacyStuff(SomeOtherLegacyClass legacyObj)
{
// do stuff using jndiName
}
}
</code></pre>
<p>This class is working in a J2EE-Container.</p>
<p>Now I would like to test the class outside of the container.</p>
<p>What is the best strategy?
Refactoring is basically allowed.</p>
<p>Accessing the LegacyDataSource is allowed (the test does not have to be a "pure" unit-test).</p>
<p>EDIT: Introducing additional runtime-frameworks is not allowed.</p>
| [
{
"answer_id": 250272,
"author": "David Santamaria",
"author_id": 24097,
"author_profile": "https://Stackoverflow.com/users/24097",
"pm_score": 1,
"selected": false,
"text": "DataSource datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);\n"
},
{
"answer_id": 25063... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32749/"
] |
250,151 | <p>When I see Lua, the only thing I ever read is "great for embedding", "fast", "lightweight" and more often than anything else: "World of Warcraft" or in short "WoW".</p>
<p>Why is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?</p>
<p>Lua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a "Desktop scripting-language" to automate tasks? For example:</p>
<ul>
<li>Renaming a bunch of files</li>
<li>Download some files from the web</li>
<li>Webscraping</li>
</ul>
<p>Is it the lack of the standard library?</p>
| [
{
"answer_id": 326660,
"author": "Norman Ramsey",
"author_id": 41661,
"author_profile": "https://Stackoverflow.com/users/41661",
"pm_score": 3,
"selected": false,
"text": "osutil"
},
{
"answer_id": 1537777,
"author": "Arthur Reutenauer",
"author_id": 46495,
"author_pr... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32756/"
] |
250,157 | <p>When you have a complex property, should you instantiate it or leave it to the user to instantiate it?</p>
<p>For example (C#)</p>
<p>A)</p>
<pre><code> class Xyz{
List<String> Names {get; set;}
}
</code></pre>
<p>When I try to use, I have to set it.</p>
<pre><code>...
Xyz xyz = new Xyz();
xyz.Name = new List<String>();
xyz.Name.Add("foo");
...
</code></pre>
<p>Where as if I modify the code</p>
<p>B)</p>
<pre><code> class Xyz{
public Xyz(){
Names = new List<String>();
}
List<String> Names {get; }
}
</code></pre>
<p>which in this case, I can make the List read-only.</p>
<p>Another scenario might arise, I suppose where you would intentionally not want to set it. For example in</p>
<p>C)</p>
<pre><code> class Xyz{
String Name {get; set;}
}
</code></pre>
<p>I would thing it bad practice to initialize.</p>
<p>Are there some rules of thumb for such scenarios?</p>
| [
{
"answer_id": 250193,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 2,
"selected": false,
"text": "class XYZ \n{\n public XYZ () { Names = new List<string>(); }\n public List<string> Names { get; private set; }\n}\... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017/"
] |
250,166 | <p>I have an application that I'm trying to wrap into a jar for easier deployment. The application compiles and runs fine (in a Windows cmd window) when run as a set of classes reachable from the CLASSPATH. But when I jar up my classes and try to run it with java 1.6 in the same cmd window, I start getting exceptions:</p>
<pre><code>C:\dev\myapp\src\common\datagen>C:/apps/jdk1.6.0_07/bin/java.exe -classpath C:\myapp\libs\commons -logging-1.1.jar -server -jar DataGen.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.example.myapp.fomc.common.datagen.DataGenerationTest.<clinit>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 1 more
</code></pre>
<p>The funny thing is, the offending LogFactory seems to be in commons-logging-1.1.jar, which is in the class path specified. The jar file (yep, it's really there):</p>
<pre><code>C:\dev\myapp\src\common\datagen>dir C:\myapp\libs\commons-logging-1.1.jar
Volume in drive C is Local Disk
Volume Serial Number is ECCD-A6A7
Directory of C:\myapp\libs
12/11/2007 11:46 AM 52,915 commons-logging-1.1.jar
1 File(s) 52,915 bytes
0 Dir(s) 10,956,947,456 bytes free
</code></pre>
<p>The contents of the commons-logging-1.1.jar file:</p>
<pre><code>C:\dev\myapp\src\common\datagen>jar -tf C:\myapp\libs\commons-logging-1.1.jar
META-INF/
META-INF/MANIFEST.MF
org/
org/apache/
org/apache/commons/
org/apache/commons/logging/
org/apache/commons/logging/impl/
META-INF/LICENSE.txt
META-INF/NOTICE.txt
org/apache/commons/logging/Log.class
org/apache/commons/logging/LogConfigurationException.class
org/apache/commons/logging/LogFactory$1.class
org/apache/commons/logging/LogFactory$2.class
org/apache/commons/logging/LogFactory$3.class
org/apache/commons/logging/LogFactory$4.class
org/apache/commons/logging/LogFactory$5.class
org/apache/commons/logging/LogFactory.class
... (more classes in commons-logging-1.1 ...)
</code></pre>
<p>Yep, commons-logging has the LogFactory class. And finally, the contents of my jar's manifest:</p>
<pre><code>Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 10.0-b23 (Sun Microsystems Inc.)
Main-Class: com.example.myapp.fomc.common.datagen.DataGenerationTest
Class-Path: commons-logging-1.1.jar commons-lang.jar antlr.jar toplink
.jar GroboTestingJUnit-1.2.1-core.jar junit.jar
</code></pre>
<p>This has stumped me, and any coworkers I've bugged for more than a day now. Just to cull the answers, for now at least, third party solutions to this are probably out due to licensing restrictions and company policies (e.g.: tools for creating exe's or packaging up jars). The ultimate goal is to create a jar that can be copied from my development Windows box to a Linux server (with any dependent jars) and used to populate a database (so classpaths may wind up being different between development and deployment environments). Any clues to this mystery would be greatly appreciated!</p>
| [
{
"answer_id": 8838405,
"author": "g_tom",
"author_id": 1145934,
"author_profile": "https://Stackoverflow.com/users/1145934",
"pm_score": 5,
"selected": false,
"text": "-jar"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/250166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13140/"
] |
250,175 | <p>When writing my own auto updater, is there a general framework that I should be following?</p>
<p>A while ago I was reading up on how one should create a 'boot strapper' that will load first before the main application (since a running appilation can't be updated due to file locks etc.)</p>
<p>So any tips/best practices for this?</p>
| [
{
"answer_id": 1220670,
"author": "Cheeso",
"author_id": 48082,
"author_profile": "https://Stackoverflow.com/users/48082",
"pm_score": 1,
"selected": false,
"text": " _Updater = new AppUpdater.SimpleAppUpdater(_MyManifestUrl);\n _Updater.Startup(App.CommandLineArgs);\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/250175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
250,189 | <p>I'm currently installing and configuring an open source project on a test server. I've been well trained to use source control, and I want to make sure everything I do is managed properly (both for me, the sole dev/admin, and for future maintaners). The open source project is available as a source download or by svn checkout.</p>
<p>I want to have my own source controlled version of the project. I don't intend to be changing the (java servlet) code much (if at all), but there are configurations, XML files, XSL, CSS, etc. all involved that I definitely want to be source controlled.</p>
<p>Should I go ahead and just make my own local repository of all of the source code? Should I try to only control the files that I need to change? In that case I would want the directory structure to match, so I could do checkouts directly to the build directories.</p>
| [
{
"answer_id": 1220670,
"author": "Cheeso",
"author_id": 48082,
"author_profile": "https://Stackoverflow.com/users/48082",
"pm_score": 1,
"selected": false,
"text": " _Updater = new AppUpdater.SimpleAppUpdater(_MyManifestUrl);\n _Updater.Startup(App.CommandLineArgs);\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/250189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8092/"
] |
250,191 | <p>I have a menu of product brands that I want to split over 4 columns. So if I have 39 brands, then I want the maximum item count for each column to be 10 (with a single gap in the last column. Here's how I'm calculating the item count for a column (using C#):</p>
<pre><code>int ItemCount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(BrandCount) / 4m));
</code></pre>
<p>All that conversion seems really ugly to me. Is there a better way to do math on integers in C#?</p>
| [
{
"answer_id": 250205,
"author": "GavinCattell",
"author_id": 21644,
"author_profile": "https://Stackoverflow.com/users/21644",
"pm_score": 3,
"selected": false,
"text": "ItemCount = BrandCount / 4;\nif (BrandCount%4 > 0) ItemCount++;\n"
},
{
"answer_id": 250206,
"author": "k... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203/"
] |
250,197 | <p>I am attempting to compose a style sheet that, given an XML input (obviously) and a parameter that specifies a "target", will produce a list of commands that match that target. Here is the style sheet as written:</p>
<pre><code><?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:param name="target" select="cora_cmd"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="command/program">
<xsl:if test="@name=$target">
<xsl:message terminate="no">found match <xsl:value-of select="$target"/> </xsl:message>
<xi:include xmlns:xi="http://www.w3.org/2003/XInclude">
<xsl:attribute name="href"><xsl:value-of select="../@help"/></xsl:attribute>
</xi:include>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
</code></pre>
<p>I am invoking xsltproc to execute this style sheet as follows:</p>
<pre><code>xsltproc --param target cora_cmd gen-commands.xsl commands.xml
</code></pre>
<p>The problem that I am encountering is that the parameter value for target does not seem to get set. At least the name that comes from the message appears to be an empty string and the test for xsl:if always fails. I am certain that this is due to some bone-headed mistake on my part but I've yet to recognise it. Does anybody know what I've done wrong?</p>
| [
{
"answer_id": 250337,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 6,
"selected": true,
"text": "xsltproc --stringparam target cora_cmd gen-commands.xsl commands.xml\n"
},
{
"answer_id": 259119,
"author": "ChuckB... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19674/"
] |
250,207 | <p>How to host the WCF service in windows service?</p>
<p>Thanks
Sekar</p>
| [
{
"answer_id": 250231,
"author": "John Sibly",
"author_id": 1078,
"author_profile": "https://Stackoverflow.com/users/1078",
"pm_score": 3,
"selected": false,
"text": " [RunInstaller(true)]\n public class ProjectInstaller : Installer\n {\n }\n"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/250207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
250,209 | <p>I'm relatively new to the Python world, but this seems very straight forward.</p>
<p>Google is yelling at me that this code needs to be optimized:</p>
<pre><code>class AddLinks(webapp.RequestHandler):
def post(self):
# Hash the textarea input to generate pseudo-unique value
hash = md5.new(self.request.get('links')).hexdigest()
# Seperate the input by line
allLinks = self.request.get('links').splitlines()
# For each line in the input, add to the database
for x in allLinks:
newGroup = LinkGrouping()
newGroup.reference = hash
newGroup.link = x
newGroup.put()
# testing vs live
#baseURL = 'http://localhost:8080'
baseURL = 'http://linkabyss.appspot.com'
# Build template parameters
template_values = {
'all_links': allLinks,
'base_url': baseURL,
'reference': hash,
}
# Output the template
path = os.path.join(os.path.dirname(__file__), 'addLinks.html')
self.response.out.write(template.render(path, template_values))
</code></pre>
<p>The dashboard is telling me that this is using a ton of CPU.</p>
<p>Where should I look for improvements?</p>
| [
{
"answer_id": 250294,
"author": "monkut",
"author_id": 24718,
"author_profile": "https://Stackoverflow.com/users/24718",
"pm_score": 2,
"selected": false,
"text": "unsplitlinks = self.request.get('links')\n"
},
{
"answer_id": 250322,
"author": "Andre Bossard",
"author_id... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9094/"
] |
250,214 | <p>I am updating a VBA program (excel). At startup the program checks if it can find a directory which is on the office file server using:</p>
<pre><code>FileSystemObject.FolderExists("\\servername\path")
</code></pre>
<p>If this is not found the program switches to offline mode and saves its output to the local hard disk (for later transfer), instead of directly to the fileserver. </p>
<p>This works OK, It's very quick if the computer can reach the path, however it can sometimes take a while (up to one minute) for the call to FolderExists to complete/time-out, especially if there is a network connection open but the required path does not exist (i.e. we are connected to some other LAN).</p>
<p>My Question(s):</p>
<ol>
<li><p>is there a quicker/better way to check for the existence of a network path using VBA?</p></li>
<li><p>is there a way to have the user cancel the search done by FolderExists() when (s)he knows it cannot succeed because they're not in the office. I.e. is there some way to prematurely exit FolderExists() (or any other function call for that matter)</p></li>
</ol>
<p>I want the solution to have as little user input as possible, which is why the check is done automatically, rather than just asking the user if (s)he's in the office or not in the first place.</p>
| [
{
"answer_id": 11306581,
"author": "Rob Gibson",
"author_id": 1498067,
"author_profile": "https://Stackoverflow.com/users/1498067",
"pm_score": 0,
"selected": false,
"text": "Dir"
}
] | 2008/10/30 | [
"https://Stackoverflow.com/questions/250214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32763/"
] |
250,216 | <p>Is there a good way to determine if a person has a popup blocker enabled? I need to maintain a web application that unfortunately has tons of popups throughout it and I need to check if the user has popup blockers enabled.</p>
<p>The only way I've found to do this is to open a window from javascript, check to see if it's open to determine if a blocker is enabled and then close it right away.</p>
<p>This is slightly annoying since users who do not have it enabled see a small flash on the screen as the window opens and closes right away.</p>
<p>Are there any other non-obtrusive methods for accomplishing this?</p>
| [
{
"answer_id": 250267,
"author": "Andre Bossard",
"author_id": 21027,
"author_profile": "https://Stackoverflow.com/users/21027",
"pm_score": 4,
"selected": true,
"text": "var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');\nif(mine)\n var popUpsBlocked = false... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2849/"
] |
250,228 | <p>I have a page with many forms on it. could be 1..200. None of these forms have buttons and they are built programatically. I am using jquery to submit all the forms that are checked.</p>
<pre><code> function FakeName()
{
$("input:checked").parent("form").submit();
}
</code></pre>
<p>My forms look like:</p>
<pre><code> <form name="FakeForm<%=i%>" action="javascript:void%200" onSubmit="processRow(<%=i%>)" method="post" style="margin:0px;">
<input type="checkbox" name="FakeNameCheck" value="FakeNameCheck"/>
<input type="hidden" name="FakeNum" value="<%= FakeNum%>"/>
<input type="hidden" name="FakeId" value="<%=FakeIdr%>"/>
<input type="hidden" name="FakeAmt" value="<%=FakeAmount%>"/>
<input type="hidden" name="FakeTrans" value="FakeTrans"/>
</form>
</code></pre>
<p>Note: action is set to "javascript:void%200" so that it posts to a fake page. I want to handle my own posting in processRow.</p>
<p>OnSubmit never gets called and therefore ProcessRow never gets called. </p>
<p>Obviously all the names of the functions and variables have been changed to protect their identity :D</p>
<p>How can I get a function in each form to fire when I call submit programmatically.</p>
| [
{
"answer_id": 250259,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 3,
"selected": true,
"text": "onsubmit"
},
{
"answer_id": 250315,
"author": "Brian G",
"author_id": 3208,
"author_profile": "https://S... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] |
250,238 | <p>We have a git project which has quite a big history.</p>
<p>Specifically, early in the project there were quite a lot of binary resource files in the project, these have now been removed as they're effectively external resources.</p>
<p>However, the size of our repository is >200MB (the total checkout is currently ~20MB) due to having these files previously committed.</p>
<p>What we'd like to do is "collapse" the history so that the repository appears to have been created from a later revision than it was. For example</p>
<pre><code>1-----2-----3-----4-----+---+---+
\ /
+-----+---+---+
</code></pre>
<ol>
<li>Repository created</li>
<li>Large set of binary files added</li>
<li>Large set of binary files removed</li>
<li>New intended 'start' of repository</li>
</ol>
<p>So effectively we want to lose the project history before a certain point. At this point there is only one branch, so there's no complication with trying to deal with multiple start points etc. However we don't want to lose all of the history and start a new repository with the current version.</p>
<p>Is this possible, or are we doomed to have a bloated repository forever?</p>
| [
{
"answer_id": 250365,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 3,
"selected": false,
"text": "git-fast-export"
},
{
"answer_id": 251252,
"author": "Pat Notz",
"author_id": 825,
"author_profile": "... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31582/"
] |
250,244 | <p>I have a simple application with the following code:</p>
<pre><code> FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles();
List<Thread> threads = new List<Thread>(files.Length);
foreach (FileInfo f in files)
{
Thread t = new Thread(delegate()
{
Console.WriteLine(f.FullName);
});
threads.Add(t);
}
foreach (Thread t in threads)
t.Start();
</code></pre>
<p>Lets say in 'I=initialDirectory' directory I have 3 files. This application should then create 3 threads, with each thread printing off one of the file names; however, instead each thread will print off the name of the last file in the 'files' array.</p>
<p>Why is this? Why is the current file 'f' variable not getting setup in the anonymous method correctly?</p>
| [
{
"answer_id": 250249,
"author": "Stewart Johnson",
"author_id": 6408,
"author_profile": "https://Stackoverflow.com/users/6408",
"pm_score": 5,
"selected": true,
"text": "f"
},
{
"answer_id": 250260,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "htt... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30006/"
] |
250,256 | <p>I have problem in some JavaScript that I am writing where the Switch statement does not seem to be working as expected.</p>
<pre><code>switch (msg.ResultType) {
case 0:
$('#txtConsole').val("Some Val 0");
break;
case 1:
$('#txtConsole').val("Some Val 1");
break;
case 2:
$('#txtConsole').text("Some Val 2");
break;
}
</code></pre>
<p>The ResultType is an integer value 0-2 and I can see that in FireBug. In all cases, the switch transfers control to the final break statement which means all the logic is completely skipped. What am I missing?</p>
| [
{
"answer_id": 250279,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "switch (msg.ResultType-0) {\n case 0:\n $('#txtConsole').val(\"Some Val 0\");\n break;\n case 1:\n $('#txtCon... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4820/"
] |
250,271 | <p>How can I get the start and end positions of all matches using the <code>re</code> module? For example given the pattern <code>r'[a-z]'</code> and the string <code>'a1b2c3d4'</code> I'd want to get the positions where it finds each letter. Ideally, I'd like to get the text of the match back too.</p>
| [
{
"answer_id": 250303,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 9,
"selected": true,
"text": "import re\np = re.compile(\"[a-z]\")\nfor m in p.finditer('a1b2c3d4'):\n print(m.start(), m.group())\n"
},
{
... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] |
250,283 | <p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p>
<pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) )
</code></pre>
<p>which is a hack, and which doesn't work outside Linux-like systems, and which needs help from the Pexpect module to avoid password prompts unless you already have passwordless SSH set up to the remote host.</p>
<p>I'm aware of Twisted's <code>conch</code>, but I'd prefer to avoid implementing scp myself via low-level ssh modules.</p>
<p>I'm aware of <code>paramiko</code>, a Python module that supports SSH and SFTP; but it doesn't support SCP.</p>
<p>Background: I'm connecting to a router which doesn't support SFTP but does support SSH/SCP, so SFTP isn't an option.</p>
<p><strong>EDIT</strong>:
This is a duplicate of <a href="https://stackoverflow.com/questions/68335/how-do-i-copy-a-file-to-a-remote-server-in-python-using-scp-or-ssh">How to copy a file to a remote server in Python using SCP or SSH?</a>. <strong>However</strong>, that question doesn't give an scp-specific answer that deals with keys from within Python. I'm hoping for a way to run code kind of like</p>
<pre><code>import scp
client = scp.Client(host=host, user=user, keyfile=keyfile)
# or
client = scp.Client(host=host, user=user)
client.use_system_keys()
# or
client = scp.Client(host=host, user=user, password=password)
# and then
client.transfer('/etc/local/filename', '/etc/remote/filename')
</code></pre>
| [
{
"answer_id": 250786,
"author": "Pat Notz",
"author_id": 825,
"author_profile": "https://Stackoverflow.com/users/825",
"pm_score": 4,
"selected": false,
"text": "# This connects to the openbsd ftp site and\n# downloads the recursive directory listing.\nimport pexpect\nchild = pexpect.sp... | 2008/10/30 | [
"https://Stackoverflow.com/questions/250283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4105/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.