instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>On Vista, I got a problem with the application crash handler. Basically, if something unexpected occurs which cannot be captured by SEH, I get this pop-up window with "The application stopped working", blablabla, "Close program/Debug program" -- that is, after I disable the error reporting using the system control p...
<p>Use</p> <pre><code>SetErrorMode(SetErrorMode(0)|SEM_NOGPFAULTERRORBOX); </code></pre> <p>But I would suggest to install an exceptions handler which creates a dump so you can verify what happened. For example <a href="http://code.google.com/p/crashrpt/" rel="nofollow noreferrer">crashrpt</a> (or <a href="http://www...
<p>Function <a href="http://www.cs.cf.ac.uk/Dave/C/node24.html" rel="nofollow noreferrer" title="signal">signal</a> works on all POSIX platforms:</p> <pre><code>signal(SIGSEGV, &amp;signal_handler); </code></pre> <p>If you need to trap an exception that isn't supported by signal, you can also take a look at <a href="...
40,248
<p>Are there any performance benchmarks for Mono compared to say Java in GNU/Linux?</p> <p>Have you ever tested Mono's performance?</p>
<p>There is an interesting post from Miguel on this. </p> <blockquote> <p>"Alvaro points out that in the Language Shootout Benchmark Mono comes in 18th place compared to Java's 10th place.</p> <p>We know that Sun's proprietary Java edition (not the open source one, as that one is nowhere to be found y...
<p>I've seen one <a href="http://shootout.alioth.debian.org/gp4/csharp.php" rel="nofollow noreferrer">http://shootout.alioth.debian.org/gp4/csharp.php</a></p>
49,894
<p>I am having problems with my tevo tarantula large bed 12Volt power supply, I am getting the thermal protection message when heating my bed with target temperature set to 115 degrees. The process slows down after reaching 90. I changed merlin settings to trigger thermal shutdown after 5minutes/2degrees and added a co...
<p>You need to increase the power of the heated bed. With a given amount of power, there is an upper limit to the maximum temperature you can reach because at a given point losses due to conduction, convection and radiation will balance out the heating power and the temperature will not increase any more.</p> <p>Somet...
<p>Some simple steps that may help to reach higher temperature:</p> <ol> <li>Check if you can use heated bed insulation of any kind - the most common approach is to use cork sheet</li> <li>Protect heated bed and printer from any possible air movements - arrange a set of walls around printer or just simply put it in th...
834
<p>Does anyone know of a good open-source zipping library for .NET?</p>
<p><a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/" rel="noreferrer">SharpZipLib</a></p> <p>Regarding the comments and other posts about the internal gzip implementation, <strong>they are <em>not</em> the same!</strong> GZip does not create the header required for archiving; it is only useful for "zipping"...
<p>Try checking out <a href="http://www.7-zip.org/" rel="nofollow noreferrer">7-zip</a>. It's open source and my fav zip program. very kewl. takes advantage of multi cores also.</p> <p>The .NET SDK is available <a href="http://www.7-zip.org/sdk.html" rel="nofollow noreferrer">here</a>.</p>
48,958
<p>I've used the <a href="http://groups.csail.mit.edu/pag/continuoustesting/" rel="noreferrer">MIT Continuous testing</a> plugin in the past, but it has long since passed out of date and is no longer compatible with anything approaching a modern release of Eclipse. </p> <p>Does anyone have a good replacement? Free, na...
<p>I found that <a href="http://infinitest.github.com/" rel="noreferrer">Infinitest</a> now has an Eclipse plugin that seems to work pretty well. </p>
<p>I've had good experience with infinitest on a small and simple project. I've not run into any issues with it and find it fast and helpful.</p>
10,269
<p>I have searched for various techniques on how to read/write dBase III (dbf) files using OLEDB or ODBC with C#/.NET. I have tried almost all of the tecniques posted, but without success. Can someone point me in the right direction?</p> <p>Thanks for your time.</p>
<p>Something like ... ?</p> <pre><code> ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" &amp; _ "Data Source=e:\My Documents\dBase;Extended Properties=dBase III" Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(ConnectionString ) dBaseConnection.Open() </code></pre> <p>From: <a href="http://bytes.c...
<p>This is a nice aproach, i didn't tested, but i will soon...</p> <p><a href="http://www.c-sharpcorner.com/uploadfile/rfederico/xbaseenginerfv12022005011623am/xbaseenginerfv.aspx" rel="nofollow noreferrer">http://www.c-sharpcorner.com/uploadfile/rfederico/xbaseenginerfv12022005011623am/xbaseenginerfv.aspx</a></p>
10,132
<p>Checkstyle reports this code as "The double-checked locking idiom is broken", but I don't think that my code actually is affected by the problems with double-checked locking.</p> <p>The code is supposed to create a row in a database if a row with that id doesn't exist. It runs in a multi-threaded environment and I ...
<p>Assuming you want that innermost line to read:</p> <pre><code>row = dao().create(id); </code></pre> <p>It's not a classic double-checked lock problem assuming <code>dao().fetch</code> is properly mutexed from the create method.</p> <p><strong>Edit</strong>: (code was updated)</p> <p>The classic problem of a doub...
<p>If you're tempted to write code like this, consider:</p> <ul> <li><p>Since Java 1.4, synchronizing methods has become pretty cheap. It's not free but the runtime really doesn't suffer that much that it's worthwhile to risk data corruption.</p></li> <li><p>Since Java 1.5, you have the Atomic* classes which allow you...
42,774
<p>recently I've been reading through Scott Meyers's excellent <a href="https://rads.stackoverflow.com/amzn/click/com/0321334876" rel="noreferrer" rel="nofollow noreferrer">Effective C++</a> book. In one of the last tips he covered some of the features from TR1 - I knew many of them via Boost. </p> <p>However, there w...
<p>It's like boost::ref, as far as I know. Basically, a reference which can be copied. Very useful when binding to functions where you need to pass parameters by reference.</p> <p>For example (using boost syntax):</p> <pre><code>void Increment( int&amp; iValue ) { iValue++; } int iVariable = 0; boost::function&l...
<p><code>reference_wrapper&lt;T&gt;</code> is an immensely useful and simple library. Internally the <code>reference_wrapper&lt;T&gt;</code> stores a pointer to T. But the interface it exposes does not contain any pointer notation. </p> <ul> <li>It allows the reference to behave like other simple objects - a <code>ref...
23,540
<p>I have a large dataset (over 100,000 records) that I wish to load into a DataGridView. The stored procedure that does this can take 10 seconds or more to complete.</p> <p>So far I have a BackgroundWorker preventing the UI from locking up, and have implemented a rudimentary 'Please Wait' dialog.</p> <p>What I'd lik...
<p>100,000 rows in a datagridview? just say "no"!</p> <ol> <li>the user cannot see 100,000 rows at a time</li> <li>the network traffic to transmit 100,000 rows is not insignificant</li> <li>the memory overhead for 100,000 datagridview rows is not insignificant</li> <li>the user only needs to select one row and go on</...
<p>I doubt you can do it in a DataGridView the same way as Management Studio does. I'd say that you get all the rows in your app at once when the stored procedure call completes. </p>
35,290
<p>I have mixed feelings about TDD. While I believe in testing I have a issues with the idea of the test driving my development effort.</p> <p>When you code to satisfy some tests written for an interface for requirements you have right now, you might shift your focus from building maintainable code, from clean design ...
<p>No.</p> <p>If done right, Test Driven Development IS your design tool.</p> <p>I hope you forgive me for linking to <a href="http://jonlimjap.net/2016/09/01/when-tdd-goes-red/" rel="nofollow noreferrer">my own blog entry, wherein I discuss the pitfalls of Test Driven Development that went wrong</a> simply because d...
<p>It's always a balance:<br> - too much TDD and you end up with code that works, but is a pain to work on.<br> - too much 'maintable code, clean design, and sound architecture' and you end up with <a href="http://www.joelonsoftware.com/articles/fog0000000018.html" rel="nofollow noreferrer">Architecture Astronauts</a...
10,567
<p>Is it possible to use something like:</p> <pre><code>require 'serialport.o' </code></pre> <p>with Shoes? serialport.o is compiled c code as a ruby extension.</p> <p>When I attempt to run the following code in shoes, I see no visible output to the screen and shoes crashes on OS X.</p> <p>Thank you</p> <p>CODE:<...
<p>You've probably already checked this, but does the same thing work if you aren't using Shoes? For example:</p> <pre><code>require "serialport.o" port = "/dev/tty.usbserial-A1001O0o" sp = SerialPort.new( port, 9600, 8, 1, SerialPort::NONE) sp.write( "1" ) sp.close </code></pre>
<p>I had a similar problem, but it's with winxp.</p> <p>Could you try like this?</p> <pre> Kernel::require "serialport.o" </pre>
45,247
<p>Every project invariably needs some type of reporting functionality. From a foreach loop in your language of choice to a full blow BI platform. </p> <blockquote> <p>To get the job done what tools, widgets, platforms has the group used with success, frustration and failure?</p> </blockquote>
<p>For knocking out fairly "run of the mill" reports, SQL Reporting Services is really quite impressive.</p> <p>For complicated analysis, loading the data (maybe pre-aggregated) into an Excel Pivot table is usually adequate for most users.</p> <p>I've found you can spend a lot of time (and money) building a comprehen...
<p>I'm the CTO at Windward and I do believe that <a href="http://www.windwardreports.com/" rel="nofollow">Windward Reports</a> is by far both the easiest to use and you can do more with it than any other reporting - and both traits are for the same reason, you design your reports in Word, Excel, &amp; PowerPoint.</p> ...
3,946
<p>I need to be able to merge two (very simple) JavaScript objects at runtime. For example I'd like to:</p> <pre><code>var obj1 = { food: 'pizza', car: 'ford' } var obj2 = { animal: 'dog' } obj1.merge(obj2); //obj1 now has three properties: food, car, and animal </code></pre> <p>Is there a built in way to do this? ...
<p><strong>ECMAScript 2018 Standard Method</strong></p> <p>You would use <a href="https://github.com/tc39/proposal-object-rest-spread" rel="noreferrer">object spread</a>:</p> <pre><code>let merged = {...obj1, ...obj2}; </code></pre> <p><code>merged</code> is now the union of <code>obj1</code> and <code>obj2</code>. Pro...
<pre><code>function extend() { var o = {}; for (var i in arguments) { var s = arguments[i]; for (var i in s) { o[i] = s[i]; } } return o; } </code></pre>
20,648
<p>I've been wanting to program for the Plan 9 operating system for a while. I'd really like to play around with a web app there. Of course, the only language I know for Plan 9 is C, and that doesn't seem ideal for web development. I also understand that it doesn't run apache or mysql either.</p> <p>What is the best w...
<p>Check out Kenji Arisawa's <a href="http://plan9.aichi-u.ac.jp/netlib/pegasus/" rel="noreferrer">Pegasus</a> (<a href="http://lsub.org/iwp9/cready/pegasus-5.pdf" rel="noreferrer">paper</a>) webserver for Plan 9.</p> <p>Plan 9 may have a reputation for being C-only, but several langauges, including Scheme, Ruby, Pyth...
<p><a href="http://werc.cat-v.org" rel="nofollow noreferrer">Werc</a> is a web framework designed to run on Plan 9 (and Plan 9 from User Space). It is built using the rc shell and following the classic Bell Labs 'tool philosophy'.</p> <p>Instead of a database, in keeping with the Unix tradition it uses plain text file...
11,657
<p>For decades, in the field of computing (except disk manufacturers), a KB (kilobyte) was understood to mean 1024 bytes. In the past few years, there has been a movement to use KiB ("kibibyte") to mean 1024 bytes, and <i>change the meaning of kilobyte to be 1000 bytes</i>, dooming us to many more years of confusion. O...
<p>KB is 1024 bytes, damnit.</p>
<p>Drivemaker/denary Kilobytes can burn in hell. Binary units for binary machines.</p>
21,311
<p>This case arises in a real-life situation where invalid data was in (and continuing to come into) an Oracle database which is extracted into a data processing system in Focus. Focus would choke and die on some rows with invalid time portions. The Oracle DBA would then go and copy the datetime into the affected col...
<p>Oracle generally doesn't allow it. The OCI layer can bypass the data type validation - Oracle basically trusts that what you put in those seven bytes make up a valid date. Similarly, at the OCI layer, Oracle can pass back seven bytes of 'date' and it is up to the client software to do whatever it wishes with those b...
<p>I cannot seem to find the bug in a quick Metalink search (if you haven't opened a SR with Oracle yet, I'd suggest doing so), but I know there were bugs in the OCI layer (Oracle Call Interface) that allowed buggy code to insert invalid dates. For the most part, those bugs have been corrected for some time, though, s...
25,159
<p><strong>Hi All</strong></p> <p>I want to ask, how to use policy injection application block to log methods entry and exit in these cases :</p> <p><strong>Case1 :</strong> in case of logging events handlers of a web form controls, you know the class let's say _Default must be inherited from class <strong>System.We...
<p>It sounds to me like they have some stupid requirements to be able to apply logging... This may be an offtopic, but you might want to look at Spring.AOP framework to apply logging to your objects without the need to inherit from MarshalByRefObject. (In multiple-inheritance-amputated languages it is an annoying and d...
<p>Regarding Case 2, your "static" class could not really be a static class. It could inherit from MarshalByRefObject or implement an interface that you specify. It could then have a private constructor and a singleton instance that you policy-inject. All of your static methods would just call corresponding (policy-inj...
40,267
<p>I am developing, a simple SharePoint Sequential Workflow which should be bound to a document library. When associating the little workflow to a document library, I checked these options </p> <ul> <li>Allow this workflow to be manually started by an authenticated user with Edit Items Permissions. </li> <li>Start t...
<p><strong>Finally, we got through the support services processes at Microsoft and got a solution!</strong></p> <p>First, Microsoft stated this to be a bug. It is a minor bug, because there is a good workaround, so it may take some longer time, until this bug will be fixed (the support technician said something with n...
<p>I've encountered this issue as well and found out that once a workflow has started, it cannot be re-started automatically, no matter how you update the item. You can, however, manually start the workflow again, as many times as you like.</p>
16,209
<p>How do you implement the search capabilities of Lucene.net in asp.net? If possible, please include links or example code.</p>
<p>I think <a href="http://www.mojoportal.com/" rel="noreferrer">mojoPortal</a> (ASP.NET CMS) uses Lucene.NET.</p> <p>Another nice example, <a href="http://www.cuyahoga-project.org/" rel="noreferrer">cuyahoga</a>, makes also use of NHibernate.</p> <p>You can take a look at their source...</p> <p><a href="http://www....
<p>Be sure to check out LINQ to Lucene. It's not feature complete, but it does make getting started a lot easier: <a href="http://www.codeplex.com/linqtolucene" rel="noreferrer">http://www.codeplex.com/linqtolucene</a></p>
44,126
<p>I'm using the <code>AsyncOperation</code> class to avoid having to write tons of "if (control.InvokeRequired) then/else" methods (as opposed to its traditional role in the Event-Based Asynchronous Pattern). In some cases, I don't really care about getting a notification when the worker thread is complete. Because ...
<p>Owen,</p> <p>If you know that in your situation you are not requiring the marshalling back onto the original callers thread, then you should just call OperationCompleted. There is an implict simple state machine held between your operation and its underlying SynchronizationContext. That in itself will not be a p...
<p>The documentation for PostOperationCompleted states "The AsyncOperation object will ensure that your delegate is invoked on the thread or context appropriate for the application model". This is very important if your GUI thread needs to do something once a background operation has completed. I think this is probably...
44,390
<p>I'm using the lines functionality to take an input and split up many variables before sending it off to a function. Please look at the run function and tell me why I get the following error. It seems like it should just assign the first string in ln to seq, but I get an error.</p> <pre> ERROR:dishonest.hs:33:11: ...
<p>First, let's look at how the compiler is interpreting it:</p> <pre><code>run :: String -&gt; String </code></pre> <p><code>String</code> is in fact <code>[Char]</code>.</p> <pre><code>run s = do ln &lt;- lines s ... </code></pre> <p>Simplifying things <em>a lot</em>, a <code>do</code> block must "run" in...
<p>I'm not sure if this is right, but the issue <em>might</em> lay in the fact that <code>&lt;-</code> isn't an assignment operator, as you <em>seem</em> to be using it; it essentially unpacks a value from a monad. But I'm not really sure if that's the cause of your issue or not.</p>
37,438
<p>I'm looking for a good method of generating an iCalendar file (*.ics) in c# (asp.net). I've found a couple resources, but one thing that has been lacking is their support for <strong>quoted-printable</strong> fields - fields that have carriage returns and line feeds.</p> <p>For example, if the <strong>description<...
<p>I use <a href="http://sourceforge.net/projects/dday-ical/" rel="noreferrer">DDay.Ical</a>, its good stuff. Has the ability to open up an ical file and get its data in a nice object model. It says beta, but it works great for us.</p> <h1>Edit Nov 2016</h1> <p>This library has been deprecated, but was picked up and ...
<p>iCal can be complicated, so I recommend using a library. DDay is a good free solution. Last I checked it didn't have full support for recurring events, but other than that it looks really nice. Definitely test the calendars with several clients.</p>
3,186
<p>If I have the code:</p> <pre><code>int f(int a) { return a; } double f(double g) { return g; } int main() { int which = f(1.0f); } </code></pre> <p>Which overload of <em>f</em> is called, and why?</p>
<p>The return type is not considered for overload purposes at all, thus you'll get the double version.</p>
<p>To understand why it's this way, consider this call:</p> <pre><code>int bar = f(g(h(foo))); </code></pre> <p>As overload resolution involves only arguments, you can deduce h, then g and finally f, independently. If the return value was involved, you'd need to deduce them concurrently. If each has 10 overloads, in ...
43,417
<p>In cleaning up <a href="https://stackoverflow.com/questions/229447/how-to-create-a-two-sided-unique-index-on-two-fields#229521">this answer</a> I learnt a bit about <code>TRIGGER</code>s and stored procedures in MySQL, but was stunned that, while <code>BEFORE INSERT</code> and <code>BEFORE UPDATE</code> triggers cou...
<p>From this <a href="https://web.archive.org/web/20180330233216/http://www.brokenbuild.com/blog/2006/08/15/mysql-triggers-how-do-you-abort-an-insert-update-or-delete-with-a-trigger/" rel="nofollow noreferrer">blog post</a></p> <blockquote> <p>MySQL Triggers: How do you abort an INSERT, UPDATE or DELETE with a tri...
<p>in MS SQL you could make it work using proper syntax:</p> <pre><code>IF UPDATE(column_name) BEGIN RAISEERROR ROLLBACK TRAN RETURN END </code></pre> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc164047.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc164047.aspx</a></p>
28,444
<p>I have a c++ program that is using the openMPI library to pass messages between different processors. It is a parallel program that uses a genetic algorithm to get a good solution for the traveling salesperson problem. I am trying to set up the MPI environment on my two dual processor computers at my house so that...
<p>I found out what the problem was. I had two packages installed that both used the mpirun command. I believe it was both openmpi and mpich packages. I removed openmpi and it worked.</p>
<p>Perhaps your initialization is wrong or you have some error checking the rank. This should be the right way to do this:</p> <pre><code>MPI_Init(&amp;argc, &amp;argv); MPI_Comm_size(MPI_COMM_WORLD, &amp;size); MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank); printf("I am process %d of %d.\n", rank, size); </code></pre> <p...
45,189
<p>I'm looking for a simple, easy to understand algorithm to alphabetically sort an array of characters in C.</p>
<p>characters in C have numeric values that happen to be in order, so you just treat your characters like integers. the C standard library includes a 'qsort' function. Use that (<code>man qsort</code> on a linux-like system). You might have to convert upper-case letters to lowercase to simplify things, but that's tr...
<p>Easy? Do a bubble sort.</p> <p>This is java and int rather than char, but you can easily adapt it...</p> <pre><code>int[] bubble(int a[]) { for (int i = a.length; --i&gt;=0; ) { for (int j = 0; j&lt;i; j++) { if (a[j] &gt; a[j+1]) { i...
14,919
<p>Now I know about the "normal" CSS list styles (roman, latin, etc) and certainly in years past they were somewhat inflexible in not allowing things like:</p> <p>(a)</p> <p>or </p> <p>a)</p> <p>only</p> <p>a.</p> <p>Now I believe that you can get an effect like the above with the :before and :after pseudo-elemen...
<p>See <a href="http://www.w3.org/TR/CSS2/generate.html" rel="noreferrer">Generated content, automatic numbering, and lists</a>.</p> <blockquote> <p>This example shows a way to number chapters and sections with "Chapter 1", "1.1", "1.2", etc.</p> </blockquote> <pre><code>H1:before { content: "Chapter " coun...
<p>A simple markup example would be:</p> <pre><code>&lt;ol&gt; &lt;li&gt;level one&lt;/li&gt; &lt;ol start="10"&gt; &lt;li&gt;level two&lt;/li&gt; &lt;li&gt;level two&lt;/li&gt; &lt;ol start="110"&gt; &lt;li&gt;level three&lt;/li&gt; &lt;/ol&gt; &lt;li&gt;l...
45,421
<p>I hope someone can guide me as I'm stuck... I need to write an emergency broadcast system that notifies workstations of an emergency and pops up a little message at the bottom of the user's screen. This seems simple enough but there are about 4000 workstations over multiple subnets. The system needs to be almost rea...
<p>Consider using WCF callbacks mechanism and events. There is <a href="http://msdn.microsoft.com/en-us/magazine/cc163537.aspx" rel="nofollow noreferrer">good introduction</a> by Juval Lowy. </p> <p>Another pattern is to implement <a href="http://xmpp.org/extensions/xep-0124.html" rel="nofollow noreferrer">blocking w...
<p>This problem i think is best solved with socket.</p> <p>Open a connection to the server, and keep it open.</p>
49,405
<p>What is the best open source java workflow framework (e.g. OSWorkflow, jBPM, XFlow etc.)?</p>
<p><a href="http://eprints.qut.edu.au/archive/00014320/" rel="nofollow noreferrer">Here's an article</a> that compares kBPM, OpenWFE, and Enhydra Shark that looks like it has some good, thorough info.</p>
<p>I'll cast a vote for jBPM. We used it on a larg-ish ETL platform in-house and it seemed to work quite well. I don't have anything to compare it to, however.</p>
9,092
<p>Using gnuplot 4.2, is it possible to obtain the value of a specific column/row and use that value somehow?</p> <p>For example, let's say my datafile contains the following</p> <pre><code>#1 2 7 13 5 11 23 17 53 12 </code></pre> <p>For a simple plot where column 1 is the x axis and column 2 is the y axis I woul...
<p>Using the running averages demo, I managed to achieve a plot normalized to the first value of the second column.</p> <p>The <code>base</code> variable is used to store the reference value, and the <code>first</code> function initializes <code>base</code> on the first row.</p> <pre><code>first(x) = ($0 &gt; 0 ? bas...
<p>ad a new column full of 13, then use:</p> <p>plot 'datafile' using 1:($2/$3)</p>
29,991
<p>I know there are emulators, but is this good enough? If someone is serious about iPhone development, do they absolutely need an iPhone?</p>
<p>Just my personal opinion: if you're serious it means that you're committed to quality of your product. If you're committed to quality there is no way to deliver a product without actually launching it on the target platform :)</p> <p>As noted in other posts you'll have tough time testing the multi-touch screen and ...
<p>I've tried iPhoney and compared to my iPhone (Mark 1) it's not the same, it's close - but not close enough to rely on if the interface is of importance to you.</p>
14,721
<p>I'm fairly new at programming, but I've wondered how shell text editors such as vim, emacs, nano, etc are able to control the command-line window. I'm primarily a Windows programmer, so maybe it's different on *nix. As far as I know, it's only possible to print text to a console, and ask for input. How do text ed...
<p>By using libraries such as the following which, in turn, use escape character sequences</p> <pre> NAME ncurses - CRT screen handling and optimization package SYNOPSIS #include DESCRIPTION The ncurses library routines give the user a terminal-independent method of updating character screens...
<p>More Windows command line specific, the app typically calls DOS or BIOS functions that do the same. Sometimes ANSI command code support is available, sometimes it isn't (depending on exact MS OS version and whether or not it's configured to load it).</p>
21,621
<p>Using SQLite3 with Python 2.5, I'm trying to iterate through a list and pull the weight of an item from the database based on the item's name.</p> <p>I tried using the "?" parameter substitution suggested to prevent SQL injections but it doesn't work. For example, when I use:</p> <pre><code>for item in self.invent...
<p>The <code>Cursor.execute()</code> method expects a sequence as second parameter. You are supplying a string which happens to be 8 characters long.</p> <p>Use the following form instead:</p> <pre><code>self.cursor.execute("SELECT weight FROM Equipment WHERE name = ?", [item]) </code></pre> <p>Python library refere...
<p>Try</p> <pre><code>execute("select fact from factoids where key like ?", "%%s%" % val) </code></pre> <p>You don't wrap anything around the <code>?</code> at all, Python sqlite will correctly convert it into a quoted entity.</p>
28,331
<p>When I run a wxPython application, it prints the string &ldquo;Redirecting output to win32trace remote collector&rdquo;and I must open PythonWin's trace collector tool to view that trace output.</p> <p>Since I'm not interested in collecting this output, how should I disable this feature?</p>
<p>You can even pass that when you instantiate your wx.App():</p> <pre><code>if __name__ == "__main__": app = wx.App(redirect=False) #or 0 app.MainLoop() </code></pre> <p><a href="http://wxpython.org/docs/api/wx.App-class.html#__init__" rel="nofollow noreferrer">wxPython wx.App docs</a></p>
<p>This message deceived me into thinking win32trace was preventing me from seeing uncaught exceptions in the regular console (of my IDE). The real issue was that wxPython by default redirects stdout/stderr to a popup window that quickly disappeared after an uncaught exception. To solve <em>that</em> problem, I simply ...
39,482
<p>Can you have smart behavior for the home key in Emacs? By smart I mean that instead of going to the character number 0, it should go to the first non-blank character, and go to 0 on a second pressing, and back to the first non-blank in a third and so on. Having smart end would be nice as well.</p>
<pre><code>(defun smart-beginning-of-line () "Move point to first non-whitespace character or beginning-of-line. Move point to the first non-whitespace character on this line. If point was already at that position, move point to beginning of line." (interactive "^") ; Use (interactive) in Emacs 22 or older (let ...
<p>I adapt @Vucovic code to jump to <code>beggining-of-line</code> first:</p> <pre><code>(defun my-smart-beginning-of-line () "Move point to beginning-of-line. If repeat command it cycle position between `back-to-indentation' and `beginning-of-line'." (interactive "^") (if (and (eq last-command 'my-smart-beginni...
17,518
<p>The XML Schema Part 2 specifies that an instance of a datatype that is defined as boolean can have the following legal literals {true, false, 1, 0}. The following XML, for example, when deserialized, sets the boolean property "Emulate" to <code>true</code>.</p> <pre><code>&lt;root&gt; &lt;emulate&gt;1&lt;/emula...
<p>You can also do this by using some XmlSerializer attribute black magic:</p> <pre><code>[XmlIgnore] public bool MyValue { get; set; } /// &lt;summary&gt;Get a value purely for serialization purposes&lt;/summary&gt; [XmlElement("MyValue")] public string MyValueSerialize { get { return this.MyValue ? "1" : "0"; }...
<p>No, not using the default System.Xml.XmlSerializer: you'd need to change the data type to an int to achieve that, or muck around with providing your own serialization code (possible, but not much fun). </p> <p>However, you can simply post-process the generated XML instead, of course, either using XSLT, or simply us...
11,003
<p>I have Default.aspx page, which inherits from BasePage.cs, which inherits from System.Web.UI.Page. BasePage is where I do some common things every page must do upon loading.</p> <p>In BasePage, lets say I'm checking for X. If X=1, then I will redirect to my "Discontinued.aspx" page immediately and stop execution ...
<p>are you exiting from the function that calls redirect, e.g.</p> <pre><code>...redirect(stopit,true); return; </code></pre> <p>?</p>
<p>For an unconditional termination, you could try a</p> <pre><code>Response.End() </code></pre>
48,750
<p>I've got a couple of rogue spid's in my database that I can see are sleeping when I log in as <code>sa</code> and use <code>sp_who</code>, but attempts to use <code>kill &lt;spid&gt;</code> to eliminate them have failed and I don't actually have access to the server itself to bounce it. Is there any other way of kil...
<p>System processes cannot be killed. For example in the output of sp_who where cmd is NETWORK HANDLER, MIRROR HANDLER and CHECKPOINT SLEEP (or rarely, CHECKPOINT) and AUDIT PROCESS cannot be killed. If they have status as "recv sleep", "send sleep", "alarm sleep" and "lock sleep" , they can be killed.</p> <p>In sp_wh...
<p>I have a client application that sometimes does similar things. The client is usually in the middle of a select, but is no longer retrieving rows. (This may be a client side cursor, but I'm not sure). These spids seem un-killable. I have to find the user and ask them to log off.</p> <p>The other scenario in which I...
47,927
<p>What is the best way of implementing a cache for a PHP site? Obviously, there are some things that shouldn't be cached (for example search queries), but I want to find a good solution that will make sure that I avoid the 'digg effect'.</p> <p>I know there is WP-Cache for WordPress, but I'm writing a custom solution...
<p>You can use <a href="http://uk3.php.net/manual/en/function.ob-get-contents.php" rel="noreferrer">output buffering</a> to selectively save parts of your output (those you want to cache) and display them to the next user if it hasn't been long enough. This way you're still rendering other parts of the page on-the-fly ...
<p><a href="https://whatcd.github.io/Gazelle/" rel="nofollow noreferrer">Project Gazelle</a> (an open source torrent site) provides a step by step guide on setting up Memcached on the site which you can easily use on any other website you might want to set up which will handle a lot of traffic.</p> <p>Grab down the so...
7,896
<p>For a very simple ajax name lookup, I'm sending an id from the client webpage to the server (Tomcat 5.5, Java 5), looking it up in a database and returning a string, which is assigned to a javascript variable back in the client (and then displayed).</p> <p>The javascript code that receives the value is pretty stand...
<p>Here is the Powershell way:</p> <pre><code>gci -ex "*.xyz" | ?{!$_.PsIsContainer} | ren -new {$_.name + ".txt"} </code></pre> <p>Or to make it a little more verbose and easier to understand:</p> <pre><code>Get-ChildItem -exclude "*.xyz" | WHere-Object{!$_.PsIsContainer} | Rename-Item -newname {$_.name +...
<p>Consider the DOS command FOR in a standard shell.</p> <pre><code>C:\Documents and Settings\Kenny&gt;help for Runs a specified command for each file in a set of files. FOR %variable IN (set) DO command [command-parameters] %variable Specifies a single letter replaceable parameter. (set) Specifies a set o...
31,380
<p>By means of a regular expression and Greasemonkey I have an array of results that looks like:<br> <code>choice1, choice2, choice3, choice3, choice1, etc..</code></p> <p>My question is how do I tally up the choices so I know how many times choice1 is in the array, choice2 is in the array, etc. if I do not know e...
<p>One technique would be to iterate over the choices and increment a counter associated to each unique choice in an object property.</p> <p>Example:</p> <pre><code>var choiceCounts = {}; for (var iLoop=0; iLoop &lt; aChoices.length; iLoop++) { var keyChoice = aChoices[iLoop]; if (!choiceCounts[keyChoice]) { ...
<p><strong><em>Sort the array first</em></strong>, then you can make a single sweep to count occurrences (similar to Ryan's suggestion above).</p>
45,286
<p>How long do you normally test an update for Zend Framework before pushing it out into a productions project. We can break this question up into minor updates 1.6.0 -> 1.6.1 or maybe a major update 1.6.2 -> 1.7.0. Obviously you don't release it if it add bugs to your code.</p> <p>Also, as with most other server so...
<p>It seems like the best method would be to have a comprehensive set of tests that exercised all the functionality in your application. With a good method for testing it seems like you could push it into production pretty quickly.</p> <p>Another simple thing you can do to help you make your decision would be to simp...
<p>Using unit testing will help catch some of the deltas. Zend Framework now comes with Zend_Test to make testing applications a bit easier. I updgrade between projects (so new projects that are coming up will get the latest version).</p>
39,110
<p>Is there a way of ordering a list of objects by a count of a property which is a collection? </p> <p>For arguments sake let's say I have a question object with a question name property, a property that is a collection of answer objects and another property that is a collection of user objects. The users join the qu...
<p>Forget about the term "best". No matter which hash algorithm anyone might come up with, unless you have a very limited set of data that needs to be hashed, every algorithm that performs very well on average can become completely useless if only being fed with the right (or from your perspective "wrong") data.</p> <...
<p>Here is the <a href="http://en.wikipedia.org/wiki/Cuckoo_hashing" rel="nofollow noreferrer">Cuckoo Hash</a>.</p> <blockquote> <p>Lookup requires inspection of just two locations in the hash table, which takes constant time in the worst case (see Big O notation). This is in contrast to many other hash table algorithm...
31,298
<p>Why does the Ender 3 only have 3 limit switches instead of 6?</p> <p>How does it handle crashes on other sides? Is it worth adding them with a new mainboard?</p>
<p>While better fitted to our friends at <a href="https://law.stackexchange.com/questions/tagged/copyright">law.SE</a>, the general gist is: <strong>No.</strong></p> <p>Art is protected by copyright, and any adaption (<em>derivative work</em>) requires the OK from the right holders <em>per se</em>. Only 70-75 years aft...
<p>This is something that might have a precedent, where the line is blurry, someone might have already tried, and in that case the judge's decision in that court case is the official interpretation of the law towards that specific scenario.</p> <p>There might also be definitive laws regarding &quot;derived works&quot;....
1,795
<p>I'm trying to add a Web Reference to a VS2008 .Net 3.5 Console Application but the option's not there. The options to "Add Reference" and "Add Service Reference" are there.</p>
<p>Kirk Evans blogged about that very issue <a href="http://blogs.msdn.com/kaevans/archive/2008/03/18/where-the-heck-is-add-web-reference-in-visual-studio-2008.aspx" rel="noreferrer">Here</a></p> <p>Basically, you just add a service reference. A web reference is just one type of service you can add.</p>
<p>I think you need to pass the url to the asmx, not the wsdl</p>
38,433
<p>Suppose a header file defines a function template. Now suppose two implementation files <code>#include</code> this header, and each of them has a call to the function template. In both implementation files the function template is instantiated with the same type.</p> <pre><code>// header.hh template &lt;typename ...
<p>In order to support C++, the linker is smart enough to recognize that they are all the same function and throws out all but one.</p> <p>EDIT: clarification: The linker doesn't compare function contents and determine that they are the same. Templated functions are marked as such and the linker recognizes that they h...
<p>This is more or less a special case just for templates.</p> <p>The compiler only generates the template instantiations that are actually used. Since it has no control over what code will be generated from other source files, it has to generate the template code once for each file, to make sure that the method gets ...
29,165
<p>It seems to me that most people write their tests against in-memory, in-process databases like SQLite when working with NHibernate. I have this up and running but my first test (that uses NHibernate) always takes between 3-4 seconds to execute. The next test runs much faster.</p> <p>I am using FluentNhibernate to d...
<p>I am using the Repository Pattern to perform Database operations, and whenever I run my Tests I just run the higher-level tests that simply Mock the Repository (with RhinoMocks). </p> <p>I have a seperate suite of tests that explicitly tests the Repository layer and the NHibernate mappings. And those usually don't ...
<p>Have you tried changing some of the defaults in the optional configuration properties? The slowdown is most likely related to certain optimizations nhibernate does with code generation.</p> <p><a href="http://nhibernate.info/doc/nh/en/index.html#configuration-optional" rel="nofollow noreferrer">http://nhibernate.in...
43,069
<p>I've always wondered why the C++ Standard library has instantiated basic_[io]stream and all its variants using the <code>char</code> type instead of the <code>unsigned char</code> type. <code>char</code> means (depending on whether it is signed or not) you can have overflow and underflow for operations like get(), w...
<p>Possibly I've misunderstood the question, but conversion from unsigned char to char isn't unspecified, it's implementation-dependent (4.7-3 in the C++ standard).</p> <p>The type of a 1-byte character in C++ is "char", not "unsigned char". This gives implementations a bit more freedom to do the best thing on the pla...
<p>I think <a href="https://stackoverflow.com/questions/10672587/representing-blobs-in-c#comment13846926_10672587">this</a> comment explains it well. To quote:</p> <blockquote> <p>signed char and unsigned char are arithmetic, integral types just like int and unsigned int. On the other hand, char is expressly intende...
35,045
<p>I tried doing this:</p> <pre><code>root.addEventListener("click", function () { navigateToURL(ClickURLRequest,"_self"); }); </code></pre> <p>And it does add the event listener. I like using closures because they work well in this situation,</p> <p>however, removing the event listener requires a...
<p>Here's a generic way of removing event listeners that i have used on production projects</p> <pre><code> addEventListener ( Event.ACTIVATE, function(event:Event):void { (event.target as EventDispatcher).removeEventListener(event.type, arguments.callee) } ) </code></pre>
<p>I dont know what you're actually doing but in this particular example perhaps you could have a _clickEnabled global variable.</p> <p>Then inside the event handler you just check _clickEnabled, and if its false you just <code>return</code> immediately.</p> <p>Then you can enable and disable the overall event withou...
21,671
<p>In the grails-framework some objects are using log. This is normally injected by grails. It works on execution of <code>grails test-app</code>. But the same test (an integration-test) fails on execution of <code>grails test-app -integration</code>.</p> <p>What goes wrong here and can I force the injection of the lo...
<p>What version of grails are you using? It's working fine for both situations for me on 1.0.4 (the latest).</p> <p>I create a new blank app and created a service class with an integration test:</p> <p>FooService.groovy: </p> <pre><code>class FooService { def logSomething(message) { log.error(message) ...
<p>I'm using 1.3.2, and logging in test is working fine. Just be sure that you have specified a log4j configuration for the test environment.</p>
38,722
<p>I have an app using PHP and the PayPal API. The basic way it works to get a payment is that you do a web service call to PayPal to get a token and then do a browser redirect to PayPal with that token for the user to pay. After the payment details have been confirmed, PayPal redirects back to the URL you originally s...
<p>Just an idea ...</p> <p>Do you have <code>session.referer_check</code> set to your host perhaps? The default is the empty string, but it might have been changed ... and when the page 'comes back' from PayPal, php will trash the session info.</p> <p>You can check the <code>session.referer_check</code> with phpinfo(...
<p>Can you do a phpinfo() and tell if session.auto_start is true?</p>
22,243
<p>From <a href="http://support.microsoft.com/kb/317277" rel="nofollow noreferrer">http://support.microsoft.com/kb/317277</a>: If Windows XP restarts because of a serious error, the Windows Error Reporting tool prompts you...</p> <p>How can <em>my</em> app know that "Windows XP has restarted because of a serious error...
<p>Note: this is a good question for a <strong><a href="https://stackoverflow.com/questions/172184">code-challenge</a></strong></p> <p>Here are some executable codes, but feel free to add other solutions, in other languages:</p> <hr> <p>The uptime might be a good indication:</p> <pre><code>net stats workstation | f...
<p>You can look for a memory or kernel dump file with a recent creation time, if dump file generation has been enabled (or, rather, not disabled since it's on by default.)</p>
20,600
<p>Does anyone else find that when they open a saved connection in Remote Desktop it sometimes sets up the login as Username@IpAddress and other times (seemingly at random) sets it up as IpAddress@Username?</p> <p>Does anyone know what the logic is behind the two / why this happens?</p>
<p>I use Remote Desktop quite a bit, but I use the Domain\Username syntax instead of Username@Domain syntax, and I've never seen it get confused by that.</p>
<p>If you rdp a lot, especially to several machines, then I would highly recommend you look at the free <a href="http://www.code4ward.net/main/" rel="nofollow noreferrer">royalts</a> tool. I find it great to give context and it can remember passwords if that does not break your rules. Easy to query who else is on rem...
33,475
<p>I'm working on a small Java application (Java 1.6, Solaris) that will use multiple background threads to monitor a series of text files for output lines that match a particular regex pattern and then make use of those lines. I have one thread per file; they write the lines of interest into a queue and another backgr...
<p>Could you keep a record of each of the length of each file? When the current length subsequently goes back to zero or is smaller than the last time you recorded the length, you know the file has been restarted by the app?</p>
<p>You could indicate somewhere on the filesystem that indicates you are reading a given file. Suppose next to the file being read (a.txt), you create a file next to it (a.txt.lock) that indicates a.txt is being read. When your process is done with it, a.txt.lock is deleted. Every time a process goes to open a file to ...
16,699
<p>For those of us who use standard shared hosting packages, such as GoDaddy or Network Solutions, how do you handle datetime conversions when your hosting server (PHP) and MySQL server are in different time zones?</p> <p>Also, does anybody have some best practice advice for determining what time zone a visitor to you...
<p>As of PHP 5.1.0 you can use <a href="http://www.php.net/manual/en/function.date-default-timezone-set.php" rel="noreferrer"><em>date_default_timezone_set()</em></a> function to set the default timezone used by all date/time functions in a script. </p> <p>For MySql (quoted from <a href="http://dev.mysql.com/doc/refma...
<p>I save all my dates as a bigint due to having had issues with the dateTime type before. I save the result of the time() PHP function into it, now they count as being in the same timezone :)</p>
3,903
<p>I have a form made up of multiple, optional subparts - each of which is enclosed in a</p> <pre><code>&lt;div class="details"&gt;&lt;/div&gt; </code></pre> <p>When editing the form I would like to hide those subparts which aren't as yet completed, and obviously I would like to do it unobtrusively. To simplify thing...
<p>No selector love? Not exactly sure it's what you're really looking for but this hides all details elements with an empty input inside. Perhaps it's a clue.</p> <pre><code>&lt;div class="details"&gt; &lt;input type="text" name="surname" /&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(".details in...
<p>This may have just been a typo, but you also don't need / shouldn't have a CSS class name of ".details" in your markup, just "details". The dot prefix is part of the CSS/jQuery selector syntax.</p> <p>According to the <a href="http://docs.jquery.com/Selectors/empty" rel="nofollow noreferrer">documentation</a>, ":em...
34,829
<p>I have a tree encoded in a MySQL database as edges:</p> <pre><code>CREATE TABLE items ( num INT, tot INT, PRIMARY KEY (num) ); CREATE TABLE tree ( orig INT, term INT FOREIGN KEY (orig,term) REFERENCES items (num,num) ) </code></pre> <p>For each leaf in the tree, <code>items.tot</cod...
<p>You sound as if you're looking for three major things: code templates, refactoring tools, and auto-completion.</p> <p>The good news is that Xcode 3 and later come with superb auto-completion and template support. By default, you have to explicitly request completion by hitting the escape key. (This actually works...
<p>I found some xtmacro files in Xcode.app package: <strong>/Developer/Applications/Xcode.app/Contents/PlugIns/TextMacros.xctxtmacro/Contents/Resources</strong></p> <p>Installed Xcode ver. 3.2.5.</p>
4,080
<p>One problem that I come across regularly and yet don't have a solution to is to restrict or permit access to specific entities in a system. Some companies (banks, for example) have very strict policies regarding which employees may access certain information. For example, an employee at a specific branch may access ...
<p>I've beat my head against this wall on several occasions.</p> <p>The best solution I've come to was to model everything in a tree hierarchy, where every domain class is an branch in the tree, and instances are leaves of that branch. Leaves can have veins if you need to secure parts of instances. Each branch has i...
<p>Have you looked into the <a href="http://msdn.microsoft.com/en-us/library/930b76w0(VS.80).aspx" rel="nofollow noreferrer">Code Access Security</a> model that Microsoft created for the .NET framework? I have only looked at it on a few occasions myself, but the jist of it is that you can lock down certain objects and ...
29,037
<p>std::next_permutation (and std::prev_permutation) permute all values in the range <code>[first, last)</code> given for a total of n! permutations (assuming that all elements are unique).</p> <p>is it possible to write a function like this:</p> <pre><code>template&lt;class Iter&gt; bool next_permutation(Iter first,...
<p>To iterate over nPk permutations, I've used the <code>for_each_permutation()</code> algorithm presented in <a href="http://www.ddj.com/cpp/184401912" rel="nofollow noreferrer">this old CUJ article</a> before. It uses a nice algorithm from Knuth which rotates the elements in situ, leaving them in the original order ...
<p>An algorithmic simplification would be to split this into two separate steps.</p> <ul> <li>Generate a list of all possible selections of R elements out of the original data.</li> <li>For each of those selections, create all possible permutations of the selected elements.</li> </ul> <p>By interleaving those operati...
29,410
<p>I am relatively new to JavaScript and am trying to understand how to use it correctly.</p> <p>If I wrap JavaScript code in an anonymous function to avoid making variables <code>public</code> the functions within the JavaScript are not available from within the html that includes the JavaScript. </p> <p>On initiall...
<p>If you aren't using a javascript framework, I strongly suggest it. I use MooTools, but there are many others that are very solid (Prototype, YUI, jQuery, etc). These include methods for attaching functionality to the DomReady event. The problem with:</p> <pre><code>window.onload = function(){...}; </code></pre> <p...
<p>It might be best not to wrap everything in an anonymous function and just hope that it is executed. You could name the function, and put its name in the body tag's onload handler. This should ensure that it's run each time the page is loaded.</p>
9,352
<p>Our app (already deployed) is using an Access/Jet database. The upcoming version of our software requires some additional columns in one of the tables. I need to first check if these columns exist, and then add them if they don't.</p> <p>Can someone provide a quick code sample, link, or nudge in the right direction...
<p>Off the top of my head, but something like:</p> <pre><code>Dim conn as New AdoConnection(someConnStr) Dim cmd as New AdoCommand cmd.Connection = conn cmd.CommandText = "ALTER TABLE X ADD COLUMN y COLUMNTYPE" cmd.ComandType = CommandType.Text cmd.ExecuteNonQuery() </code></pre>
<p>Query the table for the field you expect and handle the error if the field is not there.</p> <p>Too add the column, just feed the database an <a href="http://msdn.microsoft.com/en-us/library/bb177883.aspx" rel="nofollow noreferrer">alter table</a> SQL statement.</p>
31,335
<p>First, I'd like to establish the acceptable end-to-end latency for a real-time system in the financial world is less than 200ms. Okay, here's what I'm after. In the design of real-time systems, there are "design patterns" (or techniques) that will increase the performance (i.e. reduce processing time, improve scalab...
<p>For general real-time system work, the classic rule is to go after variability and kill it. Real hard real-time means using static schedules, streamlined operating systems, efficient device drivers, and rock-hard priorities. No dynamic or adaptive stuff is feasible, if you really want computation X to end within a ...
<p>Don't "fix" anything unless you know for sure that it's "broken".</p> <p>The first thing I'd do is tune the blazes out of that program that has to run fast. I would use my <a href="http://www.wikihow.com/Optimize-Your-Program%27s-Performance" rel="nofollow noreferrer">favorite technique</a>. Then, chances are, ther...
17,622
<p>What is the smartest way to get an entity with a field of type List persisted?</p> <h2>Command.java</h2> <pre><code>package persistlistofstring; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence...
<p>Use some JPA 2 implementation: it adds a @ElementCollection annotation, similar to the Hibernate one, that does exactly what you need. There's one example <a href="http://jazzy.id.au/2008/03/24/jpa_2_0_new_features_part_1.html" rel="noreferrer">here</a>.</p> <p><b>Edit</b></p> <p>As mentioned in the comments below...
<p>My fix for this issue was to separate the primary key with the foreign key. If you are using eclipse and made the above changes please remember to refresh the database explorer. Then recreate the entities from the tables.</p>
36,533
<p>I'm looking for good/working/simple to use PHP code for parsing raw email into parts.</p> <p>I've written a couple of brute force solutions, but every time, one small change/header/space/something comes along and my whole parser fails and the project falls apart.</p> <p>And before I get pointed at PEAR/PECL, I need ...
<p>What are you hoping to end up with at the end? The body, the subject, the sender, an attachment? You should spend some time with <a href="http://www.faqs.org/rfcs/rfc2822.html" rel="noreferrer">RFC2822</a> to understand the format of the mail, but here's the simplest rules for well formed email:</p> <pre><code>HE...
<p>yeah, ive been able to write a basic parser, based off that rfc and some other basic tutorials. but its the multipart mime nested boundaries that keep messing me up.</p> <p>i found out that MMS (not SMS) messages sent from my phone are just standard emails, so i have a system that reads the incoming email, checks t...
3,397
<p>I am trying to get the OpenNetCF.Net FTP Components working with my PDA application. I am struggling to get it doing any more than connecting to the server and wondered if anyone knew of any sample code I could use to learn how to use it with?</p> <p>I need to be able to download and upload files, as well as determ...
<p>I don't like the classes in the OpenNETCF.Net.FTP namespace (the ones in the Smart Device Framework). They're based on streams just like the full framework version (which is why we did them that way) but I find usage to be confusing (though any desktop FTP sample should work as a basis). I wrote a <a href="http://...
<p>This looks like the answer: </p> <p><a href="http://community.opennetcf.com/competition/folders/opennetcfnetftp/entry64583.aspx" rel="nofollow noreferrer">http://community.opennetcf.com/competition/folders/opennetcfnetftp/entry64583.aspx</a></p>
45,862
<p>The app uses DLLImport to call a legacy unmanaged dll. Let's call this dll Unmanaged.dll for the sake of this question. Unmanaged.dll has dependencies on 5 other legacy dll's. All of the legacy dll's are placed in the WebApp/bin/ directory of my ASP.NET application.</p> <p>When IIS is running in 5.0 isolation mode,...
<p>Solution: Create a new thread in which to run the imported dll, assign more memory to its stack.</p>
<p>What is the error given? if the application truly crashed you might have to go into the Windows Event Log to get the stack trace of the error.</p>
18,634
<p>There was a previous question suggesting that the <a href="https://3dprinting.stackexchange.com/questions/tagged/support" class="post-tag" title="show questions tagged &#39;support&#39;" rel="tag">support</a> and <a href="https://3dprinting.stackexchange.com/questions/tagged/support-materials" class="post-tag" title...
<p>I object to merging the two, my reasoning having been explained in chat several times, and brought to point by tbm115:</p> <blockquote> <p>Tbm0115 - &quot;support-material&quot; should define the material-type (ie. PLA, ABS, PVA, etc.) which in FDM is usually the same as the print-material. However, in the case of m...
<p>Both tbm0115 and Sean make very good arguments and I am really on the fence on this one... So, I am withdrawing my solution for the moment, as I am not sure that I agree with the amalgamation of the two tags. However, <em>if</em> they are to be amalgamated then I would propose that this would be the way to do it...<...
58
<p>Does anybody know of any sample databases I could download, preferably in CSV or some similar easy to import format so that I could get more practice in working with different types of data sets? </p> <p>I know that the Canadian Department of Environment has <a href="http://www.climate.weatheroffice.ec.gc.ca/Welco...
<p>The datawrangling blog posted a nice list a while back:</p> <p><a href="http://www.datawrangling.com/some-datasets-available-on-the-web" rel="noreferrer">http://www.datawrangling.com/some-datasets-available-on-the-web</a></p> <p>Includes financial, government data (labor, housing, etc.), and too many more to list ...
<p>What database engine are you importing into? That will help determine what formats you can include in your search.</p> <p>The <a href="http://www.ferc.gov/docs-filing/eqr/soft-tools/sample-csv.asp" rel="nofollow noreferrer">Federal Energy Regulatory</a> Commission has some sample data for download in CSV format.</p...
8,126
<p>I've got a stock standard ASP.NET website. Anyone can read/view any page (except the admin section) but when someone wants to contribute, they need to be logged in. Just like most contribution sites out there.</p> <p>So, if i have my OWN login control or username/password/submit input fields, why would i want to ha...
<p>You can authorize your users how ever you want. FormAuthentication is used to set the session identity and the authentication cookie that allows users to stay logged in until they logout or the session expires. You don't need to use the membership providers to use FormsAuthentication. It sounds like you are just ...
<p>Please note that you can leverage the ASP.Net forms authentication and <strong><a href="http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx" rel="nofollow noreferrer">implement your own membership provider</a></strong> which would read/write to your existing tables. </p>
37,237
<p>E.g. we this code in the asp.net form codebihind:</p> <pre><code>private void btnSendEmails_OnClick() { Send100000EmailsAndWaitForReplies(); } </code></pre> <p>This code execution will be killed by the timeout reason. For resolving the problem I'd like to see something like this:</p> <pre><code>private void b...
<p>This has been discussed as a part of other questions:</p> <p><a href="https://stackoverflow.com/questions/50221/multithreading-in-aspnet#50377">Multithreading in asp.net</a></p> <p><a href="https://stackoverflow.com/questions/57845/backgroundworker-thread-in-aspnet">BackgroundWorker thread in ASP.NET</a></p> <p>T...
<p>Server.ScriptTimeout = 360000000;</p>
14,396
<p>I have a string of arbitrary length, and starting at position p0, I need to find the first occurrence of one of three 3-letter patterns.</p> <p>Assume the string contain only letters. I need to find the count of triplets starting at position p0 and jumping forward in triplets until the first occurrence of either 'a...
<p>Moritz says this might be faster than a regex. Even if it's a little slower, it's easier to understand at 5 am. :)</p> <pre> #0123456789.123456789.123456789. my $string = "alsdhfaaasccclaaaagalkfgblkgbklfs"; my $pos = 9; my $length = 3; my $regex = qr/^(aaa|bbb|ccc)/; while( $pos &lt; leng...
<p>The main part of this is split /(...)/. But at the end of this, you'll have your positions and occurrence data. </p> <pre><code>my @expected_triplets = qw&lt;aaa bbb ccc&gt;; my $data_string = 'fjeidoaaaivtrxxcccfznaaauitbbbfzjasdjfncccftjtjqznnjgjaaajeitjgbbblafjan' ; my $place = 0; my @trip...
14,604
<p>How do you set the timeout for blocking operations on a Ruby socket?</p>
<p>The solution I found which appears to work is to use <a href="http://www.ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.html" rel="noreferrer">Timeout::timeout</a>:</p> <pre><code>require 'timeout' ... begin timeout(5) do message, client_address = some_socket.recvfrom(1024) end rescue Timeout::E...
<p>I think the non blocking approach is the way to go.<br> I tried the mentioned above article and could still get it to hang.<br> this article <a href="http://peasleer.wordpress.com/2006/11/14/non-blocking-networking-in-ruby/" rel="noreferrer">non blocking networking</a> and the jonke's approach above got me on the ri...
28,673
<p>This is silly, but I haven't found this information. If you have names of concepts and suitable references, just let me know.</p> <p>I'd like to understand how should I validate a given named id for a generic entity, like, say, an email login, just like Yahoo, Google and Microsoft do.</p> <p>I mean... If you do ha...
<p>what about:</p> <pre><code>newDate = new Date() newDate.setSeconds(newDate.getSeconds()-30); if (newDate &gt; LastTimeIDidTheLoop) { alert("oops"); } </code></pre>
<p>Create a date object and use setSeconds().</p> <pre><code>controlDate = new Date(); controlDate.setSeconds(controlDate.getSeconds() + 30); if (LastTimeIDidTheLoop &gt; controlDate) { ... </code></pre>
45,301
<p>I have implemented <a href="http://microformats.org/wiki/hatom" rel="nofollow noreferrer">hAtom microformat</a> on my blog. At least, I think I have, but I can't find any validator (or any software that uses hAtom) in order to determine if I have done this correctly. A <a href="http://www.google.com/search?num=100...
<p>How about <a href="http://microformatique.com/optimus/" rel="nofollow noreferrer">Optimus</a>?</p> <p>Otherwise, you can slow-validate it by adding it to the list of <a href="http://microformats.org/wiki/hatom-examples-in-wild" rel="nofollow noreferrer">hAtom examples in the wild</a>. Occasionally someone will go t...
<p>You might find these useful</p> <p><a href="http://microformats.org/wiki/hatom#Examples" rel="nofollow noreferrer">http://microformats.org/wiki/hatom#Examples</a></p> <p><a href="http://microformats.org/wiki/hatom#Implementations" rel="nofollow noreferrer">http://microformats.org/wiki/hatom#Implementations</a></p>...
15,223
<p>Hey all, my Computational Science course this semester is entirely in Java. I was wondering if there was a good/preferred set of tools to use in ubuntu. Currently I use gedit with a terminal running in the bottom, but I'd like an API browser. </p> <p>I've considered Eclipse, but it seems to bloated and unfriendly f...
<p>Java editing tends to go one of two ways; people either stick with a simple editor and use a terminal to compile/run their programs, or they use a big IDE with a zillion features.</p> <p>I usually go the simple route and just use a plain text editor and terminal, but there's still a lot to be said for IDEs. This i...
<p>I'm using NetBeans with success right now.</p>
9,380
<p>I'm exploring various options for mapping common C# code constructs to C++ CUDA code for running on a GPU. The structure of the system is as follows (arrows represent method calls):</p> <p>C# program -> C# GPU lib -> C++ CUDA implementation lib</p> <p>A method in the GPU library could look something like this:</p>...
<p>There's <a href="http://www.gass-ltd.co.il/en/products/cuda.net/" rel="nofollow noreferrer">CUDA.Net</a> if you want some reference how C# can be run on GPU.</p>
<p>Interesting question. I'm not very expert at C#, but I think an ICollection is a container of <em>objects</em>. If each element of c was, say, a pixel, you'd have to do a lot of marshalling to convert that into a buffer of bytes or floats that CUDA could use. I suspect that would slow everything down enough to ne...
24,044
<p>In the past people used to wrap HTML comment tags around blocks of JavaScript in order to prevent "older" browsers from displaying the script. Even Lynx is smart enough to ignore JavaScript, so why do some people keep doing this? Are there any valid reasons these days?</p> <pre><code>&lt;script type="text/javascrip...
<p>No, absolutely not. Any user agent, search engine spider, or absolutely anything else these days is smart enough to ignore Javascript if it can't execute it.</p> <p>There was only a very brief period when this was at all helpful, and it was around 1996.</p>
<p>Not having to use CDATA blocks is one of the reasons I prefer to use HTML 4.01 Strict as my docttype, but, Staicu, I thought it used the following syntax:</p> <pre><code>&lt;script charset="utf-8"&gt; //&lt;![CDATA[ //]]&gt; &lt;/script&gt; </code></pre> <p>Maybe the two are equivalent? Anyone know if there is an...
25,083
<p>I am trying to compile a labview CIN using visual studio 2003.</p> <p>I have followed the tutorial located <a href="http://zone.ni.com/devzone/cda/tut/p/id/3172" rel="nofollow noreferrer">here</a> to the letter, but am getting the following error:</p> <blockquote> <p>Project : error PRJ0019: A tool returned an e...
<p>Ok, solved it.</p> <p>Turns out it's an issue with the lsvbutil.exe bundled with labview 8.5. Workaround is to replace with the version from 8.2</p> <p>See <a href="http://digital.ni.com/public.nsf/allkb/0029165B53320B2886257369005826A1" rel="nofollow noreferrer">http://digital.ni.com/public.nsf/allkb/0029165B5332...
<p>Please post the entire error. It appears that the custom build step defined in your link does not work. </p> <p>On the Custom Build Step->General page, type:</p> <pre><code>"$(CINTOOLS_DIR)\lvsbutil" "$(TargetName)" -d "$(ProjectDir)$(OutDir)" </code></pre> <p>in the commandline field and type <code>$(OutDir)$(T...
30,195
<p>What's the best way to implement authentication over WCF?</p> <p>I'd prefer to not use WS-* as it needs to be transport independent.</p> <p>Should I "roll my own"? Is there any guidance for doing that (articles/blog posts)?<br> Or is there some way to <em>(and should I)</em> use the built in ASP.NET Membership and...
<p>Message based authentication, which is WS-Security based, is what you're looking for and is definitely supported by basicHttpBinding and netTcpBinding. I think you are making the mistaken assumption that only WsHttpBinding will support WS-Security, which is inaccurate. </p> <p>The WS bindings are for WS-* element...
<p>Why should WS-* be transport dependant?</p> <p>The whole point of the WS-* specifications is that they are part of the message, and hence transport independent.</p>
3,779
<p>I need to watch when certain processes are started or stopped on a Windows machine. I'm currently tapped into the WMI system and querying it every 5 seconds, but this causes a CPU spike every 5 seconds because WMI is WMI. Is there a better way of doing this? I could just make a list of running processes and attach a...
<p>This is not exactly how you'd do it in the real world but should help. This seems not to drive my CPU much at all.</p> <pre><code> static void Main(string[] args) { // Getting all instances of notepad // (this is only done once here so start up some notepad instances first) // you may...
<p>My answer here mentions an alternative other than WMI:<a href="https://stackoverflow.com/a/50315772/3721646">https://stackoverflow.com/a/50315772/3721646</a> WMI queries can cost heavy CPU performance if not designed properly. If an intrinsic event from Win32_Process class is used to track process creation event, t...
44,915
<p>When trying to connect to an <code>ORACLE</code> user via TOAD (Quest Software) or any other means (<code>Oracle Enterprise Manager</code>) I get this error:</p> <blockquote> <p><code>ORA-011033: ORACLE initialization or shutdown in progress</code></p> </blockquote>
<p>After some googling, I found the advice to do the following, and it worked:</p> <pre><code>SQL&gt; startup mount ORACLE Instance started SQL&gt; recover database Media recovery complete SQL&gt; alter database open; Database altered </code></pre>
<p>I faced the same problem. I restarted the oracle service for that DB instance and the error is gone.</p>
7,722
<p>Sorry for the slightly rubbish title. I could not think how to describe this one better.</p> <p>I am trying to implement the Google Friend Connect members gadget on my site, (just got into the scheme and want to put it in without a major redesign, at least for testing sake).</p> <p>My problem is as follows:</p> ...
<p>It is. You're looking for a semi-fluid layout. The quest was was originally the <a href="http://www.alistapart.com/articles/holygrail" rel="noreferrer">holy grail of CSS implementation</a>... But as you can see from that link (they're doing 3 columns, 2 fixed but it's easy to alter), it's a problem long solved =)</p...
<p>I did a quick experiment as well after looking at a number of potential solutions all over the place. What I was trying to do was to have a mix of fluid and fixed rows and columns.</p> <p>This is what I ended up with:</p> <p><a href="http://jsbin.com/hapelawake" rel="nofollow">http://jsbin.com/hapelawake</a></p>
44,647
<p>I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution:</p> <pre><code>Vector itemsVector = getItems(); Collections.shuffle(itemsVector); itemsVector....
<p>Jon Bentley discusses this in either 'Programming Pearls' or 'More Programming Pearls'. You need to be careful with your N of M selection process, but I think the code shown works correctly. Rather than randomly shuffle all the items, you can do the random shuffle only shuffling the first N positions - which is a ...
<p>How much does remove cost? Because if that needs to rewrite the array to a new chunk of memory, then you've done O(5n) operations in the second version, rather than the O(n) you wanted before.</p> <p>You could create an array of booleans set to false, and then:</p> <pre><code>for (int i = 0; i &lt; 5; i++){ in...
16,516
<p>I have 2 tables:</p> <pre><code>A s_id(key) name cli type B sa_id(key) s_id user pwd </code></pre> <p>So in Jpa I have:</p> <pre><code>@Entity class A...{ @OneToMany(fetch=FetchType.EAGER) @JoinTable( name="A_B", joinColumns={@JoinColumn(name="a_id", table="a",unique=false)}, inverseJoinColumns=...
<p>No you do not need a join table for OneToMany. Look at the @mappedBy annoatation</p>
<p>The quick answer is that if you have a Many-to-Many relationship you will need another table. If you have a One-to-Many or a Many-to-One relationship you will not.</p>
20,190
<p>Why didn't languages such as C end up being using for web dev? Surely the speed increases from being compiled would be useful for heavy load sites?</p>
<p>Another good reason is that on a big server execution speed is not so much an issue as the connection speed anyway. Most of the time is spent sending and receiving data, not number crunching. And actually in certain web services which <em>do</em> a lot of computations, the hard crunching <em>is</em> probably run as ...
<p>Scripting languages where the only option for web development a long time ago. Now we have other alternatives (Java, .NET ..) so situation is not so bad. <br /></p> <p> C as a platform was not very successful for web development since it's hard to build a module that could be loaded and executed from web/applicati...
44,213
<p>What are the hidden features of Maven2?</p>
<p>You can use the settings.xml to force ALL maven builds running on your local machine to also use a locally installed maven proxy. Saving yourself and the network time.</p> <pre><code>&lt;settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLo...
<p>With maven-dependency-plugin it's possible to resolve dependency conflicts and cyclic dependency problems. </p> <p>Add to your pom.xml:</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;/plugin&gt; </code></p...
40,113
<p>I have a dll that contains a templated class. Is there a way to export it without explicit specification?</p>
<p>Since the code for templates is usually in headers, you don't need to export the functions at all. That is, the library that is using the dll can instantiate the template.</p> <p>This is the only way to give users the freedom to use any type with the template, but in a sense it's working against the way dlls are su...
<p>When the compiler finds an instantiation of a template class, like MyTemplate&lt;int&gt;, then it generates the code for the template specialization.<br> For this reason, all the template code must be placed in an header file and included where you want to use it.<br> If you want to 'export' your template class, jus...
47,359
<p>If I have a query such as <code>SELECT * from authors where name = @name_param</code>, is there a regex to parse out the parameter names (specifically the "name_param")?</p> <p>Thanks</p>
<p>This is tricky because params can also occur inside quoted strings.</p> <pre><code>SELECT * FROM authors WHERE name = @name_param AND string = 'don\'t use @name_param'; </code></pre> <p>How would the regular expression know to use the first <code>@name_param</code> but not the second?</p> <p>It's a problem tha...
<p>Given you have no quoted strings or comments with parameters in them, the required regex would be quite trivial:</p> <pre><code>@([_a-zA-Z]+) /* match group 1 contains the name only */ </code></pre> <p>I go with <a href="https://stackoverflow.com/questions/307929/regex-for-parsing-sql-parameters#307957">Bill...
39,647
<p>I'm using visual studio 2008 and <a href="http://en.wikipedia.org/wiki/ReSharper" rel="noreferrer">ReSharper</a> 4 and it's kind of slow. My machine has 2 GB of RAM, dual core processor and a 7200 rpm hard disk. I know more RAM and a faster hard disk could improve performance, but do you have any tips to improve ReS...
<p><strong>Turn off the annoying RSS reader</strong></p> <ul> <li>Tools, Options, Environment, Startup</li> </ul> <p><strong>Turn off all the animations</strong></p> <ul> <li>Tools, Options, Environment, Animate Environment Tools</li> </ul> <p><strong>Install the <a href="http://msdn.microsoft.com/en-us/vstudio/pro...
<p>I'm having the exact same issue, and from the JetBrains site, it looks like they sort-of know about it but aren't admitting anything. Turning off solution-wide analysis does seem to help quite a bit.</p>
4,359
<p>Is anyone out there using Team Foundation Server within a team that is geographically distributed? We're in the UK, trying work with a team in Australia and we're finding it quite tough.</p> <p>Our main two issues are:</p> <ol> <li>Things are being checked out to us without us asking on a get latest. </li> <li>E...
<p>Definitely upgrade to TFS 2008 and Visual Studio 2008, as it is the "v2" version of Team System in every way. Fixes lots of small and medium sized problems.</p> <p>As for "things being randomly checked out" this is almost <em>always</em> due to Visual Studio deciding to edit files on your behalf. Try getting latest...
<p>From my understanding you can have multiple TFS Application servers in different locations. They either can both talk to the same SQL Server or you could use SQL Server mirroring. Having your own local TFS server would likely speed up your development times.</p>
3,220
<p>exact code will be helpful. I assume the DirectoryServices namespace does it but I can't find the method that does it.</p> <hr> <p>I need actual C# code. All the samples I found so far are VB or VBScript. The C# examples I found are for reading/setting ADSI properties. A command like backup seems to have a certain...
<p>You'll need to use ADSI objects. The <a href="http://msdn.microsoft.com/en-us/library/ms525753.aspx" rel="nofollow noreferrer">IIsComputer.Backup</a> method is what you want.</p> <p>As far as how to access ADSI objects from C#, check out this <a href="http://support.microsoft.com/kb/315716" rel="nofollow noreferrer...
<p>I found it:</p> <p>DirectoryEntry de = new DirectoryEntry("IIS://localhost"); de.Invoke("Backup", new object[0] );</p> <p>new object needs to be set to hold proper arguments like overwriting current backup</p>
7,270
<p>I'm having problems with cross theme compatibility in windows forms. If you don't set the font for a control on a windows form, it will use the system font with correct typeface and size. If you want to make the font <strong>bold</strong>, it hard codes in the rest of the system font values for the current theme y...
<p>FFMPEG's libavcodec and libavformat are your friend. They're extremely versatile and support more than basically anything else, and are effectively the cross-platform standard for multimedia support and manipulation.</p> <p>You could also try MP4box's library, GPAC, which is an MP4-specific library that is much mo...
<p>For x264: you can simply call the executable itself, or you can include the library itself and call it through its API (encoder_open, etc). With .NET its likely more difficult; being a C program, its API is built around C, though I know both C and C++ programs on Windows and Linux have been built that call the API....
25,504
<p>I am in the process of beginning work on several ASP.NET custom controls. I was wondering if I could get some input on your guys/girls thoughts on how you apply styling to your controls.</p> <p>I would rather push it so CSS, so for the few controls I have done in the past, I have simply stuck a string property which...
<p>It would depend on how the custom controls are being used - A commercial, re-distributable control should be compliant with the VS IDE, and behave the way users expect it to when they implement the control.</p> <p>On the other hand there is no point in wasting a lot of time to get styling to work if you or your tea...
<p>I think you should consider your "target market" for the custom control, e.g., the people who will use it.</p> <p>If it's an internal custom control, you can pretty much mandate the use of one or the other: if it's internal to the company you will have the ability to enforce its consistency.</p> <p>If it's meant f...
9,571
<p>So it's trivial to create a Settings style table on the iPhone. The problem is, they add a great deal of code as your Settings have a gamut of options/styled cells. One section might have a check list, another might have cells with accessory disclosures to drill down further, another might be labels with UITextField...
<p>The easiest way to do this is to simply add your controls during the tableView:cellForRowAtIndexPath: method.</p> <p>I also recommend this to help corral your code: <a href="http://www.speirs.org/blog/2008/10/11/a-technique-for-using-uitableview-and-retaining-your-sanity.html" rel="nofollow noreferrer">A technique ...
<p>I would rather set most of the settings that I can in Interface Builder, instead of writing a whole bunch of code to make the visual/layout just right. As you can imagine, it will take quite a few rounds of "modify - build - test" in the iPhone Simulator to get this special table view laid out the way you want it.</...
44,099
<p>How stable is WPF not in terms of stability of a WPF program, but in terms of the 'stability' of the API itself. </p> <p>Let me explain: </p> <p>Microsoft is notorious for changing its whole methodology around with new technology. Like with the move from silverlight 1 to silverlight 2. With WPF, I know that MS c...
<p>MS do have a history of "fire and movement" with regards to introducing new technology into their development stack, but they also have a strong history of maintaining support for the older stuff, and backwards-compatibility. WPF seems to be getting stuff added to it with each new release of the framework but the th...
<p>WPF is pretty stable as far as changes go. Silverlight is still in flux. Though you may watch out since silverlight brought the concept of the state manager(instead of implementing triggers) which may get adopted in wpf... </p> <p>If that happens there will be multiple ways to defining control templates and behav...
5,142
<p>If I have a Range object--for example, let's say it refers to cell <code>A1</code> on a worksheet called <code>Book1</code>. So I know that calling <code>Address()</code> will get me a simple local reference: <code>$A$1</code>. I know it can also be called as <code>Address(External:=True)</code> to get a referenc...
<p>Only way I can think of is to concatenate the worksheet name with the cell reference, as follows:</p> <pre><code>Dim cell As Range Dim cellAddress As String Set cell = ThisWorkbook.Worksheets(1).Cells(1, 1) cellAddress = cell.Parent.Name &amp; "!" &amp; cell.Address(External:=False) </code></pre> <p>EDIT:</p> <p>...
<p>[edit on 2009-04-21]</p> <p><i>&nbsp;&nbsp;&nbsp;&nbsp;As Micah pointed out, this only works when you have named that<br> &nbsp;&nbsp;&nbsp;&nbsp;particular range (hence .Name anyone?) Yeah, oops!</i></p> <p>[/edit]</p> <p>A little late to the party, I know, but in case anyone else catches this in a google sear...
15,926
<p>The output we get when printing C++ sources from Eclipse is rather ugly. </p> <p>Is there are way/a plugin to pretty print C++ source code like e.g. with a2ps (which is probably using yet another filter for C source code)?</p>
<p>I also use <code>enscript</code> for this. Here's an alias I often use:</p> <pre> alias cpp2ps='enscript --color --pretty-print=cpp --language=PostScript' </pre> <p>and I use it like this:</p> <pre> cpp2ps -P main.ps main.cpp </pre> <p>There are several other great options in <code>enscript</code> including rot...
<p>I would like to expand on the Windows 7 response because some key steps are left out:</p> <h1>This is for MinGW users with Eclipse CDT</h1> <p>0) If you don't have python GDB, open a shell/command and use MinGW-get.exe to 'install' Python-enabled GDB e.g. </p> <pre><code> MinGw-get.exe install gdb-python </...
17,868
<p>I have a table that saves some account limits like users. For most rows this value will be an integer. However I will also need to support storing unlimited (infinite) as a value. This might seem silly but is there a common integer value that represents unlimited (infinite)? I'd like to keep storing the values as in...
<ul> <li>use zero</li> <li>use -1</li> <li>use null</li> </ul> <p>I prefer null, unless the field is not nullable, then I prefer zero, unless zero is a valid limit, then I prefer -1, unless -1 is a valid value, in which case you need <em>another field</em> (say, a bit field) to signify 'unlimited'.</p>
<p>I don't think there's a perfect solution. So here goes my suggestion:</p> <p>Create constants that represent the max values that can be stored in your database and consider them as "Infinity".</p> <p><a href="http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html#integer-types" rel="nofollow">http://dev.mysql.c...
33,553
<p>I have a set of configuration items I need to persist to a "human readable" file. These items are in a hierarchy:</p> <pre> Device 1 Name Channel 1 Name Size ... Channel N Name ... Device M Name Channel 1 </pre> <p>Each of these item could be stored in a Dictionary with a string ...
<p><a href="http://www.codeplex.com/yaml" rel="nofollow noreferrer">YAML for .NET</a></p>
<p>I've generally used the registry for storing configurations (I know, bad me!), but using System.Xml to read/write a lightweight XML file isn't hard. In fact, I've done just that recently for a plugin project that uses XML documents to communicate with its host as well as store its own persistent settings.</p> <p>Th...
21,281
<p>I've a windows service that updates our product. It copies the product files into a temp directory, usually "C:\Windows\Temp", patches the binaries, and then uses MoveFileEx to copy the files back to the install directory on a reboot, usually "C:\Program Files\Product". The files in the install directory are inherit...
<p>In Windows if you copy a file the file takes on the ACLs of the destination directory. If you move a file the ACL goes with it overriding any it might inherit from that directory. I'm not sure how MoveFileEx might operate differently on a file. </p> <p>The temp directory is usually located under the user profile...
<p>One potential workaround is to patch copies of the files with-in the same directory but with different names. After the reboot, the patched versions could be swapped in. Alternatively, do a reboot first and then patch them in-place, and just back them up to the temp directory in the event a manual rollback is requir...
24,833