qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
252,260
<p>I am trying to use reflector.InvokeMethod to invoke a function with an optional parameter. The function looks like this: </p> <pre><code>Private Function DoSomeStuff(ByVal blah1 as string, ByVal blah2 as string, Optional ByVal blah3 as string = "45") as boolean 'stuff end function </code></pre> <p>and I'm Invoking...
[ { "answer_id": 319190, "author": "codeConcussion", "author_id": 1321, "author_profile": "https://Stackoverflow.com/users/1321", "pm_score": 0, "selected": false, "text": "<p>I would overload the <strong>DoSomeStuff</strong> method rather than use an optional parameter...</p>\n\n<pre><cod...
2008/10/31
[ "https://Stackoverflow.com/questions/252260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to use reflector.InvokeMethod to invoke a function with an optional parameter. The function looks like this: ``` Private Function DoSomeStuff(ByVal blah1 as string, ByVal blah2 as string, Optional ByVal blah3 as string = "45") as boolean 'stuff end function ``` and I'm Invoking it like this: ``` Dim re...
The Visual Basic compiler actually substitutes the optional parameter values into the calling code. So if your actual code was: ``` DoSomeStuff(blah1, blah2) ``` Visual Basic would have emitted IL code equivalent to: ``` DoSomeStuff(blah1, blah2, "45") ``` To know what that last parameter is, you'll need to get a r...
252,267
<p>The code at the end produces a compile error:</p> <pre><code>NotApplicable.java:7: run() in cannot be applied to (int) run(42); ^ 1 error </code></pre> <p>The question is why? Why does javac think I am calling run(), and does not find run(int bar)? It correctly called foo(int bar...
[ { "answer_id": 252276, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 0, "selected": false, "text": "<p>This is because <code>run</code> is being re-declared when you enter the <code>new Runnable() {}</code> scope. All prev...
2008/10/31
[ "https://Stackoverflow.com/questions/252267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
The code at the end produces a compile error: ``` NotApplicable.java:7: run() in cannot be applied to (int) run(42); ^ 1 error ``` The question is why? Why does javac think I am calling run(), and does not find run(int bar)? It correctly called foo(int bar). Why do I have to use NotA...
The explanation for the behavior of your code sample is that `this` is defined to be the class that you are currently "most" inside of. In this case, you are "most" inside the anonymous inner class that subclasses runnable and there is no method which matches `run(int)`. To broaden your search you specify which `this` ...
252,274
<p>I open gmail, click on an inbox item, and look at source of the page. It doesn't look like there isn't any proper html to relate to what is shown on the actual page.</p> <p>How is the source getting processed into the actual page? Is there some javascript processing this information?</p>
[ { "answer_id": 252306, "author": "GalacticCowboy", "author_id": 29638, "author_profile": "https://Stackoverflow.com/users/29638", "pm_score": -1, "selected": false, "text": "<p>In IE you get a blank page if you right-click and \"View Source\". If you use the Page menu > View Source, you...
2008/10/31
[ "https://Stackoverflow.com/questions/252274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I open gmail, click on an inbox item, and look at source of the page. It doesn't look like there isn't any proper html to relate to what is shown on the actual page. How is the source getting processed into the actual page? Is there some javascript processing this information?
GMail uses a large amount of java script to make its pages work. This javascript is manipulating the HTML DOM. If you look at the page source you aren't seeing the current contents of the DOM. You need to use a tool that will show you the HTML DOM. I use Opera Dragonfly, but there are plenty of others for other browse...
252,282
<p>I'm working on an import (from Excel) dialog to select ranges of cells.</p> <p>When the range is selected, I use the event sink to catch the event and highlight the first row and first column.</p> <p>I need to unhighlight the previous selection's first row and column. I don't think it's safe to just get the selec...
[ { "answer_id": 252439, "author": "dbb", "author_id": 25675, "author_profile": "https://Stackoverflow.com/users/25675", "pm_score": 3, "selected": true, "text": "<p>If you were working in Excel VBA, you could </p>\n\n<pre><code>Set Rng = Application.Selection\n</code></pre>\n\n<p>where Rn...
2008/10/31
[ "https://Stackoverflow.com/questions/252282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965047/" ]
I'm working on an import (from Excel) dialog to select ranges of cells. When the range is selected, I use the event sink to catch the event and highlight the first row and first column. I need to unhighlight the previous selection's first row and column. I don't think it's safe to just get the selected range at the t...
If you were working in Excel VBA, you could ``` Set Rng = Application.Selection ``` where Rng is an Excel Range object. I imagine you could replicate this object from where you are. Or you could store the cell address in a string variable as you suggested, which of course doesn't require any objects. Unfortunate...
252,286
<p>This sounds dumb, but I can't get it to work. I think i just dont' understand the difference between <code>%%v, %v% and %v</code></p> <p>Here's what I'm trying to do:</p> <pre><code>for %%v in (*.flv) do ffmpeg.exe -i "%%v" -y -f mjpeg -ss 0.001 -vframes 1 -an "%%v.jpg" </code></pre> <p>This successfully generate...
[ { "answer_id": 252308, "author": "WPWoodJr", "author_id": 32122, "author_profile": "https://Stackoverflow.com/users/32122", "pm_score": 4, "selected": true, "text": "<p>Use %%~nV to get the filename only.</p>\n" }, { "answer_id": 252316, "author": "Jeff Hillman", "author_...
2008/10/31
[ "https://Stackoverflow.com/questions/252286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10680/" ]
This sounds dumb, but I can't get it to work. I think i just dont' understand the difference between `%%v, %v% and %v` Here's what I'm trying to do: ``` for %%v in (*.flv) do ffmpeg.exe -i "%%v" -y -f mjpeg -ss 0.001 -vframes 1 -an "%%v.jpg" ``` This successfully generates a thumbnail for each of the movies, but th...
Use %%~nV to get the filename only.
252,287
<p>Here's my setup: a Mac, running OS X Tiger. Windows XP running in a virtual machine (Parallels). Windows XP has my Mac home directory mapped as a network drive.</p> <p>I have two files in a directory of my Mac home directory:</p> <h3>foo.py</h3> <pre><code>pass </code></pre> <h3>test.py</h3> <pre><code>import...
[ { "answer_id": 252299, "author": "Alex Coventry", "author_id": 1941213, "author_profile": "https://Stackoverflow.com/users/1941213", "pm_score": 2, "selected": false, "text": "<p>Add import sys; print sys.path to the start of test.py. See what it prints out in the failing case. If \".\...
2008/10/31
[ "https://Stackoverflow.com/questions/252287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15154/" ]
Here's my setup: a Mac, running OS X Tiger. Windows XP running in a virtual machine (Parallels). Windows XP has my Mac home directory mapped as a network drive. I have two files in a directory of my Mac home directory: ### foo.py ``` pass ``` ### test.py ``` import foo ``` If I run test.py from within my virtua...
Add import sys; print sys.path to the start of test.py. See what it prints out in the failing case. If "." isn't on the list, that may be your problem.
252,297
<p>I was making the following call:</p> <pre><code>result = RegOpenKeyEx(key, s, 0, KEY_READ, &amp;key); </code></pre> <p>(C++, Visual Studio 5, Vista 64bit).</p> <p>It is failing with error code 2 ("File not found") even though "<code>regedit</code>" shows that the key exists. This code has always worked on 32bit ...
[ { "answer_id": 252302, "author": "Tim Cooper", "author_id": 10592, "author_profile": "https://Stackoverflow.com/users/10592", "pm_score": 7, "selected": true, "text": "<p>I discovered that I could solve my problem using the flag: <code>KEY_WOW64_64KEY</code> , as in:</p>\n\n<pre><code...
2008/10/31
[ "https://Stackoverflow.com/questions/252297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10592/" ]
I was making the following call: ``` result = RegOpenKeyEx(key, s, 0, KEY_READ, &key); ``` (C++, Visual Studio 5, Vista 64bit). It is failing with error code 2 ("File not found") even though "`regedit`" shows that the key exists. This code has always worked on 32bit XP. Why is it "file not found" when it clearly is...
I discovered that I could solve my problem using the flag: `KEY_WOW64_64KEY` , as in: ``` result = RegOpenKeyEx(key, s, 0, KEY_READ|KEY_WOW64_64KEY, &key); ``` For a full explanation: [32-bit and 64-bit Application Data in the Registry](http://msdn.microsoft.com/en-us/library/ms724072(VS.85).aspx)
252,304
<p>In our data access layer at work we have this standard implementation where the class is accessed through a singleton public property which looks something like this:</p> <pre><code>public static CustomerController Instance { get { lock(singletonLock) ...
[ { "answer_id": 252313, "author": "goldenratio", "author_id": 31307, "author_profile": "https://Stackoverflow.com/users/31307", "pm_score": 3, "selected": true, "text": "<p>EDIT: Oh whoops I didn't catch the \"Data Access Layers\" part. But I have an example of that too: If your multithre...
2008/10/31
[ "https://Stackoverflow.com/questions/252304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
In our data access layer at work we have this standard implementation where the class is accessed through a singleton public property which looks something like this: ``` public static CustomerController Instance { get { lock(singletonLock) { ...
EDIT: Oh whoops I didn't catch the "Data Access Layers" part. But I have an example of that too: If your multithreaded app funnels all of its' database calls through a singleton class, only one thread will ever access the database at once, avoiding race conditions. If you have a logging mechanism in a multi-threaded a...
252,323
<p>I have a program that monitors debug messages and I have tried using a TextBox and appended the messages to it but it doesn't scale very well and slows way down when the number of messages gets large. I then tried a ListBox but the scrolling was snapping to the top when appending new messages. It also doesn't allow...
[ { "answer_id": 252326, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 1, "selected": false, "text": "<p>set the selectedindex of the listbox to the last element to make it scroll to the bottom</p>\n\n<p>also, limit the...
2008/10/31
[ "https://Stackoverflow.com/questions/252323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32958/" ]
I have a program that monitors debug messages and I have tried using a TextBox and appended the messages to it but it doesn't scale very well and slows way down when the number of messages gets large. I then tried a ListBox but the scrolling was snapping to the top when appending new messages. It also doesn't allow for...
RichTextBox has an AppendText method that is fast. And it can handle large text well. I believe it is the best for what you need.
252,355
<p>After I read a bunch of LINQ related stuff, I suddenly realized that no articles introduce how to write asynchronous LINQ query. </p> <p>Suppose we use LINQ to SQL, below statement is clear. However, if the SQL database responds slowly, then the thread using this block of code would be hindered.</p> <pre><code>var...
[ { "answer_id": 252426, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 6, "selected": true, "text": "<p>While LINQ doesn't really have this per se, the framework itself does... You can easily roll your own asynchron...
2008/10/31
[ "https://Stackoverflow.com/questions/252355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
After I read a bunch of LINQ related stuff, I suddenly realized that no articles introduce how to write asynchronous LINQ query. Suppose we use LINQ to SQL, below statement is clear. However, if the SQL database responds slowly, then the thread using this block of code would be hindered. ``` var result = from item i...
While LINQ doesn't really have this per se, the framework itself does... You can easily roll your own asynchronous query executor in 30 lines or so... In fact, I just threw this together for you :) **EDIT: Through writing this, I've discovered why they didn't implement it. It cannot handle anonymous types since they a...
252,365
<p>I'm trying to create a TCP connection and send/read data that uses SSL, but I haven't been able to successfully accomplish this.</p> <p>What I'd like to do is something like this:</p> <pre><code> TcpClient _tcpClient = new TcpClient("host", 110); BinaryReader reader = new BinaryReader(new System.Ne...
[ { "answer_id": 252372, "author": "toddk", "author_id": 17640, "author_profile": "https://Stackoverflow.com/users/17640", "pm_score": 1, "selected": false, "text": "<p>I'm not entirely sure if this will work for your application but I would recommend taking a look at stunnel:<br />\n<a hr...
2008/10/31
[ "https://Stackoverflow.com/questions/252365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32226/" ]
I'm trying to create a TCP connection and send/read data that uses SSL, but I haven't been able to successfully accomplish this. What I'd like to do is something like this: ``` TcpClient _tcpClient = new TcpClient("host", 110); BinaryReader reader = new BinaryReader(new System.Net.Security.SslStream(...
BinaryReader reads primitive data types as binary values in a specific encoding, is that what your server sends? If not use StreamReader: ``` TcpClient _tcpClient = new TcpClient("host", 110); StreamReader reader = new StreamReader(new System.Net.Security.SslStream(_tcpClient.GetStream(), true)); Console.Writ...
252,391
<p>Currently I have:</p> <pre><code>&lt;system.net&gt; &lt;mailSettings&gt; &lt;smtp from="me@mydomain.com"&gt; &lt;network host="localhost" port="25" /&gt; &lt;/smtp&gt; &lt;/mailSettings&gt; &lt;/system.net&gt; </code></pre> <p>How can I change it...
[ { "answer_id": 252415, "author": "Ty.", "author_id": 16948, "author_profile": "https://Stackoverflow.com/users/16948", "pm_score": 7, "selected": true, "text": "<p>Well, in code you need to put the sender's name in quotes, followed by the e-mail address.</p>\n\n<pre><code>new SmtpClient(...
2008/10/31
[ "https://Stackoverflow.com/questions/252391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2385/" ]
Currently I have: ``` <system.net> <mailSettings> <smtp from="me@mydomain.com"> <network host="localhost" port="25" /> </smtp> </mailSettings> </system.net> ``` How can I change it so the email is sent with a name and not the email address only?
Well, in code you need to put the sender's name in quotes, followed by the e-mail address. ``` new SmtpClient(...).Send("\"John Smith\" jsmith@somewhere.com", ...); ``` And...it looks like you can encode it into the attribute too... ``` <smtp from="&quot;John Smith&quot; &lt;jsmith@somewhere.com&gt;"> ```
252,411
<p>At the moment I have a console application. I would like to be able to exit the application, update through svn, recompile and then relaunch. This is running under a Linux environment. At the moment I'm not sure how I would be able to relaunch the application. Is there a way to do this?</p>
[ { "answer_id": 252415, "author": "Ty.", "author_id": 16948, "author_profile": "https://Stackoverflow.com/users/16948", "pm_score": 7, "selected": true, "text": "<p>Well, in code you need to put the sender's name in quotes, followed by the e-mail address.</p>\n\n<pre><code>new SmtpClient(...
2008/10/31
[ "https://Stackoverflow.com/questions/252411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
At the moment I have a console application. I would like to be able to exit the application, update through svn, recompile and then relaunch. This is running under a Linux environment. At the moment I'm not sure how I would be able to relaunch the application. Is there a way to do this?
Well, in code you need to put the sender's name in quotes, followed by the e-mail address. ``` new SmtpClient(...).Send("\"John Smith\" jsmith@somewhere.com", ...); ``` And...it looks like you can encode it into the attribute too... ``` <smtp from="&quot;John Smith&quot; &lt;jsmith@somewhere.com&gt;"> ```
252,417
<p>What is the easiest way to use a <code>DLL</code> file from within <code>Python</code>?</p> <p>Specifically, how can this be done <em>without</em> writing any additional wrapper <code>C++</code> code to expose the functionality to <code>Python</code>?</p> <p>Native <code>Python</code> functionality is strongly pre...
[ { "answer_id": 252438, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 3, "selected": false, "text": "<p>ctypes can be used to access dlls, here's a tutorial:</p>\n\n<p><a href=\"http://docs.python.org/library/ctypes.html#mod...
2008/10/31
[ "https://Stackoverflow.com/questions/252417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6839/" ]
What is the easiest way to use a `DLL` file from within `Python`? Specifically, how can this be done *without* writing any additional wrapper `C++` code to expose the functionality to `Python`? Native `Python` functionality is strongly preferred over using a third-party library.
For ease of use, [ctypes](http://docs.python.org/library/ctypes.html) is the way to go. The following example of ctypes is from actual code I've written (in Python 2.5). This has been, by far, the easiest way I've found for doing what you ask. ``` import ctypes # Load DLL into memory. hllDll = ctypes.WinDLL ("c:\\P...
252,459
<p>If you have multiple, unrelated projects, is it a good idea to put them in the same repository?</p> <pre><code>myRepo/projectA/trunk myRepo/projectA/tags myRepo/projectA/branches myRepo/projectB/trunk myRepo/projectB/tags myRepo/projectB/branches </code></pre> <p>or would you create new repositories for each?</p> ...
[ { "answer_id": 252463, "author": "Levi Rosol", "author_id": 23458, "author_profile": "https://Stackoverflow.com/users/23458", "pm_score": 1, "selected": false, "text": "<p>My suggestion is one. Unless you have different users accessing each one, then I'd say use multiple.</p>\n\n<p>But a...
2008/10/31
[ "https://Stackoverflow.com/questions/252459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
If you have multiple, unrelated projects, is it a good idea to put them in the same repository? ``` myRepo/projectA/trunk myRepo/projectA/tags myRepo/projectA/branches myRepo/projectB/trunk myRepo/projectB/tags myRepo/projectB/branches ``` or would you create new repositories for each? ``` myRepoA/trunk myRepoA/tag...
The single vs. multiple issue comes down to personal or organizational preference. Management of multiple vs. single mainly comes down to access control and maintenance. Access control for a single repository can be contained in a single file; Multiple repositories are may require multiple files. Maintenance has simi...
252,464
<p>I'm trying to send the output to the console (or colouredconsole) ... which I'm hoping would (also?) go to the Visual Studio's <code>Output</code> window for any ASP.NET web site/app/mvc app.</p> <p>It doesn't by default, but if I change the target to 'file' then it works for sure.</p> <p>Can NLog output to the <cod...
[ { "answer_id": 260576, "author": "Scott P", "author_id": 33848, "author_profile": "https://Stackoverflow.com/users/33848", "pm_score": 8, "selected": true, "text": "<p>You can use this configuration file (nlog.config in the app path):</p>\n<pre><code>&lt;?xml version=&quot;1.0&quot; enco...
2008/10/31
[ "https://Stackoverflow.com/questions/252464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I'm trying to send the output to the console (or colouredconsole) ... which I'm hoping would (also?) go to the Visual Studio's `Output` window for any ASP.NET web site/app/mvc app. It doesn't by default, but if I change the target to 'file' then it works for sure. Can NLog output to the `Output` window for web apps?
You can use this configuration file (nlog.config in the app path): ``` <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <targets> <target name="debugger" xsi:type="Debugger" layout="${logger}::${me...
252,489
<p>Given a simple switch statement</p> <pre><code>switch (int) { case 1 : { printf("1\n"); break; } case 2 : { printf("2\n"); } case 3 : { printf("3\n"); } } </code></pre> <p>The absence of a break statement in case 2, implies that execution will...
[ { "answer_id": 252497, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 4, "selected": false, "text": "<p>If cases were designed to break implicitly then you couldn't have fallthrough.</p>\n\n<pre><code>case 0:\ncase 1:...
2008/10/31
[ "https://Stackoverflow.com/questions/252489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
Given a simple switch statement ``` switch (int) { case 1 : { printf("1\n"); break; } case 2 : { printf("2\n"); } case 3 : { printf("3\n"); } } ``` The absence of a break statement in case 2, implies that execution will continue inside the code ...
Many answers seem to focus on the ability to fall through as the *reason* for requiring the `break` statement. I believe it was simply a mistake, due largely because when C was designed there was not nearly as much experience with how these constructs would be used. Peter Van der Linden makes the case in his book "Ex...
252,506
<p>I am having a great deal of trouble getting named queries to work with nHibernate. My latest problem is getting the error message "could not execute query" with no additional information. Are there any complete examples I can download from somewhere because all the tutorials and documentation examples provide code s...
[ { "answer_id": 252541, "author": "Nelson Miranda", "author_id": 1130097, "author_profile": "https://Stackoverflow.com/users/1130097", "pm_score": 0, "selected": false, "text": "<p>Maybe I'm wrong but it seems that could be a conflict between the table \"TABLENAME\" and the parameter \":T...
2008/10/31
[ "https://Stackoverflow.com/questions/252506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
I am having a great deal of trouble getting named queries to work with nHibernate. My latest problem is getting the error message "could not execute query" with no additional information. Are there any complete examples I can download from somewhere because all the tutorials and documentation examples provide code snip...
I assume that you have tested before the SQL in your client database, so I think that maybe we should see what is happening inside, so I can recommend you this links; 1. [Named Query Error](http://forum.hibernate.org/viewtopic.php?t=938710&sid=f457c1ab5873b97794203503d750567e) 2. [Using NHibernate and Log4Net in ASP.N...
252,515
<p>This is a question that's been nagging me for some time. I always thought that C++ should have been designed so that the <code>delete</code> operator (without brackets) works even with the <code>new[]</code> operator.</p> <p>In my opinion, writing this:</p> <pre><code>int* p = new int; </code></pre> <p>should be ...
[ { "answer_id": 252518, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 6, "selected": true, "text": "<p>It's so that the destructors of the individual elements will be called. Yes, for arrays of PODs, there isn't much o...
2008/10/31
[ "https://Stackoverflow.com/questions/252515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9936/" ]
This is a question that's been nagging me for some time. I always thought that C++ should have been designed so that the `delete` operator (without brackets) works even with the `new[]` operator. In my opinion, writing this: ``` int* p = new int; ``` should be equivalent to allocating an array of 1 element: ``` in...
It's so that the destructors of the individual elements will be called. Yes, for arrays of PODs, there isn't much of a difference, but in C++, you can have arrays of objects with non-trivial destructors. Now, your question is, why not make `new` and `delete` behave like `new[]` and `delete[]` and get rid of `new[]` an...
252,517
<p>I'm using c#, and have an open tcpip connection receiving data. Is it possible to save the stream to an ms sql server database as I'm receiving it, instead of receiving all the data then saving it all? If the stream could be sent to the database as it's being received, you wouldn't have to keep the entire chunk of...
[ { "answer_id": 252526, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 3, "selected": true, "text": "<p>Are you writing to the DB as a BLOB, or translating the data in some form, then executing inserts for each row?<...
2008/10/31
[ "https://Stackoverflow.com/questions/252517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
I'm using c#, and have an open tcpip connection receiving data. Is it possible to save the stream to an ms sql server database as I'm receiving it, instead of receiving all the data then saving it all? If the stream could be sent to the database as it's being received, you wouldn't have to keep the entire chunk of data...
Are you writing to the DB as a BLOB, or translating the data in some form, then executing inserts for each row? Your answer in the comments has me confused. Writing a stream to a BLOB column is vastly different then getting the data then translating it into inserts for separate rows. Regardless, streaming into a BLOB...
252,519
<p>How can I calculate the number of work days between two dates in SQL Server? </p> <p>Monday to Friday and it must be T-SQL.</p>
[ { "answer_id": 252532, "author": "Bogdan Maxim", "author_id": 23795, "author_profile": "https://Stackoverflow.com/users/23795", "pm_score": 5, "selected": false, "text": "<p>In <em><a href=\"http://www.sqlservercentral.com/articles/Advanced+Querying/calculatingworkdays/1660/\" rel=\"nore...
2008/10/31
[ "https://Stackoverflow.com/questions/252519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28419/" ]
How can I calculate the number of work days between two dates in SQL Server? Monday to Friday and it must be T-SQL.
For workdays, Monday to Friday, you can do it with a single SELECT, like this: ``` DECLARE @StartDate DATETIME DECLARE @EndDate DATETIME SET @StartDate = '2008/10/01' SET @EndDate = '2008/10/31' SELECT (DATEDIFF(dd, @StartDate, @EndDate) + 1) -(DATEDIFF(wk, @StartDate, @EndDate) * 2) -(CASE WHEN DATENAME(dw, @...
252,539
<p>I have an app where I create many uiviews and add them to the self.view of the UIViewController. My app is running really slowly. I am releasing all of my objects and have no memory leaks (I ran the performance tool). Can anyone tell me what could be making my app so slow? (code is below)</p> <p>[EDIT] The array ha...
[ { "answer_id": 252566, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": false, "text": "<p>It's going to depend upon how many items are in arrayTitles. If you're just adding one or two of these, you shouldn'...
2008/10/31
[ "https://Stackoverflow.com/questions/252539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23695/" ]
I have an app where I create many uiviews and add them to the self.view of the UIViewController. My app is running really slowly. I am releasing all of my objects and have no memory leaks (I ran the performance tool). Can anyone tell me what could be making my app so slow? (code is below) [EDIT] The array has around 3...
Having deep view hierarchies can lead to slow downs that you can often fix through flattening them some with custom views, but if you are using simple views you can have dozens on the screen with no perceptible performance impact, so in general I recommend ignoring how many views you have when you are developing, and t...
252,548
<p>When upgrading MySQL, I first create a backup of the database. Then I will uninstall the current version installed, and delete all the files that were left by the installer. Then I install the latest GA version, and restore the created back-up, using the MySQL Administrator.</p> <p>Is there a better way of doing an...
[ { "answer_id": 252587, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 3, "selected": true, "text": "<p>you can dump the <code>mysql.user</code> and <code>mysql.db</code> tables, which contains all the user info, and reimport tha...
2008/10/31
[ "https://Stackoverflow.com/questions/252548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26087/" ]
When upgrading MySQL, I first create a backup of the database. Then I will uninstall the current version installed, and delete all the files that were left by the installer. Then I install the latest GA version, and restore the created back-up, using the MySQL Administrator. Is there a better way of doing an upgrade o...
you can dump the `mysql.user` and `mysql.db` tables, which contains all the user info, and reimport that as well, to avoid having to recreate all that. i'd also suggest running repairs on the table after you re-import. alternatively, you could create a listing of grants: ``` select concat('show grants for ',quote(use...
252,552
<p>When should unions be used? Why do we need them?</p>
[ { "answer_id": 252561, "author": "LeopardSkinPillBoxHat", "author_id": 22489, "author_profile": "https://Stackoverflow.com/users/22489", "pm_score": 5, "selected": false, "text": "<p>Unions allow data members which are mutually exclusive to share the same memory. This is quite important...
2008/10/31
[ "https://Stackoverflow.com/questions/252552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When should unions be used? Why do we need them?
Unions are often used to convert between the binary representations of integers and floats: ``` union { int i; float f; } u; // Convert floating-point bits to integer: u.f = 3.14159f; printf("As integer: %08x\n", u.i); ``` Although this is technically undefined behavior according to the C standard (you're only ...
252,575
<p>Can we call functions using function pointer? if yes how?</p>
[ { "answer_id": 252579, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 2, "selected": false, "text": "<p>Yes you can.</p>\n" }, { "answer_id": 252581, "author": "Adam Liss", "author_id": 29157, "author_pr...
2008/10/31
[ "https://Stackoverflow.com/questions/252575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can we call functions using function pointer? if yes how?
Yes. Trivial example: ``` // Functions that will be executed via pointer. int add(int i, int j) { return i+j; } int subtract(int i, int j) {return i-j; } // Enum selects one of the functions typedef enum { ADD, SUBTRACT } OP; // Calculate the sum or difference of two ints. int math(int i, int j, OP op) { int...
252,588
<p>On large files (~200+ MB), I get the 503 error when I read the stream.</p> <pre><code>ftp = (FtpWebRequest)WebRequest.Create(new Uri(address.AbsoluteUri + @"/" + file.Name)); ftp.Credentials = new NetworkCredential(username, password); ftp.Method = WebRequestMethods.Ftp.DownloadFile; response = (FtpWebResponse)ftp...
[ { "answer_id": 264122, "author": "John Lemp", "author_id": 12915, "author_profile": "https://Stackoverflow.com/users/12915", "pm_score": 3, "selected": true, "text": "<p>Do you receive the 503 after every attempt or only subsequent attempts?</p>\n\n<p>Have you tried setting the disabling...
2008/10/31
[ "https://Stackoverflow.com/questions/252588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4068/" ]
On large files (~200+ MB), I get the 503 error when I read the stream. ``` ftp = (FtpWebRequest)WebRequest.Create(new Uri(address.AbsoluteUri + @"/" + file.Name)); ftp.Credentials = new NetworkCredential(username, password); ftp.Method = WebRequestMethods.Ftp.DownloadFile; response = (FtpWebResponse)ftp.GetResponse()...
Do you receive the 503 after every attempt or only subsequent attempts? Have you tried setting the disabling KeepAlive? ``` ftp.KeepAlive = false; ``` I would try a more rubust ftp client library, a basic free one can be at [sourceforge](http://sourceforge.net/projects/dotnetftpclient/).
252,611
<p>I need to be able to lock down the valid characters in a textbox, I presently have a regex which I can check each character against such as </p> <blockquote> <p>[A-Za-z]</p> </blockquote> <p>would lock down to just Alpha characters. </p> <pre><code>protected override void OnKeyPress(KeyPressEventArgs e) { if ...
[ { "answer_id": 252693, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>Why don't you put the check for valid characters in the OnTextChanged event</p>\n\n<p>and then deal with the Ctrl+C, Ctrl+V...
2008/10/31
[ "https://Stackoverflow.com/questions/252611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4490/" ]
I need to be able to lock down the valid characters in a textbox, I presently have a regex which I can check each character against such as > > [A-Za-z] > > > would lock down to just Alpha characters. ``` protected override void OnKeyPress(KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Back) { base...
You can use one of the OnKeyPress / OnKeyUp / OkKeyDown events and then use the Char.IsLetter method to check that the entered key is a letter.
252,615
<p>I have got the following problem since the server has safe mode turned on, and directories are being created under different users:</p> <ol> <li>I upload my script to the server, it shows as belonging to 'user1'. All it is doing is making a new directory when a new user is created so it can store files in it.</li> ...
[ { "answer_id": 252645, "author": "mlambie", "author_id": 17453, "author_profile": "https://Stackoverflow.com/users/17453", "pm_score": 0, "selected": false, "text": "<p>You might be able to turn safe mode off for a specific directory via a .htaccess file (if on Apache). </p>\n\n<pre><cod...
2008/10/31
[ "https://Stackoverflow.com/questions/252615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131/" ]
I have got the following problem since the server has safe mode turned on, and directories are being created under different users: 1. I upload my script to the server, it shows as belonging to 'user1'. All it is doing is making a new directory when a new user is created so it can store files in it. 2. New directory i...
I've used this workaround: instead of php mkdir you can create directories by FTP with proper rights. ``` function FtpMkdir($path, $newDir) { $path = 'mainwebsite_html/'.$path; $server='ftp.myserver.com'; // ftp server $connection = ftp_connect($server); // connection // login to ftp ...
252,626
<p>I've got the following url route and i'm wanting to make sure that a segment of the route will only accept numbers. as such, i can provide some regex which checks the word.</p> <p>/page/{currentPage}</p> <p>so.. can someone give me a regex which matches when the word is a number (any int) greater than 0 (ie. 1 &lt...
[ { "answer_id": 252634, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "<p>If you want it greater than 0, use this regex:</p>\n\n<pre><code>/([1-9][0-9]*)/\n</code></pre>\n\n<p>This'll work as l...
2008/10/31
[ "https://Stackoverflow.com/questions/252626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I've got the following url route and i'm wanting to make sure that a segment of the route will only accept numbers. as such, i can provide some regex which checks the word. /page/{currentPage} so.. can someone give me a regex which matches when the word is a number (any int) greater than 0 (ie. 1 <-> int.max).
``` /^[1-9][0-9]*$/ ``` Problems with other answers: ``` /([1-9][0-9]*)/ // Will match -1 and foo1bar #[1-9]+# // Will not match 10, same problems as the first [1-9] // Will only match one digit, same problems as first ```
252,644
<p>Here is one of my header file which consists of a union template with 4 different structures.</p> <pre><code>#define MAX 3 union family { struct name /*for taking the name and gender of original member*/ { unsigned char *namess; unsigned int gender; union family *ptr_ancestor; /*this...
[ { "answer_id": 252657, "author": "Windows programmer", "author_id": 23705, "author_profile": "https://Stackoverflow.com/users/23705", "pm_score": 0, "selected": false, "text": "<p>Do you know what union means in C? Your union doesn't have 3 members. Your union has 4 members. Among tho...
2008/10/31
[ "https://Stackoverflow.com/questions/252644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
Here is one of my header file which consists of a union template with 4 different structures. ``` #define MAX 3 union family { struct name /*for taking the name and gender of original member*/ { unsigned char *namess; unsigned int gender; union family *ptr_ancestor; /*this is a pointer t...
You need to read this [question about unions](https://stackoverflow.com/questions/252552/unions-in-c). You want something more like: ``` struct family { struct name { int gender; int married; blah } names; union { struct male { blah } male_ancestor; struct female_un...
252,660
<p>How can I delete the session information from my browser by using javascript? Is it possible to do?</p>
[ { "answer_id": 252675, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 1, "selected": false, "text": "<p>Session information is usually stored on the server. An HTTP request to a page that destroys the session would normally do ...
2008/10/31
[ "https://Stackoverflow.com/questions/252660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I delete the session information from my browser by using javascript? Is it possible to do?
Session information is usually stored on the server. An HTTP request to a page that destroys the session would normally do the trick (using AJAX if you wish). For cookies you can set the cookie expiry date to the current date, this will expire the cookie and remove it. ``` var d = new Date(); document.cookie = "cooki...
252,665
<p>I need to get all the <em>cookies</em> stored in my browser using JavaScript. How can it be done? </p>
[ { "answer_id": 252684, "author": "Codeslayer", "author_id": 4021, "author_profile": "https://Stackoverflow.com/users/4021", "pm_score": 4, "selected": false, "text": "<p>To retrieve all cookies for the current document open in the browser, you again use the <code>document.cookie</code> p...
2008/10/31
[ "https://Stackoverflow.com/questions/252665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to get all the *cookies* stored in my browser using JavaScript. How can it be done?
You can only access cookies for a specific site. Using **`document.cookie`** you will get a list of escaped key=value pairs seperated by a semicolon. ``` secret=do%20not%20tell%you;last_visit=1225445171794 ``` To simplify the access, you have to parse the string and unescape all entries: ``` var getCookies = functi...
252,689
<p>We had a performance issue with DataGridViews where the redraw was horridly slow and found the solution <a href="https://stackoverflow.com/questions/118528/horrible-redraw-performance-of-the-datagridview-on-one-of-my-two-screens">Here</a> to create a derived type and enable double buffering on the control. (Derived ...
[ { "answer_id": 252863, "author": "Scott Langham", "author_id": 11898, "author_profile": "https://Stackoverflow.com/users/11898", "pm_score": 3, "selected": false, "text": "<p>Double buffering by definition uses two buffers and twice the memory for rendering the view of the control into. ...
2008/10/31
[ "https://Stackoverflow.com/questions/252689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12685/" ]
We had a performance issue with DataGridViews where the redraw was horridly slow and found the solution [Here](https://stackoverflow.com/questions/118528/horrible-redraw-performance-of-the-datagridview-on-one-of-my-two-screens) to create a derived type and enable double buffering on the control. (Derived type is necess...
I think its best solution: ``` typeof(DataGridView).InvokeMember( "DoubleBuffered", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty, null, myDataGridViewObject, new object[] { true }); ``` found [here](https://stackoverflow.com/questions/118528/horrible-redraw-performance-...
252,703
<p>What's the difference between the list methods <code>append()</code> and <code>extend()</code>?</p>
[ { "answer_id": 252704, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 7, "selected": false, "text": "<p><code>append</code> appends a single element. <code>extend</code> appends a list of elements.</p>\n\n<p>Note that if y...
2008/10/31
[ "https://Stackoverflow.com/questions/252703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
What's the difference between the list methods `append()` and `extend()`?
[`append`](https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types) appends a specified object at the end of the list: ``` >>> x = [1, 2, 3] >>> x.append([4, 5]) >>> print(x) [1, 2, 3, [4, 5]] ``` [`extend`](https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types) extends the list by ap...
252,729
<p>i'm trying to make the following routes .. and currently i'm going about this in a <em>really</em> long way.. ie. one route instance for EACH route.</p> <p>this is what i'm after... (assuming i'm doing a 'stackoverflow website')</p> <pre><code>/ &lt;-- root site /page/{page} &lt...
[ { "answer_id": 252849, "author": "Norbert B.", "author_id": 2605840, "author_profile": "https://Stackoverflow.com/users/2605840", "pm_score": 0, "selected": false, "text": "<p>I would change the last url to /question/view/{subject}.\nFuther Create 3 controllers:</p>\n\n<ul>\n<li>PageCont...
2008/10/31
[ "https://Stackoverflow.com/questions/252729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
i'm trying to make the following routes .. and currently i'm going about this in a *really* long way.. ie. one route instance for EACH route. this is what i'm after... (assuming i'm doing a 'stackoverflow website') ``` / <-- root site /page/{page} <-- root site, but to the page of q...
For your third one, I'd do something like this: ``` routes.MapRoute("page-tag", "tag/{tag}/page/{page}", new {controller="question", action="FilterByTag"}); ``` Your action method then could look like this: ``` public class QuestionController : Controller { public ActionResult FilterByTag(string tag, int page) { ...
252,735
<p>I have made a bunch of changes to a number of files in a project. Every commit (usually at the file level) was accompanied by a comment of what was changed. </p> <p>Is there a way to get a list from CVS of these comments on changes since the last tagged version?</p> <p>Bonus if I can do this via the eclipse CVS pl...
[ { "answer_id": 252801, "author": "Louis Gerbarg", "author_id": 30506, "author_profile": "https://Stackoverflow.com/users/30506", "pm_score": 3, "selected": false, "text": "<p>The options for the cvs log command are available <a href=\"http://www.cvsnt.org/manual/html/log.html\" rel=\"nor...
2008/10/31
[ "https://Stackoverflow.com/questions/252735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/939/" ]
I have made a bunch of changes to a number of files in a project. Every commit (usually at the file level) was accompanied by a comment of what was changed. Is there a way to get a list from CVS of these comments on changes since the last tagged version? Bonus if I can do this via the eclipse CVS plugin. **UPDATE**...
The options for the cvs log command are available [here](http://www.cvsnt.org/manual/html/log.html). Specifically, to get all the commits since a specific tag (lets call it VERSION\_1\_0) ``` cvs log -rVERSION_1_0: ``` If your goal is to have a command that works without having to know the name of the last tag I bel...
252,748
<p>How should I use array of function pointers in C?</p> <p>How can I initialize them?</p>
[ { "answer_id": 252750, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 8, "selected": false, "text": "<p>You have a good example <a href=\"http://www.java2s.com/Code/C/Function/Arrayoffunctionpointer.htm\" rel=\"noreferrer\">here...
2008/10/31
[ "https://Stackoverflow.com/questions/252748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How should I use array of function pointers in C? How can I initialize them?
You have a good example [here (Array of Function pointers)](http://www.java2s.com/Code/C/Function/Arrayoffunctionpointer.htm), with the [syntax detailed](http://www.newty.de/fpt/fpt.html#chapter2). ``` int sum(int a, int b); int subtract(int a, int b); int mul(int a, int b); int div(int a, int b); int (*p[4]) (int x,...
252,766
<p>How can I add line numbers to a range of lines in a file opened in Vim? Not as in <code>:set nu</code>—this just <em>displays</em> line numbers—but actually have them be prepended to each line in the file?</p>
[ { "answer_id": 252770, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 5, "selected": false, "text": "<p><code>cat -n</code> adds line numbers to its input. You can pipe the current file to <code>cat -n</code> and replace the ...
2008/10/31
[ "https://Stackoverflow.com/questions/252766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31641/" ]
How can I add line numbers to a range of lines in a file opened in Vim? Not as in `:set nu`—this just *displays* line numbers—but actually have them be prepended to each line in the file?
With ``` :%s/^/\=line('.')/ ``` EDIT: to sum up the comments. This command can be tweaked as much as you want. --- Let's say you want to add numbers in front of lines from a visual selection (`V` + move), and you want the numbering to start at 42. ``` :'<,'>s/^/\=(line('.')-line("'<")+42)/ ``` --- If you wan...
252,780
<p>I have seen many programs consisting of structures like the one below</p> <pre><code>typedef struct { int i; char k; } elem; elem user; </code></pre> <p>Why is it needed so often? Any specific reason or applicable area?</p>
[ { "answer_id": 252783, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 6, "selected": false, "text": "<p>Using a <code>typedef</code> avoids having to write <code>struct</code> every time you declare a variable of that type...
2008/10/31
[ "https://Stackoverflow.com/questions/252780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
I have seen many programs consisting of structures like the one below ``` typedef struct { int i; char k; } elem; elem user; ``` Why is it needed so often? Any specific reason or applicable area?
As Greg Hewgill said, the typedef means you no longer have to write `struct` all over the place. That not only saves keystrokes, it also can make the code cleaner since it provides a smidgen more abstraction. Stuff like ``` typedef struct { int x, y; } Point; Point point_new(int x, int y) { Point a; a.x = x; ...
252,782
<p>What is the purpose of the <code>strdup()</code> function in C?</p>
[ { "answer_id": 252786, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": false, "text": "<p>From <a href=\"http://www.opengroup.org/onlinepubs/009695399/functions/strdup.html\" rel=\"noreferrer\">strdup man</a>:</p>\...
2008/10/31
[ "https://Stackoverflow.com/questions/252782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
What is the purpose of the `strdup()` function in C?
Exactly what it sounds like, assuming you're used to the abbreviated way in which C and UNIX assigns words, it ***duplicates strings*** :-) Keeping in mind it's actually not part of the current (C17) ISO C standard itself(a) (it's a POSIX thing), it's effectively doing the same as the following code: ``` char *strdup...
252,800
<p>I have the need to display a nested set structure in HTML. I am doing it with the following partial:</p> <pre><code>&lt;ul&lt;%= ' id="tree"' if depth == 0 %&gt;&gt; &lt;% items.each do |item| %&gt; &lt;li id="node_&lt;%= item.id %&gt;"&gt;&lt;a&gt;&lt;%= item.name %&gt;&lt;/a&gt; &lt;% if item.has_children? %&...
[ { "answer_id": 252829, "author": "Jarek", "author_id": 33013, "author_profile": "https://Stackoverflow.com/users/33013", "pm_score": 2, "selected": false, "text": "<p>I am not sure whether it is best practice but I used similar code for rendering project tree. </p>\n\n<p>Faster alternati...
2008/10/31
[ "https://Stackoverflow.com/questions/252800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17453/" ]
I have the need to display a nested set structure in HTML. I am doing it with the following partial: ``` <ul<%= ' id="tree"' if depth == 0 %>> <% items.each do |item| %> <li id="node_<%= item.id %>"><a><%= item.name %></a> <% if item.has_children? %> <%= render :partial => 'tree_level', :locals => {:items => i...
I am not sure whether it is best practice but I used similar code for rendering project tree. Faster alternative is to create helper method doing the same job (recursively traversing tree and adding partial strings into result string). It is a little bit PHP style :( but for such a small amount of HTML is it OK, I gu...
252,811
<p>Does anyone know of a simple method for solving this?</p> <p>I have a table which consists of start times for events and the associated durations. I need to be able to split the event durations into thirty minute intervals. So for example if an event starts at 10:45:00 and the duration is 00:17:00 then the returned...
[ { "answer_id": 252854, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 2, "selected": false, "text": "<p>You could create a lookup table with just the times (over 24 hours), and join to that table. You would need to rebase the d...
2008/10/31
[ "https://Stackoverflow.com/questions/252811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does anyone know of a simple method for solving this? I have a table which consists of start times for events and the associated durations. I need to be able to split the event durations into thirty minute intervals. So for example if an event starts at 10:45:00 and the duration is 00:17:00 then the returned set shoul...
You could create a lookup table with just the times (over 24 hours), and join to that table. You would need to rebase the date to that used in the lookup. Then perform a datediff on the upper and lower intervals to work out their durations. Each middle interval would be 30 minutes. ``` create table #interval_lookup ( ...
252,817
<p>Just out of curiosity:</p> <p>I know I can tell the compiler if I want a value to be interpreted as a certain numeric type, e.g. as Integer (32 bit signed), this way appending an "I" (type character) to the constant value:</p> <pre><code>Private Function GetTheAnswerAsInteger() As Integer Return 42I End Funct...
[ { "answer_id": 252826, "author": "arul", "author_id": 15409, "author_profile": "https://Stackoverflow.com/users/15409", "pm_score": 2, "selected": false, "text": "<p>There's no byte literal in .NET.</p>\n" }, { "answer_id": 252831, "author": "Jon Skeet", "author_id": 2265...
2008/10/31
[ "https://Stackoverflow.com/questions/252817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6461/" ]
Just out of curiosity: I know I can tell the compiler if I want a value to be interpreted as a certain numeric type, e.g. as Integer (32 bit signed), this way appending an "I" (type character) to the constant value: ``` Private Function GetTheAnswerAsInteger() As Integer Return 42I End Function ``` There's als...
There isn't one. If you need to distinguish between an integer and a byte (e.g. to call an appropriate overload) for a constant, you need to cast. (The same is true in C#, by the way.) [MSDN provides confirmation:](http://msdn.microsoft.com/en-us/library/e2ayt412.aspx) > > Byte has no literal type character or > i...
252,819
<p>I have a library A, that I develop. When I deploy it on a machine, the corresponding <em>libA.so</em> and <em>libA-X.Y.Z.so</em> are put in /usr/lib (X.Y.Z being the version number). </p> <p>Now I develop a library B, which uses A. When I link B, I use the flag -lA. Then "<em>ldd libB.so</em>" gives me : </p> <pre...
[ { "answer_id": 252841, "author": "Marcin Gil", "author_id": 5731, "author_profile": "https://Stackoverflow.com/users/5731", "pm_score": 0, "selected": false, "text": "<p>This also works in Windows as \"DLL hell\" :).</p>\n\n<p>If B needs a specific version of A and you would link to libA...
2008/10/31
[ "https://Stackoverflow.com/questions/252819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20986/" ]
I have a library A, that I develop. When I deploy it on a machine, the corresponding *libA.so* and *libA-X.Y.Z.so* are put in /usr/lib (X.Y.Z being the version number). Now I develop a library B, which uses A. When I link B, I use the flag -lA. Then "*ldd libB.so*" gives me : ``` (...) libA-X.Y.Z.so => /usr/lib/lib...
When you create libA.so, pass the -soname option to the linker (if you linking through gcc, use -Wl,-soname). Then, when B gets linked, the linker refers to A through its soname, not through its filename. On the target system, make sure you have a link from the soname to the real file. See <http://www.linux.org/docs/l...
252,848
<p>I tried this step:</p> <p>Select the menu options "Project > New Build Phase > New Run Script Build Phase", and enter the following script (don't forget to replace /Users/youruser/bin by the correct path to gen_entitlements.py) :</p> <pre><code>export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Develo...
[ { "answer_id": 253283, "author": "Jesús A. Álvarez", "author_id": 13186, "author_profile": "https://Stackoverflow.com/users/13186", "pm_score": 5, "selected": false, "text": "<p>Select the Run Script phase in your target and delete it.</p>\n\n<p><img src=\"https://i.stack.imgur.com/pQ9uu...
2008/10/31
[ "https://Stackoverflow.com/questions/252848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16066/" ]
I tried this step: Select the menu options "Project > New Build Phase > New Run Script Build Phase", and enter the following script (don't forget to replace /Users/youruser/bin by the correct path to gen\_entitlements.py) : ``` export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign...
Select the Run Script phase in your target and delete it. ![Delete](https://i.stack.imgur.com/pQ9uu.png)
252,856
<pre><code>div#thing { position: absolute; top: 0px; z-index: 2; margin: 0 auto; } &lt;div id="thing"&gt; &lt;p&gt;text text text with no fixed size, variable font&lt;/p&gt; &lt;/div&gt; </code></pre> <p>The div is at the top, but I can't center it with <code>&lt;center&gt;</code> or <code>margin: 0 auto</...
[ { "answer_id": 252872, "author": "JacobE", "author_id": 30056, "author_profile": "https://Stackoverflow.com/users/30056", "pm_score": 8, "selected": true, "text": "<p>Your problem may be solved if you give your <code>div</code> a fixed width, as follows:</p>\n\n<pre><code>div#thing {\n ...
2008/10/31
[ "https://Stackoverflow.com/questions/252856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21559/" ]
``` div#thing { position: absolute; top: 0px; z-index: 2; margin: 0 auto; } <div id="thing"> <p>text text text with no fixed size, variable font</p> </div> ``` The div is at the top, but I can't center it with `<center>` or `margin: 0 auto`;
Your problem may be solved if you give your `div` a fixed width, as follows: ``` div#thing { position: absolute; top: 0px; z-index: 2; width:400px; margin-left:-200px; left:50%; } ```
252,862
<p>I've two tables TAB_A and TAB_B. TAB_A is master table and TAB_B is child / transaction table. TAB_A is having COL_A (Primary key) and TAB_B is having COL_B (Primary key) and also COL_A.</p> <p>For some business reason, Foreign key is not defined between TAB_A and TAB_B on column COL_A.</p> <p>There are four recor...
[ { "answer_id": 252956, "author": "Martin Bøgelund", "author_id": 18968, "author_profile": "https://Stackoverflow.com/users/18968", "pm_score": 0, "selected": false, "text": "<p>You should use an ON clause instead of a WHERE clause in your inner join. The ON clause relates to the actual j...
2008/10/31
[ "https://Stackoverflow.com/questions/252862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17187/" ]
I've two tables TAB\_A and TAB\_B. TAB\_A is master table and TAB\_B is child / transaction table. TAB\_A is having COL\_A (Primary key) and TAB\_B is having COL\_B (Primary key) and also COL\_A. For some business reason, Foreign key is not defined between TAB\_A and TAB\_B on column COL\_A. There are four records in...
Both queries should return the same rows. If this really behaves as you describe, you have found a bug in DB2. What are you trying to accomplish with this query? If the values (1,2,3,4) of B.COL\_A are orphan records, then this query should return no rows. If you meant to be searching for the orphans, you probably nee...
252,882
<p>There are a couple of questions similar to this on stack overflow but not quite the same.</p> <p>I want to open, or create, a local group on a win xp computer and add members to it, domain, local and well known accounts. I also want to check whether a user is already a member so that I don't add the same account t...
[ { "answer_id": 252890, "author": "Tim Robinson", "author_id": 32133, "author_profile": "https://Stackoverflow.com/users/32133", "pm_score": 1, "selected": false, "text": "<p>You should be able to find this information inside the <a href=\"http://msdn.microsoft.com/en-us/library/ms677097(...
2008/10/31
[ "https://Stackoverflow.com/questions/252882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21429/" ]
There are a couple of questions similar to this on stack overflow but not quite the same. I want to open, or create, a local group on a win xp computer and add members to it, domain, local and well known accounts. I also want to check whether a user is already a member so that I don't add the same account twice, and p...
Okay, it's taken a while, messing around with different solutions but the one that fits best with my original question is given below. I can't get the DirectoryEntry object to access the members of a local group using the 'standard' methods, the only way I could get it to enumerate the members was by using the Invoke m...
252,893
<p>How do you change the CLASSPATH of a Java process from within the Java process?</p> <hr> <p>Before you ask me "Why would you want to do that?" I'll explain it shortly. </p> <blockquote> <p>When you have a Clojure REPL running it is common to need more jars in your CLASSPATH to load a <a href="http://clojure.org...
[ { "answer_id": 252903, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>I don't believe you can - the right thing to do (I believe) is create a new classloader with the new path. Alternativ...
2008/10/31
[ "https://Stackoverflow.com/questions/252893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
How do you change the CLASSPATH of a Java process from within the Java process? --- Before you ask me "Why would you want to do that?" I'll explain it shortly. > > When you have a Clojure REPL running it is common to need more jars in your CLASSPATH to load a [Clojure](http://clojure.org) source file, and I'd like...
Update Q4 2017: as [commented](https://stackoverflow.com/questions/252893/how-do-you-change-the-classpath-within-java/252967#comment82290481_252967) below by [vda8888](https://stackoverflow.com/users/1974520/vda8888), in Java 9, the System [`java.lang.ClassLoader`](https://docs.oracle.com/javase/9/docs/api/java/lang/Cl...
252,897
<p>I am developing an application that needs to use regini (because of legacy reasons) to insert something into the registry. I have been trying to do this in such a way the the user of the application is not aware of this. I have written the following code:</p> <pre><code>System.Diagnostics.ProcessStartInfo pi = new ...
[ { "answer_id": 252913, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 0, "selected": false, "text": "<p>I found this bug report on the Microsoft Connect Feedback Site: <a href=\"http://connect.microsoft.com/VisualStudio/feed...
2008/10/31
[ "https://Stackoverflow.com/questions/252897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32522/" ]
I am developing an application that needs to use regini (because of legacy reasons) to insert something into the registry. I have been trying to do this in such a way the the user of the application is not aware of this. I have written the following code: ``` System.Diagnostics.ProcessStartInfo pi = new ProcessStartIn...
Try to add this line: ``` pi.CreateNoWindow = true; ```
252,906
<p>Anyone got an idea how to get from an Xserver the list of all open windows?</p>
[ { "answer_id": 252911, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 8, "selected": true, "text": "<p>From the CLI you can use</p>\n\n<pre><code>xwininfo -tree -root\n</code></pre>\n\n<p>If you need to do this within your ow...
2008/10/31
[ "https://Stackoverflow.com/questions/252906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4172/" ]
Anyone got an idea how to get from an Xserver the list of all open windows?
From the CLI you can use ``` xwininfo -tree -root ``` If you need to do this within your own code then you need to use the `XQueryTree` function from the `Xlib` library.
252,915
<p>How to send array in Httpservice in Adobe Flex3</p>
[ { "answer_id": 435524, "author": "bartv", "author_id": 51371, "author_profile": "https://Stackoverflow.com/users/51371", "pm_score": 3, "selected": false, "text": "<p>I am not quite sure what you mean by sending an array to a httpservice. If you mean to send an array to a httpservice wit...
2008/10/31
[ "https://Stackoverflow.com/questions/252915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33016/" ]
How to send array in Httpservice in Adobe Flex3
I am not quite sure what you mean by sending an array to a httpservice. If you mean to send an array to a httpservice with the same field name, you can pass an array as field value. ``` var service:HTTPService = new HTTPService(); service.useProxy = true; service.destination = "myservicet"; service.resultFormat = HTTP...
252,921
<p>Magento shopping cart is built on the Zend Framework in PHP. This is the first time I've dealt with the Zend framework and I'm having the following difficulty...</p> <p>I'm creating a custom module that will allow users to upload images whenever they purchase products. </p> <p>I can overload the addAction() method...
[ { "answer_id": 253011, "author": "Simon", "author_id": 33036, "author_profile": "https://Stackoverflow.com/users/33036", "pm_score": 0, "selected": false, "text": "<p>I must admit upfront that I don't have production experience of Magento, but I have spent some time poking around their c...
2008/10/31
[ "https://Stackoverflow.com/questions/252921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17492/" ]
Magento shopping cart is built on the Zend Framework in PHP. This is the first time I've dealt with the Zend framework and I'm having the following difficulty... I'm creating a custom module that will allow users to upload images whenever they purchase products. I can overload the addAction() method whenever a user ...
hey this option is given in newer version of magento 1.3.1 to upload the file from frontend enjoy
252,924
<p>This is a simple one. I want to replace a sub-string with another sub-string on client-side using Javascript.</p> <p>Original string is <code>'original READ ONLY'</code></p> <p>I want to replace the <code>'READ ONLY'</code> with <code>'READ WRITE'</code></p> <p>Any quick answer please? Possibly with a javascript ...
[ { "answer_id": 252928, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 4, "selected": false, "text": "<p>Good <a href=\"http://www.w3schools.com/jsref/jsref_replace.asp\" rel=\"noreferrer\">summary</a>. It is regexp ba...
2008/10/31
[ "https://Stackoverflow.com/questions/252924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
This is a simple one. I want to replace a sub-string with another sub-string on client-side using Javascript. Original string is `'original READ ONLY'` I want to replace the `'READ ONLY'` with `'READ WRITE'` Any quick answer please? Possibly with a javascript code snippet...
`String.replace()` is regexp-based; if you pass in a string as the first argument, the regexp made from it will not include the **‘g’** (global) flag. This option is essential if you want to replace all occurances of the search string (which is usually what you want). An alternative **non-regexp** idiom for simple glo...
252,945
<p>I am creating a plugin for Eclipse 3.4. I created a plug-in development project using the application with a view. Now I am trying to create a <code>TextViewer</code> the documentation says that it is located in <code>org.eclipse.jface.text.TextViewer</code>. But, this whole package is missing and eclipse cannot ...
[ { "answer_id": 252982, "author": "IAdapter", "author_id": 30453, "author_profile": "https://Stackoverflow.com/users/30453", "pm_score": 1, "selected": false, "text": "<p>in 3.4 i have it inside</p>\n\n<p>eclipse-jee-ganymede-win32\\plugins\\org.eclipse.jface.text_3.4.0.v20080603-2000.jar...
2008/10/31
[ "https://Stackoverflow.com/questions/252945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
I am creating a plugin for Eclipse 3.4. I created a plug-in development project using the application with a view. Now I am trying to create a `TextViewer` the documentation says that it is located in `org.eclipse.jface.text.TextViewer`. But, this whole package is missing and eclipse cannot locate `TextViewer` class to...
``` Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.jface.text ``` Add *org.eclipse.jface.text* as a dependency in your plugin manifest. You can use 3rd party tools (like IBM's [JAR Class Finder](https://www.alphaworks.ibm.com/tech/jarclassfinder/requirements)) to locate dependencies, or, alte...
252,962
<p>We have a file that has a 64 bit integer as a string in it. How do we scanf() or otherwise parse this numeric string into an unsigned 64 bit integer type in C++ ? </p> <p>We are aware of things like %lld etc., but a lot of ways to do this parse seem to break compiles under different compilers and stdlibs. The code ...
[ { "answer_id": 252965, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 1, "selected": false, "text": "<p>Don't use <code>scanf()</code>, tokenize your input separately and then use <code>strtoull()</code> or similar.</p>\n" ...
2008/10/31
[ "https://Stackoverflow.com/questions/252962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19734/" ]
We have a file that has a 64 bit integer as a string in it. How do we scanf() or otherwise parse this numeric string into an unsigned 64 bit integer type in C++ ? We are aware of things like %lld etc., but a lot of ways to do this parse seem to break compiles under different compilers and stdlibs. The code should com...
GCC has long long, as will compilers for C++0x. MSVC++ doesn't (yet), but does have its \_\_int64 you can use. ``` #if (__cplusplus > 199711L) || defined(__GNUG__) typedef unsigned long long uint_64_t; #elif defined(_MSC_VER) || defined(__BORLANDC__) typedef unsigned __int64 uint_64_t; #else #error "Please de...
252,963
<p>How can I use Hyperlink button in gridview. I mean when I run my program,all data is displayed in gridview,but I want hyperlink in gridview, so that when I will click in hyperlink it will show the select path which is in gridview : if there is pdf file path and I just click on this hyper link then I can see the pdf ...
[ { "answer_id": 252984, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 1, "selected": false, "text": "<p>You need to use a template field. e.g. lets say you're column is called 'PdfUrl'</p>\n\n<p>Then add a column to y...
2008/10/31
[ "https://Stackoverflow.com/questions/252963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I use Hyperlink button in gridview. I mean when I run my program,all data is displayed in gridview,but I want hyperlink in gridview, so that when I will click in hyperlink it will show the select path which is in gridview : if there is pdf file path and I just click on this hyper link then I can see the pdf fil...
You need to use a template field. e.g. lets say you're column is called 'PdfUrl' Then add a column to your datagrid. that looks like ``` <asp:TemplateField HeaderText="Link" SortExpression="PdfUrl"> <itemtemplate> <asp:HyperLink runat="server" ID="hlkPDF" NavigateURL='<%# DataBinder.Eval(Container.DataIte...
252,972
<p>Please forgive my long question. I have an idea for a design that I could use some comments on. Is it a good idea to do this? And what are the pit falls I should be aware of? Are there other similar implementations that are better?</p> <p><strong>My situation is as follows:</strong><br> I am working on a rewrite of...
[ { "answer_id": 253024, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p>I have a similar situation here, though I use MySQL. Every database has a versions table that contains the version (simply a...
2008/10/31
[ "https://Stackoverflow.com/questions/252972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30366/" ]
Please forgive my long question. I have an idea for a design that I could use some comments on. Is it a good idea to do this? And what are the pit falls I should be aware of? Are there other similar implementations that are better? **My situation is as follows:** I am working on a rewrite of a windows forms applica...
I have a similar situation here, though I use MySQL. Every database has a versions table that contains the version (simply an integer) and a short comment of what has changed in this version. I use a script to update the databases. Every database change can be in one function or sometimes one change is made by multiple...
252,974
<p>I would like to hear some opinions about using the isolated storage in Silverlight for storing sensitive data. For example, is it OK to store an authentication token (some GUID that identifies a server-side session) in this storage, or is it better to use cookies?</p> <p>The isolated storage gives an advantage over...
[ { "answer_id": 253024, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p>I have a similar situation here, though I use MySQL. Every database has a versions table that contains the version (simply a...
2008/10/31
[ "https://Stackoverflow.com/questions/252974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30056/" ]
I would like to hear some opinions about using the isolated storage in Silverlight for storing sensitive data. For example, is it OK to store an authentication token (some GUID that identifies a server-side session) in this storage, or is it better to use cookies? The isolated storage gives an advantage over cookies i...
I have a similar situation here, though I use MySQL. Every database has a versions table that contains the version (simply an integer) and a short comment of what has changed in this version. I use a script to update the databases. Every database change can be in one function or sometimes one change is made by multiple...
252,976
<p>How can I create a query for a full outer join across a M2M relationchip using the django QuerySet API?</p> <p>It that is not supported, some hint about creating my own manager to do this would be welcome.</p> <p><strong>Edited to add:</strong> @S.Lott: Thanks for the enlightenment. The need for the OUTER JOIN co...
[ { "answer_id": 253057, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 5, "selected": true, "text": "<p>Django doesn't support \"joins\" in the usual SQL sense -- it supports object navigation.</p>\n\n<p>Note that a relationa...
2008/10/31
[ "https://Stackoverflow.com/questions/252976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11527/" ]
How can I create a query for a full outer join across a M2M relationchip using the django QuerySet API? It that is not supported, some hint about creating my own manager to do this would be welcome. **Edited to add:** @S.Lott: Thanks for the enlightenment. The need for the OUTER JOIN comes from the application. It h...
Django doesn't support "joins" in the usual SQL sense -- it supports object navigation. Note that a relational join (inner or outer) creates a new "class" of entities. One that doesn't have a definition in Django. So there's no proper "result set" since there's no class definition for the things you get back. The best...
252,988
<p>How to get all the database names and corresponding table names together ?</p>
[ { "answer_id": 253003, "author": "Hapkido", "author_id": 27646, "author_profile": "https://Stackoverflow.com/users/27646", "pm_score": 0, "selected": false, "text": "<p>You will have to write a store procedure.</p>\n\n<p>First get the database name</p>\n\n<pre><code>SELECT Name FROM mast...
2008/10/31
[ "https://Stackoverflow.com/questions/252988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How to get all the database names and corresponding table names together ?
``` CREATE TABLE #dbs ( DatabaseName VARCHAR(256), TableName VARCHAR(256) ) EXEC sp_msforeachdb 'INSERT INTO #dbs SELECT ''?'', [name] FROM dbo.SysObjects WHERE XType = ''U''' SELECT * FROM #dbs DROP TABLE #dbs ```
253,013
<p>We use a simple object model for our low level networking code at work where struct pointers are passed around to functions which are pretending to be methods. I've inherited most of this code which was written by consultants with passable C/C++ experience at best and I've spent many late nights trying to refactor c...
[ { "answer_id": 253119, "author": "qrdl", "author_id": 28494, "author_profile": "https://Stackoverflow.com/users/28494", "pm_score": 0, "selected": false, "text": "<p>Not sure what you want to achieve.</p>\n\n<p>You can add all foo_* functions as function pointer members to <code>struct F...
2008/10/31
[ "https://Stackoverflow.com/questions/253013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22247/" ]
We use a simple object model for our low level networking code at work where struct pointers are passed around to functions which are pretending to be methods. I've inherited most of this code which was written by consultants with passable C/C++ experience at best and I've spent many late nights trying to refactor code...
You can use macro to redefine `tcp_socket_send` to `tcp_socket_send_moc` and link with real `tcp_socket_send` and dummy implementation for `tcp_socket_send_moc`. you will need to carefully select the proper place for : ``` #define tcp_socket_send tcp_socket_send_moc ```
253,026
<p>I used a class which derives from <code>CListBox</code>, and create it with following:</p> <pre><code>style:WS_CHILD|WS_VISIBLE |LBS_OWNERDRAWFIXED | WS_VSCROLL | WS_HSCROLL </code></pre> <p>I expect the ListBox's item to be have a fixed size, not affected by the size of the list box. So I override the MeasureItem...
[ { "answer_id": 253201, "author": "Stu Mackellar", "author_id": 28591, "author_profile": "https://Stackoverflow.com/users/28591", "pm_score": 0, "selected": false, "text": "<p>If you look at the <code>MSDN</code> entry for <a href=\"http://msdn.microsoft.com/en-us/library/t7tccyw7(VS.80)....
2008/10/31
[ "https://Stackoverflow.com/questions/253026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26404/" ]
I used a class which derives from `CListBox`, and create it with following: ``` style:WS_CHILD|WS_VISIBLE |LBS_OWNERDRAWFIXED | WS_VSCROLL | WS_HSCROLL ``` I expect the ListBox's item to be have a fixed size, not affected by the size of the list box. So I override the MeasureItem() method, in which I specify the ite...
What's not mentioned in the reference is that `WM_MEASUREITEM` is called *every time* the `*_OWNERDRAWFIXED` control is resized. I don't know however, how official this behavior is and whether it should be relied on, but it has been verified at [CodeGuru](http://www.codeguru.com/Cpp/controls/listview/advanced/article....
253,030
<p>If you want to some code to execute based on two or more conditions which is the best way to format that if statement ?</p> <p>first example:-</p> <pre><code>if(ConditionOne &amp;&amp; ConditionTwo &amp;&amp; ConditionThree) { Code to execute } </code></pre> <p>Second example:-</p> <pre><code>if(ConditionOne)...
[ { "answer_id": 253034, "author": "RB.", "author_id": 15393, "author_profile": "https://Stackoverflow.com/users/15393", "pm_score": 2, "selected": false, "text": "<p>The first one is easier, because, if you read it left to right you get:\n\"If something AND somethingelse AND somethingelse...
2008/10/31
[ "https://Stackoverflow.com/questions/253030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If you want to some code to execute based on two or more conditions which is the best way to format that if statement ? first example:- ``` if(ConditionOne && ConditionTwo && ConditionThree) { Code to execute } ``` Second example:- ``` if(ConditionOne) { if(ConditionTwo ) { if(ConditionThree) { ...
I prefer Option A ``` bool a, b, c; if( a && b && c ) { //This is neat & readable } ``` If you do have particularly long variables/method conditions you can just line break them ``` if( VeryLongConditionMethod(a) && VeryLongConditionMethod(b) && VeryLongConditionMethod(c)) { //This is still readable ...
253,036
<p>I have WPF ListBox which is bound to a ObservableCollection, when the collection changes, all items update their position.</p> <p>The new position is stored in the collection but the UI does not update. So I added the following:</p> <pre><code> void scenarioItems_CollectionChanged(object sender, System.Collecti...
[ { "answer_id": 253094, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 2, "selected": false, "text": "<p>I had the same problem yesterday, and it's a complete piece of crap :) ... I'm not setting mine to null anymore ...
2008/10/31
[ "https://Stackoverflow.com/questions/253036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
I have WPF ListBox which is bound to a ObservableCollection, when the collection changes, all items update their position. The new position is stored in the collection but the UI does not update. So I added the following: ``` void scenarioItems_CollectionChanged(object sender, System.Collections.Specialized.Notif...
I have a Listbox bound to an object property which is of type `List<MyCustomType>()` and I verified that the following code updates the listbox when the List is updated. ``` void On_MyObjProperty_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { MyListBox.Items.Refresh(); } ``` If...
253,038
<p>I'm having a bit of a problem. I have a datatable in the parent form. I open a dialogbox form that gets the datatable property and creates a checkboxlist. This will be used to export those columns. But when I run the application the parentform property is null. I've tried setting it in the parent and dialogbox form ...
[ { "answer_id": 253094, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 2, "selected": false, "text": "<p>I had the same problem yesterday, and it's a complete piece of crap :) ... I'm not setting mine to null anymore ...
2008/10/31
[ "https://Stackoverflow.com/questions/253038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5906/" ]
I'm having a bit of a problem. I have a datatable in the parent form. I open a dialogbox form that gets the datatable property and creates a checkboxlist. This will be used to export those columns. But when I run the application the parentform property is null. I've tried setting it in the parent and dialogbox form (I ...
I have a Listbox bound to an object property which is of type `List<MyCustomType>()` and I verified that the following code updates the listbox when the List is updated. ``` void On_MyObjProperty_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { MyListBox.Items.Refresh(); } ``` If...
253,055
<p>When I've worked a bit with my source code, I did my usual thing commit and then I pushed to a remote repository. But then I noticed I forgot to organize my imports in the source code. So I do the amend command to replace the previous commit:</p> <pre><code>&gt; git commit --amend </code></pre> <p>Unfortunately th...
[ { "answer_id": 253229, "author": "Spoike", "author_id": 3713, "author_profile": "https://Stackoverflow.com/users/3713", "pm_score": 1, "selected": false, "text": "<p>I had to fix this problem with pulling from the remote repo and deal with the merge conflicts that arose, commit and then ...
2008/10/31
[ "https://Stackoverflow.com/questions/253055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3713/" ]
When I've worked a bit with my source code, I did my usual thing commit and then I pushed to a remote repository. But then I noticed I forgot to organize my imports in the source code. So I do the amend command to replace the previous commit: ``` > git commit --amend ``` Unfortunately the commit can't be pushed back...
I actually once pushed with `--force` and `.git` repository and got scolded by Linus **BIG TIME**. In general this will create a lot of problems for other people. A simple answer is "Don't do it". I see others gave the recipe for doing so anyway, so I won't repeat them here. But here is a tip to recover from the situa...
253,058
<p>Today I happens to find that one C# class can inherit one interface both in implicit and explicit way. This surprises me. If C# works in this way, then one instance can behave differently when referenced in different way.</p> <pre><code>interface IFoo { void DoSomething(); } class Foo : IFoo { #region IFoo...
[ { "answer_id": 253073, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 4, "selected": false, "text": "<p>Every class that implements an interface has a <em>mapping</em> between that class's members and the interface's memb...
2008/10/31
[ "https://Stackoverflow.com/questions/253058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
Today I happens to find that one C# class can inherit one interface both in implicit and explicit way. This surprises me. If C# works in this way, then one instance can behave differently when referenced in different way. ``` interface IFoo { void DoSomething(); } class Foo : IFoo { #region IFoo Members p...
Your example does **not** implement IFoo both implicitly and explicitly. You only implement IFoo.DoSometing() explicitly. You have a new method on your class called DoSomething(). It has nothing to do with IFoo.DoSomething, except that it has the same name and parameters.
253,066
<p>How do you debug <a href="http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String)" rel="noreferrer">getResource</a>-style methods that are failing, returning null?</p> <p>I am sure the file it's looking for is there, but it's returning NULL. How do I know what it is looking fo...
[ { "answer_id": 253088, "author": "boutta", "author_id": 15108, "author_profile": "https://Stackoverflow.com/users/15108", "pm_score": 2, "selected": false, "text": "<p>You could use the Eclipse-debug-mode and set a breakpoint on the method that fails. From there you can go step by step d...
2008/10/31
[ "https://Stackoverflow.com/questions/253066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
How do you debug [getResource](http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String))-style methods that are failing, returning null? I am sure the file it's looking for is there, but it's returning NULL. How do I know what it is looking for to try to spot any mismatch?
Since `getResource()` searches the classpath (as others have mentioned), it might be helpful to dump the actual classpath being searched before your problemsome `getResource()` call: ``` log.debug("classpath is: " + System.getProperty("java.class.path")); //the line that is returning null ... = Thread.currentThread()...
253,075
<p>Is there a csh script/command to list all the files in source source tree which have line endings that show up as "^M" in emacs (under linux).</p> <p>Thanks!</p>
[ { "answer_id": 253084, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 0, "selected": false, "text": "<pre><code>find . -type f -exec grep $'\\r' {} +\n</code></pre>\n\n<p>The <code>$'\\r'</code> probably requires bash to func...
2008/10/31
[ "https://Stackoverflow.com/questions/253075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5775/" ]
Is there a csh script/command to list all the files in source source tree which have line endings that show up as "^M" in emacs (under linux). Thanks!
Based on my answer to [another question](https://stackoverflow.com/questions/204765/elegant-way-to-search-for-utf-8-files-with-bom#211855): ``` fgrep -rl `echo -ne '\r'` . ```
253,099
<p>I want to examine the contents of a <code>std::vector</code> in GDB, how do I do it? Let's say it's a <code>std::vector&lt;int&gt;</code> for the sake of simplicity.</p>
[ { "answer_id": 253101, "author": "John Carter", "author_id": 8331, "author_profile": "https://Stackoverflow.com/users/8331", "pm_score": 8, "selected": false, "text": "<p>With GCC 4.1.2, to print the whole of a std::vector&lt;int&gt; called myVector, do the following:</p>\n\n<pre><code>p...
2008/10/31
[ "https://Stackoverflow.com/questions/253099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8331/" ]
I want to examine the contents of a `std::vector` in GDB, how do I do it? Let's say it's a `std::vector<int>` for the sake of simplicity.
To view vector std::vector myVector contents, just type in GDB: ``` (gdb) print myVector ``` This will produce an output similar to: ``` $1 = std::vector of length 3, capacity 4 = {10, 20, 30} ``` To achieve above, you need to have gdb 7 (I tested it on gdb 7.01) and some python pretty-printer. Installation proce...
253,121
<p>In CSS, you can specify the spacing between table cells using the border-spacing property of a table.</p> <p>However, this results in uniform spacing between columns and rows, and I am finding more situations where the designs I am using call for gaps between rows, but not columns, or visa versa.</p> <p>If I have ...
[ { "answer_id": 253126, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": true, "text": "<p>You <em>can</em> specify different spacings for horizontal and vertical edges for <code>border-spacing</code> or related p...
2008/10/31
[ "https://Stackoverflow.com/questions/253121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1577190/" ]
In CSS, you can specify the spacing between table cells using the border-spacing property of a table. However, this results in uniform spacing between columns and rows, and I am finding more situations where the designs I am using call for gaps between rows, but not columns, or visa versa. If I have a solid backgroun...
You *can* specify different spacings for horizontal and vertical edges for `border-spacing` or related properties. Just specify more than one measurement. e.g., ``` border-spacing: 1px 2px; ```
253,125
<p>Does anyone know how I can add a class to the link rendered using the Html.RouteLink helper method in ASP.Net MVC, it has the htmlAttributes object as the last parameter which I assumed I would be able to use, but since class is obviously a reserved word, I cannot supply this as one of the properties on the object.<...
[ { "answer_id": 253180, "author": "Hrvoje Hudo", "author_id": 1407, "author_profile": "https://Stackoverflow.com/users/1407", "pm_score": 3, "selected": false, "text": "<p>Just use uppercase for html attribute, like this: </p>\n\n<pre><code>&lt;%= Html.RouteLink(\"Default\", \"Default...
2008/10/31
[ "https://Stackoverflow.com/questions/253125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5160/" ]
Does anyone know how I can add a class to the link rendered using the Html.RouteLink helper method in ASP.Net MVC, it has the htmlAttributes object as the last parameter which I assumed I would be able to use, but since class is obviously a reserved word, I cannot supply this as one of the properties on the object.
Try this: ``` <%= Html.RouteLink("Default", "Default",null, new { @class="css_class"}) %> ```
253,138
<p>Having a bit of trouble with the syntax where we want to call a delegate anonymously within a Control.Invoke.</p> <p>We have tried a number of different approaches, all to no avail.</p> <p>For example:</p> <pre><code>myControl.Invoke(delegate() { MyMethod(this, new MyEventArgs(someParameter)); }); </code></pre> ...
[ { "answer_id": 253148, "author": "François", "author_id": 32379, "author_profile": "https://Stackoverflow.com/users/32379", "pm_score": 4, "selected": false, "text": "<pre><code>myControl.Invoke(new MethodInvoker(delegate() {...}))\n</code></pre>\n" }, { "answer_id": 253149, ...
2008/10/31
[ "https://Stackoverflow.com/questions/253138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7140/" ]
Having a bit of trouble with the syntax where we want to call a delegate anonymously within a Control.Invoke. We have tried a number of different approaches, all to no avail. For example: ``` myControl.Invoke(delegate() { MyMethod(this, new MyEventArgs(someParameter)); }); ``` where someParameter is local to this...
Because `Invoke`/`BeginInvoke` accepts `Delegate` (rather than a typed delegate), you need to tell the compiler what type of delegate to create ; `MethodInvoker` (2.0) or `Action` (3.5) are common choices (note they have the same signature); like so: ``` control.Invoke((MethodInvoker) delegate {this.Text = "Hi";}); `...
253,142
<p>I'd like to post some form variables into a classic ASP page. I don't want to have to alter the classic ASP pages, because of the amount of work that would need to be done, and the amount of pages that consume them.</p> <p>The classic ASP page expects form variables Username and Userpassword to be submitted to them...
[ { "answer_id": 253195, "author": "digiguru", "author_id": 5055, "author_profile": "https://Stackoverflow.com/users/5055", "pm_score": 0, "selected": false, "text": "<p>I found this on <a href=\"http://www.jigar.net/articles/viewhtmlcontent78.aspx\" rel=\"nofollow noreferrer\">another sit...
2008/10/31
[ "https://Stackoverflow.com/questions/253142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5055/" ]
I'd like to post some form variables into a classic ASP page. I don't want to have to alter the classic ASP pages, because of the amount of work that would need to be done, and the amount of pages that consume them. The classic ASP page expects form variables Username and Userpassword to be submitted to them. ``` use...
You can't really "forward" a POST on, like you're wanting to do (in your OP). The client has to initiate the POST to your ASP page(s) (which the code in your second post is doing). --- Here's the self-POSTing code from your own reply so you can mark an answer, like you suggested: ``` public class RemotePost{ p...
253,157
<p>Is there a way to resize a <code>std::vector</code> to lower capacity when I no longer need previously reserved space?</p>
[ { "answer_id": 253173, "author": "Sébastien RoccaSerra", "author_id": 2797, "author_profile": "https://Stackoverflow.com/users/2797", "pm_score": 7, "selected": true, "text": "<p>Effective STL, by Scott Meyers, Item 17: Use the <code>swap</code> trick to trim excess capacity.</p>\n\n<pre...
2008/10/31
[ "https://Stackoverflow.com/questions/253157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23766/" ]
Is there a way to resize a `std::vector` to lower capacity when I no longer need previously reserved space?
Effective STL, by Scott Meyers, Item 17: Use the `swap` trick to trim excess capacity. ``` vector<Person>(persons).swap(persons); ``` After that, `persons` is "shrunk to fit". This relies on the fact that `vector`'s copy constructor allocates only as much as memory as needed for the elements being copied.
253,178
<p>I'm developing my first Word 2007 addin, and I've added an OfficeRibbon to my project. In a button-click handler, I'd like a reference to either the current <code>Word.Document</code> or <code>Word.Application</code>.</p> <p>I'm trying to get a reference via the <code>OfficeRibbon.Context</code> property, which the...
[ { "answer_id": 256506, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 1, "selected": false, "text": "<p>While I dont know much about changes in Office 2007 word object model, here is my explanation using VBA knowledge.<...
2008/10/31
[ "https://Stackoverflow.com/questions/253178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6722/" ]
I'm developing my first Word 2007 addin, and I've added an OfficeRibbon to my project. In a button-click handler, I'd like a reference to either the current `Word.Document` or `Word.Application`. I'm trying to get a reference via the `OfficeRibbon.Context` property, which the documentation says should refer to the cur...
I also encountered this problem while creating an Excel 2007 AddIn using VS2008 SP1. The workaround I used was to store the Application in an `internal static` property in the main AddIn class and then reference it in the event handler in my ribbon: ``` public partial class ThisAddIn { internal static Application ...
253,211
<p>I'm working on a C# library which offloads certain work tasks to the GPU using NVIDIA's CUDA. An example of this is adding two arrays together using extension methods:</p> <pre><code>float[] a = new float[]{ ... } float[] b = new float[]{ ... } float[] c = a.Add(b); </code></pre> <p>The work in this code is done o...
[ { "answer_id": 253214, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>I wonder if you couldn't use the regular <code>Delegate.BeginInvoke</code>/<code>Delegate.EndInvoke</code> here? I...
2008/10/31
[ "https://Stackoverflow.com/questions/253211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4055/" ]
I'm working on a C# library which offloads certain work tasks to the GPU using NVIDIA's CUDA. An example of this is adding two arrays together using extension methods: ``` float[] a = new float[]{ ... } float[] b = new float[]{ ... } float[] c = a.Add(b); ``` The work in this code is done on the GPU. However, I woul...
It's not clear to me how much this is a framework you're implementing and how much you're calling into other code, but I would follow the ["normal" async pattern](http://msdn.microsoft.com/en-us/library/ms228975.aspx) in .NET as far as possible.
253,212
<p>How are assertions done in c++? Example code is appreciated.</p>
[ { "answer_id": 253219, "author": "Pieter", "author_id": 5822, "author_profile": "https://Stackoverflow.com/users/5822", "pm_score": 3, "selected": false, "text": "<p>Assertion are boolean expressions which should typically always be true.</p>\n\n<p>They are used to ensure what you expect...
2008/10/31
[ "https://Stackoverflow.com/questions/253212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
How are assertions done in c++? Example code is appreciated.
Asserts are a way of explicitly checking the assumptions that your code makes, which helps you track down lots of bugs by narrowing down what the possible problems could be. They are typically only evaluated in a special "debug" build of your application, so they won't slow down the final release version. Let's say yo...
253,226
<p>I have an interface - here's a nicely contrived version as an example:</p> <pre><code>public interface Particle { enum Charge { POSITIVE, NEGATIVE } Charge getCharge(); double getMass(); etc... } </code></pre> <p>Is there any difference in how implementations of this would behave if...
[ { "answer_id": 253239, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": false, "text": "<p>No, it makes no difference. From the <a href=\"http://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.5\" ...
2008/10/31
[ "https://Stackoverflow.com/questions/253226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1853/" ]
I have an interface - here's a nicely contrived version as an example: ``` public interface Particle { enum Charge { POSITIVE, NEGATIVE } Charge getCharge(); double getMass(); etc... } ``` Is there any difference in how implementations of this would behave if I defined the `Charge` en...
No, it makes no difference. However the reason is not because it is a member declaration inside an interface, as Jon says. The real reason is according to language spec (**8.9**) that > > Nested enum types are implicitly > static. It is permissable to > explicitly declare a nested enum type > to be static. > > ...
253,238
<p>When designing user table what would be the must have fields from the security/user authentication point of view for a Web based Application (.NET and SqlServer 2005)</p> <p>I came with with the following fields:</p> <pre><code>userID username -- preferably email passwordHash onceUsePassword -- to indicate that t...
[ { "answer_id": 253241, "author": "Maxam", "author_id": 15310, "author_profile": "https://Stackoverflow.com/users/15310", "pm_score": 3, "selected": true, "text": "<p>Why not just use the built-in SQL Membership Provider if you're using SQL Server anyway? It's much better than rolling you...
2008/10/31
[ "https://Stackoverflow.com/questions/253238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3241/" ]
When designing user table what would be the must have fields from the security/user authentication point of view for a Web based Application (.NET and SqlServer 2005) I came with with the following fields: ``` userID username -- preferably email passwordHash onceUsePassword -- to indicate that the password should be...
Why not just use the built-in SQL Membership Provider if you're using SQL Server anyway? It's much better than rolling your own since it's been tested by a lot of people. In any case, you should think about adding a salt field your table. [Salting](http://en.wikipedia.org/wiki/Salt_(cryptography)) Update: .NET 1.1?...
253,242
<p>I have a query where i have a date column (time) which tells about "IN" &amp; "OUT" timing of the people attendance by this single column</p> <p>My queries are :-</p> <p>1) How to get the daily attendance of each employee 2) How to come to know if the employee is present less than 5 hours</p> <p>Please let me kno...
[ { "answer_id": 253249, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 0, "selected": false, "text": "<pre><code> select \n datediff(minute, TimeFrom, TimeTo) as AttendedTimeInMinutes,\n case when datediff(minute,...
2008/10/31
[ "https://Stackoverflow.com/questions/253242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a query where i have a date column (time) which tells about "IN" & "OUT" timing of the people attendance by this single column My queries are :- 1) How to get the daily attendance of each employee 2) How to come to know if the employee is present less than 5 hours Please let me know the queries in SQL server.
You'll need to group the query by the user and the items for a particular day then compare the maximum and minimum values, e.g. ``` declare @users table ( UserId int, DateColumn datetime ) insert into @users values (1, '2008-10-31 15:15') insert into @users values (1, '2008-10-31 10:30') insert into @user...
253,247
<p>I have an animation that I'm displaying using a UIImageView:</p> <pre><code>imageView.animationImages = myImages; imageView.animationDuration = 3; [imageView startAnimating]; </code></pre> <p>I know I can stop it using stopAnimating, but what I want is to be able to pause it. The reason is that when you call stop,...
[ { "answer_id": 253349, "author": "Dan", "author_id": 9774, "author_profile": "https://Stackoverflow.com/users/9774", "pm_score": -1, "selected": false, "text": "<p>Maybe you can take a screenshot of the last animated image and display that?</p>\n" }, { "answer_id": 255109, "a...
2008/10/31
[ "https://Stackoverflow.com/questions/253247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6044/" ]
I have an animation that I'm displaying using a UIImageView: ``` imageView.animationImages = myImages; imageView.animationDuration = 3; [imageView startAnimating]; ``` I know I can stop it using stopAnimating, but what I want is to be able to pause it. The reason is that when you call stop, none of your animation im...
Hmmm...since no one seems to know I guess it's not possible. I went ahead and wrote my own `UIView`, with a `UIImageView` `subview`, that uses an `NSTimer` to switch between images. The advantage of this is that I can pause and resume the timer at my leisure, and performance doesn't seem to be an issue.
253,284
<p>I am having dependency troubles. I have two classes: <code>Graphic</code> and <code>Image</code>. Each one has its own .cpp and .h files. I am declaring them as the following: </p> <p><code>Graphic.h</code>: </p> <pre><code> #include "Image.h" class Image; class Graphic { ... }; </code><...
[ { "answer_id": 253294, "author": "marijne", "author_id": 7038, "author_profile": "https://Stackoverflow.com/users/7038", "pm_score": 3, "selected": false, "text": "<p>You don't need to include Image.h or forward declare Image in Graphic.h - that's a circular dependency. If Graphic.h depe...
2008/10/31
[ "https://Stackoverflow.com/questions/253284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3831/" ]
I am having dependency troubles. I have two classes: `Graphic` and `Image`. Each one has its own .cpp and .h files. I am declaring them as the following: `Graphic.h`: ``` #include "Image.h" class Image; class Graphic { ... }; ``` `Image.h`: ``` #include "Graphic.h" class Graphic...
This worked for me: Image.h: ``` #ifndef IMAGE_H #define IMAGE_H #include "Graphic.h" class Image : public Graphic { }; #endif ``` Graphic.h: ``` #ifndef GRAPHIC_H #define GRAPHIC_H #include "Image.h" class Graphic { }; #endif ``` The following code compiles with no error: ``` #include "Graphic.h" int ma...
253,286
<p>I'm trying to design a model for a application allowing 2 people to bet with each other (I know, sounds stupid...). What I'm wondering about is how to connect the bet with users. The structure is like this</p> <pre><code>|-------------| |----------| | Bet | | User | | BetUser1 | |--...
[ { "answer_id": 253335, "author": "tghw", "author_id": 2363, "author_profile": "https://Stackoverflow.com/users/2363", "pm_score": 3, "selected": true, "text": "<p>I would probably add a third model to represent a specific wager someone has placed, as it is conceivable that more than two ...
2008/10/31
[ "https://Stackoverflow.com/questions/253286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4172/" ]
I'm trying to design a model for a application allowing 2 people to bet with each other (I know, sounds stupid...). What I'm wondering about is how to connect the bet with users. The structure is like this ``` |-------------| |----------| | Bet | | User | | BetUser1 | |----------| | Be...
I would probably add a third model to represent a specific wager someone has placed, as it is conceivable that more than two people could enter into a bet. It would look something like this: ``` USER WAGER BET User (FK(User)) Description Bet (FK(Bet)) Winner (FK (W...
253,289
<p>I am new to PHP and trying to get the following code to work:</p> <pre><code>&lt;?php include 'config.php'; include 'opendb.php'; $query = "SELECT name, subject, message FROM contact"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "Name :{$row['name']} &lt;br&gt;"...
[ { "answer_id": 253299, "author": "Mark Biek", "author_id": 305, "author_profile": "https://Stackoverflow.com/users/305", "pm_score": 4, "selected": true, "text": "<p><strong>Edit</strong></p>\n\n<p>You say that you're still getting an error. Did you remember to add a <strong>.</strong> ...
2008/10/31
[ "https://Stackoverflow.com/questions/253289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I am new to PHP and trying to get the following code to work: ``` <?php include 'config.php'; include 'opendb.php'; $query = "SELECT name, subject, message FROM contact"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "Name :{$row['name']} <br>" . "Subject : ...
**Edit** You say that you're still getting an error. Did you remember to add a **.** when you removed that extra semi-colon? --- You have a semi-colon in the middle of your string, two lines after the echo. ![](https://farm4.static.flickr.com/3049/2989189590_754c627f5d.jpg?v=0) Also, the end of the string is missi...
253,312
<p>Any ideas why this won't validate here:</p> <p><a href="http://validator.w3.org/#validate_by_input" rel="nofollow noreferrer">http://validator.w3.org/#validate_by_input</a></p> <p>It seems the form input tags are wrong but reading through the XHTML spec they should validate fine. Any ideas?</p> <pre><code>&lt;!DO...
[ { "answer_id": 253340, "author": "Rahul", "author_id": 16308, "author_profile": "https://Stackoverflow.com/users/16308", "pm_score": 3, "selected": false, "text": "<p>Try putting a <code>fieldset</code> tag around the inputs. I think the idea of forms in XHTML is that they can't have dir...
2008/10/31
[ "https://Stackoverflow.com/questions/253312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
Any ideas why this won't validate here: <http://validator.w3.org/#validate_by_input> It seems the form input tags are wrong but reading through the XHTML spec they should validate fine. Any ideas? ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html ...
You need to move ``` <div class="Controls"> ``` so that it's **inside** the **<form** tag --- This validates nicely ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test</title> </head> ...
253,324
<p>I need a smart way to get the data types out of INFORMATION_SCHEMA.COLUMNS in a way that could be used in a CREATE TABLE statement. The problem is the 'extra' fields that need to be understood, such as NUMERIC<code>_</code>PRECISION and NUMERIC<code>_</code>SCALE.</p> <p>Obviously, I can ignore the columns for INT...
[ { "answer_id": 253330, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 1, "selected": false, "text": "<p>SMO Scripting should take care of the script generations. I believe that this is what MS uses in SQL Management Stud...
2008/10/31
[ "https://Stackoverflow.com/questions/253324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3893/" ]
I need a smart way to get the data types out of INFORMATION\_SCHEMA.COLUMNS in a way that could be used in a CREATE TABLE statement. The problem is the 'extra' fields that need to be understood, such as NUMERIC`_`PRECISION and NUMERIC`_`SCALE. Obviously, I can ignore the columns for INTEGER (precision of 10 and scale ...
Here is an update (ripoff!) of [GalacticCowboy's answer](https://stackoverflow.com/a/253374/880904) to fix some issues and update for all (I think) SQL Server 2008R2 datatypes: ``` select data_type + case when data_type like '%text' or data_type in ('image', 'sql_variant' ,'xml') then '' ...
253,351
<p>I am writing a Java Application for Data Entry using Eclipse and SWT. Naturally it has a great many Text objects. </p> <p>What I would like to happen is that when user enters something into one field focus automatically changes to the next field.</p> <p>Thanks in advance</p>
[ { "answer_id": 254030, "author": "Drazen Urch", "author_id": 33074, "author_profile": "https://Stackoverflow.com/users/33074", "pm_score": 2, "selected": false, "text": "<pre><code>final Text textBox = new Text(shell, SWT.NONE);\ntextBox.addKeyListener(new KeyAdapter() {\n public void...
2008/10/31
[ "https://Stackoverflow.com/questions/253351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33074/" ]
I am writing a Java Application for Data Entry using Eclipse and SWT. Naturally it has a great many Text objects. What I would like to happen is that when user enters something into one field focus automatically changes to the next field. Thanks in advance
``` final Text textBox = new Text(shell, SWT.NONE); textBox.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (x.getText().length() == 1); { x.traverse(SWT.TRAVERSE_TAB_NEXT); } } }); ```
253,360
<p>Whilst trying to get our app working in Firefox (I'm a big proponent of X-Browser support but our lead dev is resisting me saying IE is good enough). So I'm doing a little side project to see how much work it is to convert.</p> <p>I've hit a problem straight away.</p> <p>The main.aspx page binds to a webservice us...
[ { "answer_id": 254299, "author": "Damir Zekić", "author_id": 401510, "author_profile": "https://Stackoverflow.com/users/401510", "pm_score": 3, "selected": true, "text": "<p>I don't think that you are on the right way for achieving real cross-browser compatibility. Adding support for IE-...
2008/10/31
[ "https://Stackoverflow.com/questions/253360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4950/" ]
Whilst trying to get our app working in Firefox (I'm a big proponent of X-Browser support but our lead dev is resisting me saying IE is good enough). So I'm doing a little side project to see how much work it is to convert. I've hit a problem straight away. The main.aspx page binds to a webservice using the IE only m...
I don't think that you are on the right way for achieving real cross-browser compatibility. Adding support for IE-specific features for Firefox is definitely **not** the way to go. What about Opera, Safari, Chrome...? If the app you're working on is used strictly on the intranet then supporting Firefox may be enough ho...
253,378
<p>I am trying the following code:</p> <pre><code>&lt;?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $query = "SELECT * FROM Auctions"; $result = mysql_query($query); while($r...
[ { "answer_id": 253383, "author": "MattBelanger", "author_id": 655, "author_profile": "https://Stackoverflow.com/users/655", "pm_score": 0, "selected": false, "text": "<p>Are you getting anything returned? If no results are found, mysql_query returns FALSE.</p>\n\n<p>Check that before ru...
2008/10/31
[ "https://Stackoverflow.com/questions/253378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I am trying the following code: ``` <?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $query = "SELECT * FROM Auctions"; $result = mysql_query($query); while($row = mysql_fetch_ar...
You haven't selected a database - use [`mysql_select_db()`](http://www.php.net/mysql_select_db) That would be something like: ``` <?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $db_sele...
253,394
<p>I need to add a row to a spreadsheet using VBScript on a PC that does not have Microsoft Office installed.</p> <p>I tried [<code>Set objExcel = CreateObject("Excel.Application")</code>]</p> <p>Since Excel does not exist on the PC I cannot create this object.</p> <p>Is there a way to modify a spreadsheet without E...
[ { "answer_id": 253402, "author": "DilbertDave", "author_id": 31580, "author_profile": "https://Stackoverflow.com/users/31580", "pm_score": 0, "selected": false, "text": "<p>Without Excel installed I cannot see how you will be able to change an Excel document. </p>\n\n<p>However, If your ...
2008/10/31
[ "https://Stackoverflow.com/questions/253394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to add a row to a spreadsheet using VBScript on a PC that does not have Microsoft Office installed. I tried [`Set objExcel = CreateObject("Excel.Application")`] Since Excel does not exist on the PC I cannot create this object. Is there a way to modify a spreadsheet without Excel?
To use the code below, create an Excel workbook named "Test.xls" in the same folder as the vbscript file. In Test.xls, enter the following data in cells A1 thru B4: ``` First Last Joe Smith Mary Jones Sam Nelson ``` Paste the vbscript code below into a .vbs file: ``` Const adOpenStatic = 3 Const adLoc...
253,399
<p>Delphi (and probably a lot of other languages) has class helpers. These provide a way to add extra methods to an existing class. Without making a subclass.</p> <p>So, what are good uses for class helpers?</p>
[ { "answer_id": 253400, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 4, "selected": false, "text": "<p>At first I was kind of sceptic about class helpers. But then I read an interesting <a href=\"http://blogs.conceptf...
2008/10/31
[ "https://Stackoverflow.com/questions/253399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18061/" ]
Delphi (and probably a lot of other languages) has class helpers. These provide a way to add extra methods to an existing class. Without making a subclass. So, what are good uses for class helpers?
I'm using them: * To [insert enumerators](http://17slon.com/blogs/gabr/2007/03/fun-with-enumerators-part-5-class.html "Class helper enumerators") into VCL classes that don't implement them. * To [enhance](http://gp.17slon.com/gp/gpstreams.htm "GpStreams") VCL classes. * To add methods to the TStrings class so I can us...
253,403
<p>I am developing a java web app using servlet, in order to prevent user from hitting the back button to see previous users' info, I have the following code :</p> <pre><code> protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { ...
[ { "answer_id": 253417, "author": "Omar Kooheji", "author_id": 20400, "author_profile": "https://Stackoverflow.com/users/20400", "pm_score": 2, "selected": false, "text": "<p>Breaking the back button is a cardinal sin of web development.</p>\n\n<p>but you could try a bit of java script in...
2008/10/31
[ "https://Stackoverflow.com/questions/253403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32834/" ]
I am developing a java web app using servlet, in order to prevent user from hitting the back button to see previous users' info, I have the following code : ``` protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { Http...
How will hitting the back button cause the user to see *another* user's data? What is your use case? Is it designed for a public terminal, where each user submits data and then leaves? In this case, associate each input with a unique session id. Keep track of valid session ids in your server. Once the input is submitte...
253,410
<p>Alright, I know how the <code>fieldset</code>/<code>legend</code> works out in HTML. Say you have a form with some fields:</p> <pre><code>&lt;form&gt; &lt;fieldset&gt; &lt;legend&gt;legend&lt;/legend&gt; &lt;input name="input1" /&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>What sho...
[ { "answer_id": 253413, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 4, "selected": true, "text": "<p>Yes, the naming is ambiguous. It’s best to consider it as a caption for the fieldset.</p>\n\n<p>See <a href=\"http://www....
2008/10/31
[ "https://Stackoverflow.com/questions/253410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/909/" ]
Alright, I know how the `fieldset`/`legend` works out in HTML. Say you have a form with some fields: ``` <form> <fieldset> <legend>legend</legend> <input name="input1" /> </fieldset> </form> ``` What should I use the `legend` for? It's being displayed as a **title**, but isn't a legend semant...
Yes, the naming is ambiguous. It’s best to consider it as a caption for the fieldset. See [the HTML spec on `FIELDSET` and `LEGEND` elements](http://www.w3.org/TR/html401/interact/forms.html#h-17.10) if you haven’t already: > > The [`LEGEND`](http://www.w3.org/TR/html401/interact/forms.html#edef-LEGEND) element allo...
253,415
<p>I'm having trouble getting the right number of elements in the ArrayList <code>alt</code> in the JSP page below. When I view the JSP it shows the size is 1 (<code>&lt;%=alt.size()%&gt;</code>) when it should be 3; I think I'm adding that method to the array in the generator class, so I don't understand why it's show...
[ { "answer_id": 253432, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 1, "selected": false, "text": "<p>Why are you expecting it to return <code>3</code> when you've only <code>add</code>ed one item to the <code>List</...
2008/10/31
[ "https://Stackoverflow.com/questions/253415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28557/" ]
I'm having trouble getting the right number of elements in the ArrayList `alt` in the JSP page below. When I view the JSP it shows the size is 1 (`<%=alt.size()%>`) when it should be 3; I think I'm adding that method to the array in the generator class, so I don't understand why it's showing 1. This is my jsp page: `...
To get 3 Alerts you can redesign as follows. Notice that there is only one property of the alert class. You can create a new instance of the Alert for each alert. ``` package com.cg.mock; public class Alert { String alert1; public Alert(String alert1) { super(); this.alert1 = alert1; } public S...
253,426
<p>Working with TCL and I'd like to implement something like the <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow noreferrer">Strategy Pattern</a>. I want to pass in the "strategy" for printing output in a TCL function, so I can easily switch between printing to the screen and printing to a log fi...
[ { "answer_id": 253459, "author": "Tom", "author_id": 26155, "author_profile": "https://Stackoverflow.com/users/26155", "pm_score": 0, "selected": false, "text": "<p>How about using variable functions? I don't remember much TCL (it's been a while...) but maybe one of these would do what y...
2008/10/31
[ "https://Stackoverflow.com/questions/253426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1541/" ]
Working with TCL and I'd like to implement something like the [Strategy Pattern](http://en.wikipedia.org/wiki/Strategy_pattern). I want to pass in the "strategy" for printing output in a TCL function, so I can easily switch between printing to the screen and printing to a log file. What's the best way to do this in TCL...
TCL allows you to store the name of a procedure in a variable and then call the procedure using that variable; so ``` proc A { x } { puts $x } set strat A $strat Hello ``` will call the proc A and print out Hello
253,431
<p>I have a WPF control, that has a list of "Investors", and in the right column of the list, a "Delete" button.</p> <p>I could either waste some time making an image of an "x" in photoshop. Or, I could just use Wingdings font and set the content to "Õ" (which makes a cool looking delete button).</p> <p>Is this appro...
[ { "answer_id": 253444, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 5, "selected": true, "text": "<p>Honestly, if you're using WPF, it's probably just as easy to use a path to make an 'x' shape:</p>\n\n<pre><code> &lt;S...
2008/10/31
[ "https://Stackoverflow.com/questions/253431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11917/" ]
I have a WPF control, that has a list of "Investors", and in the right column of the list, a "Delete" button. I could either waste some time making an image of an "x" in photoshop. Or, I could just use Wingdings font and set the content to "Õ" (which makes a cool looking delete button). Is this appropriate? My thinki...
Honestly, if you're using WPF, it's probably just as easy to use a path to make an 'x' shape: ``` <Style x:Key="DeleteButtonStyle" TargetType="{x:Type Button}"> <Setter Property="HorizontalAlignment" Value="Stretch"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Pr...
253,435
<p>I was loading a Bitmap Image from a File. When I tried to save the Image to another file I got the following error "A generic error occurred in GDI+". I believe this is because the file is locked by the image object.</p> <p>Ok so tried calling the Image.Clone function. This still locks the file.</p> <p>hmm. Next ...
[ { "answer_id": 253493, "author": "Sciolist", "author_id": 16045, "author_profile": "https://Stackoverflow.com/users/16045", "pm_score": 2, "selected": false, "text": "<p>Well if you're looking for other ways to do what you're asking, I reckon it should work to create a MemoryStream, and ...
2008/10/31
[ "https://Stackoverflow.com/questions/253435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6204/" ]
I was loading a Bitmap Image from a File. When I tried to save the Image to another file I got the following error "A generic error occurred in GDI+". I believe this is because the file is locked by the image object. Ok so tried calling the Image.Clone function. This still locks the file. hmm. Next I try loading a Bi...
I have since found an alternative method to clone the image without locking the file. [Bob Powell has it all plus more GDI resources](https://web.archive.org/web/20120419185819/http://www.bobpowell.net/imagefileconvert.htm). ``` //open the file Image i = Image.FromFile(path); //create temporary ...
253,437
<p>It appears that Directory.GetFiles() in C# modifies the Last access date of a file. I've googled for hours and can't seem to find a work around for this issue. Is there anyway to keep all the MAC (Modified, Accessed, Created) attributes of a file? I'm using Directory.GetDirectories(), Directory.GetFiles(), and File...
[ { "answer_id": 253461, "author": "dbkk", "author_id": 838, "author_profile": "https://Stackoverflow.com/users/838", "pm_score": 4, "selected": true, "text": "<p>I know this is far from ideal, but u can use fsutil (provided with Windows) to disable last access time writing:</p>\n\n<pre><c...
2008/10/31
[ "https://Stackoverflow.com/questions/253437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33082/" ]
It appears that Directory.GetFiles() in C# modifies the Last access date of a file. I've googled for hours and can't seem to find a work around for this issue. Is there anyway to keep all the MAC (Modified, Accessed, Created) attributes of a file? I'm using Directory.GetDirectories(), Directory.GetFiles(), and FileInf...
I know this is far from ideal, but u can use fsutil (provided with Windows) to disable last access time writing: ``` fsutil behavior set disablelastaccess 1 ``` Presumably you'd set it back to 0 once done. You can invoke this using Process.Start from C#, but there must be a better programmatic way (calling into Wind...