qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
296,978
<p>I've got a small piece of code that is parsing an index value to determine a cell input into Excel. It's got me thinking...</p> <p>What's the difference between </p> <pre><code>xlsSheet.Write("C" + rowIndex.ToString(), null, title); </code></pre> <p>and</p> <pre><code>xlsSheet.Write(string.Format("C{0}", rowIndex), null, title); </code></pre> <p>Is one "better" than the other? And why?</p>
[ { "answer_id": 296985, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": true, "text": "xlsSheet.Write(\"C\" + rowIndex, null, title);\n" }, { "answer_id": 296999, "author": "Joel Coehoorn", "a...
2008/11/17
[ "https://Stackoverflow.com/questions/296978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33226/" ]
296,981
<p>Could someone show me a regular expression that would look through this document and select the href value of every href that has <code>RELATION_ID</code> on the end of it? Then if it does, I have to get the Id that is before the question mark (example <code>href="dctm://ISDOFSDdev/</code>37004e1f800021f3<code>?DMS_OBJECT_SPEC=RELATION_ID</code>")</p> <p>Thanks!</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;?dctm xml_app="elearningContent"?&gt; &lt;!DOCTYPE OnlineContent PUBLIC "-//ISDOFSD//DTD Online Content//EN" "file:C:/dmExport/New%20Folder%20(2)/ISDOFSDdev/elearningContent/OnlineContent.dtd"&gt; &lt;OnlineContent outputclass="Graphic Down" id="OnlineContent_955627C91D8743B98DCB8BD9BE379DE8"&gt; &lt;title&gt;Text and Popup&lt;/title&gt; &lt;OnlineContentBody&gt; &lt;lcInstruction id="lcInstruction_770F26218C064A84BFA1813562173970"&gt; &lt;p&gt;This is an example of a plain text screen with an attached popup.&lt;/p&gt; &lt;p&gt; Popups are used to display additional content in a popup window. A &lt;xref scope="local" type="topic" format="dita" href="dctm://ISDOFSDdev/37004e1f800021f3?DMS_OBJECT_SPEC=RELATION_ID"&gt;link is provided&lt;/xref&gt; in the main text of the screen, which may clicked on to open a popup. A screen may contain &lt;xref scope="local" type="topic" format="dita" href="dctm://ISDOFSDdev/37004e1f800021f4?DMS_OBJECT_SPEC=RELATION_ID"&gt;more than one popup&lt;/xref&gt;. &lt;/p&gt; &lt;/lcInstruction&gt; &lt;/OnlineContentBody&gt; &lt;OnlinePopup id="OnlinePopup_AFE53E2CACBF4D8196E6360D4DDB6B70"&gt; &lt;title&gt;A Popup&lt;/title&gt; &lt;OnlinePopupBody&gt; &lt;p&gt;This is an example of popup content.&lt;/p&gt; &lt;p&gt;A popup may contain one or more paragraphs of text. They may also contain lists, like this:&lt;/p&gt; &lt;ul id="ul_7812991BBBDD4995B7499A9557C4EA9C"&gt; &lt;li id="li_E83BDB28EC494B98BFF3DD5924AF855E"&gt;An item in a list&lt;/li&gt; &lt;li id="li_270F2A3A85BA4E6EBF98CB4023344475"&gt;Another item in a list&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;A numbered list is demonstrated in the second popup.&lt;/p&gt; &lt;/OnlinePopupBody&gt; &lt;/OnlinePopup&gt; &lt;OnlinePopup id="OnlinePopup_5AE081BFB97043CE99F39A9E4A063332"&gt; &lt;title&gt;Another Popup&lt;/title&gt; &lt;OnlinePopupBody&gt; &lt;p&gt;This is the second popup on this screen, containing a numbered list.&lt;/p&gt; &lt;ol id="ol_EF18C080E7CC40B7998DEB75772367A6"&gt; &lt;li id="li_91B42F1B886B4CF887C001577C14B3F0"&gt;An item in a list&lt;/li&gt; &lt;li id="li_95C4F32E093843FAB985A3F6981A7D07"&gt;Another item in a list&lt;/li&gt; &lt;/ol&gt; &lt;/OnlinePopupBody&gt; &lt;/OnlinePopup&gt; &lt;/OnlineContent&gt; </code></pre>
[ { "answer_id": 296997, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "href=\".*/([^\"?/]*)?[^\"]*RELATION_ID[^\"]*\"" }, { "answer_id": 297088, "author": "grieve", "author_id": 3...
2008/11/17
[ "https://Stackoverflow.com/questions/296981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
297,018
<p>I have stored a txt file as string in a database column. Now on one of my aspx page I have a link...I want to open a txt file when the user clicks on this link. How can i read a file from database. I know how to do this using streamreader for a file stored on the disk.</p> <p>Thanks</p>
[ { "answer_id": 297044, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "public void Page_Load(object sender, EventArgs e)\n var text = (from x in dataContext.MyTextTable where x.Id == someId select...
2008/11/17
[ "https://Stackoverflow.com/questions/297018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34219/" ]
297,029
<p>How to get file name and revision number as a list starting from a designated folder?</p>
[ { "answer_id": 298196, "author": "Oliver Giesen", "author_id": 9784, "author_profile": "https://Stackoverflow.com/users/9784", "pm_score": 0, "selected": false, "text": "cvs status" }, { "answer_id": 306674, "author": "Alex B", "author_id": 6180, "author_profile": "ht...
2008/11/17
[ "https://Stackoverflow.com/questions/297029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,034
<p>In <a href="https://stackoverflow.com/questions/204467/is-there-a-perl-function-to-turn-a-string-into-a-regexp-to-use-that-string-as-p">another Stack&nbsp;Overflow question</a> <a href="https://stackoverflow.com/users/4727/leon-timmermans">Leon Timmermans</a> asserted:</p> <blockquote> <p>I would advice you not to use prototypes. They have their uses, but not for most cases and definitely not in this one.</p> </blockquote> <p>Why might this be true (or otherwise)? I almost always supply prototypes for my Perl functions, and I've never before seen anyone else say anything bad about using them.</p>
[ { "answer_id": 297095, "author": "cjm", "author_id": 8355, "author_profile": "https://Stackoverflow.com/users/8355", "pm_score": 6, "selected": false, "text": "&function(...)" }, { "answer_id": 297265, "author": "Michael Carman", "author_id": 8233, "author_profile": "...
2008/11/17
[ "https://Stackoverflow.com/questions/297034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6782/" ]
297,035
<p>I am currently faced with a difficult sorting problem. I have a collection of events that need to be sorted against each other (a <a href="http://en.wikipedia.org/wiki/Comparison_sort" rel="nofollow noreferrer">comparison sort</a>) and against their relative position in the list.</p> <p>In the simplest terms I have list of events that each have a priority (integer), a duration (seconds), and an earliest occurrence time that the event can appear in the list. I need to sort the events based on priority, but no event can appear in the list before its earliest occurrence time. Here's an example to (hopefully) make it clearer:</p> <pre><code>// Psuedo C# code class Event { int priority; double duration; double earliestTime ; } void Example() { Event a = new Event { priority = 1, duration = 4.0, earliestTime = 0.0 }; Event b = new Event { priority = 2, duration = 5.0, earliestTime = 6.0 }; Event c = new Event { priority = 3, duration = 3.0, earliestTime = 0.0 }; Event d = new Event { priority = 4, duration = 2.0, earliestTime = 0.0 }; // assume list starts at 0.0 seconds List&lt;Event&gt; results = Sort( new List&lt;Event&gt; { a, b, c, d } ); assert( results[ 0 ] == a ); // 4.0 seconds elapsed assert( results[ 1 ] == c ); // 7.0 seconds elapsed assert( results[ 2 ] == b ); // 12.0 seconds elapsed assert( results[ 3 ] == d ); // 14.0 seconds elapsed } </code></pre> <p>Item "b" has to come last because it isn't allowed to start until 6.0 seconds into the list, so it is deferred and "c" gets to go before "b" even though its priority is lower. (Hopefully the above explains my problem, if not let me know and I'll edit it.)</p> <p>My current idea is to use an <a href="http://en.wikipedia.org/wiki/Insertion_sort" rel="nofollow noreferrer">insertion sort</a> to manage the sorting process. Unlike many of the other common sorting algorithms, insertion sort decides the order of the list one at a time and in order. So for each index I should be able to find the next lowest priority event whose earliest occurrence time will be satisfied.</p> <p>I'm hoping to find resources about sorting algorithms and data structures to help me design a good solution for this "sort" of problem. My real problem is actually more complex than this: hierarchical sorting, variable buffers between events, multiple non-constant time constraints, so the more information or ideas the better. Speed and space are not really a concern. Accuracy in sorting and maintainability of the code are a concern.</p> <p><strong>Edit:</strong> Clarifications (based on comments)</p> <ul> <li>Events consume their entire duration (that is there is no overlap of events allowed)</li> <li>Events <strong>must</strong> occur at or after their earliestTime, they cannot occur before their earliestTime.</li> <li>Events can occur later than their earliestTime if lower priority events exist</li> <li>Events cannot be interrupted</li> <li>There is a maximum duration the sum of all events that can fit in a list. This is not shown above. (In reality the duration of all events will be far greater than the time list's maximum duration.)</li> <li>There cannot be any gaps. (There are no holes to try and back fill.)</li> </ul> <p><strong>Edit:</strong> Answer</p> <p>While David Nehme gave the answer I selected, I wanted to point out that his answer is an insertion sorts at heart, and several other people provided insertions sort type answers. This confirms for me that a specialized insertion sort is probably the way to go. Thanks to all of you for your answers.</p>
[ { "answer_id": 297073, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "event a (priority = 1, start = 5)\nevent b (priority = 2, start = 0)\n" }, { "answer_id": 297079, "author...
2008/11/17
[ "https://Stackoverflow.com/questions/297035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11889/" ]
297,048
<p>What is the best method to determine if a user has viewed a piece of data, ie like an update to a comment. The two solutions I have thought about are these....</p> <ol> <li><p>Use a separate table that has a row for each user and the data id that is being viewed and inserting into when the item was last viewed.</p></li> <li><p>Use the same table and add a row for every user when the item is changed and delete that row when the user actually views the data.</p></li> </ol> <p>Both methods solve the problem but in solution 2 the maximum rows for the table would at worst equal that of solution 1, no one viewed anything, and at best has 0 rows, everything has been viewed. I know in solution 2 you have no way to determine when it was viewed.</p> <p>Thoughts? </p> <p>Edit: I was using an update to a comment as an example. In the actual application, new users wouldn't be expected to view or read old data. It would mean nothing to them for they just joined. </p>
[ { "answer_id": 297083, "author": "Kyle West", "author_id": 34133, "author_profile": "https://Stackoverflow.com/users/34133", "pm_score": 2, "selected": false, "text": "select count(*) from DataAlerts where dataid = 1 and userid = 1\n" } ]
2008/11/17
[ "https://Stackoverflow.com/questions/297048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/342514/" ]
297,063
<p>I'm still trying to get my head around using Java's generics. I have no problems at all with using typed collections, but much of the rest of it just seems to escape me.</p> <p>Right now I'm trying to use the JUnit "PrivateAccessor", which requires a Class[] argument with a list of all the argument types for the private method being called. In Java 1.4, I'd define that as</p> <pre><code>Class[] args = new Class[] { Collection.class, ArrayList.class }; </code></pre> <p>but the actual code is defined to now take the arguments</p> <pre><code>myMethod(Collection&lt;MyClass1&gt; first, ArrayList&lt;MyClass2&gt; second) </code></pre> <p>I tried to change the definition of args to be</p> <pre><code>Class&lt;? extends Object&gt;[] args = new Class&lt;? extends Object&gt;[] { Collection&lt;MyClass1&gt;.class, ArrayList&lt;MyClass2&gt;.class }; </code></pre> <p>But Eclipse puts a red marker on the closing >s, and says it's expecting "void" at that point. Can I do this using generics, or shouldn't I bother?</p>
[ { "answer_id": 297138, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 2, "selected": false, "text": "Class<?>[] paramTypes = new Class[]{ Collection.class, ArrayList.class };\n" }, { "answer_id": 297170, "author"...
2008/11/17
[ "https://Stackoverflow.com/questions/297063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3333/" ]
297,064
<p>This one has me beat;</p> <p>I have a WPF window with two (important for this case) controls, both from the WPF toolkit available at CodePlex; A DatePicker and a DataGrid.</p> <p>The DataContext of this window is set to a CLR object that has all the information it needs. This CLR object has a large list of data, and a method called GetDataForDate( DateTime date ) which decides which date we will see data for.</p> <p>How can I create a ObjectDataProvider (which I assume will be the correct solution) that the datagrid can bind to, which provides access to the data returned by GetDataForDate() called with the selected date of the DatePicker as the parameter?</p> <p>In other words, I want the user to use the datepicker to choose a date, and the grid should automatically update whenever the date is changed to reflect the correct data.</p> <p>What kind of black magic do I have to do to achieve something like this - which I would guess should be a relatively common databinding scenario?</p> <p>Thanks in advance!</p>
[ { "answer_id": 297186, "author": "Sacha Bruttin", "author_id": 20761, "author_profile": "https://Stackoverflow.com/users/20761", "pm_score": 1, "selected": false, "text": " <ObjectDataProvider ObjectType=\"{x:Type theObjectType}\" \n MethodName=\"GetDataForDate\"...
2008/11/17
[ "https://Stackoverflow.com/questions/297064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2122/" ]
297,068
<p>Normally, the method of passing workflow parameters to the workflow happens in the call to RunWorkflow. However, with the WorkflowServiceHost, there is no such method call involved. You simply call the Open() method on the instance. Any ideas?</p> <p>Of course, the implication is that I add more parameters to the service contract, but these parameters are not relevant for the consumers of the service. They are more like configuration values. </p>
[ { "answer_id": 297186, "author": "Sacha Bruttin", "author_id": 20761, "author_profile": "https://Stackoverflow.com/users/20761", "pm_score": 1, "selected": false, "text": " <ObjectDataProvider ObjectType=\"{x:Type theObjectType}\" \n MethodName=\"GetDataForDate\"...
2008/11/17
[ "https://Stackoverflow.com/questions/297068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5573/" ]
297,070
<p>I'm looking for Java code that can be used to generate sound at runtime - NOT playback of existing sound files.</p> <p>For example, what's the best code for generating a sawtooth waveform at 440 Hz for a duration of 2 milliseconds? <b>Source code appreciated!</b></p> <p>I remember my Commodore 128 had a simple Sound command that took as parameters voice, frequency, waveform, and duration to define a sound. That worked great in a lot of simple cases (quick and dirty games, experiments with sound, etc).</p> <p>I am looking specifically for sound-effect like sounds, not music or MIDI (which the <a href="http://www.jfugue.org" rel="noreferrer">JFugue</a> library covers quite well).</p>
[ { "answer_id": 376209, "author": "basszero", "author_id": 287, "author_profile": "https://Stackoverflow.com/users/287", "pm_score": 4, "selected": true, "text": "// in hz, number of samples in one second\nsampleRate = 44100\n\n// this is the time BETWEEN Samples\nsamplePeriod = 1.0 / sam...
2008/11/17
[ "https://Stackoverflow.com/questions/297070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197/" ]
297,081
<p>I am trying to RegisterClientScriptBlock in a method that is only called via an AJAX call. It doesn't appear to actually register the script on the page and I'm guessing this is because it's not actually reloading the entire page. Is there any way to register javascript on a page from within an ajax method call?</p> <pre><code> protected void MyMethod(object sender, EventArgs e) { // This method only called via AJAX call Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "resize", "alert('here');", true); } </code></pre>
[ { "answer_id": 297291, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": 5, "selected": true, "text": "ScriptManager.RegisterClientScriptBlock(Page, typeof(MyPage), \n \"MyScript\", \"GoStuff()\", true)\n" }, { ...
2008/11/17
[ "https://Stackoverflow.com/questions/297081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24908/" ]
297,084
<p>We're running into performance issues with our implementation of Team Foundation Build Server and I'm running out of ideas on how to speed things up. We've already added a few PropertyGroup elements to increase the performance on several steps (SkipClean, SkipLabel, SkipInitializeWorkspace), but I think we need to undergo a major restructuring to fix things. Here's our setup:</p> <ul> <li>We've got about 40 web applications that are each very different, but run off a bunch of shared assemblies</li> <li>Each of these web applications has their own solution;</li> <li>There are around 10 to 25 shared assemblies referenced by each of these web applications;</li> <li>There exists a build definition containing all the solutions which is fired on each check-in to the trunk;</li> </ul> <p>And here's the basic problems we're encountering</p> <ul> <li>During the build, it will build each shared assembly as many times as it is referenced, rather than building once and using for each app</li> <li>File copy time is reeeeally slow for the drop directory. It has to be over network share and won't take a local path.</li> <li>Every so many builds, one or more of the output files gets "locked" and causes the build to break even if compilation is fine.</li> <li>And another thing - I've also tried separate build definitions, but doing so will also force another workspace to be gotten on Get Latest version. I'd much rather have it be that the build server contains one version of the trunk to build off of.</li> </ul> <p>Over the last several months we've given in to lethargy and ignored this problem, but now the build time is over an hour to an hour and a half.</p> <p>I'm toying around with the idea of learning and switching to Cruise Control for the greater control I'd have. Anyone disagree with that?</p> <p>Any help is most appreciated. Thanks!</p>
[ { "answer_id": 352650, "author": "Chad Gilbert", "author_id": 34409, "author_profile": "https://Stackoverflow.com/users/34409", "pm_score": 2, "selected": false, "text": "<Target Name=\"CoreDropBuild\"\n Condition=\" '$(SkipDropBuild)'!='true' and '$(IsDesktopBuild)'!='true' \"\n ...
2008/11/17
[ "https://Stackoverflow.com/questions/297084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34409/" ]
297,111
<p>Can anyone point me to an example of how to use ServletUnit to test JSP's? Do I need I need to call registerServlet()? If so, what class name do I pass?</p>
[ { "answer_id": 1798413, "author": "user142435", "author_id": 142435, "author_profile": "https://Stackoverflow.com/users/142435", "pm_score": 3, "selected": true, "text": "<dependency>\n <groupId>tomcat</groupId>\n <artifactId>jasper</artifactId>\n <version>3.3.2</version>\n <scope>te...
2008/11/17
[ "https://Stackoverflow.com/questions/297111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38226/" ]
297,116
<p>I have a collection of domain objects that I need to convert into another type for use by the .NET framework. What is the best practice for doing such a transformation?</p> <p>Specifically, I have a type called ContentEntry and I need to convert it into a SyndicationItem for use in putting into a SyndicationFeed. The conversion itself is straight forward but I'm looking for a good pattern. Do I create a method on ContentEntry called CreateSyndicationItem() or perhaps a separate converter object? Perhaps an extension method?</p> <p>This will be somewhat subjective, but I'd appreciate some ideas.</p> <blockquote> <p>Edit Note: I'd like to note that I don't control SyndicationItem. It is built into the .NET Framework. Also, I'd really like to convert several ContentEntry objects into SyndicationItems at one time.</p> </blockquote>
[ { "answer_id": 297133, "author": "Joel Martinez", "author_id": 5416, "author_profile": "https://Stackoverflow.com/users/5416", "pm_score": 0, "selected": false, "text": "SyndicationItem item = (SyndicationItem)entry" } ]
2008/11/17
[ "https://Stackoverflow.com/questions/297116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2656/" ]
297,119
<p>I've struggled for the last couple of months to come up with some clean code to report progress to a user. Everything always seems to boil down to:</p> <pre><code>ReportProgress("Starting Task 1"); doTask1(); ReportProgress("Task 1 is done"); ReportProgress("Starting Task 2"); doTask2(); ReportProgress("Task 2 is done"); //etc... where report progress does some form of output to the user. </code></pre> <p>The good coder in me screams "There's got to be a cleaner way!" But I'm stumped. Any thoughts?</p> <p>EDIT :: I'm looking more for information on architectural information as opposed to implementation specific. The code given is <b>very</b> oversimplified.</p>
[ { "answer_id": 297156, "author": "Ryan Thames", "author_id": 1459442, "author_profile": "https://Stackoverflow.com/users/1459442", "pm_score": 0, "selected": false, "text": "doTask1();\ndoTask2();\n" }, { "answer_id": 297185, "author": "Steven A. Lowe", "author_id": 9345,...
2008/11/17
[ "https://Stackoverflow.com/questions/297119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33226/" ]
297,121
<p>I have a section on my ASP.net web.config for the Enterprise library logging block. Is it possible to separate the logging configuration into another configuration file? How do I do that?</p>
[ { "answer_id": 297156, "author": "Ryan Thames", "author_id": 1459442, "author_profile": "https://Stackoverflow.com/users/1459442", "pm_score": 0, "selected": false, "text": "doTask1();\ndoTask2();\n" }, { "answer_id": 297185, "author": "Steven A. Lowe", "author_id": 9345,...
2008/11/17
[ "https://Stackoverflow.com/questions/297121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
297,122
<p>What should I keep in mind when converting my projects from C to C++? Is there any reason to use C at all? The only thing in my mind now is to make sure it's friendly to DLLs so I can create a C interface if I need it.</p> <p>Note: I know C++ just fine. Templates, partial specialization, why multiple inheritance is bad (I've only seen one proper use for it), etc. I mostly want to know why I would use C over C++. DLLs and script language bindings is one reason. So I just need to keep in mind I should have a C interface for certain things. Is there anything else?</p>
[ { "answer_id": 297229, "author": "ypnos", "author_id": 21974, "author_profile": "https://Stackoverflow.com/users/21974", "pm_score": 3, "selected": false, "text": "extern \"C\" {}" }, { "answer_id": 297317, "author": "Jon Ericson", "author_id": 1438, "author_profile":...
2008/11/17
[ "https://Stackoverflow.com/questions/297122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,134
<p>I have a folder "FolderA" which contains three sub-folders: foldera1 foldera2 and foldera3</p> <p>I need to write a batch file which resides inside "FolderA". It should delete all the folders under "FolderA" as a cleanup activity. I don't know the folder names. <code>rmdir</code> does not support wild cards.</p> <p>Could someone provide a solution for this small problem?</p>
[ { "answer_id": 297152, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "for /f %%a in ('dir /ad /b') do (rmdir /S /Q \"%%a\")\nfor /d %%a in (*) do (rmdir /S /Q \"%%a\")\n" }, { "answer_id": 2...
2008/11/17
[ "https://Stackoverflow.com/questions/297134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32670/" ]
297,136
<p>Is there a way to prompt the user for input during a NAnt build? I want to execute a command that takes a password, but I don't want to put the password into the build script.</p>
[ { "answer_id": 297203, "author": "sundar venugopal", "author_id": 32670, "author_profile": "https://Stackoverflow.com/users/32670", "pm_score": 2, "selected": false, "text": "<script language=\"C#\" prefix=\"test\" >\n <code>\n <![CDATA[\n [Function(\"get...
2008/11/17
[ "https://Stackoverflow.com/questions/297136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4794/" ]
297,205
<p>I have a field (say, foo) in a table in a SQL Server database that was originally defined as nullable, but new requirements indicate that this field must be non-null.</p> <p>What's the best way of updating this field to non-null via an update script without deleting the contents of the table? I tried generating a script from the Design view, but fails during execution because the current contents of the table had NULL values for foo. Worse yet, if I ignored this error, it proceeds to delete all the contents of the table!</p>
[ { "answer_id": 297248, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 4, "selected": true, "text": "NULL" } ]
2008/11/17
[ "https://Stackoverflow.com/questions/297205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5563/" ]
297,206
<p>I have a simple page that displays a user's email addresses in a table. I also have a textbox underneath the table and an "add" button. Currently, I am using a simple form post that is handled by a controller that will add the e-mail address to the database and reload the page. This works fine, but I'm looking to streamline the process by using jQuery and AJAX so that the page doesn't need to be refreshed.</p> <p>What's the best way to go about doing this? I imagine I'll have to set up an event listener for the button's click event, perform an AJAX call to a url like "Email/Add". Where I get lost is figuring out what type of information to return from that controller action and how that information can get parsed on the client side to update the table of e-mail addresses. Are there any good samples of this out there?</p>
[ { "answer_id": 297259, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 2, "selected": false, "text": "{\n result: 'SUCCESS',\n description: 'Email Added.'\n}\n" }, { "answer_id": 298488, "author": "Morp...
2008/11/17
[ "https://Stackoverflow.com/questions/297206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
297,213
<p>Given a columns' index, how can you get an Excel column name?</p> <p>The problem is trickier than it sounds because it's <strong>not just base-26</strong>. The columns don't wrap over like normal digits would. Even the <a href="http://support.microsoft.com/kb/833402" rel="nofollow noreferrer">Microsoft Support Example</a> doesn't scale beyond ZZZ.</p> <p><sub><em>Disclaimer: This is some code I had done a while back, and it came across my desktop again today. I thought it was worthy of posting here as a pre-answered question.</em></sub></p>
[ { "answer_id": 297214, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 6, "selected": true, "text": "Function ColumnName(ByVal index As Integer) As String\n Static chars() As Char = {\"A\"c, \"B\"c, \"C\"c, \"D\"c...
2008/11/17
[ "https://Stackoverflow.com/questions/297213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
297,217
<p>I got a web application, the problem is that the text in the label will not update on the first click, I need to click the button twice, I debugged to code, and I found out that the label does not recive the data until after the second click,</p> <p>Here is my code:</p> <pre><code>System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(); System.Data.SqlClient.SqlConnection connection; string CommandText; string game; string modtype; bool filter; protected void Page_Load(object sender, EventArgs e) { labDownloadList.Text = null; //Session variables: if (Session["Game"] != null) { game = Convert.ToString(Session["Game"]); } if (Session["ModType"] != null) { modtype = Convert.ToString(Session["ModType"]); } if (Session["FilterBool"] != null) { filter = Convert.ToBoolean(Session["FilterBool"]); } string ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\inetpub\\wwwroot\\stian\\App_Data\\Database.mdf;Integrated Security=True;User Instance=True"; connection = new System.Data.SqlClient.SqlConnection(ConnectionString); System.Data.SqlClient.SqlDataReader reader; command = connection.CreateCommand(); connection.Open(); CommandText = "SELECT * FROM Command"; if (filter) { CommandText = "SELECT * FROM Command WHERE Game='" + game + "' AND Type='" + modtype + "'"; } command.CommandText = CommandText; reader = command.ExecuteReader(); labDownloadList.Text = ""; while (reader.Read()) { string game = reader.GetString(1); string author = reader.GetString(2); string downloadlink = reader.GetString(3); string size = reader.GetString(4); string description = reader.GetString(5); string version = reader.GetString(6); string screenshotlink = reader.GetString(7); Int64 AmountDownloaded = reader.GetInt64(8); labDownloadList.Text += "Game: " + game + "&lt;br&gt;"; labDownloadList.Text += "Author: " + author + "&lt;br&gt;"; labDownloadList.Text += "Size: " + size + "&lt;br&gt;"; labDownloadList.Text += "Description: " + description + "&lt;br&gt;"; labDownloadList.Text += "Version: " + version + "&lt;br&gt;"; labDownloadList.Text += "&lt;img src='" + screenshotlink + " /&gt;&lt;br&gt;"; labDownloadList.Text += "Downloaded: " + AmountDownloaded + " times&lt;br&gt;&lt;hr&gt;"; labDownloadList.Text += "&lt;a href='" + downloadlink + "'&gt;Download&lt;/a&gt;&lt;br&gt;"; } } protected void Page_UnLoad(object sender, EventArgs e) { Session["Game"] = game; Session["ModType"] = modtype; Session["FilterBool"] = filter; connection.Close(); } protected void btnFilter_Click(object sender, EventArgs e) { game = lstGames.SelectedValue; modtype = lstTypeMod.SelectedValue; filter = true; } </code></pre>
[ { "answer_id": 297230, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 2, "selected": false, "text": "if (!Page.IsPostBack)\n{\n ...\n}\n" }, { "answer_id": 297362, "author": "JackCorn", "author_id": 14919, ...
2008/11/17
[ "https://Stackoverflow.com/questions/297217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,220
<p>Using VBA in MS Office, how do I add text to the Windows clipboard so that it will paste into Word as a table?</p>
[ { "answer_id": 297288, "author": "staticsan", "author_id": 28832, "author_profile": "https://Stackoverflow.com/users/28832", "pm_score": 0, "selected": false, "text": "Paste Special" } ]
2008/11/17
[ "https://Stackoverflow.com/questions/297220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16415/" ]
297,236
<p>I am developing a site that makes extensive use of JavaScript (jQuery). I regularly get the IE 'Stop running this script?' error dialog when I try to close the browser. </p> <p>I'm guessing the problem occurs because the site is a single page that uses AJAX, so there are no postbacks to reset IE's count of commands executed.</p> <p>Client-side registry hacking is not an option.</p> <p>Does anyone know a way to get around this error?</p> <p>UPDATE: The page has a number (~10) interval timers that poll continually on 30 or 60 second intervals.</p>
[ { "answer_id": 297266, "author": "Eric Wendelin", "author_id": 25066, "author_profile": "https://Stackoverflow.com/users/25066", "pm_score": 2, "selected": false, "text": "window.onunload = null;\n" }, { "answer_id": 2251407, "author": "Narsi", "author_id": 271792, "a...
2008/11/17
[ "https://Stackoverflow.com/questions/297236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2785/" ]
297,238
<p>How do you repopulate a form in ASP.NET MVC that contains a DropDownList?</p>
[ { "answer_id": 316240, "author": "BigJoe714", "author_id": 37786, "author_profile": "https://Stackoverflow.com/users/37786", "pm_score": 3, "selected": false, "text": "private Dictionary<string, string> getListItems()\n{\n Dictionary<string, string> d = new Dictionary<string, string>(...
2008/11/17
[ "https://Stackoverflow.com/questions/297238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,239
<p>I am testing against the following test document:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;hi there&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;img class="foo" src="bar.png"/&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If I parse the document using lxml.html, I can get the IMG with an xpath just fine:</p> <pre><code>&gt;&gt;&gt; root = lxml.html.fromstring(doc) &gt;&gt;&gt; root.xpath("//img") [&lt;Element img at 1879e30&gt;] </code></pre> <p>However, if I parse the document as XML and try to get the IMG tag, I get an empty result:</p> <pre><code>&gt;&gt;&gt; tree = etree.parse(StringIO(doc)) &gt;&gt;&gt; tree.getroot().xpath("//img") [] </code></pre> <p>I can navigate to the element directly:</p> <pre><code>&gt;&gt;&gt; tree.getroot().getchildren()[1].getchildren()[0] &lt;Element {http://www.w3.org/1999/xhtml}img at f56810&gt; </code></pre> <p>But of course that doesn't help me process arbitrary documents. I would also expect to be able to query etree to get an xpath expression that will directly identify this element, which, technically I can do:</p> <pre><code>&gt;&gt;&gt; tree.getpath(tree.getroot().getchildren()[1].getchildren()[0]) '/*/*[2]/*' &gt;&gt;&gt; tree.getroot().xpath('/*/*[2]/*') [&lt;Element {http://www.w3.org/1999/xhtml}img at fa1750&gt;] </code></pre> <p>But that xpath is, again, obviously not useful for parsing arbitrary documents.</p> <p>Obviously I am missing some key issue here, but I don't know what it is. My best guess is that it has something to do with namespaces but the only namespace defined is the default and I don't know what else I might need to consider in regards to namespaces.</p> <p>So, what am I missing?</p>
[ { "answer_id": 297243, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 6, "selected": true, "text": ">>> tree.getroot().xpath(\n... \"//xhtml:img\", \n... namespaces={'xhtml':'http://www.w3.org/1999/xhtml'}\n....
2008/11/17
[ "https://Stackoverflow.com/questions/297239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2168/" ]
297,245
<p>Does anyone know of some good tutorials that explain how to use the JQuery Slider.</p> <p>I've found a few, but none of them really present what I need in clear terms. What I really need to figure out how to do is make the slider go from 1.0 - 5.0 (including all tenths) and when it changes set a hidden control based on that value.</p> <p>Thanks.</p>
[ { "answer_id": 297338, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 3, "selected": true, "text": "$('#mySlider').slider({\n min : 1,\n max : 5,\n stepping: .1, // or, steps: 40\n change : function (e, ui) {\n ...
2008/11/17
[ "https://Stackoverflow.com/questions/297245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
297,251
<p>I have a vertical menu in my system which is basically made of HTML <code>ul</code>/<code>li</code> with CSS styling (see image below). However I don't want the <code>li</code> items which are wider than the menu to wrap, I would prefer them to overflow with a horizontal scroll bar at the bottom of the menu. How can I do this in CSS?</p>
[ { "answer_id": 297255, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 3, "selected": false, "text": "white-space:nowrap" }, { "answer_id": 297272, "author": "Owen", "author_id": 4853, "author_profile": "ht...
2008/11/17
[ "https://Stackoverflow.com/questions/297251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
297,269
<p>Is there a tool which tells you (or gives you a hint) why a particular select statement dose not return any rows given the current data in your database. </p> <p>eg if you had the following 4 table join</p> <pre><code>select * from a, b, c, d where a.b_id = b.id and b.c_id = c.id and c.d_id = d.id </code></pre> <p>If there were rows which satisfied the conditions a.b_id = b.id also rows which satisfied b.c_id = c.id but no rows which satisfied the condition c.d_id = d.id it would highlight c.d_id = d.id as the problem.</p> <p>Ie it would brake up the where clause and find out which of the sub conditions returned true and highlight those which do not return true.</p> <p>It would not work well for complex querys but many select statements are simple joins over lots of tables.</p> <p>This would be useful when creating test data to exercise a peace of application code or debugging a problem with a live system.</p> <p>Graphical explain tools (that show the plan of the actual exiection path) come close but they show too much info and do not highlight the missing link in the select stament.</p> <p>I am using postgres, sqllight and mysql but would be interested in how tools for other databases/platforms work. </p> <p>Im also interested in any manula techniques.</p> <p>Does anybody else have this problem?</p> <p>Would anybody be interested if I wrote such a tool?</p>
[ { "answer_id": 297289, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 4, "selected": false, "text": "SELECT *\nFROM a -- First run just to here, are there records?\nINNER JOIN b\n ON a.b_id = b.id -- Then run just to h...
2008/11/17
[ "https://Stackoverflow.com/questions/297269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38383/" ]
297,277
<p>I am trying to do some prime factorisation with my VBA excel and I am hitting the limit of the <code>long</code> data type - </p> <blockquote> <p>Runtime Error 6 Overflow </p> </blockquote> <p>Is there any way to get around this and still stay within VBA? I am aware that the obvious one would be to use another more appropriate programming language.</p> <hr> <p><a href="https://stackoverflow.com/a/297480/1146308">Lance's solution</a> works in so far that I am able to get the big numbers into the variables now. However, when I try to apply the <code>MOD</code> function - bignumber <code>MOD 2</code>, for example - it still fails with error message </p> <blockquote> <p>Runtime Error 6 Overflow</p> </blockquote>
[ { "answer_id": 297480, "author": "Lance Roberts", "author_id": 13295, "author_profile": "https://Stackoverflow.com/users/13295", "pm_score": 2, "selected": true, "text": "r = A - Int(A / B) * B\n" }, { "answer_id": 297593, "author": "bugmagnet", "author_id": 426, "aut...
2008/11/17
[ "https://Stackoverflow.com/questions/297277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22972/" ]
297,280
<p>I have a databases table with ~50K rows in it, each row represents a job that need to be done. I have a program that extracts a job from the DB, does the job and puts the result back in the db. (this system is running right now)</p> <p>Now I want to allow more than one processing task to do jobs but be sure that no task is done twice (as a performance concern not that this will cause other problems). Because the access is by way of a stored procedure, my current though is to replace said stored procedure with something that looks something like this</p> <pre><code>update tbl set owner = connection_id() where available and owner is null limit 1; select stuff from tbl where owner = connection_id(); </code></pre> <p>BTW; worker's tasks might drop there connection between getting a job and submitting the results. Also, I don't expect the DB to even come close to being the bottle neck unless I mess that part up (~5 jobs per minute)</p> <p>Are there any issues with this? Is there a better way to do this?</p> <p>Note: the <a href="http://tripatlas.com/Database_as_an_IPC" rel="noreferrer">"Database as an IPC anti-pattern"</a> is only slightly apropos here because </p> <ol> <li>I'm not doing IPC (there is no process generating the rows, they all already exist right now) and </li> <li>the primary gripe described for that anti-pattern is that it results in unneeded load on the DB as processes wait for messages (in my case, if there are no messages, everything can shutdown as everything is done)</li> </ol>
[ { "answer_id": 297354, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 5, "selected": true, "text": "MsgId identity -- NOT NULL\nMsgTypeCode varchar(20) -- NOT NULL \nSourceCode varchar(20) -- process inserting the message ...
2008/11/17
[ "https://Stackoverflow.com/questions/297280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
297,294
<p>My build environment is configured to compile, run and create coverage file at the command line (using Ned Batchelder coverage.py tool). </p> <p>I'm using Eclipse with PyDev as my editor, but for practical reasons, it's not possible/convenient for me to convert my whole build environment to Eclipse (and thus generate the coverage data directly from the IDE, as it's designed to do)</p> <p>PyDev seems to be using the same coverage tool (or something very similar to it) to generate its coverage information, so I'm guessing there should be some way of integrating my external coverage files into Eclipse/PyDev.</p> <p>Any idea on how to do this?</p>
[ { "answer_id": 297354, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 5, "selected": true, "text": "MsgId identity -- NOT NULL\nMsgTypeCode varchar(20) -- NOT NULL \nSourceCode varchar(20) -- process inserting the message ...
2008/11/17
[ "https://Stackoverflow.com/questions/297294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8027/" ]
297,297
<p>I've got a button that I'm adding as a subview of a table view's tableHeaderView. The button appears fine, and tap-and-holding on it works intermittently - for the most part, though, it's unresponsive. I've tried adding it as a subview of the table itself; the effect is about the same. I thought the problem might be with the scroll view's touch interception, but disabling scrolling on the table has no effect either. </p> <p>Am I doing something wrong? Has anyone else encountered this?</p> <p>edit - to clarify, I'm talking about the main table header, not a section header, in a grouped-style table; think basically modeled after the "Contact" screen.</p>
[ { "answer_id": 7897148, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "- (void)viewDidLoad\n{\n [super viewDidLoad];\n\n MYCustomWidget *headerView = [[[NSBundle mainBundle] \n ...
2008/11/17
[ "https://Stackoverflow.com/questions/297297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30618/" ]
297,298
<p>When you hit F5, the browser windows pops up, how do you set which browser the debugger users in Visual Studio 2008?</p> <p><strong>Update 1</strong><br> I have looked for the 'Browse with' option and not found it.<br> <a href="https://stackoverflow.com/questions/79954/visual-studio-opens-default-browser-instead-of-ie">Visual Studio opens the default browser instead of Internet Explorer</a> </p> <p><strong>Update 2</strong><br> If you are already debugging you dont have the 'Browse with' option. </p> <ul> <li><em>Stop debugging and then its there!</em></li> </ul> <p><strong>Update 3</strong><br> The accepted answer below is also relevant to changing the default browser to debug with in Visual Studio 2010.</p>
[ { "answer_id": 618007, "author": "Matthew Lock", "author_id": 74585, "author_profile": "https://Stackoverflow.com/users/74585", "pm_score": 3, "selected": false, "text": "Project Properties -> Web -> Start Action" }, { "answer_id": 3180941, "author": "PHOTON", "author_id"...
2008/11/17
[ "https://Stackoverflow.com/questions/297298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6268/" ]
297,299
<p>I have my enumHelper class that contains these:</p> <pre><code>public static IList&lt;T&gt; GetValues() { IList&lt;T&gt; list = new List&lt;T&gt;(); foreach (object value in Enum.GetValues(typeof(T))) { list.Add((T)value); } return list; } </code></pre> <p>and</p> <pre><code>public static string Description(Enum value) { Attribute DescAttribute = LMIGHelper.GetAttribute(value, typeof(DescriptionAttribute)); if (DescAttribute == null) return value.ToString(); else return ((DescriptionAttribute)DescAttribute).Description; } </code></pre> <p>my enum is something like:</p> <pre><code>public enum OutputType { File, [Description("Data Table")] DataTable } </code></pre> <p>So far so good. All the previous work fine. Now I want to add a new helper to return BindingList>, so I can link any enum to any combo using </p> <pre><code>BindingList&lt;KeyValuePair&lt;OutputType, string&gt;&gt; list = Enum&lt;OutputType&gt;.GetBindableList(); cbo.datasource=list; cbo.DisplayMember="Value"; cbo.ValueMember="Key"; </code></pre> <p>For that I added:</p> <pre><code>public static BindingList&lt;KeyValuePair&lt;T, string&gt;&gt; GetBindingList() { BindingList&lt;KeyValuePair&lt;T, string&gt;&gt; list = new BindingList&lt;KeyValuePair&lt;T, string&gt;&gt;(); foreach (T value in Enum&lt;T&gt;.GetValues()) { string Desc = Enum&lt;T&gt;.Description(value); list.Add(new KeyValuePair&lt;T, string&gt;(value, Desc)); } return list; } </code></pre> <p>But "Enum.Description(value)" is not even compiling: Argument '1': cannot convert from 'T' to 'System.Enum'</p> <p>How can I do that? Is that even possible?</p> <p>Thank you.</p>
[ { "answer_id": 297333, "author": "nsayer", "author_id": 13757, "author_profile": "https://Stackoverflow.com/users/13757", "pm_score": -1, "selected": false, "text": "public static BindingList<KeyValuePair<T extends _interface_, String>> getBindingList()\n" }, { "answer_id": 29740...
2008/11/17
[ "https://Stackoverflow.com/questions/297299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,303
<p>Some days ago I realized that <a href="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html" rel="noreferrer">PrintWriter</a> (as well as <a href="http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html" rel="noreferrer">PrintStream</a>) <strong>never throw an IOException</strong> when writing, flushing or closing.</p> <p>Instead it sets an internal flag (<code>trouble=true</code>) when an error occurs.<br/> It's not possible to get the exact exception, but only <strong>if</strong> there was some exception (<a href="http://java.sun.com/javase/6/docs/api/java/io/PrintWriter.html#checkError()" rel="noreferrer">checkError()</a>).</p> <p>My question is: why would one want to have such behavior? Isn't that bad API design?</p>
[ { "answer_id": 297649, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 5, "selected": true, "text": "System.out" }, { "answer_id": 62482878, "author": "David L.", "author_id": 1182474, "author_profile": "h...
2008/11/17
[ "https://Stackoverflow.com/questions/297303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308/" ]
297,335
<p>I've got some code that will generically get all Controls in a form and put them in a list. Here's some of the code:</p> <pre><code> private List&lt;Control&gt; GetControlList(Form parentForm) { List&lt;Control&gt; controlList = new List&lt;Control&gt;(); AddControlsToList(parentForm.Controls, controlList); return controlList; } private void AddControlsToList(Control.ControlCollection rootControls, List&lt;Control&gt; controlList) { foreach (Control c in rootControls) { controlList.Add(c); if (c.HasChildren) AddControlsToList(c.Controls, controlList); // } } </code></pre> <p>So I'm only able to use c.HasChildren to check and see if there's any more child controls from this root control.</p> <p><strong>What about a menuStrip, toolStrip, and statusStrip? How do I get all of the controls that are in these controls generically? Ex: MenuStripItem</strong></p> <p>I know that I could try testing the c.GetType() == typeof(MenuStrip) but I was hoping to not have to do specific type tests.</p> <p>If I need to give more info, please ask.</p> <p>Thanks a bunch</p>
[ { "answer_id": 297378, "author": "P Daddy", "author_id": 36388, "author_profile": "https://Stackoverflow.com/users/36388", "pm_score": 4, "selected": true, "text": "Designer" }, { "answer_id": 297411, "author": "Joshua Tacoma", "author_id": 35514, "author_profile": "h...
2008/11/17
[ "https://Stackoverflow.com/questions/297335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21828/" ]
297,345
<p>I've got a large amount of data (a couple gigs) I need to write to a zip file in Python. I can't load it all into memory at once to pass to the .writestr method of ZipFile, and I really don't want to feed it all out to disk using temporary files and then read it back.</p> <p>Is there a way to feed a generator or a file-like object to the ZipFile library? Or is there some reason this capability doesn't seem to be supported?</p> <p>By zip file, I mean zip file. As supported in the Python zipfile package.</p>
[ { "answer_id": 297376, "author": "altunyurt", "author_id": 37491, "author_profile": "https://Stackoverflow.com/users/37491", "pm_score": 2, "selected": false, "text": "file = gzip.GzipFile('blah.gz', 'wb')\nsourcefile = open('source', 'rb')\nchunks = []\nfor line in sourcefile:\n chunks...
2008/11/17
[ "https://Stackoverflow.com/questions/297345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9161/" ]
297,349
<p>I am trying to use google search for my site:</p> <p><a href="http://www.houseofhawkins.com/search.php" rel="noreferrer">http://www.houseofhawkins.com/search.php</a></p> <p>It is not playing nice with some screen resolutions. Here is the code given from google:</p> <pre><code>&lt;div id="cse-search-results"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; var googleSearchIframeName = "cse-search-results"; var googleSearchFormName = "cse-search-box"; var googleSearchFrameWidth = 250; var googleSearchDomain = "www.google.com"; var googleSearchPath = "/cse"; &lt;/script&gt; &lt;script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"&gt;&lt;/script&gt; </code></pre> <p>I changed the "googleSearchFrameWidth" down to 250 thinking that should be setting the width in px, (it was 600 to start with). But with smaller screens (1024 * 768) it sticks out the side of my divs.</p> <p>Am I doing something stupid?</p>
[ { "answer_id": 1085229, "author": "Thomas Beck", "author_id": 131794, "author_profile": "https://Stackoverflow.com/users/131794", "pm_score": 3, "selected": false, "text": "style =\"width:500\"" }, { "answer_id": 1273628, "author": "dhorn", "author_id": 148632, "autho...
2008/11/17
[ "https://Stackoverflow.com/questions/297349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6486/" ]
297,371
<p>I want to stress test a web service method by calling it several thousand times in quick succession. The method has a single string parameter that I will vary on each call.</p> <p>I'm planning on writing a Powershell script to loop and call this method a number of times.</p> <p>Is there a better way to do this?</p>
[ { "answer_id": 53878777, "author": "davidp_1978", "author_id": 1988756, "author_profile": "https://Stackoverflow.com/users/1988756", "pm_score": 0, "selected": false, "text": "ForEach -Parallel ($item in $collection) { }\n" } ]
2008/11/17
[ "https://Stackoverflow.com/questions/297371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
297,383
<p>I am hoping to dynamically update a ModelForm's inline Meta class from my view. Although this code seems to update the exclude list in the Meta class, the output from <code>as_p()</code>, <code>as_ul()</code>, etc does not reflect the updated Meta exclude.</p> <p>I assume then that the html is generated when the ModelForm is created not when the <code>as_*()</code> is called. Is there a way to force the update of the HTML? </p> <p>Is this even the best way to do it? I just assumed this <em>should</em> work.</p> <p>Thoughts?</p> <pre><code>from django.forms import ModelForm from testprogram.online_bookings.models import Passenger class PassengerInfoForm(ModelForm): def set_form_excludes(self, exclude_list): self.Meta.exclude = excludes_list class Meta: model = Passenger exclude = [] </code></pre>
[ { "answer_id": 297478, "author": "Daniel Naab", "author_id": 32638, "author_profile": "https://Stackoverflow.com/users/32638", "pm_score": 7, "selected": true, "text": "def get_form(exclude_list):\n class MyForm(ModelForm):\n class Meta:\n model = Passenger\n ...
2008/11/17
[ "https://Stackoverflow.com/questions/297383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22306/" ]
297,387
<p>I have a problem where I am attempting to update a set of attributes with a fixed value contained within a repeating section of an XML document using the <code>Microsoft.BizTalk.Streaming.ValueMutator</code>. </p> <p>For example the XML document which I am attempting to update contains the following input:</p> <pre><code>&lt;ns0:TestXML xmlns:ns0="http://Test.Schemas"&gt; &lt;ns0:NodeA&gt; &lt;ns0:NodeB&gt; &lt;ns0:alpha Id="1" Value="Apple" Type=""&gt;&lt;/ns0:alpha&gt; &lt;ns0:alpha Id="2" Value="Banana" Type=""&gt;&lt;/ns0:alpha&gt; &lt;ns0:alpha Id="3" Value="Car" Type=""&gt;&lt;/ns0:alpha&gt; &lt;ns0:alpha Id="4" Value="Duck" Type=""&gt;&lt;/ns0:alpha&gt; &lt;/ns0:NodeB&gt; &lt;/ns0:NodeA&gt; &lt;/ns0:TestXML&gt; </code></pre> <p>The code which I am attempting to use to update the XML document is:</p> <pre><code>XmlDocument xDocInput = new XmlDocument(); XmlDocument xDocOutput = new XmlDocument(); string inputFileName = @"C:\Input.xml"; string outputFileName = @"C:\Output.xml"; string newValue = "fruit"; string xpathToUpdate = "/*[namespace-uri()='http://Test.Schemas']/*[local-name()='NodeA']/*[local-name()='NodeB']/*[@Type]"; xDocInput.Load(inputFileName); using (MemoryStream memstream = new MemoryStream()) { xDocInput.Save(memstream); memstream.Position = 0; XPathCollection queries = new XPathCollection(); queries.Add(new XPathExpression(xpathToUpdate)); //ValueMutator xpathMatcher = new ValueMutator(this.XPathCallBack); //Get resulting stream into response xml xDocOutput.Load(new XPathMutatorStream(memstream, queries, delegate(int matchIdx, XPathExpression expr, string origValue, ref string finalValue) { finalValue = newValue; })); //System.Diagnostics.Trace.WriteLine("Trace: " + memstream.Length.ToString()); } xDocOutput.Save(outputFileName); </code></pre> <p>The resulting output of this code is the file "Output.xml". Contained within the output document "Output.xml" is the following output:</p> <pre><code>&lt;ns0:TestXML xmlns:ns0="http://Test.Schemas" &gt; &lt;ns0:NodeA&gt; &lt;ns0:NodeB&gt; &lt;ns0:alpha Id="1" Value="Apple" Type="" &gt;fruit&lt;/ns0:alpha&gt; &lt;ns0:alpha Id="2" Value="Banana" Type="" &gt;fruit&lt;/ns0:alpha&gt; &lt;ns0:alpha Id="3" Value="Child" Type="" &gt;fruit&lt;/ns0:alpha&gt; &lt;ns0:alpha Id="4" Value="Duck" Type="" &gt;fruit&lt;/ns0:alpha&gt; &lt;/ns0:NodeB&gt; &lt;/ns0:NodeA&gt; &lt;/ns0:TestXML&gt; </code></pre> <p>As you will notice the "alpha" element's text value is updated incorrectly. The desired result is to update all attributes named "Type" with the value "Fruit". What is going wrong and how is this problem solved?</p>
[ { "answer_id": 297453, "author": "Dimitre Novatchev", "author_id": 36305, "author_profile": "https://Stackoverflow.com/users/36305", "pm_score": 0, "selected": false, "text": "//namespace-uri()='http://Test.Schemas']/*[local-name()='NodeA']/*[local-name()='NodeB']/*[@Type]" }, { ...
2008/11/17
[ "https://Stackoverflow.com/questions/297387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3810/" ]
297,392
<p>I'm preferably looking for a SQL query to accomplish this, but other options might be useful too.</p>
[ { "answer_id": 297400, "author": "WW.", "author_id": 14663, "author_profile": "https://Stackoverflow.com/users/14663", "pm_score": 6, "selected": true, "text": "SELECT LAST_DDL_TIME, TIMESTAMP\nFROM USER_OBJECTS\nWHERE OBJECT_TYPE = 'PROCEDURE'\nAND OBJECT_NAME = 'MY_PROC';\n" }, { ...
2008/11/17
[ "https://Stackoverflow.com/questions/297392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
297,398
<p>How can I validate date strings in Perl? I'd like to account for leap years and also time zones. Someone may enter dates in the following formats:</p> <pre> 11/17/2008 11/17/2008 3pm 11/17/2008 12:01am 11/17/2008 12:01am EST 11/17/2008 12:01am CST </pre>
[ { "answer_id": 298345, "author": "draegtun", "author_id": 12195, "author_profile": "https://Stackoverflow.com/users/12195", "pm_score": 4, "selected": true, "text": "use DateTime::Format::DateManip; \n\nmy @dates = (\n '11/17/2008',\n '11/17/2008 3pm',\n '11/17/2008 12:01am',\n ...
2008/11/17
[ "https://Stackoverflow.com/questions/297398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,417
<p>Can someone show me a regex to select <strong>#OnlinePopup_AFE53E2CACBF4D8196E6360D4DDB6B70</strong> its okay to assume <code>#OnlinePopup</code></p> <pre><code>~DCTM~dctm://aicpcudev/37004e1f8000219e?DMS_OBJECT_SPEC=RELATION_ID#OnlinePopup_AFE53E2CACBF4D8196E6360D4DDB6B70_11472026_1214836152225_6455280574472127786 </code></pre>
[ { "answer_id": 297428, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": 3, "selected": true, "text": "#[^_]+_[^_]+\n" }, { "answer_id": 297430, "author": "Paige Ruten", "author_id": 813, "author_prof...
2008/11/18
[ "https://Stackoverflow.com/questions/297417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
297,420
<p>Does anyone have a list of email addresses that I can use to test my JS address validation script? I'm looking for as complete of a list as is reasonable to test the most common edge cases, if not all cases.</p>
[ { "answer_id": 297707, "author": "some", "author_id": 36866, "author_profile": "https://Stackoverflow.com/users/36866", "pm_score": 0, "selected": false, "text": "function isEmail(address) {\n var pos = address.lastIndexOf(\"@\");\n return pos > 0 && (address.lastIndexOf(\".\") > p...
2008/11/18
[ "https://Stackoverflow.com/questions/297420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38407/" ]
297,421
<p>Where can I set it? I need files to be encoded in UTF-8 by default... there is nothing in Tools -> Options or any other menu as far as I know :( </p> <p>P.S. I don't need to set default encoding for Project or so, I need it to be default for any files I create. Thanks for your help :)</p>
[ { "answer_id": 297436, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "Save As..." } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25413/" ]
297,426
<p>I'm writing a basic sprite engine for my own amusement and to get better aquainted with Java's 2d API. Currently I am making use of large numbers of separate .png files with transparent backgrounds to represent the various sprites and different frames of animation that I need. Most 'real world' game development projects seem to make use of 'sprite sheets' which contain multiple sprites or frames of animation within a single file. Also, rather than making use of native image transparency support, people often nominate an arbitrary colour that does not appear in the sprite pallette to be the transparent colour. How does one manage a file like this programatically?</p> <ul> <li>how do you know where one sprite starts and the next begins</li> <li>how do you deal with transparency</li> </ul> <p>There may be other factors that I've not thought of here, so I may add to the list above as I think of things or as people make suggestions (please do so in the comments).</p>
[ { "answer_id": 2760766, "author": "SAKIPOOH", "author_id": 331739, "author_profile": "https://Stackoverflow.com/users/331739", "pm_score": 0, "selected": false, "text": "currentframe=spritesheet.getSubimage(x, y, w, h); \n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
297,431
<p>When I create a new instance of a ChannelFactory:</p> <pre><code>var factory = new ChannelFactory&lt;IMyService&gt;(); </code></pre> <p>and that I create a new channel, I have an exception saying that the address of the Endpoint is null. </p> <p>My configuration inside my web.config is as mentioned and everything is as it is supposed to be (especially the address of the endpoint).</p> <p>If I create a new MyServiceClientBase, it loads all the configuration from my channel factory:</p> <pre><code>var factoryWithClientBase = new MyServiceClientBase().ChannelFactory; Console.WriteLine(factoryWithClientBase.Endpoint.Address); //output the configuration inside the web.config var factoryWithChannelFactory = new ChannelFactory&lt;IMyService&gt;(); Console.WriteLine(factoryWithChannelFactory.Endpoint.Address); //output nothing (null) </code></pre> <p>Why?</p>
[ { "answer_id": 298110, "author": "AnAngel", "author_id": 38482, "author_profile": "https://Stackoverflow.com/users/38482", "pm_score": 3, "selected": false, "text": "<endpoint address=\"http://localhost:2000/MyService/\" binding=\"wsHttpBinding\"\n behaviorConfiguration=\"wsHttpBehavi...
2008/11/18
[ "https://Stackoverflow.com/questions/297431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24975/" ]
297,435
<p>If I have...</p> <pre><code>class Bunny &lt; ActiveRecord::Base has_many :carrots end </code></pre> <p>...how can I check in the View if <code>@bunny</code> has any carrots? I want to do something like this:</p> <pre><code>&lt;% if @bunny.carrots? %&gt; &lt;strong&gt;Yay! Carrots!&lt;/strong&gt; &lt;% for carrot in @bunny.carrots %&gt; You got a &lt;%=h carrot.color %&gt; carrot!&lt;br /&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre> <p>I know <code>@bunny.carrots?</code> doesn't work -- what would?</p>
[ { "answer_id": 297451, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 1, "selected": false, "text": " if @bunny.carrots.length>0\n" }, { "answer_id": 297454, "author": "James A. Rosen", "author_id": 1190,...
2008/11/18
[ "https://Stackoverflow.com/questions/297435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32154/" ]
297,438
<p>I'm using JPA (Hibernate's implementation) to annotate entity classes to persist to a relational database (MySQL or SQL Server). Is there an easy way to auto generate the database schema (table creation scripts) from the annotated classes?</p> <p>I'm still in the prototyping phase and anticipate frequent schema changes. I would like to be able to specify and change the data model from the annotated code. Grails is similar in that it generates the database from the domain classes.</p>
[ { "answer_id": 1068003, "author": "H2000", "author_id": 115887, "author_profile": "https://Stackoverflow.com/users/115887", "pm_score": 4, "selected": false, "text": "import java.util.Collection;\nimport java.util.Properties;\n\nimport org.hibernate.cfg.AnnotationConfiguration;\nimport o...
2008/11/18
[ "https://Stackoverflow.com/questions/297438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
297,460
<p>Is there any way to force Text-Mate to use a two-space tab instead of a full tab when editing HTML (Rails) documents?</p>
[ { "answer_id": 297466, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 5, "selected": true, "text": "Tabs: 4" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32154/" ]
297,465
<p>Is it possible to write a PL/SQL query to identify a complete list of a stored procedures dependencies? I'm only interested in identifying other stored procedures and I'd prefer not to limit the depth of nesting that it gets too either. For example, if A calls B, which calls C, which calls D, I'd want B, C and D reported as dependencies for A.</p>
[ { "answer_id": 297492, "author": "Eddie Awad", "author_id": 17273, "author_profile": "https://Stackoverflow.com/users/17273", "pm_score": 4, "selected": true, "text": " SELECT lvl\n , u.object_id\n , u.object_type\n , LPAD (' ', lvl) || object_name obj\n FROM ( SELECT LEVEL...
2008/11/18
[ "https://Stackoverflow.com/questions/297465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
297,470
<p>I have a couple search forms, 1 with ~50 fields and the other with ~100. Typically, as the HTML spec says, I do searches using the GET method as no data is changed. I haven't run into this problem yet, but I'm wondering if I will run out of URL space soon?</p> <p>The limit of <a href="http://support.microsoft.com/kb/208427" rel="noreferrer">Internet Explorer</a> is 2083 characters. Other browsers, have a <a href="http://www.boutell.com/newfaq/misc/urllength.html" rel="noreferrer">much higher limit</a>. I'm running Apache, so the limit there is around 4000 characters, which IIS is 16384 characters.</p> <p>At 100 fields, say average field name length of 10 characters, that's already 5000 characters...amazing on the 100 field form, I haven't had any errors yet. (25% of the fields are multiple selects, so the field length is much longer.)</p> <p>So, I'm wondering what my options are. (Shortening the forms is not an option.) Here my ideas:</p> <ul> <li>Use POST. I don't like this as much because at the moment users can bookmark their searches and perform them again later--a really dang nice feature.</li> <li>Have JavaScript loop through the form to determine which fields are different than default, populate another form and submit that one. The user would of course bookmark the shortened version.</li> </ul> <p>Any other ideas?</p> <p>Also, does anyone know if the length is the encoded length or just plain text?</p> <p>I'm developing in PHP, but it probably doesn't make a difference.</p> <p><strong>Edit:</strong> I am unable to remove any fields; I am unable to shorten the form. This is what the client has asked for and they often do use a range of fields, in the different categories. I know that it's hard to think of a form that looks nice with this many fields, but the users don't have a problem understanding how it works.</p>
[ { "answer_id": 298089, "author": "Tom", "author_id": 26155, "author_profile": "https://Stackoverflow.com/users/26155", "pm_score": 1, "selected": false, "text": "GET" }, { "answer_id": 298585, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackove...
2008/11/18
[ "https://Stackoverflow.com/questions/297470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
297,471
<p>I get an error when I compile this code:</p> <pre><code>using System; public struct Vector2 { public event EventHandler trigger; public float X; public float Y; public Vector2 func() { Vector2 vector; vector.X = 1; vector.Y = 2; return vector; // error CS0165: Use of unassigned local variable 'vector' } } </code></pre> <p>hi!</p> <p>The compiler says: "Use of unassigned local variable 'vector'" and points to the return value. It looks to me that Vector2 become a reference type (without the event member it acts normally). What is happening?</p>
[ { "answer_id": 297481, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 5, "selected": true, "text": "Vector2 vector = new Vector2()\n" }, { "answer_id": 297509, "author": "Kennet Belenky", "author_id": 37788...
2008/11/18
[ "https://Stackoverflow.com/questions/297471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38413/" ]
297,472
<p>I am trying to do a simple datagrid in Flex with a doubleclick event, but I cannot get <code>itemDoubleClick</code> to fire:</p> <pre><code>&lt;mx:DataGrid id="gridReportConversions" height="100%" width="100%" mouseEnabled="true" doubleClickEnabled="true" itemDoubleClick="refererRowDoubleClicked(event)"&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn width="75" dataField="qty" headerText="Qty" /&gt; &lt;mx:DataGridColumn dataField="referer" headerText="URL" /&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; </code></pre> <p>If I use the <code>itemClicked</code> event then the event is raised just fine. When I search for this problem I find many people saying 'you need to set <code>doubleClickEnabled=true</code>, but I've done that and it still doesn't work.</p> <p>This control is nested within quite a few levels of VBox and other containers. Surely I dont need to set <code>doubleClickEnabled</code> on each of those containers do I?</p> <p>Just to clarify how I tested this - I have an alert box in my <code>refererRowDoubleClicked</code> event handler and it never gets shown when I use <code>itemDoubleClick</code></p>
[ { "answer_id": 297481, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 5, "selected": true, "text": "Vector2 vector = new Vector2()\n" }, { "answer_id": 297509, "author": "Kennet Belenky", "author_id": 37788...
2008/11/18
[ "https://Stackoverflow.com/questions/297472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
297,482
<p>I would like to be able to manipulate the DOM just before my page is sent to be printed. Internet Explorer has an event on the window object called "onbeforeprint" but this is proprietary and isn't supported by other browsers. Is it possible to do this via javascript (jQuery in particular, if possible)?</p> <p>Before you ask, I can't easily use a print media stylesheet to apply the changes as the elements I need to change have inline styles which can't be overridden with a global stylesheet. I need to override these inline styles for print purposes. It should be possible to modify the existing jQuery if needs be, however that would be a more time-consuming and risky change.</p> <p>Cheers, Zac</p>
[ { "answer_id": 297545, "author": "foxy", "author_id": 30119, "author_profile": "https://Stackoverflow.com/users/30119", "pm_score": 3, "selected": true, "text": "!important" }, { "answer_id": 1868887, "author": "Olivier", "author_id": 218000, "author_profile": "https:...
2008/11/18
[ "https://Stackoverflow.com/questions/297482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32935/" ]
297,498
<p>I am wondering if it is possible to use Code Access Security, and a custom permission class (and attribute), without having to register the assembly that the attribute is in, in the GAC.</p> <p>At the moment, I get a TypeLoadException when the method with my attribute is called, and I can't seem to get around it. Everything i've read seems to imply that you need to use the GAC in order to achieve this.</p> <p>Does anyone have any insight?</p> <p>I've tried to acheive the same end-goal with AOP using PostSharp or AspectDNG, but both of those add an addition dependency to my product, which is not ideal.</p>
[ { "answer_id": 297545, "author": "foxy", "author_id": 30119, "author_profile": "https://Stackoverflow.com/users/30119", "pm_score": 3, "selected": true, "text": "!important" }, { "answer_id": 1868887, "author": "Olivier", "author_id": 218000, "author_profile": "https:...
2008/11/18
[ "https://Stackoverflow.com/questions/297498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/489/" ]
297,504
<p>Is there a way in MySQL to select rows which fall on a specific day, as in Mondays, using a date column?</p>
[ { "answer_id": 297513, "author": "Artelius", "author_id": 31945, "author_profile": "https://Stackoverflow.com/users/31945", "pm_score": 4, "selected": true, "text": "SELECT * FROM foo WHERE DAYOFWEEK(bar) = 2\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3410/" ]
297,514
<p>I have the following makefile that I use to build a program (a kernel, actually) that I'm working on. Its from scratch and I'm learning about the process, so its not perfect, but I think its powerful enough at this point for my level of experience writing makefiles.</p> <pre><code>AS = nasm CC = gcc LD = ld TARGET = core BUILD = build SOURCES = source INCLUDE = include ASM = assembly VPATH = $(SOURCES) CFLAGS = -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions \ -nostdinc -fno-builtin -I $(INCLUDE) ASFLAGS = -f elf #CFILES = core.c consoleio.c system.c CFILES = $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) SFILES = assembly/start.asm SOBJS = $(SFILES:.asm=.o) COBJS = $(CFILES:.c=.o) OBJS = $(SOBJS) $(COBJS) build : $(TARGET).img $(TARGET).img : $(TARGET).elf c:/python26/python.exe concat.py stage1 stage2 pad.bin core.elf floppy.img $(TARGET).elf : $(OBJS) $(LD) -T link.ld -o $@ $^ $(SOBJS) : $(SFILES) $(AS) $(ASFLAGS) $&lt; -o $@ %.o: %.c @echo Compiling $&lt;... $(CC) $(CFLAGS) -c -o $@ $&lt; #Clean Script - Should clear out all .o files everywhere and all that. clean: -del *.img -del *.o -del assembly\*.o -del core.elf </code></pre> <p>My main issue with this makefile is that when I modify a header file that one or more C files include, the C files aren't rebuilt. I can fix this quite easily by having all of my header files be dependencies for all of my C files, but that would effectively cause a complete rebuild of the project any time I changed/added a header file, which would not be very graceful.</p> <p>What I want is for only the C files that <em>include</em> the header file I change to be rebuilt, and for the entire project to be linked again. I can do the linking by causing all header files to be dependencies of the target, but I cannot figure out how to make the C files be invalidated when their included header files are newer.</p> <p>I've heard that GCC has some commands to make this possible (so the makefile can somehow figure out which files need to be rebuilt) but I can't for the life of me find an actual implementation example to look at. Can someone post a solution that will enable this behavior in a makefile?</p> <p>EDIT: I should clarify, I'm familiar with the concept of putting the individual targets in and having each target.o require the header files. That requires me to be editing the makefile every time I include a header file somewhere, which is a bit of a pain. I'm looking for a solution that can derive the header file dependencies on its own, which I'm fairly certain I've seen in other projects.</p>
[ { "answer_id": 297523, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 3, "selected": false, "text": ".h" }, { "answer_id": 297539, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "http...
2008/11/18
[ "https://Stackoverflow.com/questions/297514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19521/" ]
297,517
<p>I have a user control that has several buttons.</p> <p>On <code>page_load</code>, I want to run a method unless a specific button was pressed.</p> <p>When I check the sender on <code>page_load</code> inside the user control, I just get the name of the user control and not the button itself.</p> <p>Is there a way that I can determine what button was pressed on <code>page_load</code>? Otherwise I will have to come up with some hacky method to solve the issue.</p>
[ { "answer_id": 297546, "author": "Chris Roberts", "author_id": 475, "author_profile": "https://Stackoverflow.com/users/475", "pm_score": 2, "selected": false, "text": "Request.Form (\"__EVENTTARGET\")" }, { "answer_id": 534635, "author": "Geri Langlois", "author_id": 4888...
2008/11/18
[ "https://Stackoverflow.com/questions/297517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
297,526
<p>I do remember seeing someone ask something along these lines a while ago but I did a search and couldn't find anything. </p> <p>I'm trying to come up with the cleanest way to clear all the controls on a form back to their defaults (e.g., clear textboxes, uncheck checkboxes).</p> <p>How would you go about this?</p>
[ { "answer_id": 297529, "author": "Nathan W", "author_id": 6335, "author_profile": "https://Stackoverflow.com/users/6335", "pm_score": 5, "selected": true, "text": "public static class extenstions\n{\n private static Dictionary<Type, Action<Control>> controldefaults = new Dictionary<Ty...
2008/11/18
[ "https://Stackoverflow.com/questions/297526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
297,530
<p>I have a view that I would like the user to rotate around its center, by tapping and holding somewhere and just move their finger round and round.</p> <p>I have all the geometry worked out; What I do is store the initial touch angle relative to the center as offsetAngle, then my touchesMoved method looks like this:</p> <pre><code>- (void) touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event { self.transform = CGAffineTransformMakeRotation(0); CGPoint location = [[touches anyObject] locationInView: self]; CGPoint actualCenter = [self convertPoint: self.center fromView: self.superview]; CGPoint relativeTouch = [MathHelper translatePoint:location relativeTo: actualCenter]; CGPoint zero = CGPointMake(0, 0); float angle = [MathHelper getAngleForPoint:zero andPoint:relativeTouch]; self.transform = CGAffineTransformMakeRotation(offsetAngle-angle); } </code></pre> <p>The ugly bit is the first line, where I have to restore the rotation in order to get the correct event positions in the view. If I don't that, then the locations jump all over the place as there's no continuity, since the view is rotating...</p> <p>Another issue is when you want to manipulate a view's frame (eg. moving it down), when the view has a transform applied:</p> <pre><code>- (IBAction)toggleSettingsView { BOOL state = [settingsSwitch isOn]; float height = optionsView.bounds.size.height; CGRect polygonFrame = polygonView.frame; [UIView beginAnimations:@"advancedAnimations" context:nil]; [UIView setAnimationDuration:0.3]; if (state) { optionsView.alpha = 1.0; polygonFrame.origin.y += height; } else { optionsView.alpha = 0.0; polygonFrame.origin.y -= height; } polygonView.frame = polygonFrame; [UIView commitAnimations]; } </code></pre> <p>This distorts the view heavily.</p> <p>I must mention that both the CGTransform and the CALayer transform have the same effect.</p> <p>This smells like I'm doing something wrong, but I don't know what I should be doing.</p>
[ { "answer_id": 299787, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 2, "selected": false, "text": "- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event\n{\n CGPoint location = [[touches anyObject] locationI...
2008/11/18
[ "https://Stackoverflow.com/questions/297530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32617/" ]
297,542
<p>I would like to be able to detect what country a visitor is from on my website, using PHP. </p> <p>Please note that I'm not trying to use this as a security measure or for anything important, just changing the spelling of some words <em>(Americans seems to believe that the word "enrolment" has 2 Ls.... crazy yanks)</em>, and perhaps to give a default option in a "Select your country" list.</p> <p>As such, using a Geolocation database is a tad over-the-top and I really don't want to muck about with installing new PHP libraries just for this, so <strong>what's the easiest/simplest way to find what country a visitor is from?</strong></p>
[ { "answer_id": 297549, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 3, "selected": false, "text": " Example: http://api.hostip.info/get_html.php?ip=12.215.42.19\n Return : Country: UNITED STATES (US)\n" }, ...
2008/11/18
[ "https://Stackoverflow.com/questions/297542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
297,555
<p>I have a multipart form that takes basic user information at the beginning with some jquery.validate error checking to see if the fields have been filled in and the email address is valid.</p> <p>Below that there is a series of check boxes (type_of_request) for new accounts, delete accounts, new software etc which show/hide those form elements as they are checked/unchecked.</p> <p>I would like to validate the required sections on the form ONLY if the corressponding type_of_request item has been checked.</p> <hr> <p>Update information</p> <hr> <p>That's a great solution but seems to make all of the children of the selected section required.</p> <p>A typical scenario will be both the email and other checkbox in the type_request has been selected:</p> <pre><code> &lt;div id="email" style="display: block;"&gt; // shown because other has been selected in the type request &lt;input id="email_new_account" class="sq-form-field" type="checkbox" value="0" name="q4836:q1"/&gt; // not required &lt;input id="email_new_account_name" class="sq-form-field" type="text" name="q4836:q2"/&gt; // if email_new_account checked then make required &lt;input id="email_new_account_access" class="sq-form-field" type="text" name="q4836:q2"/&gt; // if email_new_account checked then make required &lt;input id="email_new_account_manager" class="sq-form-field" type="text" name="q4836:q3"/&gt; // if email_new_account checked then make required &lt;input id="email_add_remove_access" class="sq-form-field" type="checkbox" value="0" name="q4837:q1"/&gt; // not required &lt;input id="email_add_remove_account_name" class="sq-form-field" type="text" name="q4837:q2"/&gt; // if email_add_remove_access checked then make required &lt;input id="email_add_access" class="sq-form-field" type="text" name="q4836:q2"/&gt; // if email_add_remove_access checked then make required &lt;input id="email_remove_access" class="sq-form-field" type="text" name="q4837:q3"/&gt; // if email_add_remove_access checked then make required &lt;/div&gt; &lt;div id="other" style="display: block;"&gt; // shown because other has been selected in the type request &lt;input id="other_describe_request" class="sq-form-field" type="text" name="q4838:q1"/&gt; // required because #other was checked in type request &lt;input id="other_request_justification" class="sq-form-field" type="text" name="q48387:q2"/&gt; // required because #other was checked in type request &lt;/div&gt; </code></pre> <hr> <p>Further Reading</p> <hr> <p>I have reviewed this even further and found that the following can be added to the class of the input items</p> <pre><code>class="{required:true, messages:{required:'Please enter your email address'}}" </code></pre> <p>or</p> <pre><code>class="{required:true, email:true, messages:{required:'Please enter your email address', email:'Please enter a valid email address'}}" </code></pre> <p>but when I add </p> <pre><code>class="{required:'input[@name=other]:checked'}" </code></pre> <p>which was described on the <a href="http://jquery.bassistance.de/api-browser/plugins.html#jQueryvalidatormethodsrequiredStringElementBooleanStringFunction" rel="nofollow noreferrer">http://jquery.bassistance.de</a> site, it doesn't work. Do I need to change the syntax to get this working?</p>
[ { "answer_id": 297597, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "$(document).ready( function() { $('form').validate(); } );\n\nfunction init_validation(divName)\n{\n $('div#' + divN...
2008/11/18
[ "https://Stackoverflow.com/questions/297555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38419/" ]
297,563
<p>I have a property defined in my HBM file like this:</p> <pre><code>&lt;property name="OwnerId" column="OwnerID" type="System.Int32" not-null="false" /&gt; </code></pre> <p>It is defined as a nullable field in the database also. If a record in the DB has the OwnerID column set to an integer, this object is correctly loaded by NHibernate. But if the record has it set to null, NHibernate bombs with seemingly random errors including:</p> <p>1) Column name 'ModuleAnchorID' appears more than once in the result column list:</p> <pre><code>[SqlException (0x80131904): Column name 'ModuleAnchorID' appears more than once in the result column list.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +925466 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800118 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1005 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +149 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation) +35 NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session) +1055 </code></pre> <p>2) not-null property references a null or transient value:</p> <pre><code>[PropertyValueException: not-null property references a null or transient value:] NHibernate.Impl.SessionImpl.CheckNullability(Object[] values, IEntityPersister persister, Boolean isUpdate) +224 NHibernate.Impl.SessionImpl.FlushEntity(Object obj, EntityEntry entry) +1019 NHibernate.Impl.SessionImpl.FlushEntities() +182 NHibernate.Impl.SessionImpl.FlushEverything() +90 NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet querySpaces) +64 NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results) +217 NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria) +42 NHibernate.Impl.CriteriaImpl.List() +29 </code></pre> <p>Is OwnerID a reserved field name that is somehow confusing NHibernate?</p>
[ { "answer_id": 297597, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "$(document).ready( function() { $('form').validate(); } );\n\nfunction init_validation(divName)\n{\n $('div#' + divN...
2008/11/18
[ "https://Stackoverflow.com/questions/297563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10475/" ]
297,586
<p>I am having a lot of trouble finding good information on how to call a standard SOAP/WSDL web service with Android. All I've been able to find are either very convoluted documents and references to "kSoap2" and then some bit about parsing it all manually with <a href="http://en.wikipedia.org/wiki/Simple_API_for_XML" rel="noreferrer">SAX</a>. OK, that's fine, but it's 2008, so I figured there should be some good library for calling standard web services.</p> <p>The web service is just basically one created in <a href="http://en.wikipedia.org/wiki/NetBeans" rel="noreferrer">NetBeans</a>. I would like to have IDE support for generating the plumbing classes. I just need the easiest/most-elegant way to contact a <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language" rel="noreferrer">WSDL</a> based web service from an Android-based phone.</p>
[ { "answer_id": 426241, "author": "Neil", "author_id": 52115, "author_profile": "https://Stackoverflow.com/users/52115", "pm_score": 7, "selected": false, "text": "org.apache.http.impl.client.DefaultHttpClient" }, { "answer_id": 2199036, "author": "Priyanjan", "author_id":...
2008/11/18
[ "https://Stackoverflow.com/questions/297586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38426/" ]
297,609
<p>What is the simplest way to get the NT-ID of a user in a C# application? I would probably need to get it only having a name of the user, or maybe an email address.</p>
[ { "answer_id": 297805, "author": "DylanW", "author_id": 13463, "author_profile": "https://Stackoverflow.com/users/13463", "pm_score": 2, "selected": true, "text": "SPPrincipalInfo pi = SPUtility.ResolveWindowsPrincipal(SPContext.Current.Site.WebApplication, \"MYDOMAIN\\\\myusername\", SP...
2008/11/18
[ "https://Stackoverflow.com/questions/297609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29227/" ]
297,615
<p>I'm having the hardest time trying to get this to work, hoping one of you has done this before.</p> <p>I have a C# console app that is running a child process which inherits its console. I want a ctrl-c caught by the outer app to be passed along to the inner app so that it can have a chance to shut down nicely.</p> <p>I have some very simple code. I start a Process, then poll it with WaitForExit(10). I also have a CancelKeyPress handler registered, which sets a bool to true when it fires. The polling loop also checks this, and when it's true, it calls GenerateConsoleCtrlEvent() (which I have mapped through pinvoke).</p> <p>I've tried a lot of combinations of params to GenerateConsoleCtrlEvent(). 0 or 1 for the first param, and either 0 or the child process's ID for the second param. Nothing seems to work. Sometimes I get a false back and Marshal.GetLastWin32Error() returns 0, and sometimes I get true back. But none cause the child app to receive a ctrl-c.</p> <p>To be absolutely sure, I wrote a test C# app to be the child app which prints out what's going on with it and verified that manually typing ctrl-c when it runs does properly cause it to quit.</p> <p>I've been banging my head against this for a couple hours. Can anyone give me some pointers on where to go with this?</p>
[ { "answer_id": 297637, "author": "Hans Passant", "author_id": 17034, "author_profile": "https://Stackoverflow.com/users/17034", "pm_score": 2, "selected": false, "text": "CreateProcess()" }, { "answer_id": 1802908, "author": "Weeble", "author_id": 2283, "author_profil...
2008/11/18
[ "https://Stackoverflow.com/questions/297615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14582/" ]
297,654
<p>I'm learning about Win32 programming, and the <code>WinMain</code> prototype looks like:</p> <pre><code>int WINAPI WinMain ( HINSTANCE instance, HINSTANCE prev_instance, PSTR cmd_line, int cmd_show ) </code></pre> <p>I was confused as to what this <code>WINAPI</code> identifier was for and found:</p> <pre><code>#define WINAPI __stdcall </code></pre> <p>What does this do? I'm confused by this having something at all after a return type. What is <code>__stdcall</code> for? What does it mean when there is something between the return type and function name?</p>
[ { "answer_id": 297661, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 9, "selected": true, "text": "__stdcall" }, { "answer_id": 758972, "author": "Community", "author_id": -1, "author_profile": "https:...
2008/11/18
[ "https://Stackoverflow.com/questions/297654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30529/" ]
297,656
<p>I'm having a syntax error. I want to take the floor of a function that returns a floating point number.</p> <p>I <em>thought</em> this would give me the right answer</p> <pre><code>let cyclesPerInterrupt bps bpw cpu factor = floor (fudge (float(factor) cyclesPerWord cpu wordsPerSec bps bpw)) </code></pre> <p>But it doesn't. I've tried everything I can think of, and it's just not coming together for me. I know it's something stupid, but I can't think of it.</p> <p>For reference, fudge takes a float and an integer, cyclesPerWord takes 2 integers and wordsPerSec takes 2 integers. Floor takes a generic and returns a float.</p>
[ { "answer_id": 297752, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 2, "selected": false, "text": "...(cyclesPerWord cpu (wordsPerSec bps bpw))\n" }, { "answer_id": 298538, "author": "simonuk", "author_id": ...
2008/11/18
[ "https://Stackoverflow.com/questions/297656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
297,671
<p>I have read a book whose title is "Oracle PL SQL Programming" (2nd ed.) by Steven Feuerstein &amp; Bill Pribyl. On page 99, there is a point suggested that </p> <p><strong>Do not "SELECT COUNT(*)" from a table unless you really need to know the total number of "hits." If you only need to know whether there is more than one match, simply fetch twice with an explicit cursor.</strong></p> <p>Could you anyone explain this point more to me by providing example? Thank you.</p> <h3>Update:</h3> <p>As Steven Feuerstein &amp; Bill Pribyl recommends us not to use SELECT COUNT() to check whether records in a table exist or not, could anyone help me edit the code below in order to avoid using SELECT COUNT(*) by using explicit cursor instead? This code is written in the Oracle stored procedure.</p> <p>I have a table emp(emp_id, emp_name, ...), so to check the provided employee ID corret or not:</p> <pre><code>CREATE OR REPLACE PROCEDURE do_sth ( emp_id_in IN emp.emp_id%TYPE ) IS v_rows INTEGER; BEGIN ... SELECT COUNT(*) INTO v_rows FROM emp WHERE emp_id = emp_id_in; IF v_rows &gt; 0 THEN /* do sth */ END; /* more statements */ ... END do_sth; </code></pre>
[ { "answer_id": 297699, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 1, "selected": false, "text": "SELECT COUNT(*)" }, { "answer_id": 297761, "author": "TheSoftwareJedi", "author_id": 18941, "author_...
2008/11/18
[ "https://Stackoverflow.com/questions/297671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1602746/" ]
297,678
<p>I am implementing an asynchronous command pattern for the "client" class in a client/server application. I have done some socket coding in the past and I like the new Async pattern that they used in the Socket / SocketAsyncEventArgs classes.</p> <p>My async method looks like this: <code>public bool ExecuteAsync(Command cmd);</code> It returns true if the execution is pending and false if it completed synchronously. <strong>My question is: Should I always call the callback (cmd.OnCompleted), even in the event of an exception? Or should I throw exceptions right from ExecuteAsync?</strong></p> <p>Here are some more details if you need them. This is similar to using SocketAsyncEventArgs, but instead of SocketAsyncEventArgs my class is called SomeCmd.</p> <pre><code>SomeCmd cmd = new SomeCmd(23, 14, 10, "hike!"); cmd.OnCompleted += this.SomeCmd_OnCompleted; this.ConnectionToServer.ExecuteAsync(cmd); </code></pre> <p>As with the Socket class, if you need to coordinate with your callback method (SomeCmd_OnCompleted in this case), you can use the return value of ExecuteAsync to know if the operation is pending (true) or if the operation completed synchronously.</p> <pre><code>SomeCmd cmd = new SomeCmd(23, 14, 10, "hike!"); cmd.OnCompleted += this.SomeCmd_OnCompleted; if( this.ConnectionToServer.ExecuteAsync(cmd) ) { Monitor.Wait( this.WillBePulsedBy_SomeCmd_OnCompleted ); } </code></pre> <p>Here is a greatly simplified version of my base classes, but you can see how it works:</p> <pre><code>class Connection { public bool ExecuteAsync(Command cmd) { /// CONSIDER: If you don't catch every exception here /// then every caller of this method must have 2 sets of /// exception handling: /// One in the handler of Command.OnCompleted and one where ExecuteAsync /// is called. try { /// Some possible exceptions here: /// 1) remote is disposed. happens when the other side disconnects (WCF). /// 2) I do something wrong in TrackCommand (a bug that I want to fix!) this.TrackCommand(cmd); remote.ServerExecuteAsync( cmd.GetRequest() ); return true; } catch(Exception ex) { /// Command completing synchronously. cmd.Completed(ex, true); return false; } } /// &lt;summary&gt;This is what gets called by some magic when the server returns a response.&lt;/summary&gt; internal CommandExecuteReturn(CommandResponse response) { Command cmd = this.GetTrackedCommand(response.RequestId); /// Command completing asynchronously. cmd.Completed(response, false); } private IServer remote; } abstract class Command: EventArgs { internal void Completed(Exception ex, bool synchronously) { this.Exception = ex; this.CompletedSynchronously = synchronously; if( this.OnCompleted != null ) { this.OnCompleted(this); } } internal void Completed(CommandResponse response, bool synchronously) { this.Response = response; this.Completed(response.ExceptionFromServer, synchronously) } public bool CompletedSynchronously{ get; private set; } public event EventHandler&lt;Command&gt; OnCompleted; public Exception Exception{ get; private set; } internal protected abstract CommandRequest GetRequest(); } </code></pre>
[ { "answer_id": 297937, "author": "Nicholas Piasecki", "author_id": 32187, "author_profile": "https://Stackoverflow.com/users/32187", "pm_score": 3, "selected": false, "text": "BackgroundWorker" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16387/" ]
297,680
<p>I have a code sample that gets a <code>SEL</code> from the current object, </p> <pre><code>SEL callback = @selector(mymethod:parameter2); </code></pre> <p>And I have a method like </p> <pre><code> -(void)mymethod:(id)v1 parameter2;(NSString*)v2 { } </code></pre> <p>Now I need to move <code>mymethod</code> to another object, say <code>myDelegate</code>.</p> <p>I have tried:</p> <pre><code>SEL callback = @selector(myDelegate, mymethod:parameter2); </code></pre> <p>but it won't compile. </p>
[ { "answer_id": 297695, "author": "Grant Limberg", "author_id": 27314, "author_profile": "https://Stackoverflow.com/users/27314", "pm_score": 4, "selected": false, "text": "[object setCallbackObject:self withSelector:@selector(myMethod:)];\n" }, { "answer_id": 297720, "author"...
2008/11/18
[ "https://Stackoverflow.com/questions/297680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32096/" ]
297,686
<p>Is there a good <strong>cross-browser</strong> way to set a <code>max-height</code> property of a DIV and when that DIV goes beyond the <code>max-height</code>, it turns into an overflow with scrollbars?</p>
[ { "answer_id": 297802, "author": "ethyreal", "author_id": 18159, "author_profile": "https://Stackoverflow.com/users/18159", "pm_score": 5, "selected": false, "text": " div{\n _height: expression( this.scrollHeight > 332 ? \"333px\" : \"auto\" ); /* sets max-height for IE6 */\n ...
2008/11/18
[ "https://Stackoverflow.com/questions/297686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
297,687
<p>I haven't worked much with Visual Studio before. I've started a personal project in my spare time and I would like to use test-driven development since it has been a huge benefit to me in my Java development. I started this project quite a while ago, and I used CppUnit. I know there are probably other frameworks that are better, but this is what's already in place.</p> <p>My Visual Stuido 2005 solution has 2 projects in it. It worked fine when the unit tests resided right alongside the application code. As the project grew in size, this became quite cumbersome and inelegant. I created a new project under my solution to house the unit tests (so it now has 3 projects). Everything went fine until I tried to build the solution. Everything compiled, but the unit test project failed to link. The output gives me 51 "unresolved external symbol" errors (LNK2019) for what seems like every function that my tests call.</p> <p>As far as I can deduce, the problem is the directory structure that Visual Studio creates. Each project gets its own directory, and then below that are the object files and executables that get created. I think the problem is that, while the header files are properly included in each unit test, the linker can't find the cpp files because they are in a different directory. When it fails to find the implementation of a called function, it gives me the 2019 error.</p> <p>Am I right in my evaluation of the problem? How can I fix it? Do I need to completely reorganize my projects or is it a simple configuration of the linker?</p> <p>Thanks</p>
[ { "answer_id": 297802, "author": "ethyreal", "author_id": 18159, "author_profile": "https://Stackoverflow.com/users/18159", "pm_score": 5, "selected": false, "text": " div{\n _height: expression( this.scrollHeight > 332 ? \"333px\" : \"auto\" ); /* sets max-height for IE6 */\n ...
2008/11/18
[ "https://Stackoverflow.com/questions/297687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,701
<p>Every time that I create a new form in my application, it uses the "Microsoft Sans Serif, 8.25pt" font by default. I'm not changing it because I know that in this case my form <em>should</em> pick up whatever the default font is for the system. However, when I run my application, the font that is used is still anything but Segoe UI (my default system font in my Windows Vista OS).</p> <p>Why does this happen? How do I make sure that my application looks like a normal Windows application?</p>
[ { "answer_id": 300081, "author": "Hans Passant", "author_id": 17034, "author_profile": "https://Stackoverflow.com/users/17034", "pm_score": 4, "selected": false, "text": "GetStockObject(DEFAULT_GUI_FONT)" }, { "answer_id": 461126, "author": "CS.", "author_id": 57085, ...
2008/11/18
[ "https://Stackoverflow.com/questions/297701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21952/" ]
297,713
<p>I would like to convert an array if IDs, into a string of comma separated values, to use in a MySQL UPDATE query. How would I do this?</p>
[ { "answer_id": 297719, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 4, "selected": false, "text": "implode(',', $array);\n" }, { "answer_id": 298245, "author": "troelskn", "author_id": 18180, "au...
2008/11/18
[ "https://Stackoverflow.com/questions/297713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,743
<p>Does anyone think it is possible to build a Google Docs style PDF document viewer, which will convert a document to a format that doesn't require Adobe Reader on the client machine?</p> <p>If so, any references to point to? Either a place that had done it, or an explanation of how to do it.</p>
[ { "answer_id": 2199297, "author": "Tom van Enckevort", "author_id": 108816, "author_profile": "https://Stackoverflow.com/users/108816", "pm_score": 1, "selected": false, "text": "http://docs.google.com/viewer?embedded=true&url=http%3A%2F%2Fwww.domain.com%2Fdocument.pdf\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24126/" ]
297,749
<p>Given:</p> <pre><code>CR = %0d = \r LF = %0a = \n </code></pre> <p>What does</p> <p>%3E, %3C </p> <p>Mean?</p>
[ { "answer_id": 297757, "author": "x0n", "author_id": 6920, "author_profile": "https://Stackoverflow.com/users/6920", "pm_score": 3, "selected": false, "text": "javascript:alert(unescape(\"%3E\"))\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4960/" ]
297,762
<p><strong>Does anyone know of an algorithm (or search terms / descriptions) to locate a known image within a larger image?</strong></p> <p>e.g.</p> <p>I have an image of a single desktop window containing various buttons and areas (target). I also have code to capture a screen shot of the current desktop. I would like an algorithm that will help me find the target image within the larger desktop image (what exact x and y coordinates the window is located at). The target image may be located anywhere in the larger image and may not be 100% exactly the same (very similar but not exact possibly b/c of OS display differences)</p> <p>Does anyone know of such an algorithm or class of algorithms?</p> <p>I have found various image segmentation and computer vision algorithms but they seem geared to "fuzzy" classification of regions and not locating a specific image within another.</p> <p>** <em>My goal is to create a framework that, given some seed target images, can find "look" at the desktop, find the target area and "watch" it for changes.</em> **</p>
[ { "answer_id": 297820, "author": "Mr Fooz", "author_id": 25050, "author_profile": "https://Stackoverflow.com/users/25050", "pm_score": 3, "selected": false, "text": "// look for all (x,y) positions where target appears in desktop\nList<Loc> findMatches(Image desktop, Image target, float ...
2008/11/18
[ "https://Stackoverflow.com/questions/297762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29009/" ]
297,804
<p>How are the java API thread priorities (1-10) gets translated to the OS level priorities since most OS don't have thread priority levels (in terms of number) which match this.</p> <p>So keeping in mind , can there be a scenario when two or more threads with different priorities eventually get the same priority at OS level.</p> <p>Please clarify, if I there is some correction in my understanding.</p>
[ { "answer_id": 297835, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": true, "text": "nice" }, { "answer_id": 1648281, "author": "Jé Queue", "author_id": 199305, "author_profile": "https://St...
2008/11/18
[ "https://Stackoverflow.com/questions/297804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11614/" ]
297,822
<p>As the title says. How would I create an instance of a class that is globally available(for example I have a functor for printing and i want to have a single global instance of this(though the possibility of creating more)).</p>
[ { "answer_id": 297847, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 6, "selected": true, "text": "// myclass.h\n\nclass MyClass {\npublic:\n MyClass();\n void foo();\n // ...\n};\n\nextern MyClass g_MyClassInsta...
2008/11/18
[ "https://Stackoverflow.com/questions/297822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37181/" ]
297,840
<p>Right now I have a few new applications being developed against an Oracle Database, and sometimes they crash or fail to end correctly, etc... anyways the problem is they sometimes seem to leave their connections open, and I need to cleanup after them. My question is if there is a way from the database-side of things to determine dead connections and clean them up?</p>
[ { "answer_id": 297917, "author": "WW.", "author_id": 14663, "author_profile": "https://Stackoverflow.com/users/14663", "pm_score": 2, "selected": false, "text": "SELECT 'alter system kill session ''' || sid || ',' || serial# || '''; ' || sql_id death\nFROM v$session\n/\n" }, { ...
2008/11/18
[ "https://Stackoverflow.com/questions/297840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
297,850
<p>I have spent several hours trying to find a means of writing a cross platform password prompt in php that hides the password that is input by the user. While this is easily accomplished in Unix environments through the use of stty -echo, I have tried various means of passthru() and system() calls to make windows do the same thing to no avail.</p> <p>I have tried:</p> <pre><code>passthru('set /p pass=Password: '); system('echo %pass% &gt; out.txt'); $pass = file_get_contents('out.txt', 'r'); </code></pre> <p>This seems to hang on the passthru('set /p pass=Password: '); line without allowing me to input any text and must be killed with a Ctrl-c.</p> <p>I have also tried various methods of fgetc and fgets and printing backspace characters to hide the input since this works in other languages. However, PHP does not appear to be able to interact with text prior to a carriage return.</p> <p>I would really like to find a way to make this work, is this an impossible task or is this something that can be done?</p> <p>Note that I am aware that I could wrap the php script in a batch file and pass the password as a command line argument, but that doesn't work for me in this case.</p>
[ { "answer_id": 297943, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": false, "text": "<?php\necho 'Password: ';\n$pwd = preg_replace('/\\r?\\n$/', '', `stty -echo; head -n1 ; stty echo`);\necho \"\\n\";\n...
2008/11/18
[ "https://Stackoverflow.com/questions/297850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
297,855
<p><em>Overview</em></p> <p>I'm working on some Emergency Services reporting and mapping application for California (kind of weird, considering the fires there, right now...). We need to map demographic and emergency data for an internal govt unit.</p> <p>What we have are <em>all</em> the streets, cities and neighborhoods in California. Each neighborhood also has it's relevant shapefile (lat long that defines it's boundaries). This was given to us by the US Census board (all public domain stuff) website.</p> <p><em>Problem</em></p> <p>I'm not sure how to best design the DB tables. We haven't been told what type of DB we need to use .. so we're open to suggestions if that helps. We have experience with MS SQL 2005 and 2008 (and the spatial stuff in '08).</p> <p>We can have the following legit data.</p> <ul> <li>Street, City, State</li> <li>City, State</li> <li>Neighborhood, State</li> <li>State</li> </ul> <p>The reason why State is a legit location is because we're told this might be sold to other states, so we need to plan for that now.</p> <p>So, originally, i thought of this...</p> <ul> <li>LocationId INTEGER PK Identity</li> <li>Street NVARCHAR(100)</li> <li>Neighbourhood NVARCHAR(100)</li> <li>City NVARCHAR(100)</li> <li>State NVARCHAR(100)</li> <li>Latitude VARCHAR(15)</li> <li>Longitude VARCHAR(15)</li> <li>Shapefile </li> </ul> <p>None of those are nullable, btw. But after a short while, i thought that it was a waste to have so many 'California' text or 'San Diego' text in the fields. So i changed the table to be more normalised by making the Neighborhood, City and State fields a foreign key to their own new table (eg. lookups) .. and those two fields are now NULLABLE.</p> <p>So .. that all works fine. except when i try and do some Sql statements on them. Because of the NULLABLE FK's, it's a nightmare to make all these outer join queries :(</p> <p>What about having the main table, the sub-lookup tables (eg. Neighbourhoods, Cities and States) linked via ID's and then place all this in a view? Remember, NeighborhoodID and CitiyID would be NULLABLE.. ???</p> <p>I just want to see people's thoughts on this and the <em>reasons</em> they made their suggestions, please. I'm really worried and confused but are eager to learn.</p> <p>Please help!</p> <hr> <p>edit 1: I need to stick to an RDBMS Database.</p> <p>edit 2: I'm thinking about going a single table (de-normalized) with constraints to keep the sum of the fields unqiue OR multi-tables with nullable FK's on the main table (eg. Locations (main table), Neighborhoods, Cities, States ... normalized db schema).</p> <p>edit 3: Added City to the sample, second list.</p> <p>edit 4: Added view question.</p>
[ { "answer_id": 310662, "author": "Richard Harrison", "author_id": 19624, "author_profile": "https://Stackoverflow.com/users/19624", "pm_score": 2, "selected": false, "text": "- la Maison des Fou\n- 24500 Eymet\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
297,889
<p>I have an MDI application that allows me to open different types of child windows. I can open multiple (but different) instances of the same type of child window. (Example: I can open 3 instances of child window type A and 2 instances of child window type B. All 5 windows are distinct entities and do not share data until unless the user explicitly drags the same data onto multiple windows.) Each child window has a ToolStripContainer with one or more ToolStrips. How do I prevent:</p> <ol> <li>the user from dragging a ToolStrip from a child window of type A to a ToolStripContainer in a child window of type B?</li> <li>the user from dragging a ToolStrip from one instance of child window A to a ToolStripContainer in another instances of the same type of window?</li> </ol> <p>I'm trying to prevent the user from dragging a ToolStrip from instance 1 of type A to instance 2 of type A, selecting some stuff on instance 2, and then clicking a button on the toolbar only to have something weird happen to some other window. Similarly it doesn't make sense to drag a ToolStrip from a window of type A to a window of type B -- the actions don't apply to that type, but to the user it looks like everything is fine because I let them do the drag.</p> <p>Is it as simple as adding my own handler for the ControlAdded event or is there a better way to do this? I'm using WinForms in .NET 3.0.</p> <p>edit: Steps to reproduce</p> <ol> <li>Create a new Windows Application project.</li> <li>Add a new user control. Give the control a ToolStripContainer that contains one ToolStrip with a single button.</li> <li>Repeat step 2, giving you a UserControl2 class.</li> <li>Compile the solution so UserControl1 and UserControl2 show up in your toolbox.</li> <li>Drag UserControl1 and UserControl2 onto the form. Set the borders so you know where the boundaries are.</li> <li>Run the app.</li> <li>It's now possible to drag the ToolStrip from the container in UserControl1 and drop it into the container in UserControl2 (leaving zero ToolStrips in UC1 and two ToolStrips in UC2.)</li> <li>Now imagine you only have access to the code in UserControl1. How do you prevent the user from dragging the ToolStrip out of that instance of the ToolStripContainer?</li> </ol>
[ { "answer_id": 838981, "author": "Pondidum", "author_id": 1500, "author_profile": "https://Stackoverflow.com/users/1500", "pm_score": 1, "selected": false, "text": "Public Class UserControl2\n\n Private Sub tsMainMenu_BeginDrag(ByVal sender As Object, ByVal e As System.EventArgs) Hand...
2008/11/18
[ "https://Stackoverflow.com/questions/297889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20788/" ]
297,899
<p>I am trying to import an existing PDF as a template with FPDI. The template is in landscape format. If I import the template into a new document the template page is inserted in portrait form with the content rotated 90 degrees. If my new document is in portrait the full content appears, but if the new document is also landscape, the content is cropped.</p> <p>Is it possible to use a landscape template with FPDI? </p>
[ { "answer_id": 300565, "author": "crono", "author_id": 1462, "author_profile": "https://Stackoverflow.com/users/1462", "pm_score": 6, "selected": true, "text": "<?php\nrequire_once('fpdf.php');\nrequire_once('fpdi.php');\n\n$pdf =& new FPDI();\n$pdf->addPage('L');\n$pagecount = $pdf->set...
2008/11/18
[ "https://Stackoverflow.com/questions/297899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38458/" ]
297,909
<p>I have a question about variable initialization in MASM's assembly. </p> <p>How can I initialize 2^32 to a variable and to what kind of variable should I initialize? DWORD or REAL4?</p> <p>I try to do it like:</p> <pre><code>val DWORD 2.0E+32 </code></pre> <p>When I assign var to a register(e.g. mov eax,val) and try to write the value, I see something that is not 2^32. I also tried it with REAL4 type. Result is still same. </p> <p>So What I am doing wrong here?</p> <p>Thanks in advance...</p>
[ { "answer_id": 297957, "author": "Artelius", "author_id": 31945, "author_profile": "https://Stackoverflow.com/users/31945", "pm_score": 2, "selected": false, "text": "2.0E+32" }, { "answer_id": 297975, "author": "Cheery", "author_id": 21711, "author_profile": "https:/...
2008/11/18
[ "https://Stackoverflow.com/questions/297909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26379/" ]
297,938
<p>In Java, is there a way to have a window that is "Always on top" regardless if the user switches focus to another application? I've searched the web, and all of the solutions lean to some sort of JNI interface with native bindings. Truly this can't be the only way to do it?.. or is it?</p>
[ { "answer_id": 297948, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 8, "selected": true, "text": "Window" }, { "answer_id": 20923379, "author": "pinkpanther", "author_id": 2354099, "author_profile": "...
2008/11/18
[ "https://Stackoverflow.com/questions/297938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14204/" ]
297,951
<p>my goal is to get lots of rows from a translation table. I use an ID to get a subset of the table (say 50 rows) then I use another ID to the rows I want from this subset. Using typed datasets I do the following to get the main dataset: </p> <pre><code>funderTextsDS.tbl_funderTextsDataTable fd = (funderTextsDS.tbl_funderTextsDataTable)(new funderTextsDSTableAdapters.tbl_funderTextsTableAdapter()).GetData(); </code></pre> <p>Then for each value I want to get: </p> <pre><code>fd.Select("eng_code = '" + element + "' and funderID = '" + funderID + "'")[0]["funderText"].ToString(); </code></pre> <p>Using ANTS profiler to check the code I found that this method used about 170ms over 10 page refreshes (220 calls to the fd.select...) </p> <p>When I rewrote this to LINQ it took more than 2000ms to do the same work. Here is the LINQ code I used: </p> <pre><code>IrmDatabaseContext irmDB = new IrmDatabaseContext(); irmDB.tbl_funderTexts.Single(f =&gt; f.funderID == funderId &amp;&amp; f.eng_code == element).funderText; </code></pre> <p>Anyone have a good way of doing this with LINQ? By looking into sql server profiler i saw that the LINQ actually generated a single select for each text i retrieved. (ie LINQ= 220 selects from the db, tableadapter method = 10 selects) </p> <p>Solution: After having read around the net I found that David B was on the right track, although the for loop threw me off for quite a while. Anyway, the trick as he said, is to use a list as this actually forces linq to run the query against the DB and cache it localy. <a href="http://blogs.msdn.com/wriju/archive/2007/07/17/linq-to-sql-caching-the-query-execution.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/wriju/archive/2007/07/17/linq-to-sql-caching-the-query-execution.aspx</a>. </p> <p>So my solution ended up like this: </p> <pre><code>List&lt;tbl_funderText&gt; fd = (from tf in irmDB.tbl_funderTexts where tf.funderID == (int)cpcrow.cpc_fundingPartnerID select tf).ToList(); </code></pre> <p>Then everytime I want an element I do: </p> <pre><code>fd.Single(f =&gt; f.eng_code == element).funderText; </code></pre> <p>Analyzing with ANTS I then found that time was reduced to 150ms (about the same as the tableAdapter. SQL query analyzer shows that the SQL is run only one time.</p>
[ { "answer_id": 297979, "author": "Nathan W", "author_id": 6335, "author_profile": "https://Stackoverflow.com/users/6335", "pm_score": 0, "selected": false, "text": "var data = mDB.tbl_funderTexts.where(f => f.funderID == funderid && f.eng_code == element)\nvar fundertext = data.single()....
2008/11/18
[ "https://Stackoverflow.com/questions/297951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37083/" ]
297,954
<p>I have this form in my view: </p> <pre><code>&lt;!-- Bug (extra 'i') right here-----------v --&gt; &lt;!-- was: &lt;form method="post" enctype="mulitipart/form-data" action="/Task/SaveFile"&gt; --&gt; &lt;form method="post" enctype="multipart/form-data" action="/Task/SaveFile"&gt; &lt;input type="file" id="FileBlob" name="FileBlob"/&gt; &lt;input type="submit" value="Save"/&gt; &lt;input type="button" value="Cancel" onclick="window.location.href='/'" /&gt; &lt;/form&gt; </code></pre> <p>And this code in my controller: </p> <pre><code>public ActionResult SaveFile( FormCollection forms ) { bool errors = false; //this field is never empty, it contains the selected filename if ( string.IsNullOrEmpty( forms["FileBlob"] ) ) { errors = true; ModelState.AddModelError( "FileBlob", "Please upload a file" ); } else { string sFileName = forms["FileBlob"]; var file = Request.Files["FileBlob"]; //'file' is always null, and Request.Files.Count is always 0 ??? if ( file != null ) { byte[] buf = new byte[file.ContentLength]; file.InputStream.Read( buf, 0, file.ContentLength ); //do stuff with the bytes } else { errors = true; ModelState.AddModelError( "FileBlob", "Please upload a file" ); } } if ( errors ) { return ShowTheFormAgainResult(); } else { return View(); } } </code></pre> <p>Based on every code sample I've been able to find, this seems like the way to do it. I've tried with small and large files, with no difference in the result. The form field always contains the filename which matches what I've chosen, and the Request.Files collection is always empty. </p> <p>I don't think it's relevant, but I'm using the VS Development Web Server. AFAIK it supports file uploads the same as IIS. </p> <p>It's getting late and there's a chance I'm missing something obvious. I'd be grateful for any advice. </p>
[ { "answer_id": 297966, "author": "Pure.Krome", "author_id": 30674, "author_profile": "https://Stackoverflow.com/users/30674", "pm_score": 2, "selected": false, "text": "var file = Request.Files[sFileName];\n" }, { "answer_id": 298010, "author": "Jason Diller", "author_id"...
2008/11/18
[ "https://Stackoverflow.com/questions/297954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2187/" ]
297,955
<p>I am developing a .NET CF based Graphics Application, my project involves a lot of drawing images, We have decided to go for porting the application on different handset resolution.(240 X 240 , 480 X 640) etc. </p> <p>How would i go onto achieve this within single solution/project?</p> <p>Is there a need to create different projects based on resolutions? How would i handle common files? and i need the changes in one of the common classes to occur across all devices.</p> <p>Thank you, Cronos</p>
[ { "answer_id": 298025, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 2, "selected": false, "text": "[DllImport(\"coredll.dll\", EntryPoint = (\"GetSystemMetrics\"))]\npublic static extern int GetSystemMetrics(int nInd...
2008/11/18
[ "https://Stackoverflow.com/questions/297955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13046/" ]
297,960
<p>I have some code on my PHP powered site that creates a random hash (using <code>sha1()</code>) and I use it to match records in the database.</p> <p>What are the chances of a collision? Should I generate the hash, then check first if it's in the database (I'd rather avoid an extra query) or automatically insert it, based on the probability that it <em>probably</em> won't collide with another.</p>
[ { "answer_id": 298133, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 1, "selected": false, "text": "id = 5;\nhash = hash(\"My Private String \" + id)\nlink = \"http://mySite.com/resource?id=\" + id + \"&hash=\" + has...
2008/11/18
[ "https://Stackoverflow.com/questions/297960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
297,970
<p>There are a number of great Javascript libraries\frameworks out there (jQuery, Prototype, MooTools, etc.), but they all seem to focus on DOM interaction and AJAX functionality. I haven't found any that focus on extending the built-in data types (String, Date, Number, etc.). And by "Extending" I mean methods to solve typical work-a-day problems we all have. </p> <p>An example would be the .NET String.Format() method. Not only more convenient, but makes reading and trouble-shooting string concatenation better. While I have already created a String prototype method for this, I'd like to see if a good library has already been developed to address similar productivity issues before launching into a library of my own.</p> <p>Prototype has a few interesting methods in this regard, but since I've already settled on jQuery for DOM work, I really don't need to duplicate functionality on every page.</p> <p>Is anyone aware of a good, lean data type productivity library for Javascript?</p>
[ { "answer_id": 298019, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 2, "selected": false, "text": "$.trim(String), $.inArray(value, Array)" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/297970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30214/" ]
297,996
<p>I'm currently working on a very short project on Prolog, and just got stuck trying to apply a "filter" I have created to a list. I have what you could call the filter ready, but I can't apply it. It'd be better if I illustrate:</p> <pre><code>filter(A, B) </code></pre> <p>...outputs 'true' if certain conditions are met.</p> <pre><code>filterList(A, [X, Y, Z]) </code></pre> <p>...outputs a list which includes all elements from the second argument that make the filter output <strong>false</strong>. (So if filter(A, X) is true, the output is [Y, Z] ).</p> <p>I have the "filter" function ready, but now I need to apply it to a list as shown on the second example, excluding all elements for which the filter returns true when applied with the first argument. </p> <p>So, if the filter is a simple A == B, the function is supposed to receive A [A,B,A,C,D,A] and output [B,C,D], having removed all the elements for which the filter applies, obviously.</p> <p>I'm having trouble with the basic structure of the function, so if anyone could supply a basic outline for a function such as this it would be of great help. I've simplified my situation as much as possible so I can take whatever you may be able to provide and modify it for my needs.</p> <p>Thanks in advance!</p>
[ { "answer_id": 298022, "author": "Sergio Morales", "author_id": 9506, "author_profile": "https://Stackoverflow.com/users/9506", "pm_score": 0, "selected": false, "text": "filterList(_,[],R,R). % Returns answer when the list is exhausted.\nfilterList(L,[A|List],Temp,Res) :-\n ...
2008/11/18
[ "https://Stackoverflow.com/questions/297996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9506/" ]
298,004
<p>Is there a neat archiving library that automatically handles archiving a folder or directories for you out there? I am using Jython, so Java libs are also open for use. -UPDATE- Also Im looking for timestamp archiving. ie </p> <p>archive-dir/2008/11/16/zipfilebypreference.zip</p> <p>then the next day call it again and it creates another folder. Im sure there is something out there on the internet, who knows?</p>
[ { "answer_id": 298030, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "import javax.servlet.http.HttpServlet\n\nimport cStringIO\nimport gzip\nimport string\n\ndef compressBuf(buf):\n zbuf = c...
2008/11/18
[ "https://Stackoverflow.com/questions/298004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
298,009
<p>Is there any way to direct C# to ignore <code>NullReferenceException</code> (or any specific exception for that matter) for a set of statements. This is useful when trying to read properties from a deserialized object that may contain many null objects in it. Having a helper method to check for null could be one way but I'm looking for something close to 'On Error Resume Next' (from VB) at a block of statement level.</p> <p>EDIT:Try-Catch will skip the succeeding statements on exception</p> <pre><code>try { stmt 1;// NullReferenceException here, will jump to catch - skipping stmt2 and stmt 3 stmt 2; stmt 3; } catch (NullReferenceException) { } </code></pre> <p>For Example: I'm deserializing an XML message to an object and then try to access a property like</p> <pre><code>Message.instance[0].prop1.prop2.ID </code></pre> <p>now prop2 could be a null object (because it doesn't exists in XML Message - an optional element in XSD). right now I need to check for null for each element in the hierarchy before accessing the leaf element. i.e I've to check if instance[0], prop1, prop2 are not null, before accessing 'ID'.</p> <p>Is there a better way that avoids null-checking for each element in the hierarchy?</p>
[ { "answer_id": 298012, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "string foo = null;\nfoo.Spooky();\n...\npublic static void Spooky(this string bar) {\n Console.WriteLine(\"boo!\")...
2008/11/18
[ "https://Stackoverflow.com/questions/298009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7722/" ]