qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
265,650
<p>I have a question regarding a symptom of my misuse of CreateProcess. I'm using the lpcommandline parameter to feed the path to my executable and parameters. My misuse is that I have not surrounded the path to the exe with quotes. </p> <p>My question is, why does the CreateProcess work just fine on most computers and not others? I know that the path will have a space in most of the time, yet on 90% of XP machines it works. I of course found out my issue on those 10% where it did not. But I'm wondering what is different on the machines where it does not work? Is there a setting or a policy that any of you folks know about. And yes, I am going to fix the quote issue. Just curious about why something like this would not have just failed off the bat. </p> <p>So the code would look something like below and the szCommandLine Parameter would be something like below. Notice no quotes around the path to the exe.</p> <p>"C:\Program Files\My Company\doit.exe parameter1 parameter2"</p> <pre><code>CreateProcess( NULL, szCommandLine, NULL, NULL, FALSE, NULL, NULL, NULL, &amp;si, &amp;pi ) </code></pre>
[ { "answer_id": 265847, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 2, "selected": false, "text": "char commandline[] = \"C:\\Program Files\\My Company\\doit.exe parameter1 parameter2\";\nCreateProcess(NULL,commandlin...
2008/11/05
[ "https://Stackoverflow.com/questions/265650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24979/" ]
265,669
<p>I have some code that opens a word document using VBScript on an ASP.net page:</p> <pre><code>set objWord = CreateObject("Word.Application") objWord.Visible = True objWord.Documents.Open "c:\inetpub\wwwroot\JSWordTest\test.doc", False, False, False </code></pre> <p>This works great but opens the word doc in another window. Ideally I would like to make this look as if it is contained in the current page perhaps in an IFrame. I have some other buttons which paste text into the word document when clicked. </p> <p>I cannot just set the src of the iframe to the word document as need a reference to the word document (objWord) to allow me to paste text into it in real time again using Vbscript to do this.</p> <p>Not sure if this is possible but any ideas/alternatives welcome?</p> <p>Requirements: The word doc needs to be displayed from web browser</p> <p>At the side of the word document will be some buttons which when clicked paste text into it</p>
[ { "answer_id": 267116, "author": "unrealtrip", "author_id": 11130, "author_profile": "https://Stackoverflow.com/users/11130", "pm_score": 2, "selected": false, "text": "' Declare an object for the word application '\nSet objWord = CreateObject(\"Word.Application\")\n\nobjWord.Visible = F...
2008/11/05
[ "https://Stackoverflow.com/questions/265669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23066/" ]
265,679
<p>I want to do something like this from within Eclipse: <a href="http://svn.collab.net/viewvc/svn?view=rev&amp;revision=33845" rel="nofollow noreferrer">http://svn.collab.net/viewvc/svn?view=rev&amp;revision=33845</a></p> <p>I use Subversive 0.7.5 with the Native JavaHL 1.5.3 (r33570) Connector.</p> <p>I tried to change something in a my working copy of a branch i'd like to tag and creating a Tag with Team -&gt; Tag... But I got the error message:</p> <blockquote> <p>Tag operation for some of selected resources failed.</p> <p>A path under version control is needed for this operation</p> </blockquote> <p>I tried only a tag name and one with full repository path. Both resulted in the same error. This is the error I get:</p> <pre><code>*** Tag svn copy &quot;C:/workspace/some_branch&quot; &quot;http://server:8080/svn/project/tags/TagWithChange&quot; -r WORKING -m &quot;TagWithChange&quot; --username &quot;masi&quot; A path under version control is needed for this operation </code></pre> <p>Is it possible from within Eclipse?</p> <p>How would you do something like this from the command line? See my own answer.</p> <p>Though if I use the following at the command line I get an error:</p> <pre><code>svn copy &quot;C:/workspace/some_branch&quot; &quot;http://server:8080/svn/project/tags/TagWithChange&quot; -r WORKING -m &quot;TagWithChange&quot; --username &quot;masi&quot; </code></pre> <p>Error:</p> <blockquote> <p>svn: Syntax error in revision argument 'WORKING'</p> </blockquote> <p>I'm using the svn client 1.5.4.</p>
[ { "answer_id": 265697, "author": "masi", "author_id": 12398, "author_profile": "https://Stackoverflow.com/users/12398", "pm_score": 2, "selected": false, "text": "svn copy some_branch http://server:8080/svn/tags/TagWithChange -m\"TagWithChange\"\n" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/265679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12398/" ]
265,680
<p>I'm using AspectJ to advice all the public methods which do have an argument of a chosen class. I tried the following:</p> <pre><code>pointcut permissionCheckMethods(Session sess) : (execution(public * *(.., Session)) &amp;&amp; args(*, sess)); </code></pre> <p>This is working wonderfully for methods with at least 2 arguments:</p> <pre><code>public void delete(Object item, Session currentSession); </code></pre> <p>but it does not work with methods like:</p> <pre><code>public List listAll(Session currentSession); </code></pre> <p>How may I change my pointcut to advice both methods executions? In other words: I expected the ".." wildcard to represent "zero or more arguments", but it looks like it means instead "one or more"...</p>
[ { "answer_id": 320404, "author": "Manrico Corazzi", "author_id": 4690, "author_profile": "https://Stackoverflow.com/users/4690", "pm_score": 4, "selected": true, "text": "pointcut permissionCheckMethods(EhealthSession eheSess) : \n (execution(public * *(.., EhealthSession)) && args(*,...
2008/11/05
[ "https://Stackoverflow.com/questions/265680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4690/" ]
265,708
<p>A fairly basic question, but I don't see it asked anywhere.</p> <p>Let's say we have a global struct (in C) like so:</p> <pre><code>struct foo { int written_frequently1; int read_only; int written_frequently2; }; </code></pre> <p>It seems clear to me that if we have lots of threads reading and writing, we need a semaphore (or other lock) on the <code>written_frequently</code> members, even for reading, since we can't be 100% sure that assignments to this struct will be atomic.</p> <p>If we want lots of threads to read the <code>read_only</code> member, and none to write, to we need a semaphore on the struct access just for reading?</p> <p>(I'm inclined to say no, because the fact that the locations immediately before and after are constantly changed shouldn't affect the <code>read_only</code> member, and multiple threads reading the value shouldn't interfere with each other. But I'm not sure.)</p> <hr> <p>[Edit: I realize now I should have asked this question much better, in order to clarify <em>very specifically</em> what I meant. Naturally, I didn't really grok all of the issues involved when I first asked the question. Of course, if I comprehensively edit the question now, I will ruin all of these great answers. What I meant is more like:</p> <pre><code>struct bar { char written_frequently1[LONGISH_LEN]; char read_only[LONGISH_LEN]; char written_frequently2[LONGISH_LEN]; }; </code></pre> <p>The major issue I asked about is, since this data is part of a struct, is it at all influenced by the other struct members, and might it influence them in return?</p> <p>The fact that the members were ints, and therefore writes are likely atomic, is really just a red herring in this case.]</p>
[ { "answer_id": 265748, "author": "Yogi", "author_id": 32801, "author_profile": "https://Stackoverflow.com/users/32801", "pm_score": 2, "selected": false, "text": "int" }, { "answer_id": 267617, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stac...
2008/11/05
[ "https://Stackoverflow.com/questions/265708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15456/" ]
265,720
<p>In Python 2.6, a new "timeout" parameter was added to the httplib.HTTPConnection class: <a href="http://docs.python.org/library/httplib.html#httplib.HTTPConnection" rel="nofollow noreferrer">http://docs.python.org/library/httplib.html#httplib.HTTPConnection</a></p> <p>However, this is only a timeout for the connection to a server. I am looking to set a timeout value for the <b>request</b>, not the connection. This doesn't seem to be supported by httplib.</p> <p>Is there any way to emulate this behavior?</p>
[ { "answer_id": 265741, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": true, "text": "import socket\n\ntimeout = 10\nsocket.setdefaulttimeout(timeout)\n" }, { "answer_id": 4453301, "author": "Pankr...
2008/11/05
[ "https://Stackoverflow.com/questions/265720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16148/" ]
265,722
<p>I'm trying to create an ASP page that has a bridged connection with an SQL Server 2005 database (separate sever from the ASP's server). For this I am trying to use a Windows Authentication setup. I have my name with full rights to the SQL server yet I am still getting the error 'Login failed for user COMPANY\name'. To see if this was just a Windows Authentication problem I tried to do a SQL Server Authentication; This also will not let me login. I have no idea why there would be a problem with the SQL Authentication, but I could really use some help figuring out why the Windows Authentication won't work. Thank you for your time.</p> <p>Regards,</p> <p>Franco</p>
[ { "answer_id": 266238, "author": "Dave Swersky", "author_id": 34796, "author_profile": "https://Stackoverflow.com/users/34796", "pm_score": 0, "selected": false, "text": "<identity impersonate=\"true\" />\n" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/265722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
265,725
<p>I have some constants that represent the valid options in one of my model's fields. What's the best way to handle these constants in Ruby?</p>
[ { "answer_id": 265767, "author": "Micah", "author_id": 19964, "author_profile": "https://Stackoverflow.com/users/19964", "pm_score": 4, "selected": false, "text": "class MyClass < ActiveRecord::Base\n ACTIVE_STATUS = \"active\"\n INACTIVE_STATUS = \"inactive\"\n PENDING_STATUS = \"pen...
2008/11/05
[ "https://Stackoverflow.com/questions/265725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34746/" ]
265,750
<p>I have a xml build of</p> <pre><code>&lt;elig&gt; &lt;subscriber code="1234"/&gt; &lt;date to="12/30/2004" from="12/31/2004"/&gt; &lt;person name="bob" ID="654321"/&gt; &lt;dog type="labrador" color="white"/&gt; &lt;location name="hawaii" islandCode="01"/&gt; &lt;/subscriber&gt; &lt;/elig&gt; </code></pre> <p>In XSL I have:</p> <pre><code>&lt;xsl:template match="subscriber"&gt; &lt;xsl:for-each select="date"&gt; &lt;xsl:apply-templates match="person" /&gt; &lt;xsl:apply-templates match="location" /&gt; &lt;xsl:apply-templates match="dog" /&gt; &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; </code></pre> <p>The problem I have is that I need the location block in between the person and the dog block. I have tried ../ and it does not work. I simplified this majorly but the point comes across. I can't seem to remember what I need to place in front of location to get it to work. Thanks.</p>
[ { "answer_id": 265828, "author": "mkoeller", "author_id": 33433, "author_profile": "https://Stackoverflow.com/users/33433", "pm_score": 1, "selected": false, "text": "<elig>\n <subscriber code=\"1234\">\n <date to=\"12/30/2004\" from=\"12/31/2004\"/>\n <person name=\"bob\" ID=\"...
2008/11/05
[ "https://Stackoverflow.com/questions/265750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16354/" ]
265,761
<p>In the iPhone 2.x firmware, can you make the iPhone vibrate for durations other than the system-defined:</p> <pre><code>AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); </code></pre> <p>In jailbroken phones, you used to be able to use the MeCCA.framework to do this:</p> <p><a href="http://pastie.org/94481" rel="nofollow noreferrer">http://pastie.org/94481</a></p> <pre><code>MeCCA_Vibrator *v = new MeCCA_Vibrator; v-&gt;activate(1); sleep(5); v-&gt;deactivate(); </code></pre> <p>But MeCCA.framework doesn't exist on my 2.x iPhone.</p>
[ { "answer_id": 281614, "author": "KevinButler", "author_id": 34463, "author_profile": "https://Stackoverflow.com/users/34463", "pm_score": 5, "selected": true, "text": "extern void * _CTServerConnectionCreate(CFAllocatorRef, int (*)(void *, CFStringRef, CFDictionaryRef, void *), int *);\...
2008/11/05
[ "https://Stackoverflow.com/questions/265761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34463/" ]
265,762
<p>Always when I run java application it will display in Windows Task Manager is java.exe or javaw.exe. How to rename java.exe or javaw.exe process without wrapper by other programming languages.</p>
[ { "answer_id": 46060331, "author": "jbilander", "author_id": 7253471, "author_profile": "https://Stackoverflow.com/users/7253471", "pm_score": 1, "selected": false, "text": "javapackager" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/265762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24550/" ]
265,769
<p>I'm designing a database table which will hold filenames of uploaded files. What is the maximum length of a filename in NTFS as used by Windows XP or Vista?</p>
[ { "answer_id": 265782, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 9, "selected": true, "text": "MAX_PATH" }, { "answer_id": 265785, "author": "Kibbee", "author_id": 1862, "author_profile": "htt...
2008/11/05
[ "https://Stackoverflow.com/questions/265769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
265,774
<p>Consider the following code:</p> <pre><code>&lt;a href="#label2"&gt;GoTo Label2&lt;/a&gt; ... [content here] ... &lt;a name="label0"&gt;&lt;/a&gt;More content &lt;a name="label1"&gt;&lt;/a&gt;More content &lt;a name="label2"&gt;&lt;/a&gt;More content &lt;a name="label3"&gt;&lt;/a&gt;More content &lt;a name="label4"&gt;&lt;/a&gt;More content </code></pre> <p>Is there a way to emulate clicking on the "GoTo Label2" link to scroll to the appropriate region on the page through code?</p> <p><strong>EDIT</strong>: An acceptable alternative would be to scroll to an element with a unique-id, which already exists on my page. I would be adding the anchor tags if this is a viable solution.</p>
[ { "answer_id": 265789, "author": "mkoeller", "author_id": 33433, "author_profile": "https://Stackoverflow.com/users/33433", "pm_score": 2, "selected": false, "text": "window.location=\"<yourCurrentUri>#label2\";\n" }, { "answer_id": 265805, "author": "Ken Pespisa", "autho...
2008/11/05
[ "https://Stackoverflow.com/questions/265774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
265,807
<p>I have a control that is basically functioning as a client-side timer countdown control.</p> <p>I want to fire a server-side event when the count down has reached a certain time.</p> <p>Does anyone have an idea how this could be done?</p> <p>So, when timer counts down to 0, a server-side event is fired.</p>
[ { "answer_id": 265840, "author": "wonderchook", "author_id": 32113, "author_profile": "https://Stackoverflow.com/users/32113", "pm_score": 1, "selected": false, "text": "function NotifyServer()\n{\n xmlHttp = new ActiveXObject(\"Microsoft.XMLHTTP\");\n xmlHttp.onreadystatechange = ...
2008/11/05
[ "https://Stackoverflow.com/questions/265807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5853/" ]
265,809
<p>I'm scouring the internet for a definition of the term &quot;Internal Node.&quot; I cannot find a succinct definition. Every source I'm looking at uses the term without defining it, and the usage doesn't yield a proper definition of what an internal node actually is.</p> <p>Here are the two places I've been mainly looking: <a href="https://planetmath.org/ExternalNode" rel="nofollow noreferrer">Link</a> assumes that internal nodes are nodes that have two subtrees that aren't null, but doesn't say what nodes in the original tree are internal vs. external. <br /></p> <p><a href="http://www.math.bas.bg/%7Enkirov/2008/NETB201/slides/ch06/ch06-2.html" rel="nofollow noreferrer">http://www.math.bas.bg/~nkirov/2008/NETB201/slides/ch06/ch06-2.html</a> seems to insinuate that internal nodes only exist in proper binary trees and doesn't yield much useful information about them.</p> <p>What actually <em>is</em> an internal node!?</p>
[ { "answer_id": 265823, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 8, "selected": true, "text": " I ROOT (root is also an INTERNAL NODE, unless it is leaf)\n / \\\n I I INTERNAL NODES\n / ...
2008/11/05
[ "https://Stackoverflow.com/questions/265809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29119/" ]
265,814
<p>How can I create a regex for a string such as this:</p> <pre><code>&lt;SERVER&gt; &lt;SERVERKEY&gt; &lt;COMMAND&gt; &lt;FOLDERPATH&gt; &lt;RETENTION&gt; &lt;TRANSFERMODE&gt; &lt;OUTPUTPATH&gt; &lt;LOGTO&gt; &lt;OPTIONAL-MAXSIZE&gt; &lt;OPTIONAL-OFFSET&gt; </code></pre> <p>Most of these fields are just simple words, but some of them can be paths, such as FOLDERPATH, OUTPUTPATH, these paths can also be paths with a filename and wildcard appended.</p> <p>Retention is a number, and transfer mode can be bin or ascii. The issue is, LOGTO which can be a path with the logfile name appended to it or can be NO, which means no log file.</p> <p>The main issue, is the optional arguments, they are both numbers, and OFFSET can't exist without MAXSIZE, but MAXSIZE can exist without offset.</p> <p>Heres some examples:</p> <pre><code>loveserver love copy /muffin* 20 bin C:\Puppies\ NO 256 300 loveserver love copy /muffin* 20 bin C:\Puppies\ NO 256 loveserver love copy /hats* 300 ascii C:\Puppies\no\ C:\log\love.log 256 </code></pre> <p>Now the main issue, is that paths can have spaces in them, so if I use . to match everything, the regex ends up breaking, when parsing the optional arguments where the LOG destination ends up getting attached to the outputpath.</p> <p>Also if I end up using . and start removing parts of it, the regex will start putting things where it shouldn't.</p> <p>Heres my regex:</p> <pre><code>^(\s+)?(?P&lt;SRCHOST&gt;.+)(\s+)(?P&lt;SRCKEY&gt;.+)(\s+)(?P&lt;COMMAND&gt;COPY)(\s+)(?P&lt;SRCDIR&gt;.+)(\s+)(?P&lt;RETENTION&gt;\d+)(\s+)(?P&lt;TRANSFER_MODE&gt;BIN|ASC|BINARY|ASCII)(\s+)(?P&lt;DSTDIR&gt;.+)(\s+)(?P&lt;LOGFILE&gt;.+)(\s+)?(?P&lt;SIZE&gt;\d+)?(\s+)?(?P&lt;OFFSET&gt;\d+)?$ </code></pre>
[ { "answer_id": 265940, "author": "Stroboskop", "author_id": 23428, "author_profile": "https://Stackoverflow.com/users/23428", "pm_score": 0, "selected": false, "text": "<OUTPUTPATH> <LOGTO>\n" }, { "answer_id": 266010, "author": "Markus Jarderot", "author_id": 22364, ...
2008/11/05
[ "https://Stackoverflow.com/questions/265814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34395/" ]
265,849
<p>That's it. It's a dumb dumb (embarrassing!) question, but I've never used C# before, only C++ and I can't seem to figure out how to access a Label on my main form from a secondary form and change the text. If anybody can let me know real quick what to do I'd be so grateful!</p> <p>BTW, I should really clarify. Sorry: I've got two separate .cs files that each look about like below. I was using the [Designer] in VS2008 to add in the label in Form1. When I type something like Form1.label1 it doesn't understand. The dropdown shows a list of methods and properties for Form1, but there's only about 7, like ControlCollection, Equals, MouseButtons, and a couple others... I can publicly define a variable in Form1 and that shows, but I don't know how to access the label...</p> <pre><code>namespace AnotherProgram { public partial class Form1 : Form { public Form1() { InitializeComponent(); } } } </code></pre>
[ { "answer_id": 265885, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "this" }, { "answer_id": 265887, "author": "Craig Norton", "author_id": 24804, "author_profile": "http...
2008/11/05
[ "https://Stackoverflow.com/questions/265849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
265,850
<p>Usually, I need to retrieve data from a table in some range; for example, a separate page for each search result. In MySQL I use LIMIT keyword but in DB2 I don't know. Now I use this query for retrieve range of data.</p> <pre><code>SELECT * FROM( SELECT SMALLINT(RANK() OVER(ORDER BY NAME DESC)) AS RUNNING_NO , DATA_KEY_VALUE , SHOW_PRIORITY FROM EMPLOYEE WHERE NAME LIKE 'DEL%' ORDER BY NAME DESC FETCH FIRST 20 ROWS ONLY ) AS TMP ORDER BY TMP.RUNNING_NO ASC FETCH FIRST 10 ROWS ONLY </code></pre> <p>but I know it's bad style. So, how to query for highest performance?</p>
[ { "answer_id": 273106, "author": "Paul Morgan", "author_id": 16322, "author_profile": "https://Stackoverflow.com/users/16322", "pm_score": 2, "selected": false, "text": "SELECT SMALLINT(RANK() OVER(ORDER BY NAME DESC)) AS RUNNING_NO,\n DATA_KEY_VALUE,\n SHOW_PRIORITY\n FROM ...
2008/11/05
[ "https://Stackoverflow.com/questions/265850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24550/" ]
265,855
<p>I've got a database here that runs entirely on GMT. The client machines, however, may run on many different time zones (including BST). When you pull data back using SqlConnection, it will translate the datetime value so, for instance</p> <p>19 August 2008</p> <p>becomes</p> <p>18 August 2008 23:00:00.</p> <p>My question is, is there a way to specify to the connection that you do not wish this translation to take place?</p>
[ { "answer_id": 265971, "author": "Craig Norton", "author_id": 24804, "author_profile": "https://Stackoverflow.com/users/24804", "pm_score": 2, "selected": false, "text": "returnedDataTable.Columns(\"ColumnName\").DateTimeMode = DataSetDateTime.Unspecified\n" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/265855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
265,875
<p>I have always initialized my strings to NULL, with the thinking that NULL means the absence of a value and &quot;&quot; or String.Empty is a valid value. I have seen more examples lately of code where String.Empty is considered the default value or represents no value. This strikes me as odd, with the newly added nullable types in c# it seems like we are taking strides backwards with strings by not using the NULL to represent 'No Value'.</p> <p><strong>What do you use as the default initializer and why?</strong></p> <p><em>Edit: Based on the answers I futher my further thoughts</em></p> <ol> <li><p><strong>Avoiding error handling</strong> If the value shouldn't be null, why did it get set to <code>NULL</code> in the first place? Perhaps it would be better to identify the error at the place where it occurs rather than cover it up through out the rest of your codebase?</p> </li> <li><p><strong>Avoiding null checks</strong> If you are tired of doing null checks in code, wouldn't it be better to abstract the null checks? Perhaps wrap (or extend!) the string methods to make them <code>NULL</code> safe? What happens if you constantly use <code>String.Empty</code> and a null happens to work it's way into your system, do you start adding <code>NULL</code> checks anyways?</p> </li> </ol> <p>I can't help but return to the opinion that it is laziness. Any DBA would slap you nine ways to silly if you used '' instead of <code>null</code> in his\her database. I think the same principles apply in programming and there should be somebody to smack those upside the head who use <code>String.Empty</code> rather than <code>NULL</code> to represent no value.</p> <blockquote> <h3>Related Questions</h3> <ul> <li><a href="https://stackoverflow.com/questions/263191/in-c-should-i-use-stringempty-or-stringempty-or">In C#, should I use string.Empty or String.Empty or “” ?</a></li> <li><a href="https://stackoverflow.com/questions/151472/what-is-the-difference-between-stringempty-and">What is the difference between String.Empty and “”</a></li> <li><a href="https://stackoverflow.com/questions/167952/null-or-empty-string-to-represent-no-data-in-table-column">Null or empty string to represent no data in table column?</a></li> </ul> </blockquote>
[ { "answer_id": 265900, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 5, "selected": false, "text": "Empty" }, { "answer_id": 266272, "author": "Robert Rossney", "author_id": 19403, "author_profile": "ht...
2008/11/05
[ "https://Stackoverflow.com/questions/265875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24279/" ]
265,879
<p>I am interested in using/learning RoR in a project where I have to use a .NET dll. Is Ruby capable of importing a .NET dll?</p>
[ { "answer_id": 266032, "author": "mackenir", "author_id": 25457, "author_profile": "https://Stackoverflow.com/users/25457", "pm_score": 2, "selected": false, "text": "\"Your Ruby Code\" -> RubyCOM -> \"COM-Callable Wrappers\" -> \"Your .NET objects\"\n" }, { "answer_id": 266403, ...
2008/11/05
[ "https://Stackoverflow.com/questions/265879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34766/" ]
265,896
<p>I've got a junk directory where I toss downloads, one-off projects, email drafts, and other various things that might be useful for a few days but don't need to be saved forever. To stop this directory from taking over my machine, I wrote a program that will delete all files older than a specified number of days and logs some statistics about the number of files deleted and their size just for fun.</p> <p>I noticed that a few project folders were living way longer than they should, so I started to investigate. In particular, it seemed that folders for projects in which I had used SVN were sticking around. It turns out that the read-only files in the .svn directories are not being deleted. I just did a simple test on a read-only file and discovered that <code>System.IO.File.Delete</code> and <code>System.IO.FileInfo.Delete</code> will not delete a read-only file.</p> <p>I don't care about protecting files in this particular directory; if something important is in there it's in the wrong place. Is there a .NET class that can delete read-only files, or am I going to have to check for read-only attributes and strip them?</p>
[ { "answer_id": 265916, "author": "mkoeller", "author_id": 33433, "author_profile": "https://Stackoverflow.com/users/33433", "pm_score": 1, "selected": false, "text": ">del /F *\n" }, { "answer_id": 265938, "author": "Gulzar Nazim", "author_id": 4337, "author_profile":...
2008/11/05
[ "https://Stackoverflow.com/questions/265896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2547/" ]
265,898
<p>I'm coding a small CMS to get a better understanding of how they work and to learn some new things about PHP. I have however come across a problem.</p> <p>I want to use mod_rewrite (though if someone has a better solution I'm up for trying it) to produce nice clean URLs, so site.com/index.php?page=2 can instead be site.com/tools</p> <p>By my understanding I need to alter my .htaccess file each time I add a new page and this is where I strike a problem, my PHP keeps telling me that I can't update it because it hasn't the permissions. A quick bit of chmod reveals that even with 777 permissions it can't do it, am I missing something?</p> <p>My source for mod_rewrite instructions is currently <a href="http://wettone.com/code/clean-urls" rel="noreferrer">this page here</a> incase it is important/useful.</p>
[ { "answer_id": 265934, "author": "Ken", "author_id": 20074, "author_profile": "https://Stackoverflow.com/users/20074", "pm_score": 4, "selected": true, "text": "RewriteEngine on\nRewriteBase /\n\n# only rewrite if the requested file doesn't exist\nRewriteCond %{REQUEST_FILENAME} !-s \n\n...
2008/11/05
[ "https://Stackoverflow.com/questions/265898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
265,919
<p>I'm working on a program that processes many requests, none of them reaching more than 50% of CPU (<strong>currently I'm working on a dual core</strong>). So I created a thread for each request, the whole process is faster. Processing 9 requests, a single thread lasts 02min08s, while with 3 threads working simultaneously the time decreased to 01min37s, but it keeps not using 100% CPU, only around 50%.</p> <p>How could I allow my program to use full processors capability?</p> <p><strong>EDIT</strong> The application isn't IO or Memory bounded, they're at reasonable levels all the time.</p> <p>I think it has something to do with the 'dual core' thing.</p> <p>There is a locked method invocation that every request uses, but it is really fast, I don't think this is the problem.</p> <p>The more cpu-costly part of my code is the call of a dll via COM (the same external method is called from all threads). This dll is also no Memory or IO-bounded, it is an AI recognition component, I'm doing an OCR recognition of paychecks, a paycheck for request.</p> <p><strong>EDIT2</strong></p> <p>It is very probable that the STA COM Method is my problem, I contacted the component owners in order to solve this problem.</p>
[ { "answer_id": 265935, "author": "mackenir", "author_id": 25457, "author_profile": "https://Stackoverflow.com/users/25457", "pm_score": 2, "selected": false, "text": "class Test\n{\n static void Main() //This will be an MTA thread by default\n {\n var o = new COMObjectClass();\n ...
2008/11/05
[ "https://Stackoverflow.com/questions/265919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21668/" ]
265,930
<p>I'm generating and showing a new WinForms window on top of a Main Window. How can I achieve that the original (Main Window) keeps the focus? Setting the focus back after showing the new window does not solve my problem because I need to prevent the Main Window's title bar from flickering. The new window has to stay on top of the Main Window so I have to set topMost=true. However, this makes no difference for the problem I think.</p> <p>Thank you!</p>
[ { "answer_id": 265987, "author": "Spidey", "author_id": 4236, "author_profile": "https://Stackoverflow.com/users/4236", "pm_score": 2, "selected": false, "text": "private void button1_Click(object sender, EventArgs e)\n{\n Form2 f2 = new Form2();\n f2.TopMost = true;\n f2.Sho...
2008/11/05
[ "https://Stackoverflow.com/questions/265930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
265,944
<p>How do you reverse the effect of a merge on polarised branches without dying of agony?</p> <p>This problem has been plaguing me for <strong>months</strong> and I have finally given up. </p> <p>You have 1 Repository, with 2 <strong>Named</strong> Branches. A and B. </p> <p>Changes that occur to A will inevitably occur on B. </p> <p>Changes that occur directly on B MUST NEVER occur on A. </p> <p>In such a configuration, merging "B" into "A" produces a dire problem in the repository, as all the changes to B appear in A as if they were made in A. </p> <p>The only "normal" way to recover from this situation appears to be "backing out" the merge, ie: </p> <pre><code> hg up -r A hg backout -r BadMergeRev --parent BadMergerevBeforeOnA </code></pre> <p>Which looks all fine and dandy, until you decide to merge later in the correct direction, and you end up with all sorts of nasty things happening and code that was erased / commented out on specifically branch B suddenly becomes unerased or uncommented. </p> <p>There has not been a working viable solution to this so far other than "let it do its thing, and then hand fix all the problems" and that to be honest is a bit fubar. </p> <p>Here is an image clarifying the problem: </p> <p><em>[Original image lost]</em></p> <p>Files C &amp; E ( or changes C &amp; E ) must appear only on branch b, and not on branch a. Revision A9 here ( branch a, revno 9 ) is the start of the problem. </p> <p>Revisions A10 and A11 are the "Backout merge" and "merge the backout" phases. </p> <p>And revision B12 is mercurial, erroneously repeatedly dropping a change that was intended not to be dropped. </p> <p>This Dilemma has caused much frustration and blue smoke and I would like to put an end to it. </p> <h3>Note</h3> <p>It may be the obvious answer to try prohibiting the reverse merge from occurring, either with hooks or with policies, I have found the ability to muck this up is rather high and the chance of it happening so likely that even with countermeasures, you <em>must</em> still assume that inevitably, it <em>will</em> happen so that you can solve it when it does.</p> <h3>To Elaborate</h3> <p>In the model I have used Seperate files. These make the problem sound simple. These merely represent <em>arbitrary changes</em> which could be a separate line. </p> <p>Also, to add insult to injury, there have been substantial changes on branch A which leaves the standing problem "do the changes in branch A conflict with the changes in branch B which just turned up ( and got backed out ) which looks like a change on branch A instead " </p> <h3>On History Rewriting Tricks:</h3> <p>The problem with all these retro-active solutions is as follows:</p> <ol> <li>We have 9000 commits. </li> <li>Cloning freshly thus takes half an hour</li> <li>If there exists <em>even one</em> bad clone of the repository <em>somewhere</em>, there is a liklihood of it comming back in contact with the original repository, and banging it up all over again. </li> <li>Everyone has cloned this repository already, and now several days have passed with on-going commits.</li> <li>One such clone, happens to be a live site, so "wiping that one and starting from scratch" = "big nono" </li> </ol> <p>( I admit, many of the above are a bit daft, but they are outside of my control ). </p> <p>The only solutions that are viable are the ones that assume that people <em>can</em> and <em>will</em> do everything wrong, and that there is a way to 'undo' this wrongness. </p>
[ { "answer_id": 2093167, "author": "oenli", "author_id": 251438, "author_profile": "https://Stackoverflow.com/users/251438", "pm_score": 6, "selected": false, "text": "hg update 11" }, { "answer_id": 10203239, "author": "Kevin", "author_id": 1340389, "author_profile": ...
2008/11/05
[ "https://Stackoverflow.com/questions/265944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15614/" ]
265,953
<p>Basically, I would like to check if I have rights to open the file before I actually try to open it; I do not want to use a try/catch for this check unless I have to. Is there a file access property I can check before hand?</p>
[ { "answer_id": 265958, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 7, "selected": false, "text": ".Exists()" }, { "answer_id": 266316, "author": "Robert Rossney", "author_id": 19403, "author_profi...
2008/11/05
[ "https://Stackoverflow.com/questions/265953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12333/" ]
265,956
<p>I am pretty new to php, but I am learning! I have a simple form on a client website. I am testing the form and when I click submit, I get the following error:</p> <p>Form Mail Script</p> <pre><code>Wrong referrer (referring site). For security reasons the form can only be used, if the referring page is part of this website. Note for the Admin: Please add the name of your server to the referrer variable in the index.php configuration file: mywebsite.com </code></pre> <p>Powered by Form Mail Script</p> <p>I am looking through the forms configuration and support files but I do not understand exactly what it is I need to change.</p> <p>Can someone please explain to me what the Admin note above means and how to fix it?</p>
[ { "answer_id": 266105, "author": "pd.", "author_id": 19066, "author_profile": "https://Stackoverflow.com/users/19066", "pm_score": 2, "selected": false, "text": "$referring_server = 'http://www.mywebsite.com, scripts';\n" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/265956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30043/" ]
265,960
<p>It seems like there should be a simpler way than:</p> <pre><code>import string s = "string. With. Punctuation?" # Sample string out = s.translate(string.maketrans("",""), string.punctuation) </code></pre> <p>Is there?</p>
[ { "answer_id": 265995, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 5, "selected": false, "text": "import re, string\ns = \"string. With. Punctuation?\" # Sample string \nout = re.sub('[%s]' % re.escape(string.punct...
2008/11/05
[ "https://Stackoverflow.com/questions/265960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
265,970
<p>I'm more of a programmer than a designer, and I'm trying to embrace <code>&lt;div&gt;</code>s rather than using tables but am getting stuck.</p> <p>Here's what I'm trying to do. I am setting up a survey page. I want each question's text to sit at the top of the blue div, and wrap if it's too long. I want all of the red divs to line up at the top right corner of the container div.</p> <p><a href="http://img528.imageshack.us/img528/4330/divsforsurveyop2.jpg" rel="nofollow noreferrer">Layout http://img528.imageshack.us/img528/4330/divsforsurveyop2.jpg</a></p> <p>Here's what I've started with, it works fine so long as the frame is more than 420 pixels wide. Then the red div skips to the next line. I think I may have approached it wrong, perhaps I should be floating things to the right?</p> <pre><code>.greencontainer{ width:100%; spacing : 10 10 10 10 ; float: left; } .redcontainer{ float: left; width: 20px; padding: 2 0 2 0; font-size: 11px; font-family: sans-serif; text-align: center; } .bluecontainer{ clear: both; float: left; width: 400px; padding: 2 2 2 10; font-size: 11px; font-family: sans-serif; text-align: left; } </code></pre>
[ { "answer_id": 266007, "author": "philnash", "author_id": 28376, "author_profile": "https://Stackoverflow.com/users/28376", "pm_score": 3, "selected": true, "text": "<div class=\"greencontainer\">\n <div class=\"redcontainer\">\n <input type=\"checkbox\" />\n </div>\n <div class=\"...
2008/11/05
[ "https://Stackoverflow.com/questions/265970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28351/" ]
265,973
<p>I've inherited someone else's monster of a BASH script. The script was written in such a way that it uses a ridiculous amount of memory (around 1GB). I can run it from a shell with out issue, but if I run it from cron I crashes with a sig fault. </p> <p>Apart from digging into the poorly commented behemoth, is there a way to run it from cron with out running into the sig fault? </p> <p>Cheers,</p> <p>Steve</p>
[ { "answer_id": 266161, "author": "JimB", "author_id": 32880, "author_profile": "https://Stackoverflow.com/users/32880", "pm_score": -1, "selected": false, "text": "/path/to/bigscript.sh &> /dev/null\n" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/265973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
265,984
<p>Let's say we have defined a CSS class that is being applied to various elements on a page.</p> <pre><code>colourful { color: #DD00DD; background-color: #330033; } </code></pre> <p>People have complained about the colour, that they don't like pink/purple. So you want to give them the ability to change the style as they wish, and they can pick their favourite colours. You have a little colour-picker widget that invokes a Javascript function:</p> <pre><code>function changeColourful(colorRGB, backgroundColorRGB) { // answer goes here } </code></pre> <p>What goes in the body of that function?</p> <p>The intent being that when the user picks a new colour on the colour-picker all the elements with <code>class="colourful"</code> will have their style changed.</p>
[ { "answer_id": 266023, "author": "kemiller2002", "author_id": 1942, "author_profile": "https://Stackoverflow.com/users/1942", "pm_score": -1, "selected": false, "text": "function changeColourful(colorRGB, backgroundColorRGB)\n {changeColor (document, colorRGB, backgroundColorRGB)}\n\nfun...
2008/11/05
[ "https://Stackoverflow.com/questions/265984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34778/" ]
266,002
<p>I'm using this XPath to get the value of a field:</p> <pre class="lang-none prettyprint-override"><code>//input[@type="hidden"][@name="val"]/@value </code></pre> <p>I get several results, but I only want the first. Using</p> <pre class="lang-none prettyprint-override"><code>//input[@type="hidden"][@name="val"]/@value[1] </code></pre> <p>Doesn't work. Once I have this, how do I pick up the value in Greasemonkey? I am trying things like:</p> <pre><code>alert("val " + val.snapshotItem); </code></pre> <p>But I think that's for the node, rather than the string.</p>
[ { "answer_id": 266083, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": false, "text": "var result = document.evaluate(\n \"//input[@type='hidden' and @name='var' and position()=1]/@value\",\n document, null,...
2008/11/05
[ "https://Stackoverflow.com/questions/266002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
266,015
<p>I want to have two items on the same line using <code>float: left</code> for the item on the left.</p> <p>I have no problems achieving this alone. The problem is, I want the two items to <strong>stay</strong> on the same line <em>even when you resize the browser very small</em>. You know... like how it was with tables.</p> <p>The goal is to keep the item on the right from wrapping <em>no matter what</em>.</p> <p>How to I tell the browser using CSS that I would rather <strong>stretch the containing <code>div</code></strong> than wrap it so the the <code>float: right;</code> div is below the <code>float: left;</code> <code>div</code>?</p> <p>what I want:</p> <pre><code> \ +---------------+ +------------------------/ | float: left; | | float: right; \ | | | / | | |content stretching \ Screen Edge | | |the div off the screen / &lt;--- +---------------+ +------------------------\ / </code></pre>
[ { "answer_id": 266025, "author": "Eric Wendelin", "author_id": 25066, "author_profile": "https://Stackoverflow.com/users/25066", "pm_score": 7, "selected": true, "text": "<div>" }, { "answer_id": 9978234, "author": "Inserve", "author_id": 1308275, "author_profile": "h...
2008/11/05
[ "https://Stackoverflow.com/questions/266015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2908/" ]
266,026
<p>Just looking for the relevant documentation. An example is not necessary, but would be appreciated. </p> <p>We have a situation where we are having to create 100s of virtual directories manually, and it seems like automating this would be a good way to make the process more efficient for now. </p> <p>Perhaps next year we can rework the server environment to allow something more sane, such as URL rewriting (unfortunately this does not seem feasible in the current cycle of the web application). Isn't it great to inherit crap code?</p> <p>~ William Riley-Land</p>
[ { "answer_id": 266045, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 2, "selected": false, "text": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.DirectoryServices;\nusing System.IO;...
2008/11/05
[ "https://Stackoverflow.com/questions/266026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17847/" ]
266,028
<p>We are looking to provide two <strong>custom Platform switches</strong> (the <strong>platform dropdown</strong> in the configuration manager) for our projects <strong>in Visual Studio</strong>. </p> <p>For example one for 'Desktop' and one for 'Web'. The target build tasks then compile the code in a custom way based on the platform switch. We don't want to add to the Debug Release switch because we would need those for each Desktop and Web platforms.</p> <p>We found one way to attempt this, is to modify the .csproj file to add something like this</p> <pre><code>&lt;Platform Condition=" '$(Platform)' == '' "&gt;Desktop&lt;/Platform&gt; </code></pre> <p>and add propertygroups like,</p> <pre><code> &lt;PropertyGroup Condition=" '$(Platform)' == 'Web' "&gt; &lt;DefineConstants&gt;/define Web&lt;/DefineConstants&gt; &lt;PlatformTarget&gt;Web&lt;/PlatformTarget&gt; &lt;/PropertyGroup&gt; &lt;PropertyGroup Condition=" '$(Platform)' == 'Desktop' "&gt; &lt;DefineConstants&gt;/define Desktop&lt;/DefineConstants&gt; &lt;PlatformTarget&gt;Desktop&lt;/PlatformTarget&gt; &lt;/PropertyGroup&gt; </code></pre> <p>But still this doesn't work, and compiler throws an error</p> <p><em>Invalid option 'Desktop' for /platform; must be anycpu, x86, Itanium or x64</em></p> <p>So does it have to be one of those options and can't we add our custom platforms?</p> <p>Has anyone been able to do this? any pointers would be helpful.</p> <p>Update: Using DebugDesktop and ReleaseDesktop will make it more complicated for users. Because 'desktop' and 'web' are actually platforms and also there is ability to add new platforms in the dropdown (i.e. ), I believe 'platform' switch should be used for the exact same purpose.</p>
[ { "answer_id": 6463259, "author": "aster.x", "author_id": 506499, "author_profile": "https://Stackoverflow.com/users/506499", "pm_score": 3, "selected": false, "text": "<PropertyGroup Condition=\" '$(Platform)' == 'Web' \">\n <DefineConstants>Web</DefineConstants>\n <PlatformTarget...
2008/11/05
[ "https://Stackoverflow.com/questions/266028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1747/" ]
266,082
<p>How do I tell if my application (compiled in Visual&nbsp;Studio&nbsp;2008 as <em>Any CPU</em>) is running as a 32-bit or 64-bit application?</p>
[ { "answer_id": 266084, "author": "Redwood", "author_id": 1512, "author_profile": "https://Stackoverflow.com/users/1512", "pm_score": 3, "selected": false, "text": "public static bool Is64BitMode() {\n return System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr)) == 8;\n}\n" }...
2008/11/05
[ "https://Stackoverflow.com/questions/266082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
266,114
<p>I'm running <a href="http://en.wikipedia.org/wiki/Mac_OS_X_Leopard" rel="nofollow noreferrer">Mac&nbsp;OS&nbsp;X Leopard</a> and wanted to know what the easy way to setup a web development environment to use Python, MySQL, Apache on my machine which would allow me to develop on my Mac and then easily move it to a host in the future.</p> <p>I've been trying to get mod_wsgi installed and configured to work with Django and have a headache now. Are there any web hosts that currently use mod_wsgi besides Google, so I could just develop there?</p>
[ { "answer_id": 266509, "author": "Null303", "author_id": 13787, "author_profile": "https://Stackoverflow.com/users/13787", "pm_score": 1, "selected": false, "text": "manager.py" }, { "answer_id": 624603, "author": "Idan Gazit", "author_id": 29451, "author_profile": "h...
2008/11/05
[ "https://Stackoverflow.com/questions/266114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
266,115
<p>The title is kind of obscure. What I want to know is if this is possible:</p> <pre><code>string typeName = &lt;read type name from somwhere&gt;; Type myType = Type.GetType(typeName); MyGenericClass&lt;myType&gt; myGenericClass = new MyGenericClass&lt;myType&gt;(); </code></pre> <p>Obviously, MyGenericClass is described as:</p> <pre><code>public class MyGenericClass&lt;T&gt; </code></pre> <p>Right now, the compiler complains that 'The type or namespace 'myType' could not be found." There has got to be a way to do this.</p>
[ { "answer_id": 266282, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": true, "text": "using System;\nusing System.Reflection;\n\npublic class Generic<T>\n{\n public Generic()\n {\n Console.Write...
2008/11/05
[ "https://Stackoverflow.com/questions/266115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9209/" ]
266,116
<p>How do you programmatically obtain a picture of a .Net control?</p>
[ { "answer_id": 266139, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": true, "text": "Control c = new TextBox();\nSystem.Drawing.Bitmap bmp = new System.Drawing.Bitmap(c.Width, c.Height);\nc.DrawToBitmap(bmp, c.Cl...
2008/11/05
[ "https://Stackoverflow.com/questions/266116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34787/" ]
266,123
<p>Maybe I should further qualify this - Is there a way to specify which direction a ComboBox will open without copying and pasting the entire ComboBox class and ripping out the code where it determines which direction it will open in...</p> <p>I'm my specific case - I need it to open upwards - always.</p> <p>UPDATE: You can't fix this by subclassing it because the function that handles the direction of the opening is:</p> <pre><code>private function displayDropdown(show:Boolean, trigger:Event = null):void </code></pre> <p>And that bad boy uses a fair amount of private variables which my subclass wouldn't have access to...</p>
[ { "answer_id": 268915, "author": "Mitch Haile", "author_id": 28807, "author_profile": "https://Stackoverflow.com/users/28807", "pm_score": 3, "selected": true, "text": "private function initMenu(): void {\n var m:Menu = new Menu();\n m.dataProvider = theMenuData;\n m.addEventLis...
2008/11/05
[ "https://Stackoverflow.com/questions/266123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3435/" ]
266,168
<p>Can someone post a simple example of starting two (Object Oriented) threads in C++. </p> <p>I'm looking for actual C++ thread objects that I can extend run methods on (or something similar) as opposed to calling a C-style thread library.</p> <p>I left out any OS specific requests in the hopes that whoever replied would reply with cross platform libraries to use. I'm just making that explicit now.</p>
[ { "answer_id": 266180, "author": "LorenzCK", "author_id": 3118, "author_profile": "https://Stackoverflow.com/users/3118", "pm_score": 3, "selected": false, "text": "class RThread : public wxThread {\n\npublic:\n RThread()\n : wxThread(wxTHREAD_JOINABLE){\n }\nprivate:\n R...
2008/11/05
[ "https://Stackoverflow.com/questions/266168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2112692/" ]
266,184
<p>I'm trying to be responsible with my "DOM" references in this little Flash 8/AS2 project.</p> <p>What has become increasingly frustrating is obtaining references to other movie clips and objects. For example, currently my code to access the submit button of a form looks something like this</p> <pre><code>var b:Button = _level0.instance4.submitBtn; </code></pre> <p>I was hoping there was an instance-retrieval method for AS2 similar to AS3's <code>MovieClip.getChildByName()</code> or even Javascript's <code>document.getElementById()</code>. Because hard-coding the names of these anonymous instances (like <code>instance4</code> in the above) just feel really, really dirty.</p> <p>But, I can't find anything of the sort at <a href="http://flash-reference.icod.de/" rel="nofollow noreferrer">this AS2 Reference</a>.</p>
[ { "answer_id": 266604, "author": "moritzstefaner", "author_id": 23069, "author_profile": "https://Stackoverflow.com/users/23069", "pm_score": 2, "selected": true, "text": "var my_MC=createEmptyMovieClip(\"instanceName\", depth);\n" }, { "answer_id": 266912, "author": "Luke", ...
2008/11/05
[ "https://Stackoverflow.com/questions/266184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8815/" ]
266,196
<p>I'm looking at having certain users access one database and other users accessing another database based on the company they belong to. What would be the best way to handle the connection strings and make sure the user connects to the right db when they login?</p> <p>Thanks for any ideas.</p>
[ { "answer_id": 266225, "author": "GeekyMonkey", "author_id": 29900, "author_profile": "https://Stackoverflow.com/users/29900", "pm_score": 4, "selected": true, "text": "<connectionStrings>\n <add name=\"ConnectionForDudes\" providerName=\"System.Data.SqlClient\"\n connectionString=...
2008/11/05
[ "https://Stackoverflow.com/questions/266196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34571/" ]
266,199
<p>I'm trying to do a very simple button that changes color based on mouseover, mouseout and click, I'm doing this in prototype and the weird thing is if I used mouseover and mouseout, after I clicked on the button, the button wouldn't change to white, seems like it is because of the mouseout, here's my code</p> <pre><code>$("izzy").observe('mouseover', function() { $('izzy').setStyle({ color: '#FFFFFF' }); }); $("izzy").observe('mouseout', function() { $('izzy').setStyle({ color: '#666666' }); }); $("izzy").observe('click', function() { $('izzy').setStyle({ color: '#FFFFFF' }); }); </code></pre> <p>how can I fix it? Thanks.</p>
[ { "answer_id": 266223, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 2, "selected": false, "text": "var wasClicked = false;\n\n$(\"izzy\").observe('mouseover', function() {\n if (!wasClicked) $('izzy').setStyle({ co...
2008/11/05
[ "https://Stackoverflow.com/questions/266199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34797/" ]
266,202
<h2>There seems to be two major conventions for organizing project files and then many variations.</h2> <p><strong>Convention 1: High-level type directories, project sub-directories</strong></p> <p>For example, the <a href="http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk/" rel="nofollow noreferrer">wxWidgets</a> project uses this style:</p> <pre><code>/solution /bin /prj1 /prj2 /include /prj1 /prj2 /lib /prj1 /prj2 /src /prj1 /prj2 /test /prj1 /prj2 </code></pre> <p><strong>Pros:</strong></p> <ul> <li>If there are project dependencies, they can be managed from a single file</li> <li>Flat build file structure</li> </ul> <p><strong>Cons:</strong></p> <ul> <li>Since test has its own header and cpp files, when you generate the unit test applications for EXE files rather than libraries, they need to include the <a href="https://en.wikipedia.org/wiki/Object_file" rel="nofollow noreferrer">object files</a> from the application you are testing. This requires you to create inference rules and expand out relative paths for all the source files.</li> <li>Reusing any of the projects in another solution requires you to extract the proper files out of the tree structure and modify any build scripts</li> </ul> <p><strong>Convention 2: High-level project directories, type sub-directories</strong></p> <p>For example, the <a href="http://anonsvn.wireshark.org/wireshark/trunk/" rel="nofollow noreferrer">Wireshark</a> project uses this style</p> <pre><code>/solution /prj1 /bin /include /lib /src /test /prj2 /bin /include /lib /src /test </code></pre> <p><strong>Pros:</strong></p> <ul> <li>Projects themselves are self-contained within their folders, making them easier to move and reuse</li> <li>Allows for shorter inference rules in the build tools</li> <li>Facilitates hierarchical build scripts</li> </ul> <p><strong>Cons:</strong></p> <ul> <li>If there are dependencies between projects, you need an additional layer of build scripts above the project directories to manage the build order</li> </ul> <p>We are currently using convention 1 on our project and so far it has worked fairly well. Now, I am in the process of adding unit testing (via CxxTest) and facilitating the migration to continuous integration using <a href="https://en.wikipedia.org/wiki/Make_%28software%29#Modern_versions" rel="nofollow noreferrer">nmake</a>, convention 1 is causing some serious headaches in the creation of the proper nmake files.</p> <h2>My primary requirements/goals are:</h2> <ul> <li><p>Reduce the level of effort to maintain the build scripts of the entire solution.</p></li> <li><p>De-couple projects and their build steps within a solution from other projects.</p></li> <li><p>Facilitate continuous integration via the use of build scripts for check-out to release media generation for each commit (obviously leveraging other tools such as CruiseControl as well).</p></li> <li><p>Make adding or removing additional projects or source files as easy and least error-prone as possible for the developers.</p></li> </ul> <h2>So I ask:</h2> <ul> <li>Are there other pros and cons of either of these methods?</li> <li>Is there a clear agrument that favors only one of these conventions?</li> </ul>
[ { "answer_id": 268485, "author": "Thomas L Holaday", "author_id": 29403, "author_profile": "https://Stackoverflow.com/users/29403", "pm_score": 1, "selected": false, "text": "mkdir /solution/test\nlinkd /solution/test/prj1 /solution/prj1/test\nlinkd /solution/test/prj2 /solution/prj2/tes...
2008/11/05
[ "https://Stackoverflow.com/questions/266202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2233/" ]
266,206
<p>I'm relatively new to C++. In Java, it's easy for me to instantiate and use a hashmap. I'd like to know how to do it in a simple way in C++, since I saw many different implementations and none of them looked simple to me.</p>
[ { "answer_id": 266233, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 6, "selected": true, "text": "std::hash_map" }, { "answer_id": 266452, "author": "Kasprzol", "author_id": 5957, "author_profile": "https...
2008/11/05
[ "https://Stackoverflow.com/questions/266206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33857/" ]
266,213
<p>Is there a way (preferrably using JavaScript) to determine whether a URL is to a SWF or a JPG? </p> <p>The obvious answer is to sniff the filename for ".jpg" or ".swf" but I'm dealing with banners that are dynamically decided by the server and usually have a lot of parameters and generally don't include an extension. </p> <p>so i'm wondering if I could load the file first and then read it somehow to determine whether it's SWF or JPG, and then place it, because the JavaScript code I'd need to display a JPG vs a SWF is very different. </p> <p>Thanks! </p>
[ { "answer_id": 266273, "author": "loraderon", "author_id": 22092, "author_profile": "https://Stackoverflow.com/users/22092", "pm_score": 3, "selected": true, "text": "function isImage(url, callback) {\n var img = document.createElement('img');\n img.onload = function() {\n c...
2008/11/05
[ "https://Stackoverflow.com/questions/266213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8349/" ]
266,245
<p>I have a git repository with remote foo.</p> <p>foo is a web app, is contains some files and dirs directly in its root:</p> <pre><code>Rakefile app ... public script </code></pre> <p>My main git repository is a larger system which comprises this web app. I want to pull the commits from foo, but I need the files to reside inside the <code>web</code> dir. So they should become <code>web/app</code>, <code>web/public</code>, etc.</p> <p>I don't want to use foo as a submodule. I want to merge foo into the main repository and then get rid of it.</p>
[ { "answer_id": 12243677, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "/path/to/B" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
266,250
<p>I'm learning some PowerShell. Is it possible to see the source code for a built-in cmdlet like <a href="http://technet.microsoft.com/en-us/library/hh849800.aspx" rel="noreferrer">Get-ChildItem</a>?</p>
[ { "answer_id": 267600, "author": "halr9000", "author_id": 6637, "author_profile": "https://Stackoverflow.com/users/6637", "pm_score": 5, "selected": false, "text": "Get-Command Get-ChildItem | Reflect-Cmdlet\n" }, { "answer_id": 20484505, "author": "ImpossibleSqui", "auth...
2008/11/05
[ "https://Stackoverflow.com/questions/266250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
266,255
<p>I try to instantiate an instance of <code>SPSite</code> on the farm server in a custom process (MyApp.exe) and I give it as parameter the whole URI (<a href="http://mysite:80/" rel="nofollow noreferrer">http://mysite:80/</a>). I also made sure that the account running <code>MyApp.exe</code> is <code>Site Collection Administrator</code>.</p> <p>However, I can't make an instance of <code>SPSite</code> whatever I am trying to do. It always throws a <code>FileNotFoundException</code>.</p> <p>Anyone got an idea?</p> <p>StackTrace:</p> <blockquote> <p>at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)<br> at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at MyCompanyName.Service.HelperClass.GetItemStateInSharePoint(SharePointItem item) in C:\Workspaces\MyCompanyName\Development\Main\MyCompanyName.SharePoint\Service\HelperClass.cs:line 555</p> </blockquote> <p>Another side note... I have a Web Application + Site collection that I can access through the browser without any problem.</p>
[ { "answer_id": 266333, "author": "Lars Fastrup", "author_id": 27393, "author_profile": "https://Stackoverflow.com/users/27393", "pm_score": 5, "selected": true, "text": "System.IO.FileNotFoundException : The site http://server/sites/bah could not be found in the Web application SPWebAppl...
2008/11/05
[ "https://Stackoverflow.com/questions/266255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24975/" ]
266,308
<p>Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does?</p> <p>When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like:</p> <p>vbc.exe [bunch of options] [looooong list of .vb files]</p> <p>I would like to programatically call "something" that would take the .vbproj file and do whatever Visual Studio does to generate this long command line. I know i <em>could</em> parse the .vbproj myself and generate that command line, but I'd rather save myself all the reverse engineering and trial-and-error...</p> <p>Is there a tool to do this? I'd rather be able to do it in a machine without having Visual Studio installed. However, if there's a way to call Visual Studio with some parameters to do it, then that'll be fine too.</p> <p>I looked briefly at MSBuild, and it looks like it works from a .proj project file that i'd have to make especially, and that I'd need to update every time I add a file to the .vbproj file. (I did look <em>briefly</em> at it, so it's very likely I missed something important)</p> <p>Any help will be greatly appreciated</p>
[ { "answer_id": 266319, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "msbuild /property:Configuration=Release MyFile.vbproj\n" }, { "answer_id": 18820303, "author": "JWPlatt", ...
2008/11/05
[ "https://Stackoverflow.com/questions/266308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
266,321
<p>I'm interested to find which way of creating box shadows with css is most effective. But that I mean : ease of implementation, flexibility, and cross browser compatibility. </p>
[ { "answer_id": 50398229, "author": "allenski", "author_id": 9132582, "author_profile": "https://Stackoverflow.com/users/9132582", "pm_score": 0, "selected": false, "text": "box-shadow: 3px 3px 3px rgba(0,0,0,0.33);\n" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32582/" ]
266,326
<p>Am I safe in casting a C++ bool to a Windows API BOOL via this construct</p> <pre><code>bool mybool = true; BOOL apiboolean = mybool ? TRUE : FALSE; </code></pre> <p>I'd assume this is a yes because I don't see any obvious problems but I wanted to take a moment to ask only because this may be more subtle than it appears. </p> <p><em>Thanks to Dima for (gently) pointing out my carelessness in the way I'd originally phrased the question.</em> </p>
[ { "answer_id": 266338, "author": "Dima", "author_id": 13313, "author_profile": "https://Stackoverflow.com/users/13313", "pm_score": 4, "selected": true, "text": "\nbool b;\n...\nBOOL apiboolean = b ? TRUE : FALSE;\n" }, { "answer_id": 266468, "author": "James Curran", "au...
2008/11/05
[ "https://Stackoverflow.com/questions/266326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2820/" ]
266,327
<p>A pattern that's started to show up a lot in one of the web apps I'm working are links that used to just be a regular a-tag link now need a popup box asking "are you sure?" before the link will go. (If the user hits cancel, nothing happens.)</p> <p>We've got a solution that works, but somehow we're a web app shop without a Javascript expert, so I'm left with this crawling feeling like there's a better way to get the job done.</p> <p>So, JS experts, what's the most standards-compliant, cross-browser way to get this done?</p> <p>(For the record, this is already a site that requires JS, so no need to have a "non-JS" version. But, it does need to work in any and all reasonably modern browsers.)</p> <p>(Also, for bonus points it would be nice if people with JS turned off didn't have the links work, rather than bypassing the confirm box.)</p>
[ { "answer_id": 266347, "author": "Electrons_Ahoy", "author_id": 19074, "author_profile": "https://Stackoverflow.com/users/19074", "pm_score": 3, "selected": false, "text": "<a href=\"#\" onClick=\"goThere(); return false;\">Go to new page</a>`\n\nfunction goThere() \n{ \n if( confirm(\...
2008/11/05
[ "https://Stackoverflow.com/questions/266327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19074/" ]
266,332
<p>I have a <strong>MS Access</strong> form with a <strong>Datasheet</strong> subform.<br> Using code, I change the <strong>ColumnHidden</strong> property of various of its columns. But, when I close the form, I'm asked whether to save the table layout of the Datasheet's table.</p> <ul> <li>How can I stop the form from asking the user to same the table layout continually?</li> <li>Do I have no choice but to change the Datasheet to a regular subform?</li> </ul>
[ { "answer_id": 271263, "author": "David-W-Fenton", "author_id": 9787, "author_profile": "https://Stackoverflow.com/users/9787", "pm_score": 0, "selected": false, "text": " DoCmd.Close acForm, Me.Name, acSaveNo\n" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15884/" ]
266,357
<p>I have been trying to tokenize a string using SPACE as delimiter but it doesn't work. Does any one have suggestion on why it doesn't work?</p> <p>Edit: tokenizing using:</p> <pre><code>strtok(string, " "); </code></pre> <p>The code is like the following</p> <pre><code>pch = strtok (str," "); while (pch != NULL) { printf ("%s\n",pch); pch = strtok (NULL, " "); } </code></pre>
[ { "answer_id": 266405, "author": "gbjbaanb", "author_id": 13744, "author_profile": "https://Stackoverflow.com/users/13744", "pm_score": 6, "selected": false, "text": "char s[256];\nstrcpy(s, \"one two three\");\nchar* token = strtok(s, \" \");\nwhile (token) {\n printf(\"token: %s\\n\...
2008/11/05
[ "https://Stackoverflow.com/questions/266357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/382480/" ]
266,364
<p>I've got a DB table where we store a lot of MD5 hashes (and yes I know that they aren't 100% unique...) where we have a lot of comparison queries against those strings. This table can become quite large with over 5M rows.</p> <p>My question is this: Is it wise to keep the data as hexadecimal strings or should I convert the hex to binary or decimals for better querying?</p>
[ { "answer_id": 266405, "author": "gbjbaanb", "author_id": 13744, "author_profile": "https://Stackoverflow.com/users/13744", "pm_score": 6, "selected": false, "text": "char s[256];\nstrcpy(s, \"one two three\");\nchar* token = strtok(s, \" \");\nwhile (token) {\n printf(\"token: %s\\n\...
2008/11/05
[ "https://Stackoverflow.com/questions/266364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
266,370
<p>I'd like to write some unit tests for some code that connects to a database, runs one or more queries, and then processes the results. (Without actually using a database)</p> <p>Another developer here wrote our own DataSource, Connection, Statement, PreparedStatement, and ResultSet implementation that will return the corresponding objects based on an xml configuration file. (we could use the bogus datasource and just run tests against the result sets it returns).</p> <p>Are we reinventing the wheel here? Does something like this exist already for unit testing? Are there other / better ways to test jdbc code?</p>
[ { "answer_id": 274752, "author": "P Arrayah", "author_id": 33459, "author_profile": "https://Stackoverflow.com/users/33459", "pm_score": 1, "selected": false, "text": "DBUtils.getMetadataFor(String tablename)" }, { "answer_id": 20901399, "author": "Paweł Prażak", "author_...
2008/11/05
[ "https://Stackoverflow.com/questions/266370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
266,371
<p>In VIM in command line mode a "%" denotes the current file, "cword" denotes the current word under the cursor. I want to create a shortcut where I need the current line number. What is the symbol which denotes this?</p>
[ { "answer_id": 266386, "author": "WMR", "author_id": 2844, "author_profile": "https://Stackoverflow.com/users/2844", "pm_score": 4, "selected": false, "text": ":1,.s/foo/bar/g" }, { "answer_id": 267827, "author": "Oli", "author_id": 22035, "author_profile": "https://S...
2008/11/05
[ "https://Stackoverflow.com/questions/266371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29653/" ]
266,372
<p>For a rigorous marker of the source database state, I'd like to capture the @@DBTS of an external database in a sproc. Yeah, I think I could issue </p> <blockquote> <code> <br/>USE ExternalDB <br/>GO <br/> <br/>SELECT @myVarbinary8 = @@DBTS <br/>GO <br/> <br/>USE OriginalDB <br/>GO </code> </blockquote> <p>but, even if I could, it seems ugly.</p> <p>For now, I've embedded a scalar-valued function in the source database to invoke the </p> <p>SET @Result = SELECT @@DBTS</p> <p>which worked fine until I forgot to ask the DBA to grant the appropriate rights for a new user, which crashed a process.</p> <p>Something akin to</p> <blockquote><code>SELECT ExternalServer.dbo.@@DBTS </code> <br/><br/>(I know that doesn't work).</blockquote> <p><br/> <br/>See &nbsp; <a href="http://msdn.microsoft.com/en-us/library/ms187366(SQL.90).aspx" rel="nofollow noreferrer">MSDN @@DBTS documentation</a></p> <blockquote>@@DBTS (Transact-SQL) <br/>Returns the value of the current timestamp data type for the current database. <br/>This timestamp is guaranteed to be unique in the database. </blockquote>
[ { "answer_id": 267396, "author": "6eorge Jetson", "author_id": 23422, "author_profile": "https://Stackoverflow.com/users/23422", "pm_score": 0, "selected": false, "text": "\nDECLARE @sourceDbName nvarchar(128)\nSET     @sourceDbName = N'sbaportia1'\n\nDECLARE @strQuery nvarchar(...
2008/11/05
[ "https://Stackoverflow.com/questions/266372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23422/" ]
266,373
<p>If something is making a single-thread program take, say, 10 times as long as it should, you could run a profiler on it. You could also just halt it with a "pause" button, and you'll see exactly what it's doing. </p> <p>Even if it's only 10% slower than it should be, if you halt it more times, before long you'll see it repeatedly doing the unnecessary thing. Usually the problem is a function call somewhere in the middle of the stack that isn't really needed. This doesn't measure the problem, but it sure does find it.</p> <p>Edit: The objections mostly assume that you only take 1 sample. If you're serious, take 10. Any line of code causing some percentage of wastage, like 40%, will appear on the stack on that fraction of samples, on average. Bottlenecks (in single-thread code) can't hide from it.</p> <p>EDIT: To show what I mean, many objections are of the form "there aren't enough samples, so what you see could be entirely spurious" - vague ideas about chance. But if something of <em>any recognizable description</em>, not just being in a routine or the routine being active, is in effect for 30% of the time, then the probability of seeing it on any given sample is 30%. </p> <p>Then suppose only 10 samples are taken. The number of times the problem will be seen in 10 samples follows a <a href="http://en.wikipedia.org/wiki/Binomial_distribution" rel="noreferrer">binomial distribution</a>, and the probability of seeing it 0 times is .028. The probability of seeing it 1 time is .121. For 2 times, the probability is .233, and for 3 times it is .267, after which it falls off. Since the probability of seeing it less than two times is .028 + .121 = .139, that means the probability of seeing it two or more times is 1 - .139 = .861. The general rule is if you see something you could fix on two or more samples, it is worth fixing. </p> <p>In this case, the chance of seeing it in 10 samples is 86%. If you're in the 14% who don't see it, just take more samples until you do. (If the number of samples is increased to 20, the chance of seeing it two or more times increases to more than 99%.) So it hasn't been precisely measured, but it has been precisely found, and it's important to understand that it could easily be something that a profiler could not actually find, such as something involving the state of the data, not the program counter.</p>
[ { "answer_id": 8290367, "author": "Crashworks", "author_id": 53543, "author_profile": "https://Stackoverflow.com/users/53543", "pm_score": 4, "selected": false, "text": "malloc" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23771/" ]
266,389
<p>What's the easiest programmatic way to restart a service on a remote Windows system? Language or method doesn't matter as long as it doesn't require human interaction.</p>
[ { "answer_id": 266423, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 8, "selected": true, "text": "sc.exe" }, { "answer_id": 266434, "author": "dkretz", "author_id": 31641, "author_profile": "https://St...
2008/11/05
[ "https://Stackoverflow.com/questions/266389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
266,395
<p>I have a git repository which tracks an svn repository. I cloned it using <code>--stdlayout</code>.</p> <p>I created a new local branch via <code>git checkout -b foobar</code></p> <p>Now I want this branch to end up in <code>…/branches/foobar</code> in the svn repository.</p> <p>How do I go about that?</p> <p>(snipped lots of investigative text. see question history if you care)</p>
[ { "answer_id": 266561, "author": "kch", "author_id": 13989, "author_profile": "https://Stackoverflow.com/users/13989", "pm_score": 7, "selected": true, "text": "git svn branch" }, { "answer_id": 1911069, "author": "Jesper Rønn-Jensen", "author_id": 109305, "author_pro...
2008/11/05
[ "https://Stackoverflow.com/questions/266395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
266,409
<p>I've got a WAR file that I need to add two files to. Currently, I'm doing this:</p> <pre><code>File war = new File(DIRECTORY, "server.war"); JarOutputStream zos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(war))); //Add file 1 File file = new File(DIRECTORY, "file1.jar"); InputStream is = new BufferedInputStream(new FileInputStream(file)); ZipEntry e = new ZipEntry("file1.jar"); zos.putNextEntry(e); byte[] buf = new byte[1024]; int len; while ((len = is.read(buf, 0, buf.length)) != -1) { zos.write(buf, 0, len); } is.close(); zos.closeEntry(); //repeat for file 2 zos.close(); </code></pre> <p>The result is that the previous contents get clobbered: the WAR has only the 2 files I just added in it. Is there some sort of append mode that I'm not using or what?</p>
[ { "answer_id": 266469, "author": "hark", "author_id": 34826, "author_profile": "https://Stackoverflow.com/users/34826", "pm_score": 3, "selected": false, "text": "JarOutputStream zos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(war, True)));\n" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4893/" ]
266,417
<p>We are in a Windows environment and looking to automate this process for non-company machines. If a vendor comes on site, we'd like to be able to have him/her hit a website that can perform a quick scan of the workstation to determine if they have the proper MS KB patches and if their virus scanner dats are up to date.</p> <p>I can scan for the KB updates relatively easy, what I'm having a hard time finding is a way to check the virus dat status and since there are so many different engines out there, it seemed to make sense to use the (built into XP at least) proprietary MS security center stuff.</p> <p>Eventually we'd like to have our routers redirect non-company machines to a website that will force validation, but until that point it will be a manual process.</p> <p>Any thoughts?</p>
[ { "answer_id": 392605, "author": "Hernán", "author_id": 48026, "author_profile": "https://Stackoverflow.com/users/48026", "pm_score": 3, "selected": true, "text": " Set oWMI = GetObject\n(\"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\SecurityCenter\") \n Set colItems ...
2008/11/05
[ "https://Stackoverflow.com/questions/266417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11130/" ]
266,431
<p>I used to use the standard mysql_connect(), mysql_query(), etc statements for doing MySQL stuff from PHP. Lately I've been switching over to using the wonderful MDB2 class. Along with it, I'm using prepared statements, so I don't have to worry about escaping my input and SQL injection attacks.</p> <p>However, there's one problem I'm running into. I have a table with a few VARCHAR columns, that are specified as not-null (that is, do not allow NULL values). Using the old MySQL PHP commands, I could do things like this without any problem:</p> <pre class="lang-sql prettyprint-override"><code>INSERT INTO mytable SET somevarchar = ''; </code></pre> <p>Now, however, if I have a query like:</p> <pre class="lang-sql prettyprint-override"><code>INSERT INTO mytable SET somevarchar = ?; </code></pre> <p>And then in PHP I have:</p> <pre><code>$value = ""; $prepared = $db-&gt;prepare($query, array('text')); $result = $prepared-&gt;execute($value); </code></pre> <p>This will throw the error "<code>null value violates not-null constraint</code>"</p> <p>As a temporary workaround, I check if <code>$value</code> is empty, and change it to <code>" "</code> (a single space), but that's a horrible hack and might cause other issues.</p> <p>How am I supposed to insert empty strings with prepared statements, without it trying to instead insert a NULL?</p> <p><strong>EDIT:</strong> It's too big of a project to go through my entire codebase, find everywhere that uses an empty string "" and change it to use NULL instead. What I need to know is why standard MySQL queries treat "" and NULL as two separate things (as I think is correct), but prepared statements converts "" into NULL. </p> <p>Note that "" and NULL are <strong>not</strong> the same thing. For Example, <code>SELECT NULL = "";</code> returns <code>NULL</code> instead of <code>1</code> as you'd expect. </p>
[ { "answer_id": 266464, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 0, "selected": false, "text": "\"\"" }, { "answer_id": 266512, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Sta...
2008/11/05
[ "https://Stackoverflow.com/questions/266431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14569/" ]
266,433
<p>So... I used to think that when you accessed a file but specified the name without a path (CAISLog.csv in my case) that .NET would expect the file to reside at the same path as the running .exe. </p> <p>This works when I'm stepping through a solution (C# .NET2.* VS2K5) but when I run the app in normal mode (Started by a Websphere MQ Trigger monitor &amp; running in the background as a network service) instead of accessing the file at the path where the .exe is it's being looked for at C:\WINDOWS\system32. If it matters The parent task's .exe is in almost the same folder structure/path as my app</p> <p>I get a matching error: "<em>System.UnauthorizedAccessException: Access to the path 'C:\WINDOWS\system32\CAISLog.csv' is denied.</em>"</p> <p>My workaround is to just fully qualify the location of my file. What I want to understand, however is <strong>"What is the .NET rule that governs how a path is resolved when only the file name is specified during IO?"</strong> I feel I'm missing some basic concept and it's bugging me bad.</p> <p>edit - I'm not sure it's a.NET rule per se but Schmuli seems to be explaining the concept a little clearer. I will definitely try Rob Prouse's suggestions in the future so +1 on that too.</p> <p>If anyone has some re-wording suggestions that emphasize I don't <em>really</em> care about finding the path to my .exe - rather just didn't understand what was going on with relative path resolution (and I may still have my terminlogy screwed up)...</p>
[ { "answer_id": 266473, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 3, "selected": false, "text": "Assembly ass = Assembly.GetEntryAssembly();\nstring dir = Path.GetDirectoryName(ass.Location);\nstring filename = Path....
2008/11/05
[ "https://Stackoverflow.com/questions/266433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30901/" ]
266,448
<p>How would I format the standard RSS pubDate string as something closer to ASP.NET's DateTime?</p> <p>So, from this:</p> <p>Wed, 29 Oct 2008 14:14:48 +0000</p> <p>to this:</p> <p>10/29/2008 2:14 PM</p>
[ { "answer_id": 266470, "author": "AaronS", "author_id": 26932, "author_profile": "https://Stackoverflow.com/users/26932", "pm_score": 3, "selected": true, "text": "string orig = \"Wed, 29 Oct 2008 14:14:48 +0000\";\nstring newstring = String.Format(\"{0:MM/dd/yyyy hh:mm tt}\", DateTime.P...
2008/11/05
[ "https://Stackoverflow.com/questions/266448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4241/" ]
266,457
<p>I have a linq query and I am trying to put that in to a serializable object for a distributed caching (Velocity) but its failing due to a LINQ-to-SQL lazy list</p> <p>like so</p> <pre><code> return from b in _datacontext.MemberBlogs let cats = GetBlogCategories(b.MemberBlogID) select new MemberBlogs { MemberBlogID = b.MemberBlogID, MemberID = b.MemberID, BlogTitle = b.BlogTitle, BlogURL = b.BlogURL, BlogUsername = b.BlogUsername, BlogPassword = b.BlogPassword, Categories = new LazyList&lt;MemberBlogCategories&gt;(cats) }; </code></pre> <p>LazyList is the same class Rob Conery uses in his MVC storefront...</p> <p>all three classes are marked serializable (MemberBlogs,MemberBlogCategories,LazyList... any ideas?</p>
[ { "answer_id": 266541, "author": "Duncan", "author_id": 25035, "author_profile": "https://Stackoverflow.com/users/25035", "pm_score": 4, "selected": true, "text": "(from x select new MemberBlogs).ToList()\n" }, { "answer_id": 266547, "author": "Chris Shaffer", "author_id"...
2008/11/05
[ "https://Stackoverflow.com/questions/266457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22093/" ]
266,486
<p>I am trying to write out a png file from a java.awt.image.BufferedImage. Everything works fine but the resulting png is a 32-bit file.</p> <p>Is there a way to make the png file be 8-bit? The image is grayscale, but I do need transparency as this is an overlay image. I am using java 6, and I would prefer to return an OutputStream so that I can have the calling class deal with writing out the file to disk/db.</p> <p>Here is the relevant portion of the code:</p> <pre><code> public static ByteArrayOutputStream createImage(InputStream originalStream) throws IOException { ByteArrayOutputStream oStream = null; java.awt.Image newImg = javax.imageio.ImageIO.read(originalStream); int imgWidth = newImg.getWidth(null); int imgHeight = newImg.getHeight(null); java.awt.image.BufferedImage bim = new java.awt.image.BufferedImage(imgWidth, imgHeight, java.awt.image.BufferedImage.TYPE_INT_ARGB); Color bckgrndColor = new Color(0x80, 0x80, 0x80); Graphics2D gf = (Graphics2D)bim.getGraphics(); // set transparency for fill image gf.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f)); gf.setColor(bckgrndColor); gf.fillRect(0, 0, imgWidth, imgHeight); oStream = new ByteArrayOutputStream(); javax.imageio.ImageIO.write(bim, "png", oStream); oStream.close(); return oStream; } </code></pre>
[ { "answer_id": 267316, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 1, "selected": false, "text": "public class ImageUtil\n{\n public static int ALPHA_BIT_MASK = 0xFF000000;\n\n public static BufferedImage imageToBuffere...
2008/11/05
[ "https://Stackoverflow.com/questions/266486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
266,491
<p>I have a lot of buttons and by clicking on different button, different image and text would appear. I can achieve what I want, but the code is just so long and it seems very repetitive. For example:</p> <pre><code> var aaClick = false; $("aa").observe('click', function() { unclick(); $('characterPic').writeAttribute('src',"aa.jpg"); $('characterBio').update("aatext"); $('aa').setStyle({ color: '#FFFFFF' }); aaClick = true; }); $("aa").observe('mouseover', function() { if (!aaClick) $('aa').setStyle({ color: '#FFFFFF' }); }); $("aa").observe('mouseout', function() { if (!aaClick) $('aa').setStyle({ color: '#666666' }); }); function unclick() { aaClick = false; $('aa').setStyle({ color: '#666666' }); } </code></pre> <p>same thing with bb, cc, etc. and every time I add a new button, I need to add it to unclick function as well. This is pretty annoying and I tried to google it, and I only found observe click on all listed items, so I still couldn't figure out since what I want involves button up when other buttons are clicked. </p> <p>Is there any way to just have a generic function that takes different id but do the exact same thing? Because from what I can see, if I can just replace aa with other id, I can reduce a lot of code. Thanks!!!</p>
[ { "answer_id": 266515, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 0, "selected": false, "text": "$(container).childElements().each(function(element) {\n $(element).observe('click', function () { … });\n …\n})...
2008/11/05
[ "https://Stackoverflow.com/questions/266491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34797/" ]
266,501
<p>Is there a way to define a macro that contains a <code>#include</code> directive in its body?</p> <p>If I just put the "<code>#include</code>", it gives the error</p> <pre><code>C2162: "expected macro formal parameter" </code></pre> <p>since here I am not using <code>#</code> to concatenate strings.<br> If I use "<code>\# include</code>", then I receive the following two errors:</p> <pre><code>error C2017: illegal escape sequence error C2121: '#' : invalid character : possibly the result of a macro expansion </code></pre> <p>Any help?</p>
[ { "answer_id": 266580, "author": "HanClinto", "author_id": 26933, "author_profile": "https://Stackoverflow.com/users/26933", "pm_score": -1, "selected": false, "text": "#include \"standardAppDefs.h\"\n#myStandardIncludeMacro\n" }, { "answer_id": 266647, "author": "Bing Jian",...
2008/11/05
[ "https://Stackoverflow.com/questions/266501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34829/" ]
266,506
<p>Using a standard ASP.NET ListView with a LinqDataSource and pagination enabled (with a DataPager), what would be the best way to default to displaying the last page of results?</p>
[ { "answer_id": 266580, "author": "HanClinto", "author_id": 26933, "author_profile": "https://Stackoverflow.com/users/26933", "pm_score": -1, "selected": false, "text": "#include \"standardAppDefs.h\"\n#myStandardIncludeMacro\n" }, { "answer_id": 266647, "author": "Bing Jian",...
2008/11/05
[ "https://Stackoverflow.com/questions/266506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9433/" ]
266,507
<p>I'm using linq to pull back an object (i.e. customer) that might have a collection of other objects(customer.orders). I would be nice if I can pass this list of customers to the ultragrid and a hierarchical view of customers and thier orders displayed on databind. When I try this, I just get customers. Anyone know how to get this to work with non dataset objects?</p>
[ { "answer_id": 272436, "author": "Bless Yahu", "author_id": 32120, "author_profile": "https://Stackoverflow.com/users/32120", "pm_score": 4, "selected": true, "text": "IList<T>" }, { "answer_id": 3055563, "author": "KTN", "author_id": 368490, "author_profile": "https:...
2008/11/05
[ "https://Stackoverflow.com/questions/266507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32120/" ]
266,523
<p>Are there any drawbacks to using the STL or templates. Are there any situations for which they are inappropriate.</p>
[ { "answer_id": 267412, "author": "ididak", "author_id": 28888, "author_profile": "https://Stackoverflow.com/users/28888", "pm_score": 1, "selected": false, "text": "hash_map" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
266,549
<p>Using MEF I want to do the following.</p> <p>I have a WPF Shell. To the shell I want to Import from another DLL a UserControl that is also a View of my MVP triad. The way the MVP triad works, is that in presenter I have a constructor that takes both IModel and IView and wires them up. So, in order for this to work, I need MEF to do the following:</p> <ol> <li>Create IView implementation</li> <li>Create IModel implementation</li> <li>Create Presenter and pass IModel and IView to its constructor</li> <li>Import IView implementation into my shell when it gets displayed</li> </ol> <p>Instead what it does, is it only creates the type Exporting IView and passes it to the shell, basically skipping steps 2 and 3. Its pretty logical, when you think about it, but how can I tell MEF to also create the whole triad when I ask for a IView. I don't need to reference Presenter nor model anywhere else in my Shell .dll so puting it as an Import as well is not an option (and it would be quite ugly anyway :).</p> <p>I'm using the latest drop of MEF (Preview 2 Refresh). Anyone?</p> <p><strong>==Update==</strong></p> <p>I have found a solution and I blogged about it here:<br> <a href="http://kozmic.pl/archive/2008/11/06/creating-tree-of-dependencies-with-mef/" rel="nofollow noreferrer" title="here">Krzysztof Koźmic's blog - Creating tree of dependencies with MEF</a></p> <p>However, I'd be more than happy if someone came up with a better solution.**</p>
[ { "answer_id": 285744, "author": "Glenn Block", "author_id": 18419, "author_profile": "https://Stackoverflow.com/users/18419", "pm_score": 3, "selected": true, "text": " 1: using System.ComponentModel.Composition;\n 2: using System.Reflection;\n 3: using Microsoft.VisualStudio.Test...
2008/11/05
[ "https://Stackoverflow.com/questions/266549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13163/" ]
266,570
<p>Is there any performance difference between the for loops on a primitive array? </p> <p>Assume:</p> <pre><code>double[] doubleArray = new double[300000]; for (double var: doubleArray) someComplexCalculation(var); </code></pre> <p>or :</p> <pre><code>for ( int i = 0, y = doubleArray.length; i &lt; y; i++) someComplexCalculation(doubleArray[i]); </code></pre> <p><strong>Test result</strong></p> <p>I actually profiled it:</p> <pre><code>Total timeused for modern loop= 13269ms Total timeused for old loop = 15370ms </code></pre> <p>So the modern loop actually runs faster, at least on my Mac OSX JVM 1.5. </p>
[ { "answer_id": 266727, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 4, "selected": true, "text": "1: double[] tmp = doubleArray;\n2: for (int i = 0, y = tmp.length; i < y; i++) {\n3: double var = tmp[i];\n4: someComple...
2008/11/05
[ "https://Stackoverflow.com/questions/266570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9774/" ]
266,578
<p>I really like the Flex framework, however I routinely deal with SWF files that are ~ 500KB. </p> <p>I don't know at what point a file considered to be "too big" to be served on the internet, but I would assume that a 500KB download just to use a web application would certainly annoy some users.</p> <p>Are there any tips or techniques on reducing the size of compiled SWFS? </p> <p>As a side note, the 500KB SWF file really isn't that big of application...</p>
[ { "answer_id": 266613, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 1, "selected": false, "text": "URLRequest" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
266,586
<p>I am coding in ColdFusion, but trying to stay in cfscript, so I have a function that allows me to pass in a query to run it with <code> &lt;cfquery blah > #query# &lt;/cfquery> </code></p> <p>Somehow though, when I construct my queries with <code>sql = "SELECT * FROM a WHERE b='#c#'"</code> and pass it in, ColdFusion has replaced the single quotes with 2 single quotes. so it becomes <code> WHERE b=''c''</code> in the final query.</p> <p>I have tried creating the strings a lot of different ways, but I cannot get it to leave just one quote. Even doing a string replace has no effect. </p> <p>Any idea why this is happening? It is ruining my hopes of living in cfscript for the duration of this project</p>
[ { "answer_id": 266680, "author": "ale", "author_id": 21960, "author_profile": "https://Stackoverflow.com/users/21960", "pm_score": 4, "selected": false, "text": "<cfquery>" }, { "answer_id": 266787, "author": "Tomalak", "author_id": 18771, "author_profile": "https://S...
2008/11/05
[ "https://Stackoverflow.com/questions/266586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
266,601
<p>My spring-context file is shown below.</p> <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jms="http://www.springframework.org/schema/jms" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt; &lt;bean id="cfaBeanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext"&gt; &lt;constructor-arg value="classpath:cfa-spring-core.xml" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>When I try to run my application, I get the following error:</p> <pre><code>Caused by: org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*:cfa-spring-context.xml], factory key [cfaBeanFactory]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Line 16 in XML document from URL [file:/C:/.../cfa-spring-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null". at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:389) ... 56 more Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Line 16 in XML document from URL [file:/C:/.../cfa-spring-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null". at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:169) ... 59 more Caused by: org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null". at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) </code></pre> <p>Can someone tell me what I'm doing wrong?</p>
[ { "answer_id": 266627, "author": "Mike Pone", "author_id": 16404, "author_profile": "https://Stackoverflow.com/users/16404", "pm_score": 0, "selected": false, "text": "<beans>" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23249/" ]
266,606
<p>I'm running an application (web service) in tomcat with TLS enabled (with certificates both for the client and the server).</p> <p>I want that my application will be able to send audit message (logging) when TLS handshake fails. For example I want to log when:</p> <ul> <li>the client certificate is expired,</li> <li>the client certificate is unknown (not in the server trust store)</li> <li>any other handshake failure</li> </ul> <p>Is there any event that I can catch and handle in order to do that?</p> <p>My application is web service based and is running in tomcat. Tomcat is handling all network and the TLS layers, and the application does not aware of that.</p> <p>As I don't open any socket myself, where should I catch this Exception?</p>
[ { "answer_id": 266650, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "javax.net.ssl.SSLHandshakeException" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20065/" ]
266,621
<p>I'm consuming an axis 1.4 web service that returns soap responses that I want to unmarshal into my domain objects using jaxb annotations. My initial tests worked very well until some of the returned messages had multiRef elements. Objects that were marshalled using multiRef were showing up as null in my client side annotated model objects. </p> <p>My question is does JAXB support unmarshalling soap responses with multiRef elements? If so, how? and if not, does anybody know of a better way to unmarshal axis 1.4 soap responses into my domain model in java?</p>
[ { "answer_id": 444582, "author": "martsraits", "author_id": 55036, "author_profile": "https://Stackoverflow.com/users/55036", "pm_score": 0, "selected": false, "text": "org.apache.axis.AxisEngine.PROP_DOMULTIREFS" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32825/" ]
266,639
<p>What is the best tool / practice to enable browser history for Flash (or AJAX) websites? I guess the established practice is to set and read a hash-addition to the URL like</p> <pre><code>http://example.com/#id=1 </code></pre> <p>I am aware of the Flex History Manager, but was wondering if there are any good alternatives to consider. Would also be interested in a general AJAX solution or best practice.</p>
[ { "answer_id": 405704, "author": "nakajima", "author_id": 39589, "author_profile": "https://Stackoverflow.com/users/39589", "pm_score": 0, "selected": false, "text": "(function() {\n var oldHash, newHash;\n\n function checkHash() {\n // Grab the hash\n newHash = document.location...
2008/11/05
[ "https://Stackoverflow.com/questions/266639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23069/" ]
266,648
<p>How can I check if a file uploaded by a user is a real jpg file in Python (Google App Engine)?</p> <p>This is how far I got by now:</p> <p>Script receives image via HTML Form Post and is processed by the following code</p> <pre><code>... incomming_image = self.request.get("img") image = db.Blob(incomming_image) ... </code></pre> <p>I found mimetypes.guess_type, but it does not work for me.</p>
[ { "answer_id": 266731, "author": "Brian", "author_id": 9493, "author_profile": "https://Stackoverflow.com/users/9493", "pm_score": 6, "selected": true, "text": "Start Marker | JFIF Marker | Header Length | Identifier\n0xff, 0xd8 | 0xff, 0xe0 | 2-bytes | \"JFIF\\0\"\n" }, {...
2008/11/05
[ "https://Stackoverflow.com/questions/266648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26763/" ]
266,652
<p>We are trying to build a Crystal Report that sends control characters directly to the printer, without going through the (buggy) Windows driver for that printer. Does anyone know a way to do this from within a Crystal Report? </p> <p>The specific control character we are trying to send is CHR(2). However when we put that in a Crystal Report, and print to a Generic Text Only printer, it is converting the character to a period on output. The character appears as a box in Crystal's preview, so I suspect it is the Windows driver, rather than Crystal, that is the problem.</p> <p>The device is a Datamax printer. We do have drivers for it, but are encountering various problems - the infrastructure group knows more about the problems than I do, I don't feel I have enough information to try and ask about the specific problem. It is some combination of the interplay of Crystal Reports, Citrix, our market-specific ERP package, and automatically selecting label printers for the appropriate label size based on user at the time the report is run.</p>
[ { "answer_id": 266731, "author": "Brian", "author_id": 9493, "author_profile": "https://Stackoverflow.com/users/9493", "pm_score": 6, "selected": true, "text": "Start Marker | JFIF Marker | Header Length | Identifier\n0xff, 0xd8 | 0xff, 0xe0 | 2-bytes | \"JFIF\\0\"\n" }, {...
2008/11/05
[ "https://Stackoverflow.com/questions/266652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20068/" ]
266,665
<p>I'm learning C++ and writing little programs as I go along. The following is one such program:</p> <pre><code>// This program is intended to take any integer and convert to the // corresponding signed char. #include &lt;iostream&gt; int main() { signed char sch = 0; int n = 0; while(true){ std::cin &gt;&gt; n; sch = n; std::cout &lt;&lt; n &lt;&lt; " --&gt; " &lt;&lt; sch &lt;&lt; std::endl; } } </code></pre> <p>When I run this program and keep inputs at reasonably small absolute values, it behaves as expected. But when I enter larger inputs, e.g., 10000000000, the program repetitively spits out the same output. Some combinations of input cause erratic behavior. For example:</p> <pre><code>#: ./int2ch 10 10 --&gt; 10000000000 10 --&gt; 10 --&gt; 10 --&gt; 10 --&gt; </code></pre> <p>The program spits out "10 --> " until it's killed. (With this particular sequence of inputs, the program's output changes speed erratically.) I also noticed that the output of large values is determined by the previous legal input as well as the value of the current illegal input.</p> <p>What's going on? (I don't care about fixing the program, that's easy. I want to understand it.)</p>
[ { "answer_id": 266703, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 5, "selected": true, "text": "cin" }, { "answer_id": 266711, "author": "Dima", "author_id": 13313, "author_profile": "https://Stac...
2008/11/05
[ "https://Stackoverflow.com/questions/266665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32944/" ]
266,681
<p>I just realized that in some place in my code I have the return statement inside the lock and sometime outside. Which one is the best?</p> <p>1)</p> <pre><code>void example() { lock (mutex) { //... } return myData; } </code></pre> <p>2)</p> <pre><code>void example() { lock (mutex) { //... return myData; } } </code></pre> <p>Which one should I use?</p>
[ { "answer_id": 266685, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 5, "selected": false, "text": "T myData;\nMonitor.Enter(mutex)\ntry\n{\n myData= // something\n}\nfinally\n{\n Monitor.Exit(mutex);\n}\n\nreturn...
2008/11/05
[ "https://Stackoverflow.com/questions/266681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
266,688
<p>As many do I have a config.php file in the root of a web app that I want to include in almost every other php file. So most of them have a line like:</p> <pre><code>require_once("config.php"); </code></pre> <p>or sometimes</p> <pre><code>require_once("../config.php"); </code></pre> <p>or even</p> <pre><code>require_once("../../config.php"); </code></pre> <p>But I never get it right the first time. I can't figure out what php is going to consider to be the current working directory when reading one of these files. It is apparently not the directory where the file containing the require_once() call is made because I can have two files in the same directory that have different paths for the config.php.</p> <p>How I have a situation where one path is correct for refreshing the page but an ajax can that updates part of the page requires a different path to the config.php in the require_once() statement;</p> <p>What's the secret? From where is that path evaluated?</p> <p>Shoot, I was afraid this wouldn't be a common problem - This is occurring under apache 2.2.8 and PHP 5.2.6 running on windows.</p>
[ { "answer_id": 266730, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 4, "selected": false, "text": "require_once(dirname(__FILE__).\"/../_include/header.inc\");\n" }, { "answer_id": 266749, "author": "Kent ...
2008/11/05
[ "https://Stackoverflow.com/questions/266688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28565/" ]
266,693
<p>I'd like to remove all "unchecked" warnings from this general utility method (part of a larger class with a number of similar methods). In a pinch, I can use @SuppressWarnings("unchecked") but I'm wondering if I can use generics properly to avoid the warning.</p> <p>The method is intended to be allow callers to compare two objects by passing through to compareTo, with the exception that if the object is a strings it does it in a case insensitive manner.</p> <pre><code>public static int compareObject(Comparable o1, Comparable o2) { if ((o1 instanceof String) &amp;&amp; (o2 instanceof String)) return ((String) o1).toUpperCase().compareTo(((String) o2).toUpperCase()); else return o1.compareTo(o2); } </code></pre> <p>This was my first (incorrect) attempt at a solution. The parameters work fine, but the line o1.compareTo(o2) has a compile error "The method compareTo(capture#15-of ?) in the type Comparable is not applicable for the arguments (Comparable".</p> <pre><code>public static int compareObject(Comparable&lt;?&gt; o1, Comparable&lt;?&gt; o2) { if ((o1 instanceof String) &amp;&amp; (o2 instanceof String)) return ((String) o1).toUpperCase().compareTo(((String) o2).toUpperCase()); else return o1.compareTo(o2); } </code></pre> <p>Any suggestions?</p>
[ { "answer_id": 266741, "author": "jfpoilpret", "author_id": 1440720, "author_profile": "https://Stackoverflow.com/users/1440720", "pm_score": -1, "selected": false, "text": "public static <T> int compareObject(Comparable<T> o1, Comparable<T> o2)\n{\n if ((o1 instanceof String) && (o2 ...
2008/11/05
[ "https://Stackoverflow.com/questions/266693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32978/" ]
266,697
<p>I have a stored procedure that has a optional parameter, <code>@UserID VARCHAR(50)</code>. The thing is, there are two ways to work with it:</p> <ol> <li>Give it a default value of <code>NULL</code>, the have an <code>IF...ELSE</code> clause, that performs two different <code>SELECT</code> queries, one with <code>'WHERE UserID = @UserID'</code> and without the where.</li> <li>Give it a default value of <code>'%'</code> and then just have the where clause use <code>'WHERE UserID LIKE @UserID'</code>. In the calling code, the '%' wont be used, so only exact matches will be found.</li> </ol> <p>The question is: Which option is faster? Which option provides better performance as the table grows? Be aware that the <code>UserID</code> column is a foreign key and is not indexed. </p> <p><b>EDIT:</b> Something I want to add, based on some answers: The <code>@UserID</code> parameter is not (necessarily) the only <b>optional</b> parameter being passed. In some cases there are as many as 4 or 5 optional parameters.</p>
[ { "answer_id": 266717, "author": "Matt Rogish", "author_id": 2590, "author_profile": "https://Stackoverflow.com/users/2590", "pm_score": 3, "selected": false, "text": "WHERE ( @UserID IS NULL OR UserID = @UserID )\n" }, { "answer_id": 266728, "author": "Greg Beech", "auth...
2008/11/05
[ "https://Stackoverflow.com/questions/266697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8363/" ]
266,704
<p>Is there any way in JavaScript to create a &quot;weak reference&quot; to another object? <a href="http://en.wikipedia.org/wiki/Weak_reference" rel="nofollow noreferrer">Here is the wiki page describing what a weak reference is.</a> <a href="https://community.oracle.com/blogs/enicholas/2006/05/04/understanding-weak-references" rel="nofollow noreferrer">Here is another article that describes them in Java.</a> Can anyone think of a way to implement this behavior in JavaScript?</p>
[ { "answer_id": 266892, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 6, "selected": true, "text": "WeakRef" }, { "answer_id": 42119578, "author": "Markus", "author_id": 1826075, "author_profile": "https...
2008/11/05
[ "https://Stackoverflow.com/questions/266704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21317/" ]
266,716
<p>Is there a way to select which TestMethods you want to execute in Visual Studio 2008 Unit Test project while debugging? I want to debug one particular test without having my other TestMethods execute during each debug session.</p>
[ { "answer_id": 1999464, "author": "peSHIr", "author_id": 50846, "author_profile": "https://Stackoverflow.com/users/50846", "pm_score": 0, "selected": false, "text": "Test" } ]
2008/11/05
[ "https://Stackoverflow.com/questions/266716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
266,719
<p>I've seen a lot of discussion on URL Routing, and LOTS of great suggestions... but in the real world, one thing I haven't seen discussed are: </p> <ol> <li>Creating Friendly URLs <strong>with Spaces and illegal characters</strong> </li> <li>Querying the DB</li> </ol> <p>Say you're building a Medical site, which has <strong>Articles</strong> with a <strong>Category</strong> and optional <strong>Subcategory</strong>. (1 to many). ( <strong>Could've used any example, but the medical field has lots of long words</strong>)</p> <hr> <h2><strong>Example Categories/Sub/Article Structure:</strong></h2> <ol> <li><strong>Your General Health (Category)</strong> <ul> <li><em>Natural Health <strong>(Subcategory)</em></strong> <ol> <li>Your body's immune system and why it needs help. <strong>(Article)</strong></li> <li>Are plants and herbs really the solution?</li> <li>Should I eat fortified foods?</li> </ol></li> <li>Homeopathic Medicine <ol> <li>What's homeopathic medicine?</li> </ol></li> <li><em>Healthy Eating</em> <ol> <li>Should you drink 10 cups of coffee per day?</li> <li>Are Organic Vegetables worth it?</li> <li>Is Burger King&reg; evil?</li> <li>Is "French café" or American coffee healthier?</li> </ol></li> </ul></li> <li><strong>Diseases &amp; Conditions (Category)</strong> <ul> <li><em>Auto-Immune Disorders <strong>(Subcategory)</em></strong> <ol> <li>The #1 killer of people is some disease</li> <li>How to get help </li> </ol></li> <li><em>Genetic Conditions</em> <ol> <li>Preventing Spina Bifida before pregnancy.</li> <li>Are you predisposed to live a long time?</li> </ol></li> </ul></li> <li><strong>Dr. FooBar's personal suggestions (Category)</strong> <ol> <li>My thoughts on Herbal medicine &amp; natural remedies <strong>(Article - no subcategory)</strong></li> <li>Why should you care about your health?</li> <li>It IS possible to eat right and have a good diet.</li> <li>Has bloodless surgery come of age?</li> </ol></li> </ol> <hr> <p>In a structure like this, you're going to have some <strong>LOOONG URLs</strong> if you go: /{Category}/{subcategory}/{Article Title}</p> <p>In addition, there are numerous <strong>illegal characters</strong>, like # ! ? ' é " etc.</p> <h2><strong>SO, the QUESTION(S) ARE:</strong></h2> <ol> <li>How would you handle illegal characters and Spaces? (Pros and Cons?)</li> <li>Would you handle getting this from the Database <ul> <li>In other words, would you <strong>trust the DB to find</strong> the Item, passing the title, <strong>or pull all the titles</strong> and find the key in code to get the key to pass to the Database (two calls to the database)?</li> </ul></li> </ol> <p><em>note: I always see nice pretty examples like /products/beverages/Short-Product-Name/ how about handling some ugly examples ^_^</em></p>
[ { "answer_id": 266834, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 1, "selected": false, "text": "http://www.example.com/x/category-name/subcat-name/article-name/348254863\n" }, { "answer_id": 266898, "author...
2008/11/05
[ "https://Stackoverflow.com/questions/266719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26931/" ]
266,761
<p>I'm pivoting data in MS SQL stored procedure. Columns which are pivoted are dynamically created using stored procedure parameter (for exampe: "location1,location2,location3,") so number of columns which will be generated is not known. Output should look like (where locations are taken from stored procedure parameter):</p> <blockquote> <p>OrderTime | Location1 | Location2 | Location3</p> </blockquote> <p>Any chance that this can be used in LINQ to SQL? When I dragged this procedure to dbml file it shows that this procedure returns int type.</p> <p>Columns I use from <code>log_sales</code> table are:</p> <ul> <li>Location (various location which I'm pivoting),</li> <li>Charge (amount of money)</li> <li>OrderTime</li> </ul> <p>Stored procedure:</p> <pre><code>CREATE PROCEDURE [dbo].[proc_StatsDay] @columns NVARCHAR(64) AS DECLARE @SQL_PVT1 NVARCHAR(512), @SQL_PVT2 NVARCHAR(512), @SQL_FULL NVARCHAR(4000); SET @SQL_PVT1 = 'SELECT OrderTime, ' + LEFT(@columns,LEN(@columns)-1) +' FROM (SELECT ES.Location, CONVERT(varchar(10), ES.OrderTime, 120),ES.Charge FROM dbo.log_sales ES ) AS D (Location,OrderTime,Charge) PIVOT (SUM (D.Charge) FOR D.Location IN ('; SET @SQL_PVT2 = ') )AS PVT ORDER BY OrderTime DESC'; SET @SQL_FULL = @SQL_PVT1 + LEFT(@columns,LEN(@columns)-1) + @SQL_PVT2; EXEC sp_executesql @SQL_FULL, N'@columns NVARCHAR(64)',@columns = @columns </code></pre> <p>In dbml <code>designer.cs</code> file my stored procedure part of code:</p> <pre><code>[Function(Name="dbo.proc_StatsDay")] public int proc_EasyDay([Parameter(DbType="NVarChar(64)")] string columns) { IExecuteResult result = this.ExecuteMethodCall(this,((MethodInfo)MethodInfo.GetCurrentMethod())), columns); return ((int)(result.ReturnValue)); } </code></pre>
[ { "answer_id": 266860, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "SELECT ES.Location, DateAdd(dd, DateDiff(dd, 0, ES.OrderTime), 0),ES.Charge\nFROM dbo.log_sales ES\n" }, { "answer_id"...
2008/11/05
[ "https://Stackoverflow.com/questions/266761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23280/" ]
266,771
<p>I'm trying to figure out a way to detect files that are not opened for editing but have nevertheless been modified locally. <code>p4 fstat</code> returns a value <code>headModTime</code> for any given file, but this is the change time in the depot, which should not be equal to the filesystem's <code>stat</code> last modified time.</p> <p>I'm hoping that there exists a more lightweight operation than backing up the original file, forcing a sync of the file, and then running a diff. Ideas?</p>
[ { "answer_id": 266813, "author": "grieve", "author_id": 34329, "author_profile": "https://Stackoverflow.com/users/34329", "pm_score": 6, "selected": true, "text": "p4 diff -se //myclient/... | p4 -x - edit\n" }, { "answer_id": 1013591, "author": "Cristian Diaconescu", "au...
2008/11/05
[ "https://Stackoverflow.com/questions/266771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
266,776
<p>We have some methods that call File.Copy, File.Delete, File.Exists, etc. How can we test these methods without actually hitting the file system?</p> <p>I consider myself a unit testing n00b, so any advice is appreciated.</p>
[ { "answer_id": 266804, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 6, "selected": true, "text": "public interface IFile {\n void Copy(string source, string dest);\n void Delete(string fn);\n bool Exists(string...
2008/11/05
[ "https://Stackoverflow.com/questions/266776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/681/" ]
266,777
<p>As a web developer, a number of the projects I work on fall under government umbrellas and hence are subject to <a href="http://www.section508.gov/" rel="noreferrer">508 Accessibility</a> laws, and sometimes <a href="http://www.w3.org/TR/WCAG/" rel="noreferrer">W3C accessibility</a> guidelines. To what extent can JavaScript be used while still meeting these requirements?</p> <p>Along these lines, to what extent is JavaScript, specifically AJAX and using packages like jQuery to do things such as display modal dialogues, popups, etc. supported by modern accessibility software such as JAWS, Orca, etc? In the past, the rule went something like "If it won't work in Lynx, it won't work for a screen reader." Is this still true, or has there been more progress in these areas?</p> <p>EDIT: The consensus seems to be that javascript is fine as long as there are non-javascript fallbacks, however it still seems uncertain about the support for AJAX in screen reader software. If anyone has specific experience with this, that would be most helpful.</p>
[ { "answer_id": 266833, "author": "danpickett", "author_id": 21788, "author_profile": "https://Stackoverflow.com/users/21788", "pm_score": 2, "selected": false, "text": "<script>\n $(\"#hello\").click(function(){\n alert(\"Hi\");\n });\n</script>\n<a href=\"/say_hello.htm\" id=\"hell...
2008/11/05
[ "https://Stackoverflow.com/questions/266777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20770/" ]
266,794
<p>I'm trying to submit a form with javascript. Firefox works fine but IE complains that "Object doesn't support this property or method" on the submit line of this function:</p> <pre><code>function submitPGV(formName, action) { var gvString = ""; pgVisibilities.each(function(pair) { gvString += pair.key + ":" + pair.value + ","; }); $('pgv_input').value = gvString; var form = $(formName); form.action = action; form.submit(); } </code></pre> <p>Called here:</p> <pre><code>&lt;a href="javascript:submitPGV('ProductGroupVisibility','config/productgroupvis/save')"&gt; </code></pre> <p>Here's the form:</p> <pre><code>&lt;form id="ProductGroupVisibility" action="save" method="post"&gt; &lt;input type="hidden" name="ows_gv..PGV" id="pgv_input" value=""/&gt; &lt;/form&gt; </code></pre> <p>Any ideas?</p>
[ { "answer_id": 266822, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": "alert($('ProductGroupVisibility').id)\n" }, { "answer_id": 266866, "author": "Brian", "...
2008/11/05
[ "https://Stackoverflow.com/questions/266794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34859/" ]
266,800
<p>I have a C# class the returns a List, using System.Collections.Generic Lists not F# List</p> <p>I want to iterate though the list to find a object or not find it. Here is how I would do it in C#. How would I accomplish the similar thing in F#</p> <pre><code>foreach (AperioCaseObj caseObj in CaseList) { if (caseObj.CaseId == "") { } else { } } </code></pre>
[ { "answer_id": 267047, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": true, "text": "#light\nopen System.Collections.Generic\n\nlet genList = new List<int>()\n\ngenList.Add(1)\ngenList.Add(2)\ngenL...
2008/11/05
[ "https://Stackoverflow.com/questions/266800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72123/" ]