instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Unbalanced_binary_tree.svg/251px-Unbalanced_binary_tree.svg.png" alt="alt text"></p> <p>The image above is from <a href="http://en.wikipedia.org/wiki/AVL_tree" rel="nofollow noreferrer">"Wikipedia's entry on AVL trees"</a> which Wikipedia indicates...
<p>To be balanced, every node in the tree must, either,</p> <ul> <li>have no children, (be a "leaf" node)</li> <li>Have two children.</li> <li><p>Or, if it has only one child, that child must be a leaf.</p> <p>In the chart you posted, 9, 54 &amp; 76 violate the last rule.</p></li> </ul> <p>Properly balanced, the tre...
<p>Intuitively, it's because it's not as small as possible. e.g., 12 should be the parent of 9 and 14. As it is, 9 has no left sub-tree so it's out of balance. A tree is a hierarchical data structure so a rule like "balanced" often apply to every node and not just the root node.</p> <p>You're correct the root node ...
28,572
<p>I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but at the end, I get a "Trying to use an SPWeb object that has been closed or disposed and is no longer valid." error message.</p> <p>From what I see, SPContext.Current.Web is Disposed by someone, <strong>but I have no idea where</strong>. I...
<p>Check if this helps:</p> <ol> <li>Add a new breakpoint using <strong>Debug > New Breakpoint > Break at Function... (Ctrl+B)</strong>.</li> <li>Enter <strong>Microsoft.SharePoint.SPWeb.Dispose</strong> in the Function edit box.</li> <li>Dismiss the dialog box that says that Intellisense could not find the specified ...
<p>You should read this: <a href="http://msdn.microsoft.com/en-us/library/aa973248.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa973248.aspx</a></p> <p>To be quick: you should dispose all your SPWeb and SPSite using either</p> <pre><code>using(SPWeb web = ...) { .... } </code></pre> <...
24,603
<p>Does anyone have sample code to copy open (in-use and locked by another program) files using Volume Shadow Copy Service (VSS) API?</p> <p>There was an article about this in The Delphi Magazine (September 2005). But that code is no longer available and even if it was, it's not current.</p> <p>I am looking for sampl...
<p>there is a digital edition on usb stick of the "The Delphi Magazine". you can order that on their webpage.</p> <p>maybe someone has created a torrent of that stick.</p> <p><strong>update</strong></p> <p><strike>i found that sample here: <a href="http://www.google.com/codesearch/p?hl=de#XIdFp1PskBE/VSS/VssAPI.pas"...
<p>I found a working (XE2) example here: <a href="http://www.rathlev-home.de/sources/delphi.html#progsxe2" rel="nofollow">http://www.rathlev-home.de/sources/delphi.html#progsxe2</a></p> <p>For compilation with XE8 get the latest "gnugettext.pas"</p> <p>This package contains all units necessary for compiling a delphi ...
36,031
<p>My <code>C#</code> program has a list of files that can be dragged from it and dropped into another program. My requirements are that the file be copied to a different directory first.</p> <p>So, can I be notified of the drop operation so that I can only copy the file if operation succeeds? I'd rather wait till I k...
<p>There are a few ambiguities in your question. What operation needs to be successful?</p> <p>For everything you want to know about drag and drop, browse through these search results (multiple pages worth):</p> <p><a href="http://www.google.com/search?q=drag+drop+site%3Ablogs.msdn.com%2Foldnewthing&amp;rls=com.micro...
<p>So, you intend to modify the data being dropped based on the drop target? I don't think this is possible; after all, you populate the data when the drag is initiated.</p>
4,331
<p>I have a vba macro which runs a loop for about 200 iterations, using up the ram page file as it runs.</p> <p>I need some kind of quick fix to clear the page file after every iteration. I know the best fix would be to clean up the code, but time is a constraint here.</p>
<p>At the end of each loop iteration set any objects that will be re-created to <code>Nothing</code>.</p> <p>This <a href="http://www.vbi.org/Items/article.asp?id=106" rel="nofollow noreferrer">article</a> explains it in detail.</p>
<p>I've never seen this happen. It sounds like you have an ever-expanding array and may be running out of memory. I would stop it in a few places during the run, to see what is happening.</p>
30,508
<p>What's the best way to implement a classic curry function in actionscript with a nice syntax?</p> <p>I've tried:</p> <pre><code>Function.prototype.curry = function() { return "helloWorld"; } trace((function():void {}).curry()); </code></pre> <p>...approach but that didn't work. </p> <p>I guess I'm stuck with a ...
<p>I must admit I've never understood the difference between "curry" and "partial". I use the following function to do more or less what you want to do:</p> <pre><code>package { public function partial( func : Function, ...boundArgs ) : Function { return function( ...dynamicArgs ) : * { return func.apply(n...
<p>Ended up with (heavily inspired by dojo's implementation):</p> <pre><code>public static function curry(func:Function, ... args:Array):* { var arity:int = func.length; var currying:Function = function(func:Function, arity:int, args:Array):* { return function(... moreArgs:Array):* { if...
46,914
<p>What are the maximum allowed number of columns in a query in access 2003?</p>
<p>255 I believe. You can check by going to <em>Help > Specifications > Query</em> within Access.</p>
<h2>From Access Help File</h2> <p>Thank you Ben</p> <p>Number of enforced relationships: 32 per table minus the number of indexes that are on the table for fields or combinations of fields that are not involved in relationships<br> Number of tables in a query: 32<br> Number of fields in a recordset: 255<br> Recordset...
22,851
<p>We are developing a new web service and are looking into the "best practice" for returning errors in the soap response. </p> <p>We were looking into creating a error response object which every response would contain as a property. This seems a little heavy however and are wondering if it is possible to use the S...
<p>Soap already uses custom headers for error info, all you need to do is throw an exception on the server side, and exception is raised on the client side as a <a href="http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapexception.aspx" rel="nofollow noreferrer">SoapException</a>.</p> <p>You can...
<p>I've used similar techniques in the past for complex operations. Especially when you need (multiple?) error descriptions as well as as error code.</p>
30,074
<p>jQuery's <code>draggable</code> functionality doesn't seem to work on tables (in FF3 or Safari). It's kind of difficult to envision how this <em>would</em> work, so it's not really surprising that it doesn't.</p> <pre><code>&lt;html&gt; &lt;style type='text/css'&gt; div.table { display: table; } div.row {...
<p>If you have truly tabular data, you should stick with table indeed.</p> <p>And if you want to drag rows <em>within</em> a table, this <strong><a href="http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/" rel="noreferrer">JQuery + "draggable row table" library</a></strong> works perfectly in FireFox3</p...
<p>One can also set css <code>tr.ui-draggable-dragging {display: block}</code> - this way one can drag the rows, however, their coordinates are poorly calculated. I haven't found a good solution for this issue yet.</p>
39,642
<p>I have built a 3D printer with Marlin bugfix-2.0.x forked from github.</p> <p>I am attempting to set the default value for junction deviation so that I don't have to change it through the printer's screen/interface every time I power cycle the printer, but what I thought would set it properly isn't doing the trick....
<p>I've bought an SKR Pro V1.1 which is suffering from the same problem. It has actually to do with a shortcoming or design flaw (of the "HAL" or "Hardware Abstraction Layer" addressing of SPI devices) of Marlin and access to the SD card; I <a href="https://github.com/MarlinFirmware/Marlin/pull/16260" rel="nofollow nor...
<p>For the SKR, to store the new Marlin definitions it is necessary to send the comand <code>M502</code> to restore to the factory settings (will use the configuration on the SD card) and send the comand <code>M500</code> to save the configurations.</p>
1,497
<p>For the life of me, I cannot get the SqlProfileProvider to work in an MVC project that I'm working on.</p> <p>The first interesting thing that I realized is that Visual Studio does not automatically generate the ProfileCommon proxy class for you. That's not a big deal since it's simpy a matter of extending the Pro...
<p>Here's what you need to do:</p> <p>1) In Web.config's section, add "inherits" attribute in addition to your other attribute settings:</p> <pre><code>&lt;profile inherits="MySite.Models.ProfileCommon" defaultProvider=".... </code></pre> <p>2) Remove entire <code>&lt;properties&gt;</code> section from Web.config, ...
<p>The web.config file in the MVC Beta is wrong. The SqlProfileProvider is in System.Web.Profile, not System.Web.Security. Change this, and it should start working for you.</p>
10,451
<p>Would having a nice little feature that makes it quicker to write code like Automatic Properties fit very nicely with the mantra of VB.NET?</p> <p>Something like this would work perfect:</p> <pre><code>Public Property FirstName() As String Get Set End Property </code></pre> <p><strong>UPDATE:</strong> VB.NET...
<p>One reason many features get delayed in VB is that the development structure is much different than in C# and additionally, that often more thought goes into details. The same seems to be true in this case, as suggested by <a href="http://www.panopticoncentral.net/archive/2008/03/27/23050.aspx" rel="noreferrer">Paul...
<p>automatic properties are not necessary in vb the concession one makes by using an automatic property is that you can not modify the Get and Set. </p> <p>If you dont require those, just make a public data field. </p> <p>VB has had automatic properties for years. They just called them something else. </p>
14,880
<p>Is it Oracle or MySQL or something they have built themselves?</p>
<h2>Bigtable</h2> <p><a href="http://research.google.com/archive/bigtable.html" rel="noreferrer">A Distributed Storage System for Structured Data</a></p> <blockquote> <p>Bigtable is a distributed storage system (built by Google) for managing structured data that is designed to scale to a very large size: peta...
<p>Google services have a polyglot persistence architecture. BigTable is leveraged by most of its services like YouTube, Google Search, Google Analytics etc. The search service initially used MapReduce for its indexing infrastructure but later transitioned to BigTable during the Caffeine release. </p> <p>Google Cloud ...
47,377
<p>Can anyone explain in simple words what First and Second Level caching in Hibernate/NHibernate are?</p>
<p>1.1) First-level cache</p> <blockquote> <p><strong>First-level cache</strong> always Associates with the <strong>Session object</strong>. Hibernate uses this cache by default. Here, it processes one transaction after another one, means wont process one transaction many times. Mainly it reduces the number of S...
<p>In a second level cache, domain hbm files can be of key mutable and value false. For example, In this domain class some of the duration in a day remains constant as the universal truth. So, it can be marked as immutable across application.</p>
43,734
<p>I need to copy about 40 databases from one server to another. The new databases should have new names, but all the same tables, data and indexes as the original databases. So far I've been: </p> <p>1) creating each destination database<br> 2) using the "<a href="http://msdn.microsoft.com/en-us/library/ms140052.a...
<p>Given that you're performing this on multiple databases -- you want a simple scripted solution, not a point and click solution.</p> <p>This is a backup script that i keep around. Get it working for one file and then modify it for many.</p> <pre><code>(on source server...) BACKUP DATABASE Northwind TO DISK = 'c:...
<p>use backups to restore the databases to the new server with the new names.</p>
10,507
<p>If I have the following code,</p> <pre><code>Foo *f = new Foo(); vector&lt;Foo*&gt; vect; vect.push_back(f); // do stuff vect.erase(f); </code></pre> <p>Did I create a memory leak? I guess so, but the word <em>erase</em> gives the feeling that it is deleting it. </p> <p>Writing this, I am wondering if it is not ...
<p>Yes, you created a memory leak by that. std::vector and other containers will just remove the pointer, they won't free the memory the pointer points to.</p> <p>It's not unusual to put a pointer into a standard library container. The problem, however, is that you have to keep track of deleting it when removing it fr...
<p>It is definitely not a mistake to point a pointer into a standard container (it's a mistake to make a container of auto_ptr's however). Yes, you do need to explicitly delete to free the memory pointed to by the individual elements, or you can use one of the boost <a href="http://www.boost.org/doc/libs/1_37_0/libs/s...
35,599
<p>I am using WCF to upload data to a server.</p> <p>If the communication fails, is there any way to resume the upload?</p>
<p>This</p> <pre><code>eval { qr/$re/; }; if ( $@ ) { # do something } </code></pre> <p>compiles an expression, and lets you recover from an error. </p> <p>You can watch for malicious expression, since you're only going to do matching, by looking for these patterns, which would allow arbitrary code to be ...
<p>Would the <a href="http://perldoc.perl.org/Safe.html" rel="nofollow noreferrer" title="Safe">Safe</a> module be of any use with regard to compiling/executing untrusted regular expressions?</p>
29,972
<p>How do I convert between big-endian and little-endian values in C++?</p> <p>For clarity, I have to translate binary data (double-precision floating point values and 32-bit and 64-bit integers) from one CPU architecture to another. This doesn't involve networking, so ntoh() and similar functions won't work here.</p>...
<p>If you're using <strong>Visual C++</strong> do the following: You include intrin.h and call the following functions:</p> <p>For 16 bit numbers:</p> <pre><code>unsigned short _byteswap_ushort(unsigned short value); </code></pre> <p>For 32 bit numbers:</p> <pre><code>unsigned long _byteswap_ulong(unsigned long val...
<p>Look up bit shifting, as this is basically all you need to do to swap from little -> big endian. Then depending on the bit size, you change how you do the bit shifting.</p>
13,079
<p>I want to highlight C/C++/Java/C# etc source codes in my website.</p> <p>How can I do this?</p> <p>Is it a CPU intensive job to highlight the source code?</p>
<p>You can either do this server-side or client-side. It's not very processor intensive, but if you do it client side (using Javascript) there will be a noticeable lag. Most client side solutions revolve around Google Code's syntax highlighting engine. This seems to be the most popular one: <a href="http://alexgorba...
<p>I use <a href="http://code.google.com/p/syntaxhighlighter/wiki/Usage" rel="nofollow noreferrer">SyntaxHighligher</a> on <a href="http://bradwilson.typepad.com" rel="nofollow noreferrer">my blog</a>.</p>
9,557
<p>Ages ago when I was a java developer I could make separate ant scripts that I would call from my main ant script. I would put properties unique to each environment where my main script would run. I want to do the same thing in MSBuild but I can't find out how to chain MSBuild scripts together.</p>
<p>You need to <a href="http://msdn.microsoft.com/en-us/library/92x05xfs.aspx" rel="nofollow noreferrer">Import</a> them.</p> <pre><code> &lt;Import Project="MyTargets" Condition="Exists('MyTargets')"/&gt; </code></pre>
<p>The import is definitely useful, you can also actively invoke other projects:</p> <pre><code>&lt;MSBuild Projects="Other.proj" Properties="SomeProp=$(MyProperty)" /&gt; </code></pre>
33,847
<p>If I am to send a message to a mobile device from a website and viceversa, how can that be done?</p> <p>What I know: A couple of years ago I developed a simple enrollment system on J2ME platform(just for trying J2ME out). I had a mysql database that I setup in a pc/server, and for the communication I used the stati...
<p>It can be done by using a mobile phone connected to your computer, but a more robust way would be to use an SMS aggregator - well known ones are <a href="http://www.mblox.com/" rel="nofollow noreferrer">Mblox</a> or <a href="http://www.hslsms.com/" rel="nofollow noreferrer">Hay</a>, but a google search will show man...
<p>The short answer is that you have 4 options: </p> <ul> <li>Having your own SMS server </li> </ul> <p>OR</p> <ul> <li>Having to use the webportal for each provider you want to sent the message</li> </ul> <p>OR</p> <ul> <li>Some provider let you send SMS with email to SMS</li> </ul> <p>OR</p> <ul> <li>Use some ...
42,274
<p>So I want to trigger an event (pausing/unpausing some media) whenever the user presses spacebar anywhere in the my Swing app.</p> <p>Since there are so many controls and panels that could have focus, its not really possible to add keyevents to them all(not to mention gross).</p> <p>So I found </p> <pre><code>Key...
<p>I think you answered that yourself - yes I think you can find out the current element that has focus, and if it is an instanceof a certain field class, you ignore the space for the purpose of pause event. If it seams heavy handed, don't worry, instanceof is VERY fast for the JVM (and in any cause you are talking hum...
<p>Ok... Well im trying to filter based on source. Problem is my editable ComboBoxes... They are instanceof </p> <pre><code>javax.swing.plaf.basic.BasicComboBoxEditor$BorderlessTextField </code></pre> <p>And since BorderlessTextField is a private inner class, I apparently cant do an instanceof check against it.</p> ...
33,163
<p>I have the .net framework 3.5 on my development machine and also am using the AJAX toolkit in my code. In order to publish this code to a server for my users, do I need anything on the server in order for my AJAX code to operate correctly? </p>
<p>You need only the .NET framework 3.5.</p> <p>If you publish your project, the AJAX Toolkit used will be also copied over. If you only reference the AJAX Toolkit via file, not via project, then be sure you set the dll to "Copy always" in the properties window.</p>
<p>Of course, you will need to install the .NET Framework on your server. If you are using the AJAX Toolkit you will want to copy over the AjaxControlToolkit.dll to the bin folder of your web application on your server. </p> <p>Also want to make sure that you set your web application to use .NET Framework 2.0. In IIS ...
14,679
<p>Is it possible to define a timestamp column in a MySQL table that will automatically be updated every time a field in the same row is modified? Ideally this column should initially be set to the time a row was inserted.</p> <p>Cheers, Don</p>
<p>That is the default functionality of the <strong><a href="http://dev.mysql.com/doc/refman/5.0/en/timestamp.html" rel="noreferrer">timestamp</a></strong> column type. However, note that the format of this type is yyyymmddhhmmss (all digits, no colons or other separation).</p> <p><strong>EDIT:</strong> The above com...
<p>A MySQL timestamp is set with creation or update time only if their default value is set as it. <code>ALTER TABLE some_table ADD when TIMESTAMP DEFAULT CURRENT_TIMESTAMP</code>.<br> Otherwise it works just like a DateTime field, only that it's relative to 1970/01/01 UTC, so it's an absolute point in time not dependi...
18,743
<p>I have a program that writes to a FILE *cgiOut and just after it has written to the stream, I need to fork and run a background process. The trouble is that after the fork, the FILE * stream seems to flush out sometimes and I get duplicated output (after the fork, all open files are closed which I guess causes the ...
<p>Not quite sure I understand your question, but if you want to make sure your <code>cgiOut</code> buffers are empty before you <code>fork()</code> you can use <code>fflush()</code> on the stream just before you <code>fork()</code>. That should force the buffers to be flushed.</p> <p>It maybe suitable to use an unbuf...
<p><a href="http://opengroup.org/onlinepubs/007908775/xsh/fflush.html" rel="nofollow noreferrer"><code>fflush(file)</code></a></p>
44,602
<p>I've been trying to run a jar file - let's call it test.jar - that uses the Sybase jconn3.jar on a Unix system.</p> <p>I have created a MANIFEST.MF file that has the following:</p> <pre><code>Class-Path: $SYBASE/jConnect-6_0/classes/jconn3.jar commons-net-1.3.0.jar </code></pre> <p>This gives a ClassNotFoundError...
<p>The entries in the class-path are either relative to the JAR in which they are embedded (which you have working) or are URLs. To make your absolute paths work, you'll need to convert them to URLs, e.g., </p> <p><code>file:/opt/sybase13/...</code></p> <p>There's no mechanism for using variables.</p> <p>Although th...
<p>Environment variables are not readed by the classloader AFAIK. However you could add the jar in a configuration script</p> <p>Accoding to the specification the entries are relatives to the jar not absolute:</p> <blockquote> <p>Class-Path :</p> <p>The value of this attribute specifies the relative URLs of the extensi...
43,077
<p>How do I clear the cin buffer in C++?</p>
<p>Possibly:</p> <pre><code>std::cin.ignore(INT_MAX); </code></pre> <p>This would read in and ignore everything until <code>EOF</code>. (you can also supply a second argument which is the character to read until (ex: <code>'\n'</code> to ignore a single line).</p> <p>Also: You probably want to do a: <code>std::cin.c...
<p>fflush(stdin) − It is used to clear the input buffer memory. It is recommended to use before writing scanf statement.</p> <p>fflush(stdout) − It is used for clearing the output buffer memory. It is recommended to use before printf statement. The following should work:</p> <p>cin.flush(); On some systems it's not ava...
32,078
<p>My only problem is making them line up three-across and have equal spacing. Apparently, spans can not have width and divs (and spans with display:block) don't appear horizontally next to each other. Suggestions?</p> <p><code>&lt;div style='width:30%; text-align:center; float:left; clear:both;'&gt;</code> Is what I ...
<p>You can use divs with the <code>float: left;</code> attribute which will make them appear horizontally next to each other, but then you may need to use clearing on the following elements to make sure they don't overlap. </p>
<p>Look at the css Float property. <a href="http://w3schools.com/css/pr_class_float.asp" rel="nofollow noreferrer">http://w3schools.com/css/pr_class_float.asp</a></p> <p>It works with block elements like div. Alternatively, what are you trying to display, tables aren't evil if you're really trying to show a table of...
27,934
<p>I'm printing a cylindrical piece but at any moment it breaks down. I tried it two times, both have break down in different place. I'm using a 1.75&nbsp;mm PLA filament in my Anet A8. I'm using Cura 2.6.2 to export to a <code>.gcode</code> file.</p> <p>This is the original model: </p> <p><a href="https://i.stack.im...
<p>The first thought that pops into my mind is insufficient cooling. Consider to either slow down the nozzle speed or to construct a toss-away model nearby. I prefer the toss-away or duplicate model method. It allows the material printed on the first column to cool more effectively while the material on the second colu...
<p>The first thought that pops into my mind is insufficient cooling. Consider to either slow down the nozzle speed or to construct a toss-away model nearby. I prefer the toss-away or duplicate model method. It allows the material printed on the first column to cool more effectively while the material on the second colu...
744
<p>How do I load a true color image into a CImageList?</p> <p>Right now I have</p> <pre><code>mImageList.Create(IDB_IMGLIST_BGTASK, 16, 1, RGB(255,0,255)); </code></pre> <p>Where <code>IDB_IMGLIST_BGTASK</code> is a 64x16 True color image. The ClistCtrl I am using it in shows 16 bpp color. I don't see a Create ove...
<p>Needs 4 lines of code, but this works:</p> <pre><code>CBitmap bm; bm.LoadBitmap(IDB_IMGLIST_BGTASK); mImageList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 4, 4); mImageList.Add(&amp;bm, RGB(255,0,255)); </code></pre>
<pre><code>CImageList::Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow) </code></pre> <p>allows to specify different flags with the <code>nFlags</code> parameter. You can try to use something like <code>ILC_COLOR32 | ILC_MASK</code>.</p>
27,947
<p>I have a string which starts with <code>//#...</code> goes upto the newline characater. I have figured out the regex for the which is this <code>..#([^\n]*)</code>.</p> <p>My question is how do you remove this line from a file if the following condition matches</p>
<p>Your regex is badly chosen on several points:</p> <ol> <li><p>Instead of matching two slashes specifically, you use <code>..</code> to match two characters that can be anything at all, presumably because you don’t know how to match slashes when you’re also using them as delimiters. (Actually, dots match <em>almost<...
<p>Read the file line by line and only write those lines to a new file that don't match the regex. You cannot just remove a line.</p>
10,588
<p>As a programmer I have no idea how one would go about programming menus for a DVD, I have heard that this is possible, and even seen basic games using DVD menus - although it may very well be a closed-system. Is it even possible and if so, what language, compilers etc exist for this?</p>
<p>There are a couple of open source projects that can create DVDs plus menus. I recently used <a href="https://web.archive.org/web/20201109023628/http://dvd-slideshow.sourceforge.net/wiki/Main_Page" rel="nofollow noreferrer">dvd-slideshow</a> to create a simple dvd with menus etc. Another one is <a href="http://www.dv...
<p>Looks like <a href="http://dvdauthor.sourceforge.net/" rel="nofollow">http://dvdauthor.sourceforge.net/</a> is able to help here since you can use command line interface and feed xml files. </p> <p>You may need to write a framework which can generate xml files (and other content) from your game authoring tool.</p>
8,930
<p>I'm programming in C++ on Visual Studio 2005. My question deals with .rc files. You can manually place include directives like (#include "blah.h"), at the top of an .rc file. But that's bad news since the first time someone opens the .rc file in the resource editor, it gets overwritten. I know there is a place t...
<p>Add your #include to the file in the normal way, but also add it to one the three "TEXTINCLUDE" sections in the file, like so:</p> <pre><code>2 TEXTINCLUDE BEGIN "#include ""windows.h""\r\n" "#include ""blah.h\r\n" "\0" END </code></pre> <p>Note the following details:</p> <ul> <li>Each line is cont...
<p>I'm not completely sure why you're trying to do, but modifying the resource files manually probably isn't a good idea.</p> <p>I believe general practice for VC++ for globally-accessible values is to define them in stdafx.h (at least that's how I've seen it done), or to create something like a "globals.h" header fil...
12,094
<p>I'm trying to use jcarousel to build a container with multiple rows, I've tried a few things but have had no luck. Can anyone make any suggestions on how to create it?</p>
<p>We have had to make a similar modifiaction. We do this by extending the default options, to include a rows value, and the width of each item (we call them modules) then divide the width by the number of rows.</p> <p>Code added to jCarousel function...</p> <p>Add to default options: </p> <pre><code>moduleWidth: n...
<p>I tried the above solutions and found changing the original jCarousel code to be troublesome - it introduced buggy behaviour for me because it didn't play nice with some of the features of jCarousel such as the continous looping etc.</p> <p>I used another approach which works great and I thought others may benefit ...
26,268
<p>I'm building an XML document with PHP's SimpleXML extension, and I'm adding a token to the file:</p> <pre><code>$doc-&gt;addChild('myToken'); </code></pre> <p>This generates (what I know as) a self-closing or single tag:</p> <pre><code>&lt;myToken/&gt; </code></pre> <p>However, the aging web-service I'm communic...
<p>From the documentation at <a href="http://www.php.net/manual/en/function.simplexml-element-construct.php" rel="nofollow noreferrer">SimpleXMLElement->__construct</a> and <a href="http://cz2.php.net/manual/en/libxml.constants.php" rel="nofollow noreferrer">LibXML Predefined Constants</a>, I think this should work:</p...
<p>May be not the best solution but got same problem and solved it with using pre_replace to change all the self closing tags to full form...</p> <pre><code>$xml_reader = new XMLReader; $xml_reader-&gt;open($xml_file); $data = preg_replace('/\&lt;(\w+)\s*\/\s*\&gt;/i', '&lt;$1&gt;&lt;/$1&gt;', $xml_reader-&gt;readOut...
32,452
<p>Using strictly SQL (no PHP or anything else), is it possible to create a table <strong>and insert default data into that table</strong> only if that table doesn't exist?</p>
<p>Use the CREATE TABLE ... SELECT format:</p> <pre>create table if not exists tablename as select * from defaultdata;</pre>
<p>Here is one way of doing it:</p> <pre><code>CREATE TABLE IF NOT EXISTS T ( ID int(10) unsigned NOT NULL primary key, NAME varchar(255) NOT NULL ); REPLACE INTO T SELECT 1, 'John Doe'; REPLACE INTO T SELECT 2, 'Jane Doe'; </code></pre> <p>REPLACE is a MySQL extension to the SQL standard that either inserts, or...
37,194
<p>When using Lucene.Net with ASP.NET, I can imagine that one web request can trigger an update to the index while another web request is performing a search. Does Lucene.Net have built in it the ability to manage concurrent access, or do I have to manage it, to avoid "being used by another process" errors?</p> <p>E...
<p>According to <a href="http://darksleep.com/lucene/" rel="noreferrer">this page</a>,</p> <blockquote> <p>Indexing and searching are not only thread safe, but process safe. What this means is that:</p> <ul> <li>Multiple index searchers can read the lucene index files at the same time.</li> <li>An ind...
<p>You don't have a problem with that so much as managing concurrent writes to the index. I've had an easier path going with SOLR, which abstracts most of those differences away for me since it runs as a server. </p>
23,529
<p>I'm working on a System Preferences Pane. It opens fine on some computers, but on other Macs (all running 10.5.5), the preference pane refuses to load and simply hangs, spitting the following into the console:</p> <pre><code>11/9/08 8:38:50 PM [0x0-0x31031].com.apple.systempreferences[369] Sun Nov 9 20:38:50 Macint...
<p>You should read up on Reflection in Java.</p> <p>The following example would invoke the method </p> <p>myObjectThatContainsMethod#methodNameAsString(Integer arg1, Integer arg2)</p> <pre><code>Integer[] params = {new Integer(123),new Integer(567)}; Class cl=Class.forName("stringParsedFromYourXML"); Class[] par=n...
<p>First, you need to choose an implementation of XACML. You should take one that is written in Java, to make things simpler.</p> <p>Everything else depends on the chosen implementation. The implementation should document how to add custom functions. If it's not documented, ask the authors.</p>
34,962
<p>I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is run like:</p> <pre><code>sudo mod args </code></pre> <p>where mod is a perl...
<p>I would choose to go with Pexpect. </p> <pre><code>import pexpect child = pexpect.spawn ('sudo mod -p -c noresource -u dtt -Q') child.expect ('First question:') child.sendline ('Y') child.expect ('Second question:') child.sendline ('Yup') </code></pre>
<p>We need more information.</p> <ol> <li>Is sudo asking you for a password?</li> <li>What kind of interface does the mod script have for asking questions?</li> </ol> <p>Because these kind of things are not handled as normal over the pipe.</p> <p>A solution for both of these might be <a href="http://www.noah.org/wik...
31,201
<pre><code>$(document).ready(function() { $("span.link").mouseover(function(e){ $(this.children).css("display","inline"); }); }); </code></pre> <p>I'm not a javascript expert, but I've cobbled together a few functions using jQuery. </p> <p>In this case, the stylesheet hides some cont...
<p>Try it like this:</p> <pre><code>$(function() { $("span.link").mouseover(function(e){ $(this).children().css("display","inline"); }); }); </code></pre>
<p>Check out this <a href="http://tredosoft.com/Multiple_IE" rel="nofollow noreferrer">app</a> which installs multiple versions of Internet Explorer</p> <p>...ranging from v3, v4, v5 and most importantly, v6 (you should include tests in ie6 when developing)</p>
45,486
<p>This is one of the possible ways I come out:</p> <pre><code>struct RetrieveKey { template &lt;typename T&gt; typename T::first_type operator()(T keyValuePair) const { return keyValuePair.first; } }; map&lt;int, int&gt; m; vector&lt;int&gt; keys; // Retrieve all keys transform(m.begin(), m.e...
<p>While your solution should work, it can be difficult to read depending on the skill level of your fellow programmers. Additionally, it moves functionality away from the call site. Which can make maintenance a little more difficult.</p> <p>I'm not sure if your goal is to get the keys into a vector or print them to ...
<blockquote> <p>(I'm always wondering why std::map does not include a member function for us to do so.)</p> </blockquote> <p>Because it can't do it any better than you can do it. If a method's implementation will be no superior to a free function's implementation then in general you should not write a method; you s...
13,538
<p>I have a Prusa i3 that homes properly when you use the menu. After adjusting the bed and homing several times, it keeps the head at a reliable distance. However, when I try to print from an SD card, the printer buries the hot end in the heat bed.</p> <p>What needs to be adjusted to fix this issue?</p> <p>G-code from...
<p>The correlation between the endstop switch -- or sensor -- and the surface of the bed is not known <em>a priori</em> . In your case, there are two possibilities. I'd say the more likely is that your g-code generator is not setting the Z-height offset from the bed correctly. The other is that your bed is tilted,...
<p>I had the same issue: Z-axis correctly homing manually but not when printing.</p> <p>What worked for me is disabling the following line in the Marlin configuration file:</p> <pre><code>#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN </code></pre>
523
<p>I know it's a long shot, but is there some package or means to insert emoticons into a LaTeX document?</p>
<p>I know at least two partial ways:</p> <p>First:</p> <pre><code>$\ddot\smile$ </code></pre> <p>Second:</p> <pre><code>\usepackage{wasysym} \smiley \frownie </code></pre> <p>Or you can use images (as mentioned in other replies).</p>
<p>One solution is to use bclogo package. It contains two smileys (happy &amp; sad), plus many other small "logos" like flags and others.</p>
23,068
<p>Is it possible in .NET to ascertain whether my application is closing due to Windows being given a shutdown command (as opposed to any old application closing) in order to either write out some temporary cache files or even block the shutdown long enough to prompt for user input?</p> <p>Whilst my current scope invo...
<p><a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.sessionending.aspx" rel="noreferrer">SystemEvents.SessionEnding</a> looks like a good starting point for you. That article talks about the event sequence involved when a logout/shutdown is occurring.</p>
<p>In general, you will want to handle the <a href="http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx" rel="nofollow noreferrer"><code>WM_QUERYENDSESSION</code></a> Windows message. This will give your application a chance to do cleanup, or to block the shutdown if it's really necessary.</p>
30,405
<p>I am designing some parts that should modular fit together. I am currently exploring a Lego-like design with octagonal holes and cylindrical pins.</p> <p>I notice that (depending on the amount of clearance) that the fit is initially tight (to the extent that the pieces are very difficult to remove from each other), ...
<p>A flexible material, such as PETG or ABS, is probably the best. PLA is brittle, especially after absorbing moisture, and probably would crack under continued use.</p> <p>Nylon is good, but not easy to use. With PETG in an enclosure, I end up running fans to avoid heat creep; so PETG may actually do better without ...
<p>PETG, ABS and NYLON would work great for press-fit or snap-fit connections. If you really can't build a (cardboard) enclosure I would go for PETG as it has good repeatable mechanical properties and does not require an enclosure.</p>
1,904
<p>I can't shake this error when compiling my Visual Studio.NET 2008 solution. The project that's generating the error is a VB.NET Web Application in a 12 project solution (mixed types and languages).</p> <p>I've tried all the tricks I can find on google, and the obvious of removing the directoy and folder manually.<...
<p>Restart IIS on local.</p> <p>If that's not the issue then, install <a href="http://www.emptyloop.com/unlocker/" rel="nofollow noreferrer">Unlocker</a> and try to delete that pdb file when you get the error, Unlocker will tell you which process is holding an open handle to that file.</p>
<p>I had this in Visual Studio 2005 except it was Error 1. I restarted my machine and it fixed the problem.</p>
19,381
<p>I'm programmatically adding ToolStripButton items to a context menu.</p> <p>That part is easy.</p> <pre><code>this.tsmiDelete.DropDownItems.Add("The text on the item."); </code></pre> <p>However, I also need to wire up the events so that when the user clicks the item something actually happens!</p> <p>How do I d...
<p>Couldn't you just subscribe to the Click event? Something like this:</p> <pre><code>ToolStripButton btn = new ToolStripButton("The text on the item."); this.tsmiDelete.DropDownItems.Add(btn); btn.Click += new EventHandler(OnBtnClicked); </code></pre> <p>And OnBtnClicked would be declared like this:</p> <pre><code...
<p>Thanks for your help with that Andy. My only problem now is that the AutoSize is not working on the ToolStripButtons that I'm adding! They're all too narrow. </p> <p>It's rather odd because it was working earlier.</p> <hr> <p>Update: There's definitely something wrong with AutoSize for programmatically created To...
11,035
<p>I have a habit of keeping my variable usage to a bare minimum. So I'm wondering if there is any advantage to be gained by the following:</p> <pre><code>$query = $mysqli-&gt;query('SELECT * FROM `people` ORDER BY `name` ASC LIMIT 0,30'); // Example 1 $query = $query-&gt;fetch_assoc(); // Example 2 $query_r = $que...
<p>The <a href="http://us2.php.net/manual/en/mysqli-result.free.php" rel="noreferrer">manual</a> seems to suggest that you should still be using <code>free()</code> to release the memory. I believe the reasoning is that <code>free()</code> is freeing the memory in <em>MySQL</em>, not in PHP. Since PHP can't garbage-col...
<p>Example 1 <strong>dissociates</strong> the $query variable from the MySQL result. The MySQL result still exists in memory, and will continue to exist and waste memory until garbage collection occurs.</p> <p>Example 2 <strong>frees</strong> the MySQL result immediately, releasing the used resources.</p> <p>However,...
4,606
<p>I've written a simple control which basically displays a few words with an image next to it.</p> <p>I want the containing items to strech when the parent form is resized and as you can see from my commented out code, I don't want to use a loop as it flickers.</p> <p>Any idea on how to get the items to grow and shr...
<p>Avoid triggering a redraw every time you resize a child control by embedding your <code>foreach</code> in <code>SuspendLayout()</code> and <code>ResumeLayout()</code>:</p> <pre><code>this.SuspendLayout(); foreach (FlowLayoutPanel item in _listItems) { item.Width = this.Width - 10; } this.ResumeLayout(); </co...
<p>Anchor right and bottom on the form and maybe dock them.</p>
45,439
<p>Our app allows multiple files to be selected in a file selection dialog which is shown via the GetOpenFileName function (this question also applies to folks using CFileDialog, etc...)</p> <p>There appears to be a limit to the number of characters that can be typed into the filename field (259 seems to be the magic ...
<p>Turns out that the edit control (At least in my development environment) is a combo box, so <code>EM_SETLIMITTEXT</code> isn't appropriate. </p> <p>Instead, I tracked down the combo box using <code>GetDlgCtrl</code> on the parent of the file open dialog (I do this in the <code>OnInitDialog</code> handler), cast it ...
<p>I believe this is a hard limit that cannot be bypassed. The only time it should matter is when you want to select more than one file, since the limit is enough for the maximum file name length.</p> <p>I have added an "All Files" button to these dialogs for opening all of the files in a folder; that's the only worka...
47,157
<p>I need to be able to create basic MS Project items (tasks, projects, resources, etc.) programmatically from my app to my Project Server 2003 install, and haven't found any good examples. Can anyone point me to some good references or have some sample code of connecting to the server and creating these items?</p>
<p>Developing against Project Server 2003 isn't the friendliest experience around, but I have worked a little bit with the PDS (Project Data Services) which is SOAP based</p> <p><A HRef="http://msdn.microsoft.com/en-us/library/aa204408(office.11).aspx" rel="nofollow noreferrer"><a href="http://msdn.microsoft.com/en-us...
<p>As far as I know, the only programatic access to PS 2003 is through PWS. </p> <p>I don't know if it would work, but you could try writing a managed extension for Microsoft Project 2003 (The client application) .There <A href="http://msdn.microsoft.com/en-us/library/aa209377(office.11).aspx" rel="nofollow noreferrer...
3,925
<p>I'm writing an MFC App to automatically configure Postgresql with ODBC for use by another app. The idea being that the user runs the app and it automatically creates the database and the tables within it. My problem is that when I set up the File DSN it seems to require the name of the database it will access. This ...
<p>One simple option would be to create a view to render an XML-version of an Excel File. You could either use the new Office 2007 version, or the older 2003 version. We chose the 2003 version so that more people could use it, but that's up to you, of course.</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa1...
<p>Here is a blog post from Stephen Walther entitled <a href="http://stephenwalther.com/blog/archive/2008/06/16/asp-net-mvc-tip-2-create-a-custom-action-result-that-returns-microsoft-excel-documents.aspx" rel="noreferrer">ASP.NET MVC Tip #2 - Create a custom Action Result that returns Microsoft Excel Documents</a></p>
38,762
<p>I wanted to try a little design by contract in my latest C# application and wanted to have syntax akin to:</p> <pre><code>public string Foo() { set { Assert.IsNotNull(value); Assert.IsTrue(value.Contains("bar")); _foo = value; } } </code></pre> <p>I know I can get static methods lik...
<blockquote> <h2>C# 4.0 Code Contracts</h2> </blockquote> <p>Microsoft has released a library for design by contract in version 4.0 of the .net framework. One of the coolest features of that library is that it also comes with a static analysis tools (similar to FxCop I guess) that leverages the details of the contracts...
<p>You may want to check out <a href="http://www.codeplex.com/umbrella" rel="nofollow noreferrer">nVentive Umbrella</a>:</p> <pre><code>using System; using nVentive.Umbrella.Validation; using nVentive.Umbrella.Extensions; namespace Namespace { public static class StringValidationExtensionPoint { publi...
32,612
<p>I have a very dense point cloud (billions of points) of the exterior of a building obtained by laser scanning it with a Leica head. I successfully subsampled it down to around 500,000 and I'm trying to print the building by first creating a mesh. I tried using CloudCompare, Meshlab and PDAL, using Poisson surface re...
<p>The foundation of any 3D printer is the controller and the firmware. Many devices are based on Arduino type controllers, with stepper motor driver boards either integrated or added as a plug-in component.</p> <p>Some manufacturers will use in-house or outside resources and develop their own boards and firmware.</p>...
<p>this is an extension to fred_dot_u answer. As I am in the process of building my own printer, I decided to use RAMPS Arduino shield for electronics and Marlin firmware + Arduino mega2560 as a logic controller. </p> <p>As above are battle-tested, I don't need to discover wheel again, but rather focus on the mechani...
885
<p>I need to convert an x12 850 v4010 to a x12 940 v4010. Most of the tools convert from x12 to xml then I would need to map the xml to a 940. I am hoping there is a tool that could convert from one edi document to another.</p> <p>EDIT FOR INFORMATION:</p> <blockquote> <p><a href="http://www.rawlinsecconsulting.com...
<p>Going to give Altova MapForce and Stylus Studio® a try. </p> <p><a href="http://www.altova.com/downloadtrialmapforce3.html" rel="nofollow noreferrer">http://www.altova.com/downloadtrialmapforce3.html</a></p> <p><a href="http://www.stylusstudio.com/xml_product_index.html" rel="nofollow noreferrer">http://www.stylus...
<p>I would like to try out ALTOVA's mapforce tool to convert EDI 850 X12 to Oracle Apps. Is this a good choice. I hear that the most popular is <a href="http://www.sterlingcommerce.com/" rel="nofollow noreferrer">http://www.sterlingcommerce.com/</a>, but it is very costly..</p> <p>Please advice Shashi</p>
9,221
<p>This is a for a Silverlight project that isn't anchored to an .aspx file, so right clicking, etc. is a bit out of the question. Any ideas?</p> <p>Edit: </p> <p>Add an .html file, then click it. Really dumb. Last time I ask a question at three in the morning.</p>
<p>Why is right-clicking out of the question? With any HTML document at least (even in <em>Miscellaneous Files</em>) you can right-click on it, select <em>Browse With...</em>, select the browser, and click on <strong><em>Set as Default</em></strong>. If the browser doesn't appear in the list, click on <em>Add...</em>.<...
<p>Default Browser Changer extension:</p> <p><a href="http://visualstudiogallery.msdn.microsoft.com/233945ae-0b7b-47e7-9b02-c5a11798afb5" rel="nofollow">http://visualstudiogallery.msdn.microsoft.com/233945ae-0b7b-47e7-9b02-c5a11798afb5</a></p>
21,990
<p>Is there a way for me to loop over a Javascript Object's built-in properties?</p> <p>for...in gets me close to where I want to go, but "A for...in loop does not iterate over built-in properties."</p>
<p>I realize this question is three years old, but now, with ES5, it is possible:</p> <p><code>&gt;&gt;&gt; Object.getOwnPropertyNames(Object)</code></p> <p><code>["prototype", "getPrototypeOf", "getOwnPropertyDescriptor", "keys", "defineProperty", "defineProperties", "create", "getOwnPropertyNames", "isExtensible", ...
<p>This will work with JSON. It hasn't been tested much:</p> <pre><code>&lt;style&gt; .tree { margin-left:5px; } &lt;/style&gt; &lt;div id='out'&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; data = {"feep":{"bar":{"baz":"37628","quux":{"a":"179","b":"7"}},"foo":"1025"},"Bleh":"1234"} $('out').innerHTML = r...
32,871
<p>I am trying to configure Reporting Services 2005SP2 on a machine with SQL 2008 on another hosting the ReportServer DB.</p> <p>When I create the ReportServerDB the DB is created as version C.0.9.45:</p> <p>When, afterwards, I try to initialise Reporting Services, I get an error about an incorrect version number. Re...
<p>I got a reply from microsoft support saying that it is impossible on the same box.</p> <p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4153333&amp;SiteID=1" rel="nofollow noreferrer">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4153333&amp;SiteID=1</a></p>
<p>You must have created the reportServerDB using the SQL 2008 configuration tool. If you want to use the 2005 version of the server you need to create the configuration database using the configuration tool that came with SQL 2005. The 2005 SP2 tool will create a database with version C.0.8.54</p>
18,964
<p>Anyone use a language called Interactive Data Language, IDL? It is popular with scientists. I think it is a poor language because it is proprietary (every terminal running it has to have an expensive license purchased) and it has minimal support (try searching for IDL, the language, right now on stack) . I am try...
<p>So many IDL fanboys here! I'm also an astronomer and I've extensively used IDL and Python. All I can say is that IDL survives to this day because of the laziness of fellow astronomers, who can't or don't want to learn new better programming language. Most of my colleagues haven't used anything else besides Fortran o...
<p>Well, I did search for IDL on stack and that's how I got here! :-)</p> <p>I've been programming for almost 30 years and am just learning IDL. Thus far, I admit that I'm not overly fond of it. However, it does have some things that many other languages don't have (e.g. mathematical array operations can be done wi...
32,616
<p>I've looked at every question so far and none seem to actually answer this question.</p> <p>I created a UITabBarController and added several view controllers to it. Most of the views are viewed in portrait, but one should be viewed in landscape. I don't want to use the accelerometer or detect when the user rotate...
<p>An <a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/3219-force-landscape-mode-one-view-2.html" rel="nofollow noreferrer">post</a> on a forum that might help. Short answer is you have to manually rotate your view or controller once the view has been drawn, in the viewWillAppear: method</p> <pre><co...
<p>Override the Orientation method in your controller class and force it to Landscape like this :</p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Overriden to allow any orientation. return UIInterfaceOrientationIsLandscape(interfaceOrientation); ...
46,537
<p>I'm looking at sessions in Django, and by default they are stored in the database. What are the benefits of filesystem and cache sessions and when should I use them?</p>
<p>The filesystem backend is only worth looking at if you're not going to use a database for any other part of your system. If you are using a database then the filesystem backend has nothing to recommend it.</p> <p>The memcache backend is much quicker than the database backend, but you run the risk of a session being...
<p>If the database have a DBA that isn't you, you may not be allowed to use a database-backed session (it being a front-end matter only). Until django supports easily merging data from several databases, so that you can have frontend-specific stuff like sessions and user-messages (the messages in django.contrib.auth ar...
7,337
<p>I am coding a client-server application using Eclipse's RCP. We are having trouble testing the interaction between the two sides as they both contain a lot of GUI and provide no command-line or other remote API.</p> <p>Got any ideas?</p>
<p>I have about 1.5 years worth of experience with the RCP framework, I really liked it. We simply JUnit for testing...</p> <p>It's sort of cliche to say, but if it's not easy to test, maybe the design needs some refactoring?</p> <p>Java and the RCP framework provide great facilities for keeping GUI code and logic co...
<p>Separate your client-server communication into a pure logic module (or package). Test this separately - either have a test server, or use mock objects.</p> <p>Then, have your UI actions invoke the communications layer. Also, have a look at the <a href="http://en.wikipedia.org/wiki/Command_pattern" rel="nofollow nor...
5,157
<p>Does anybody know how I can see the actual machine code that <a href="http://code.google.com/p/v8/" rel="noreferrer">v8</a> generates from Javascript? I've gotten as far as <code>Script::Compile()</code> in <code>src/api.cc</code> but I can't figure out where to go from there.</p>
<p>I don't know how to invoke the disassembler from C++ code, but there is a quick-and-dirty way to get a disassembly from the shell.</p> <p>First, compile v8 with disassembler support:</p> <pre><code>scons [your v8 build options here] disassembler=on sample=shell </code></pre> <p>Now you can invoke the shell with t...
<p>Take a look at <code>v8_root/build/features.gypi</code>, and you will find disassembler related and many other compile time feature switches for V8.</p>
35,006
<p>I have roughly the following code. Could this be made nicer or more efficient? Perhaps using <code>std::remove_if</code>? Can you remove items from the map while traversing it? Can we avoid using the temporary map?</p> <pre><code>typedef std::map&lt;Action, What&gt; Actions; static Actions _actions; bool expired(c...
<p>You could use erase(), but I don't know how BOOST_FOREACH will handle the invalidated iterator. The <a href="http://en.cppreference.com/w/cpp/container/map/erase" rel="noreferrer">documentation for map::erase</a> states that only the erased iterator will be invalidated, the others should be OK. Here's how I would ...
<p>If the idea is to remove expired items, why not use <a href="http://www.cplusplus.com/reference/stl/map/erase.html" rel="nofollow noreferrer">map::erase</a>? This way you only have to remove elements you don't need anymore, not rebuild an entire copy with all the elements that you want to keep.</p> <p>The way you w...
21,780
<p>I'm using the sortable function in jquery to sequence a faq list. Needless to say, i'm new to this concept. Anybody have any good examples of the backend for this. I have the front working fine, but updating the sequence in the database is another story. My backend is ColdFusion btw.</p> <p>Thanks in advance</p>...
<p>Define the faq:</p> <pre><code>&lt;div id="faq"&gt; &lt;div id="q1"&gt;...&lt;/div&gt; &lt;div id="q2"&gt;...&lt;/div&gt; (...) &lt;div id="q100"&gt;..&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Make faq sortable:</p> <pre><code>&lt;script type="text/javascript"&gt; $("#faq").sortable(); &lt;/script&gt; ...
<p>Here is simple example of Jquery UI Sortable,how it can be used with div's.</p> <p>First include libraries in your html:</p> <pre><code> &lt;link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/&gt;` &lt;script src="http://ajax.googleapis.com/ajax...
22,651
<p>In Vim editor I opted <code>]I</code> on a function (in C++ code). This presented a list, which says <em>'Press ENTER or type command to continue'</em>.</p> <p>Now to jump to an occurrence say 6, I type <code>6</code> - but this is not working.</p> <p>What commands can I type in such a case, and how do I jump to ...
<p>It should present you a list like:</p> <pre><code>1: 345 my_func (int var) 2: 4523 my_func (int var) 3: 10032 my_func (3); </code></pre> <p>The second column is line numbers. Type :345 to jump to line 345.</p>
<p>Try using <code>123G</code> to go to line 123 (see <code>:h G</code>).</p>
16,683
<p>I have a small problem with interfaces. Here it is in Pseudo code :</p> <pre><code>type Interface1 = interface end; Interface2 = interface end; TParentClass = class(TInterfacedObject, Interface1) private fChild : Interface2; public procedure AddChild(aChild : Interface2); end; TChildCla...
<p>A reference-counted reference has two semantics: it acts as a share of ownership as well as a means of navigating the object graph.</p> <p>Typically, you don't need <strong>both</strong> of these semantics on all links in a cycle in the graph of references. Perhaps only parents own children, and not the other way a...
<p>With the use of a function pointer in the first example then the cyclic reference problem doesn't exist. .NET uses delegates, and VB6 uses events. All of which have the benefit of not incrementing the reference count of the object being pointed too.</p>
20,704
<p>To recap for those .NET gurus who might not know the Java API:</p> <p><a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html" rel="nofollow noreferrer">ConcurrentHashMap</a> in Java has atomic methods (i.e. require no external locking) for common Map modification operations such ...
<p>The incoming .Net 4.0 has a <a href="http://msdn.microsoft.com/en-us/library/dd287191(VS.100).aspx" rel="noreferrer">ConcurrentDictionary</a> class, it has a convenient <a href="http://msdn.microsoft.com/en-us/library/ee378677(VS.100).aspx" rel="noreferrer">GetOrAdd</a> method.</p> <pre><code>public TValue GetOrAdd...
<p>EDIT: This was written prior to .NET 4 being released, when obviously there's <code>ConcurrentDictionary</code>. I'm leaving it here as a reference for those needing .NET 3.5.</p> <p>I don't know of any equivalent to <code>ConcurrentHashMap</code>.</p> <p>In terms of general concurrency utilities - .NET has always...
35,917
<p>I've heard that <code>SELECT *</code> is generally bad practice to use when writing SQL commands because it is more efficient to <code>SELECT</code> columns you specifically need.</p> <p>If I need to <code>SELECT</code> every column in a table, should I use </p> <pre><code>SELECT * FROM TABLE </code></pre> <p>or ...
<p>One reason that selecting specific columns is better is that it raises the probability that SQL Server can access the data from indexes rather than querying the table data. </p> <p>Here's a post I wrote about it: <a href="http://weblogs.asp.net/jgalloway/archive/2007/07/18/the-real-reason-select-queries-are-bad-in...
<p>There can be a huge performance gain by limiting what columns are returned if the records are traversing the internet.</p>
9,125
<p>I recently converted a site from asp to CF. Unfortunately, alot of the old users had the "homepage" bookmarked. www.example.com/homepage.asp</p> <p>Is there a sort of catch all way I could redirect any traffic from that page to the current index.cfm?</p> <p>I would normally just delete those files, but the owner...
<p>Put this in the old homepage.asp</p> <pre><code>&lt;%@ Language=VBScript %&gt; &lt;% Response.Status="301 Moved Permanently" Response.AddHeader "Location", "/index.cfm" %&gt; </code></pre>
<p>The best bet is to do either a meta refresh in the actual homepage.asp page, it is quick and dirty, but works.</p> <p>A better solution would be to have the .asp page do a 301 redirect to the new homepage, that way when search engines access the page as well they know it has moved.</p>
30,654
<p>I'm writing a basic crawler that simply caches pages with PHP.</p> <p>All it does is use <code>get_file_contents</code> to get contents of a webpage and regex to get all the links out <code>&lt;a href="URL"&gt;DESCRIPTION&lt;/a&gt;</code> - at the moment it returns:</p> <pre><code>Array { [url] =&gt; URL [desc] =&...
<p>First of all, regex and HTML don't mix. Use:</p> <pre><code>foreach(DOMDocument::loadHTML($source)-&gt;getElementsByTagName('a') as $a) { $a-&gt;getAttribute('href'); } </code></pre> <p>Links that may go outside your site start with protocol or <code>//</code>, i.e.</p> <pre><code>http://example.com //example.c...
<p>You would have to look for http:// in the href. Else, you could determine if it starts with ./ or any combination of "./". If you don't find a "/" then you would have to assume that its a file. Would you like a script for this?</p>
47,145
<p>Informed options needed about the merits of flat file database. I'm considering using a flat file database scheme to manage data for a custom blog. It would be deployed on Linux OS variant and written in Java. </p> <p>What are the possible negatives or positives regarding performance for reading and writing of b...
<p>Flat file databases have their place and are quite workable for the right domain.</p> <p>Mail servers and NNTP servers of the past really pushed the limits of how far you can really take these things (which is actually quite far -- files systems can have millions of files and directories). </p> <p>Flat file DBs tw...
<p>Horrible idea. Appending would involve seeking to the end of the file every time you want to add something. Updating would require rewriting the entire file each time. Reading involves a table scan (or maintaining a separate index, which would have the same problems with writing/updating). Just use a database un...
43,136
<p>When trying to run the Flex Builder 3 profiler on any I don't get the profiler dialog window and then after a few seconds I get "Socket timeout" in the console window. Any ideas why it can't connect?</p> <p>I've got the latest debug version of Flash player and have tried shutting off my firewall.<br> I'm running i...
<p>It looks like the browser (Firefox in my case) has to be shutdown before the profiler is started. Step 1. in the livedocs even says this -- wish I had read it earlier. :)</p> <p><a href="http://livedocs.adobe.com/flex/3/html/help.html?content=profiler_3.html" rel="nofollow noreferrer">http://livedocs.adobe.com/fl...
<p>Browser tabs, make sure you have latest debug as you said you did, also make sure that the port is correct, for some reason the port sometimes changes(1001 or 20957) from the default 9999, be sure that your mm.cfg has ProfilingFileOutputEnable=1 and that bittorrent isn't on. hth</p>
14,070
<p>I'm writing some Java code that uses a FileReader to load data from a few input files. I'm using TDD pretty heavily, and I'd like to add some tests that ensure that I'm cleaning up properly by calling close() on the reader when I'm done with it. Unfortunately, I can't come up with a good way to test for this. Anyone...
<p>I think the way to do this is to inject the FileReader, or a Factory that creates the FileReader, into your class. Then in your unit test you can inject a mock version of the FileReader and check that the proper method on it has been called. You might want to look at <a href="http://www.jmock.org/" rel="noreferrer...
<p>If you can pass the FileReader object in to the call then you can provide a custom FileReader that has an overridden close method -- in that, you have a boolean variable that checks on closed or not. You can then use that for your unit test. </p>
46,728
<p>My windows service is creating a directory on a shared folder, and I am getting a error:</p> <pre><code>at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path,DirectorySecurity dirSecurity) at System.IO.Directory.CreateDirec...
<p>This could be a couple of things depending upon the platform your server runs. As a complete (and assuming a windows based server) guess cross check both the share AND the folder have write permissions given to the appropriate user account. </p> <p>Just providing permissions on the share only may not work.</p> <p>...
<p>For security in shared folders on .net you need to configure the .net security with <a href="http://msdn.microsoft.com/en-us/library/2bc0cxhc(VS.80).aspx" rel="nofollow noreferrer">".net Framework Configuration Tool"</a>. </p>
49,214
<p>Hopefully a nice simple one.</p> <p>I've got a php3 website that I want to run on php 5.2</p> <p>To start with I'd just like to have every reference to the current "index.php3" _within_each_file_ (recursively) changed to "index.php" and then move on to worrying about globals etc.</p> <p>K. Go!</p> <p>:) </p> <p...
<pre><code>find -type f -exec perl -pi -e 's/\bindex\.php3\b/index.php/g' {} \; </code></pre>
<p>To do this recursively, use Jonathan's answer but substitute <code>find . -type f</code> for *.php3. Note that the back ticks are important and you can substitute any directory for "." (i.e. the current directory). Here is a version that also renames the file in the process (*.php3 -> *.php).</p> <pre><code>#!/bin/...
39,629
<p>Can a Silverlight 2 enabled web page be managed from an Apache server? (I'm not actually interested in doing this but trying to understand Silverlight 2 a bit more.)</p> <p>Assuming that I have IIS6 and Server 2003 what are the .NET version requirements to host a web site with Silverlight 2? Are .NET 3.0 and 3.5 re...
<p>Since Silverlight is a browser technology, it is <strong>server-agnostic</strong> and can be hosted on a variety of server platforms: LAMP, UNIX, and IIS. You don't have to install .NET or any other Microsoft software on the server.</p> <p>The only configuration required on the web server is to <strong>register the...
<p>The <a href="http://www.microsoft.com/silverlight/overview/faq.aspx#sys-req" rel="nofollow noreferrer">system requirements for Microsoft Silverlight</a> and associated technologies are listed below.</p> <pre><code>* Windows o Operating System: Windows Vista; Windows XP Service Pack 2 o Intel® Pentium® I...
35,620
<p>I am looking to improve the performance of my site, not because it is performing badly but just as a general exercise. The usual suggestion for asp.net sites is to remove viewstate wherever possible. I believe this can be done by each control on a page separately or for the whole page.</p> <p>My question is if I di...
<p>Yes, the page is the originator of the page flow. Thus, disabling viewstate for the page takes the viewstate rendering out of the OnInit process. A better question would be why does disabling the viewstate for the master page do the same?</p>
<p>Just a quick note on the side before optimising the site, have you optimised the server by making sure all the files are gzipped before being sent.</p> <p>If not this will get you a nice boost before you even start tinkering with the page. </p> <p><a href="http://www.codinghorror.com/blog/archives/000059.html" rel...
24,591
<p>WinForms C#.. am getting some JSON in the format below (bottom of message) and trying to deserialise using:</p> <p>using System.Web.Script.Serialization;</p> <p>When I had simply this json returned:</p> <pre><code>{ "objects": [ { "categoryid": "1", "name": "funny", "serverimageid": "1...
<p>This seems to work fine (And no wacky string trimming!):</p> <pre><code>using System; using System.Collections.Generic; using System.Web.Script.Serialization; class Program { static void Main( string[] args ) { string json = System.IO.File.ReadAllText( "../../input.json" ); var serializer ...
<p>Edit: The following works with <code>DataContractJsonSerializer</code>, but does <strong>not</strong> work with the JavascriptSerializer from the OP. So this is just for refernence.</p> <pre><code>[DataContract] class Foo { [DataMember(Name = "objects")] public Bar Bar { get; set; } } [DataContract] class ...
42,083
<p>The standard model has been that OpenGL is for professional apps (CAD) and Direct3D is for games. </p> <p>With the debacle of openGL 3.0, is openGl still the natural choice for technical 3D apps (cad/GIS)?<br> Are there scenegraph libraries for Direct3D? </p> <p>(Of course Direct3D is windows only.)</p>
<p>D3D makes you pay the Microsoft "strategy tax." That is, D3D serves two masters. One is giving you features and performance. The other is to ensure lock-in to other MS products and the Windows platform generally. This has some consequences for you:</p> <ol> <li><p>A D3D app won't run on anything but Windows (in...
<p>Direct3D is only available on Windows and XBox. If you plan on targeting Unix or Mac, in addition to Windows, OpenGL is a good choice.</p>
15,177
<p>In honor of the <a href="http://prize.hutter1.net/" rel="noreferrer">Hutter Prize</a>, what are the top algorithms (and a quick description of each) for text compression?</p> <p>Note: The intent of this question is to get a description of compression algorithms, not of compression programs.</p>
<p>The boundary-pushing compressors combine algorithms for insane results. Common algorithms include:</p> <ul> <li>The <a href="http://en.wikipedia.org/wiki/Burrows-Wheeler_transform" rel="noreferrer">Burrows-Wheeler Transform</a> and <a href="http://marknelson.us/1996/09/01/bwt/" rel="noreferrer">here</a> - shuffle c...
<p>If you want to use PAQ as a program, you can install the <code>zpaq</code> package on debian-based systems. Usage is (see also <code>man zpaq</code>)</p> <pre><code>zpaq c archivename.zpaq file1 file2 file3 </code></pre> <p>Compression was to about <strong>1/10th of a zip file's size</strong>. (1.9M vs 15M)</p>
29,265
<p>When I do an "os.execute" in Lua, a console quickly pops up, executes the command, then closes down. But is there some way of getting back the console output only using the standard Lua libraries?</p>
<p>I think you want this <a href="http://pgl.yoyo.org/luai/i/io.popen" rel="noreferrer">http://pgl.yoyo.org/luai/i/io.popen</a> io.popen. But it's not always compiled in.</p>
<p>I don't know about Lua specifically but you can generally run a command as:</p> <pre><code>comd &gt;comd.txt 2&gt;&amp;1 </code></pre> <p>to capture the output and error to the file comd.txt, then use the languages file I/O functions to read it in.</p> <p>That's how I'd do it if the language itself didn't provide...
16,054
<p>I have an Oracle table which contains event log messages for an application. We don't want this table to grow out of control and eat up too much space, so we'd like to set a cap on the number of rows that it can contain to some big number like one million.</p> <p>So we'd like to tell Oracle that when the table gro...
<p>Depending on your definition of simpler...</p> <p>My bias would be to schedule a job that runs periodically (say, nightly) in order to delete the oldest rows. If you expect that you could generate a million event logs in a single day, you may want the job to run more frequently, but nightly is generally sufficient...
<p>you can't tell Oracle to keep my table at a certain size. If this is news, partitioning might not be for you. Otherwise, I'd completely agree with Nick. </p> <p>Remember the 1M is just a magic number that you've decided to keep, it's ok if it gets to 1.1M before an clean up occurs. If you do rolling partitions, you...
24,562
<p>I've got a load-balanced (not using Session state) ASP.Net 2.0 app on IIS5 running back to a single Oracle 10g server, using version 10.1.0.301 of the ODAC/ODP.Net drivers. After a long period of inactivity (a few hours), the application, seemingly randomly, will throw an Oracle exception:</p> <blockquote> <p>Excep...
<blockquote> <p>ORA-03113: end-of-file on communication channel</p> </blockquote> <p>Is the database letting you know that the network connection is no more. This could be because:</p> <ol> <li>A network issue - faulty connection, or firewall issue</li> <li>The server process on the database that is servicing you d...
<p>The article previously mentioned is good. <a href="http://forums.oracle.com/forums/thread.jspa?threadID=191750" rel="nofollow noreferrer">http://forums.oracle.com/forums/thread.jspa?threadID=191750</a> (as far as it goes) </p> <p>If this is not something that runs frequently (don't do it on your home page), you ...
10,875
<p>I know this is odd. but I can't figure other ways to do what I need. I have a controller: report and a view: report. Also I have a view that acts as a dashboard where I can see several zones (partials). I need to add this report view to my dashboard but don't know how. This report view utilizes complex logic from co...
<p>(I hope I'm understanding the problem, here...)</p> <p>This part seemed significant:</p> <blockquote> <p>This report view utilizes complex logic from controller</p> </blockquote> <p>As a general rule, controllers should be simple. Really simple. The rule of thumb is "thin controller, fat model" (Rails Envy ma...
<p>I had a similar problem a while ago, when they deprecated render_controller. The only solution I found then was to use ajax, passing a parameter to the page you want to load that bypasses the layout.</p>
46,410
<p>Any hints or suggestions (filament type? suggested settings? model sources?) for 3D printing minis to use in Dungeons &amp; Dragons?</p> <p>I've done a couple where the support structures were difficult to break off without breaking off a hand or something.</p> <p>I have a Lulzbot Mini (1), single-extruder if that m...
<p>There are adequate demonstration videos on YouTube showing that it is possible to print very acceptable 28 mm scale miniatures with FDM printers, easily rivaling the quality of resin printers from only a few years ago.</p> <p>There are a couple of key requirements to get optimum quality for small, highly detailed pa...
<p>Buckle up, this is going to be rough:</p> <p>FDM printers are not the best choice for printing figurines in the 25 to 40 mm scale that is typical for wargaming and D&amp;D games. Resolution-wise, that's the area of <em>resin</em> printers.</p> <p>But there are ways to get some partially decent prints made:</p> <ul> ...
1,931
<p>Why does nvarchar(256) seem to the be the standard for user names in SQL Server? </p> <p>Any system functions that return a user name return nvarchar(256), the ASP Membership provider uses nvarchar(256)</p> <p>256 seems like an odd number (yes, I know its even...) - 255 I could understand (1 byte address) but 256 ...
<p>As programmers we automatically count starting at 0, but in this case nvarchar(0) would mean no characters. Turns out that 256 is your nice round number 2^8.</p>
<p>Experience suggests that, across various database over a period of time, 256 seems to be the minimum value for the maximum length of string fields. I wouldn't be surprised if it goes back to dBASE.</p>
43,995
<p>I have a <code>mysql</code> database filled up and running on a <em>Windows</em> computer, is there any tool to transfer the database to another computer (running <em>Ubuntu</em>)?</p> <p>Else I'll just write a <code>script</code> to take all the data base into <code>SQL</code> and <em>insert</em> it on the other c...
<p>The tool you speak of already exists: mysqldump</p> <p>It dumps out to sql, which you can then copy to another machine and re-load.</p> <p>eg:</p> <p>on source:</p> <pre><code>mysqldump -u username -p databasename &gt; dumpfile.sql </code></pre> <p>Then use ftp/rsync/whatever to move the file to the destination...
<p>You can make a backup using any gui tool, like Mysql Administrator (<a href="http://dev.mysql.com/downloads/gui-tools/" rel="nofollow noreferrer">http://dev.mysql.com/downloads/gui-tools/</a> on Windows, aptitude install mysql-admin on Ubuntu) or phpmyadmin (<a href="http://www.phpmyadmin.net/home_page/index.php" re...
42,616
<p>More specifically, if I have:</p> <pre><code>public class TempClass : TempInterface { int TempInterface.TempProperty { get; set; } int TempInterface.TempProperty2 { get; set; } public int TempProperty { get; set; } } public inter...
<p>I think the class you are looking for is System.Reflection.InterfaceMapping.</p> <pre><code>Type ifaceType = typeof(TempInterface); Type tempType = typeof(TempClass); InterfaceMapping map = tempType.GetInterfaceMap(ifaceType); for (int i = 0; i &lt; map.InterfaceMethods.Length; i++) { MethodInfo ifaceMethod = m...
<p>Jacob's code is missing a filter:</p> <pre><code> var props = typeof(TempClass).GetInterfaces().Where(i =&gt; i.Name=="TempInterface").SelectMany(i =&gt; i.GetProperties()); foreach (var prop in props) Console.WriteLine(prop); </code></pre>
35,233
<p>We are currently working in a private beta and so are still in the process of making fairly rapid changes, although obviously as usage is starting to ramp up, we will be slowing down this process. That being said, one issue we are running into is that after we push out an update with new JavaScript files, the clien...
<p>As far as I know a common solution is to add a <code>?&lt;version&gt;</code> to the script's src link.</p> <p>For instance:</p> <pre><code>&lt;script type="text/javascript" src="myfile.js?1500"&gt;&lt;/script&gt; </code></pre> <hr> <blockquote> <p>I assume at this point that there isn't a better way than find-...
<p>A simple trick that works fine for me to prevent conflicts between older and newer javascript files. That means: If there is a conflict and some error occurs, the user will be prompted to press Ctrl-F5.</p> <p>At the top of the page add something like</p> <pre><code>&lt;h1 id=&quot;welcome&quot;&gt; Welcome to this ...
5,235
<p>Has anyone had any experience in building a 'real world' application with the <a href="http://www.codeplex.com/smartclient" rel="noreferrer">Smart Client Software Factory</a>, from Microsofts Patterns and Practices group? I'm looking for advice on how difficult it was to master, whether it decreased your time to ma...
<p>We used SCSF for a real world app with about 10 developers. It was a steep learning curve to set up and develop a pattern of usage, but once it was set up, introducing new developers to the project was VERY easy. Using CAB and SCSF was very beneficial to our project especially getting each developer up to speed and ...
<p>We use the <a href="http://www.codeplex.com/servicefactory" rel="nofollow noreferrer">Web Service Software Factory</a>, and we really like it because it makes it easier for developers to follow standards and appropriate patterns. The learning curve for us wasn't bad - a few hours per developer at most.</p> <p>Other...
2,800
<p>The more I think about how I use computers, the more I become convinced that 'workflow' is the key factor in terms of productivity, and the way I should go about designing interactions. I'm thinking of workflow as the way we approach and manage data, information and knowledge as it relates to a task.</p> <p>I'm st...
<p>I think your right on that solid and engaging workflows are the key to successful user applications. As an example, consider this site (stackoverflow) which has an engaging and simple workflow around questions. It's a great example. I have been thinking a lot about this as well. Let me point you to a couple reso...
<p>Look at the source code to (open source) alternative applications of a similar workflow orientation, and others written in the framework you have chosen.</p> <p>Theory is excellent, but for true understanding you will need to investigate the actual concrete applications already out there.</p>
32,060
<p>I have a number of tables that use the trigger/sequence column to simulate auto_increment on their primary keys which has worked great for some time.</p> <p>In order to speed the time necessary to perform regression testing against software that uses the db, I create control files using some sample data, and added ...
<p>You can generate a script to create the sequences with the start values you need (based on their existing values)....</p> <pre><code>SELECT 'CREATE SEQUENCE '||sequence_name||' START WITH '||last_number||';' FROM ALL_SEQUENCES WHERE OWNER = your_schema </code></pre> <p>(If I understand the question correctly)</...
<p>As part of your schema rebuild, why not drop and recreate the sequence? </p>
14,279
<p>I suppose it allows for moving changes from one branch to the next but that's what cherry picking is for and if you're not making a commit of your changes, perhaps you shouldn't be moving them around?</p> <p>I have on occasion applied the wrong stash at the wrong branch, which left me wondering about this question....
<p>As mentioned, if you want a “per-branch stash,” you really want a new branch forking off from the existing branch.</p> <p>Also, besides the already mentioned fact that the stash allows you to pull into a branch that you’re working on, it also allows you to <em>switch</em> branches before you have committed everythi...
<p>git-stash is most useful to me to move not-yet-checked-in changes off to a different branch than the one that is currently checked out.</p> <p>For example - I often find myself doing simple changes on a bug-fixes branch; only to find that a change I'm working on is more complex than I first guessed. Git-stash is t...
11,499
<p>I have images being sent to my database from a remote video source at about 5 frames per second as JPEG images. I am trying to figure out how to get those images into a video format so I can stream a live video feed to Silverlight.</p> <p>It seems to make sense to create a MJPEG stream but I'm having a few problems...
<p>I did MJPEG a long time ago (3-4 years ago) and I'm scratching my head trying to remember the details and I simply can't. But, if its possible, I would suggest finding some kind of web site that streams MJPEG content and fire up wireshark/ethereal and see what you get over the wire. My guess is you are missing som...
<p>First, write your mjpeg frames out to separate files. You should then be able to open these in Phototshop (this will independently verify that you are parsing the stream correctly). If this fails, by bet is that you have HTTP headers embedded in your image data.</p>
26,632
<p>At the beginning of all my executable Python scripts I put the <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)" rel="noreferrer">shebang</a> line:</p> <pre><code>#!/usr/bin/env python </code></pre> <p>I'm running these scripts on a system where <code>env python</code> yields a Python 2.2 environment. My scrip...
<p>"env" simply executes the first thing it finds in the PATH env var. To switch to different python, prepend the directory for that python's executable to the path before invoking your script.</p>
<p>@morais: That's an interesting idea, but I think maybe we can take it one step farther. Maybe there's a way to use <a href="http://pypi.python.org/pypi/virtualenv" rel="nofollow noreferrer">Ian Bicking's virtualenv</a> to:</p> <ul> <li>See if we're running in an acceptable environment to begin with, and if so, do n...
6,195
<p>I have read (or perhaps heard from a colleague) that in .NET, TransactionScope can hit its timeout and then VoteCommit (as opposed to VoteRollback). Is this accurate or hearsay? I couldn't track down information on the web that talked about this issue (if it IS an issue), so I wonder if anyone has any direct exper...
<p>If you mean in relation to SQL Server, then there is an issue that you can fix in the connection string; see my reply <a href="https://stackoverflow.com/questions/189534/net-transactionscope-class-and-t-sql-tran-commit-and-rollback#190332">here</a>, or the full details <a href="http://weblogs.asp.net/ryangaraygay/ar...
<p>The behaviour that Marc Gravell described has been changed in .Net 4.0. Instead of the operation being autocommitted, it will now throw an InvalidOperationException. So in 4.0 you no longer need to use Explicit Unbind.</p>
23,738
<p>How can my vbscript detect whether or not it is running in a UAC elevated context?</p> <p>I have no problem detecting the user, and seeing if the user is within the Administrators group. But this still doesn't answer the question of whether the process has elevated privs or not, when running under Vista or Windows ...
<p>The method I finally settled on depends on the fact that Vista and Windows 2008 have the whoami.exe utility, and it detects the integrity level of the user who owns the process. A couple of screenshots help here:</p> <p><a href="http://lh3.ggpht.com/_Svunm47buj0/SQ6ql4iNjPI/AAAAAAAAAeA/iwbcSrAZqRg/whoami%20-%20admi...
<p>a little bit shorter in WSH Jscript</p> <pre><code>function isElevated(){ var strCaption = ""; for (var enumItems=new Enumerator(GetObject("winmgmts:\\\\.\\root\\CIMV2").ExecQuery("Select * from Win32_OperatingSystem")); !enumItems.atEnd(); enumItems.moveNext()) { strCaption += enumItems.item().C...
29,184
<p>I have trouble. One of the users of an application I'm developing is occasionally, but regularly, experiencing an application hang.</p> <p>When this happens, we find an entry with a source of "Application Hang" in the machine's Event Log, with the informative message "Hanging application [my app], version [the rig...
<p>In answer to your specific question, when a background/worker thread blocks or hangs, the effect on the rest of the application would depend a lot on the synchronization happening between the threads in the app. There's no particular reason why it would necessarily hang the whole app, but it's entirely possible that...
<p>Thought 1) step into .net framework code (from a KB at my work):</p> <p>If you’ve installed VS2008 SP1, all you need to do is go to Tools -> Options -> Debugging</p> <ol> <li>Uncheck Enable Just My Code</li> <li>Check Enable .NET Framework Source Stepping</li> <li>Check Enable source server support</li> <li>Under ...
24,746
<p>What is the best way to perform a couple of tasks together and if one task fails then the next tasks should not be completed? I know if it were the database operations then I should have used Transactions but I am talking about different types of operations like the following: </p> <p>All tasks must pass: </p> <p>...
<p>in C#</p> <p>return SendEmail() &amp;&amp; ArchiveResportsInDatabase() &amp;&amp; CreateAFile();</p>
<p>If your language allows it, this is very tidy:</p> <ol> <li>Put your tasks in an array of code blocks or function pointers.</li> <li>Iterate over the array.</li> <li>Break if any block returns failure.</li> </ol>
20,350