instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm filtering the messages that come to a form with PreFilterMessage like this:</p> <p><code>print("code sample");</code></p> <pre><code> public bool PreFilterMessage(ref Message m) { if (m.Msg == WM_KEYDOWN &amp;&amp; (int)m.WParam == VK_ESCAPE) { this.Close(); return true; } ...
<p>I don't know if this fits with what you are doing. I usually set Form.CancelButton to the close or cancel button on my form, and it will automatically call the button OnClick when the user hits Esc on the keyboard.</p>
<p>According to MSDN</p> <blockquote> <p>The two conditions when a form is not disposed on Close is when (1) it is part of a multiple-document interface (MDI) application, and the form is not visible; and (2) you have displayed the form using ShowDialog. In these cases, you will need to call Dispose manually to mark...
27,879
<p>When presenting preformatted text on the web (e.g. code samples), line wrapping can be a problem. You want to wrap for readability without scrolling, but also need it to be unambiguous to the user that it is all one line with no line break.</p> <p>For example, you may have a really long command line to display, lik...
<p>Here is one (unpleasant) way of doing this. It requires a number of bad practices. But SO is about solutions to real problems so here we go...</p> <p>First each line needs to be wrapped in some sort of containing block. Span or p are probably the most appropriate.</p> <p>Then the style of the containing block nee...
<p>This cannot be done with CSS. Sorry. :(</p>
42,782
<p>Every morning, after logging into your machine, you do a variety of routine stuffs. The list can include stuffs like opening/checking your email clients, rss readers, launching visual studio, running some business apps, typing some replies, getting latest version from Source Control, compiling, connecting to a diffe...
<p>A favorite way is to leave the computer on at night or better, if it's a laptop, put it to sleep. Running a web browsing virtual machine in VMware or similar works also, you can set the VM start along with the machine and save its state on shutdown, so your web pages and email client stay open. This works for develo...
<p><strong><a href="http://www.bayden.com/SlickRun/" rel="nofollow noreferrer">SlickRun</a></strong> is very handy for this, just a few keys to navigate to anything common and a very small footprint. With input variables and file path recognition all part of it I can quick remote desktop to any machine, search anythin...
13,691
<p>I am looking for information about providing a license, or "terms of use", for a web application. The <a href="http://en.wikipedia.org/wiki/Terms_of_Use" rel="nofollow noreferrer">Wikipedia article</a> is very limited, and it seems that unlike "downloadable" software (or perhaps "installable" software, for lack of a...
<p>Hire a lawyer. Undesirable (and costly) as it seems, it can cost you a helluva lot more to get your TOS wrong.</p>
<p>What are you hoping to cover? Are you worried about your code being stolen or someone doing something stupid on the back of something they see on your site? (Or something else entirely.) </p> <p>Could you edit to widen what you hope your disclaimer or terms would hope to cover? </p> <p>Hiring a lawyer might well t...
49,876
<p>I've just received my Ender 3v2 and tried multiple SD cards, all have been formatted to FAT32 with no luck. Under the Print selection, all I get is the back button. I looked and I have the V4.2.2 and the firmware is up to date, Showing 1.0.2 unless this is not right and this is why I'm having this issue. Even when p...
<p>Abd to follow along with J Boughtons advice, I've noticed if the word &quot;end&quot; is in the first file, it won't read any of the files.</p>
<p>I have the same issue but whilst none of these worked for me they have worked for other people:</p> <ul> <li>Make sure the name of the G-code file begins with a letter or number</li> <li>Make sure the G-code is not in a subfolder</li> <li>Make sure the name of the G-code file is less than or equal to 8 characters lo...
1,906
<p>I know how to use tags in subversion. I create a tag every time I get to a release milestone.</p> <p>What I don't quite understand is how they work. </p> <p>Is a tag just a copy, made from what ever revision I specify? Or is a tag more like a reference, where internally subversion just says <code>GO TO /trunk/proj...
<p>Yes, a svn copy (whether you are thinking of it as a tag, a branch, or copying a file in trunk) is all the same. SVN will internally create a pointer to the source location at that revision. If you then make changes to the copy (which you are likely to do if it is a branch or a copied file in trunk, but shouldn't ...
<p>an example:</p> <pre><code>$ svn copy https://jorgesysgr.com/svn/AndNews/branches \ https://jorgesysgr.com/svn/AndNews/tags/release-1.1 \ -m "release 1.1 Android News." </code></pre> <p>More info:: <a href="http://svnbook.red-bean.com/nightly/en/svn.branchmerge.tags.html" rel="nofollow">Creat...
6,116
<p>We have a (non-web app) Spring application that throws a NoSuchBeanDefinitionException when running tests on our CruiseControl continuous integration linux box. The test runs fine on Windows in Eclipse.</p> <p>The exception is thrown on the getBean() method:</p> <pre><code>ApplicationContext context = new ClassPat...
<p>Solved. The instantiation of "myBean" in CONTEXT_FILE occurred after another bean that depended on it. This really should not be an issue, but I suspect that the parser on the Linux box must be stricter. Anyway, changing the order of definitions made it work on both Windows and Linux.</p>
<p>I had the same problem. It turned out that it was a subtle classpath issue. Specifically - my classpath on linux was set up so that my config directory containing my build.xml file came after my x-jars (external jars) directory - and some other beans.xml was being picked up from my x-jars which, as the log message c...
49,166
<p>I'm building a shared library with g++ 3.3.4. I cannot link to the library because I am getting </p> <pre><code>./BcdFile.RHEL70.so: undefined symbol: _ZNSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE13insert_uniqueERKj </code></pre> <p>Which c++filt describes as </p> <pre><code>std::_Rb_tree&lt;unsigned int, unsi...
<p><code>std::_Rb_Tree</code> might be a red-black tree, which would most likely be from using <code>map</code>. It should be part of <code>libstdc++</code>, unless your library is linking against a different version of <code>libstdc++</code> than the application, which from what you've said so far seems unlikely.</p> ...
<p>Try <pre><code>#include &lt; map > </code></pre> in the source file where you are using map.</p>
17,158
<p>I'm currently using Subversion to manage my ASP.NET website. I'm finding that whenever I go to upload my website to my server, I'm copying a large number of hidden .svn folders and whatever contents may lie within them.</p> <p>Does anyone have any suggestions for avoiding this? I don't particularly want those hidde...
<p>How about you run Subversion on the server and then do an svn export from the repository? svn export is like a checkout, but w/o the .svn folders (and w/o the ability to do Subversion work in that directory).</p> <p>Alternately, do a svn export of the repo on your local machine and then FTP up the exported version...
<p>two suggestions:</p> <ul> <li>Use <a href="http://en.wikipedia.org/wiki/Robocopy" rel="nofollow noreferrer">robocopy</a> or xcopy to filter out the <code>.svn</code> folders</li> <li><code>svn export</code> the repository to the webserver (<a href="http://svnbook.red-bean.com/en/1.0/re10.html" rel="nofollow norefer...
27,725
<p>When I run a particular SQL script in Unix environments, I see a '^M' character at the end of each line of the SQL script as it is echoed to the command line.<br /> I don't know on which OS the SQL script was initially created.</p> <p>What is causing this and how do I fix it?</p>
<p>It's caused by the DOS/Windows line-ending characters. Like Andy Whitfield said, the Unix command dos2unix will help fix the problem. If you want more information, you can read the man pages for that command.</p>
<p>Another vi command that'll do: <code>:%s/.$//</code> This removes the last character of each line in the file. The drawback to this search and replace command is that it doesn't care what the last character is, so be careful not to call it twice.</p>
9,033
<p>I'm having a small problem in Java. I have an interface called Modifiable. Objects implementing this interface are Modifiable.</p> <p>I also have a ModifyCommand class (with the Command pattern) that receive two Modifiable objects (to swap them in a list further on - that's not my question, I designed that solution...
<p>If you're using java 1.5 or higher, you can get the behavior you want and remove casting this way:</p> <pre><code>public interface Modifiable&lt;T extends Modifiable&lt;T&gt;&gt; extends Cloneable { T clone(); } public class Foo implements Modifiable&lt;Foo&gt; { public Foo clone() { //this is required ...
<p>Did you define the signature exactly as it is in object?</p> <pre><code>public Object clone() throws CloneNotSupportedException { return super.clone(); } </code></pre> <p>This should compile - add custom code to the body. <a href="http://en.wikipedia.org/wiki/Clone_(Java_method)" rel="nofollow noreferrer">Wik...
29,801
<p>I have a Simulink xPC target application that has blocks with discrete states at several different sample rates and some sections using continuous states. My intention on keeping the continuous states is for better numerical integration. </p> <p>What creates the problem: One block is reading a device at a very fast...
<p>You are thinking about continuous solvers in the wrong way - continuous doesn't only mean that it's run as fast as possible - it uses a fundamentally different algorithm to solve the equations than discrete. Due to this, they must be run at least as fast as the discrete solvers.</p> <p>From <a href="http://www.ece...
<p>My take on this is that it cannot be done. One way to approach this is to replace the continuous states by discrete ones (perhaps at an intermediate rate, say 100 Hz), and cross my fingers that the loss of precision is bearable.</p> <p>Maybe it's possible to isolate a block and run it separately at a faster rate so...
6,482
<p>I would like to make two database operation in one transaction. Those two operations are</p> <ol> <li>Do one insert operation.</li> <li>Create one user (using membership - sql membership provider)</li> </ol> <p>I tried <strong>TransactionScope</strong> but it went to distributed transaction at that line: ...
<p>The current implementation of TransactionScope will only use a lightweight transaction if you use a single database connection. So it is not possible to achieve this in your scenario.</p>
<p>I was looking for this topic and I think I have found an answer. It only applies to SQLServer 2008. It does not require changes to System.Transactions namespace or our Application code. It's interesting. ;)</p> <p><a href="http://blogs.msdn.com/b/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlcl...
39,162
<p>My ASP.NET MVC application will take a lot of bandwidth and storage space. How can I setup an ASP.NET upload page so the file the user uploaded will go straight to Amazon S3 without using my web server's storage and bandwidth?</p>
<p>Update Feb 2016:</p> <p>The AWS SDK can handle a lot more of this now. Check out <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/HTTPPOSTForms.html" rel="nofollow noreferrer">how to build the form</a>, and <a href="http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-authentication-HTTPPOST.html" rel="nofo...
<p><a href="http://www.codeplex.com/ThreeSharp" rel="nofollow noreferrer">ThreeSharp</a> is a library to facilitate interactions with Amazon S3 in a .NET environment.</p> <p>You'll still need to host the logic to upload and send files to s3 in your mvc app, but you won't need to persist them on your server.</p>
14,342
<p>I have a generic list of objects in C#, for example sake, here's what the object might be.</p> <pre><code>public class Thing { public string Name { get; set; } public DateTime EditDate { get; set; } } var things = new List&lt;Thing&gt;(); </code></pre> <p>Now I want to call:</p> <pre><code>thing.Sort((t1...
<p>You can create a somewhat more complex lambda, such as:</p> <pre><code>things.Sort((t1, t2) =&gt; { if (t1 == null) { return (t2 == null) ? 0 : -1; } if (t2 == null) { return 1; } return t1.EditDate.CompareTo(t2.EditDate); }); </code></pre> <p><code>EndDate</code> cannot be <code>null</code> as it is...
<p>List has a <a href="http://msdn.microsoft.com/en-us/library/w56d4y5z.aspx" rel="nofollow noreferrer">sort function</a> that takes a delegate.</p> <p>Now that I've read the question </p> <pre><code>TheList.Sort(int delegate(Type a, Type b) { if (a.memeber == null) return -1; if (b.memeber == null) return 1;...
41,097
<p>I have two unix partitions under debian which I would like to merge (disk space problems :/). What would be the easiest way to do it? I think it would be best to tar or copy files from one partition to the other, delete one and resize the other. I will use parted to resize but how should I copy the files? There are ...
<p>You could run the following (as root) to copy the files. It works for symlinks, devices and ordinary files.</p> <pre><code>cd /partition2 tar cf - . | ( cd /partition1 &amp;&amp; tar xf - ) </code></pre> <p>Another way is to use cpio, but I never remember the correct syntax.</p>
<p>You can also use SquashFS to create a mirror of the partition and copy that over. After resizing your 2nd partition, mount the SquashFS image and copy over the necessary files. Keep in mind that your kernel will need SquashFS support to mount the image.</p> <ul> <li><a href="http://squashfs.sourceforge.net/" rel="n...
46,340
<p>Is it possible to use Flex 3 component/code inside Flash (cs4) SWF file ?</p> <p>I know its possible in the opposite direction.</p>
<p>With my minimal testing <strong>it seems you can't use Flex components when building a "pure AS3" project.</strong> (Can we start calling it PAS3 or something? Like "passé". Or "pastry". :)</p> <p>I did this admittedly limited testing by creating a test project with one AS class as the "document class", which would...
<p>In general you need to use MXML to initialise the Flex framework and use Flex components. </p> <p>Mike Chambers from Adobe says:</p> <blockquote>There is not support for using the Flex Framework in an AS only project. While it is theoretically possible, you would have to manually bootstrap a lot of the application...
44,701
<p>I have an embedded flash that is transparent so it looks like part of the background. I achieved that by setting wmode to transparent.</p> <p>My problem is that the area underneath the flash becomes inaccessible, even though the flash is transparent. Therefore I cannot click on any links or buttons that are under t...
<p>The problem is that in your document, the <code>object</code>/<code>embed</code> that contains the Flash animation is on top of the elements you need to access. You need to put these elements on top of the Flash animation instead of the other way around.</p> <p>The way to do this is to set the object's <code>wmode<...
<p>What is the purpose of the Flash? If it doesn't do anything visible, then you can make it 1 pixel in size and/or put it in a div that is absolutely positioned off the screen.</p>
29,984
<p>In IIS7 for Vista, you can select your machine and it gives you several options in which you can use to configure your system. Where is this file stored at? It seems like there's a big master.config file which stores all my settings like the "Connection Strings" which are inherited by the webpages. </p> <p>Suppo...
<p>If you're talking about machine-wide ASP.NET configuration, look under your .NET framework config directory, e.g. <code>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG</code> - check web.config and machine.config for the settings you've been configuring.</p> <p>(Note: this is a bit of an educated guess. Don't ...
<p>"Connection Strings" do seem to be in the <a href="http://chiragrdarji.wordpress.com/2008/08/11/how-to-encrypt-connection-string-in-webconfig/" rel="nofollow noreferrer">web.config file</a></p> <p>There can be multiple web.config files in a single web project (but not in a single directory), but here, you are refer...
46,766
<p>I'm trying to learn RegEx in Ruby, based on what I'm reading in "<em>The Rails Way</em>". But, even this simple example has me stumped. I can't tell if it is a typo or not:</p> <pre><code>text.gsub(/\s/, "-").gsub([^\W-], '').downcase </code></pre> <p>It seems to me that this would replace all spaces with <code>-<...
<pre><code>&gt;&gt; text = "I love spaces" =&gt; "I love spaces" &gt;&gt; text.gsub(/\s/, "-").gsub(/[^\W-]/, '').downcase =&gt; "--" </code></pre> <p>Missing //</p> <p>Although this makes a little more sense :-)</p> <pre><code>&gt;&gt; text.gsub(/\s/, "-").gsub(/([^\W-])/, '\1').downcase =&gt; "i-love-spaces" </cod...
<p>The slashes are to say that the thing between them is a regular expression, much like quotes say the thing between them is a string.</p>
16,805
<p>Has anybody tried any Unit Test generators for .Net?</p> <p>I assume although it won't be any substitute for any good unit test written by a person who has written the functionality, but I think it will take away some of work and be a starting point on which we can better the unit tests. </p> <p>Thanks.</p>
<p>Unit test generation is the wrong way to perform unit testing. The proper way to do unit testing is to create test cases before you write functional code, then develop your code until the tests validate, this is know as TDD (Test Driven Development).</p> <p>One of the key reasons unit test generation is a bad idea...
<p>I created ErrorUnit an unit test generator for .Net</p> <p>Using a generator for TDD development is certainly practical; for instance in coding what happens on a button click, a way to use ErrorUnit in a TDD way would be:</p> <p>1) First create a test manually to ensure there is a button press event; then create t...
46,562
<p>Consider the following table structure...</p> <pre><code>Appointment ----------- ID integer Description nvarchar StatusID smallint Status ------ ID smallint DisplayText nvarchar </code></pre> <p>Now, for good or for evil, we want this situation to map to a class that looks like this</p> <pre><code>class Appointm...
<p>The obvious answer is to create a Status entity and make the appointment class have a reference to that and map it in the normal way.</p>
<p>The obvious answer is to create a Status entity and make the appointment class have a reference to that and map it in the normal way.</p>
44,229
<p>Does Eclipse have a feature that lets you search a project to find all calls to deprecated methods?</p>
<p>You can set the compiler to generate errors or warnings (your choice) for any usage of deprecated API.</p> <blockquote> <p>Preferences -> Java -> Compiler -> Errors/Warnings -> <em>Deprecated and restricted API</em> section. </p> </blockquote> <p>Then, each use of a deprecated method or API will show up as an e...
<p>You can always use the grep facilities under 'Search -> File'. Eclipse can do a recursive search for <code>@deprecated</code> after you check on the 'consider derived resources' option box.</p>
28,914
<p>I'm about to start a project that will record and edit audio files, and I'm looking for a good library (preferably Ruby, but will consider anything other than Java or .NET) for on-the-fly visualization of waveforms.</p> <p>Does anybody know where I should start my search?</p>
<p>That's a lot of data to be streaming into a browser. Flash or Flex charts is probably the only solution that will be memory efficient. Javascript charting tends to break-down for large data sets. </p>
<p>The other option is generating the waveforms on the server-side with GD or RMagick. But good luck getting RubyGD to compile.</p>
6,247
<p>I'm looking for a <em>SimpleGrepSedPerlOrPythonOneLiner</em> that outputs all quotations in a text.</p> <hr> <p>Example 1:</p> <pre><code>echo “HAL,” noted Frank, “said that everything was going extremely well.” | SimpleGrepSedPerlOrPythonOneLiner </code></pre> <p>stdout:</p> <pre><code>"HAL," "said that everyt...
<p>I like this:</p> <pre><code>perl -ne 'print "$_\n" foreach /"((?&gt;[^"\\]|\\+[^"]|\\(?:\\\\)*")*)"/g;' </code></pre> <p>It's a little verbose, but it handles escaped quotes and backtracking a lot better than the simplest implementation. What it's saying is:</p> <pre><code>my $re = qr{ " # Begin ...
<pre><code>grep -o '"[^"]*"' file </code></pre> <blockquote> <p>The option '-o' print only pattern</p> </blockquote>
44,674
<p>I have a UI-dialog something like this: You must choose a book from a list. Optionally, you can either choose a publisher (another class) from a list or enter the publisher-name as as a string. </p> <p>I think this gives me 3 types as the output from the dialog.</p> <ol> <li>book</li> <li>book with publisher-class...
<p>Number two would be my approach.</p> <p>I would have a class for Publisher with a property called Name, along with any other properties needed to describe a publisher.</p> <p>Then I would have a class for book with properties to describe it, along with a property of type Publisher. </p> <p>If the user enters a ne...
<p>I think it's difficult to make a design decision based just on this dialog. For instance, are you picking from a set of existing books? In that case, what if the user enters a publisher who doesn't exist? In this case, you may not want to return an instance of any Book class at all, but raise some kind of excepti...
46,112
<p>I have a Struts + Velocity structure like for example, a Person class, whose one property is a Car object (with its own getter/setter methods) and it is mapped to a Velocity form that submits to an Action, using ModelDriven and getModel structure.</p> <p>I what to put a button on the form that shows "View Car" if c...
<p>You should change the #if line to:</p> <pre><code>#if($car) </code></pre>
<p>In the upcoming Velocity 1.6 release, you will be able to do <code>#if( $car == $null )</code> without error messages. This will allow you to distinguish easily between when <code>$car</code> is null and when it is false. To do that now requires <code>#if( $car &amp;&amp; $car != false )</code>, which just isn't a...
4,410
<p>I have an access database, with a query made. I need to automate it so that each night this query can run and export to a tab delimited csv file. It is not possible to export a query to a csv file from within access. My question is, are there any tools that can select certain tables, or perform an sql query on an md...
<p>Actually, you can export a query to a csv file from within Access.</p> <p>You can do this with a Macro using the TransferText method.</p> <p>Macro:</p> <pre><code> Name = ExportQuery Action = TransferText Transfer Type = Export Delimited Table Name = [name of your Access query] File Name = [path of ...
<p>SQL Server Integration Services is able to do the transformation that you are talking about. Don't be fooled by the name, because you don't need SQL Server in order to automate and run the packages.</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms141026.aspx" rel="nofollow noreferrer">http://msdn.microso...
35,531
<p>What is the best way to build a loopback URL for an AJAX call? Say I have a page at</p> <pre><code>http://www.mydomain.com/some/subdir/file.php </code></pre> <p>that I want to load with an AJAX call. In Firefox, using jQuery this works fine:</p> <pre><code>$.post('/some/subdir/file.php', ...); </code></pre> <p>S...
<p><a href="https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.figure.html" rel="noreferrer"><code>figure</code></a> tells you the call signature:</p> <pre><code>from matplotlib.pyplot import figure figure(figsize=(8, 6), dpi=80) </code></pre> <p><code>figure(figsize=(1,1))</code> would create an inch-by-inch...
<p>I've made research and wrote article about <a href="https://mljar.com/blog/matplotlib-change-figure-size/" rel="nofollow noreferrer">3 different ways to change figure size in Matplotlib</a>. It is important to remember that:</p> <ul> <li>figure size in Matplotlib is in <strong>inches</strong>,</li> <li><code>dpi</co...
43,046
<p>Has Object Prevalance mechanisms been used in an actual Production system? I'm referring to something like <a href="http://www.prevayler.org/wiki/" rel="nofollow noreferrer">Prevayler</a> or <a href="http://madeleine.rubyforge.org/" rel="nofollow noreferrer">Madeleine</a></p> <p>The only thing I've found is <a href...
<p>A company I used to work for used Prevayler as part of a computer-based student examination/assessment system for about five or six years.</p> <p>Prevayler was used to store the state of candidates’ tests on a server physically located within a single testing centre. The volume of data stored was fairly low, since ...
<p>Well, we're using Prevayler in a project that's aiming <em>towards</em> production by sometime next year, but we're not close enough to give any real scouting report. We <em>think</em> it's going to work...</p>
29,194
<p>I am an Ajax developer and I want to build a Flash application. Given my previous experience with JavaScript, what do you thing will be the easiest way to learn ActionScript and what are the obstacles I might encounter? </p>
<p>Don't whatever you do start by buying Flash Pro. It is a designer tool and is really rather crap for developing code. By all means invest in it later, but it is a hindrance to coders getting into ActionScript; not an aid. I'd recommend getting yourself either <a href="http://www.adobe.com/products/flex/features/flex...
<p>the best way to learn action script can only through video tutorials. Better tryout video tutorials which helps u lot teach you step by step (very easily understandable) which is very easy to understand. you can also vist <a href="http://www.infoclassi.do.am" rel="nofollow noreferrer">http://www.infoclassi.do.am</a>...
23,946
<p>I would like to format a price in JavaScript. I'd like a function which takes a <code>float</code> as an argument and returns a <code>string</code> formatted like this:</p> <pre><code>&quot;$ 2,500.00&quot; </code></pre> <p>How can I do this?</p>
<h2><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed" rel="noreferrer">Number.prototype.toFixed</a></h2> <p>This solution is compatible with every single major browser:</p> <pre><code> const profits = 2489.8237; profits.toFixed(3) // Returns 2489.824 (rounds u...
<p>after converting PHP number_format() to javascript this work for me</p> <pre><code>function number_format(number, decimals = 0, dec_point = &quot;.&quot;,thousands_sep = &quot;,&quot;) { number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); var n = !isFinite(+number) ? 0 : +number, prec = !isFinite(+d...
17,964
<p>I have this form:</p> <pre><code>&lt;form name="customize"&gt; Only show results within &lt;select name="distance" id="slct_distance"&gt; &lt;option&gt;25&lt;/option&gt; &lt;option&gt;50&lt;/option&gt; &lt;option&gt;100&lt;/option&gt; &lt;option value="10...
<p>The comma in the selector string separates completely separate expressions, just like in CSS, so the selector you've given gets the select elements within the form named "customize" and all inputs on the form (as you've described). It sounds like you want something like this:</p> <pre><code>$("form[name='customize'...
<p>For me your suggestion worked. You could also use</p> <pre><code>form[name='customize'] select, form[name='customize'] input </code></pre> <p>Both selectors work as I see it. Maybe the the problem lies somewhere else?</p> <p>I tried</p> <pre><code>$("form[name='customize'] select, input").css( 'font-size', '80px...
34,832
<p>When I try to display the contents of a LOB (large object) column in SQL*Plus, it is truncated. How do I display the whole thing?</p>
<pre><code>SQL&gt; set long 30000 SQL&gt; show long long 30000 </code></pre>
<p>You may also need:</p> <pre><code>SQL&gt; set longchunksize 30000 </code></pre> <p>Otherwise the LOB/CLOB will wrap.</p>
14,936
<p>I've got to get a directory listing that contains about 2 million files, but when I do an <code>ls</code> command on it nothing comes back. I've waited 3 hours. I've tried <code>ls | tee directory.txt</code>, but that seems to hang forever. </p> <p>I assume the server is doing a lot of inode sorting. Is there any w...
<pre><code>ls -U </code></pre> <p>will do the ls without sorting.</p> <p>Another source of slowness is <code>--color</code>. On some linux machines, there is a convenience alias which adds <code>--color=auto'</code> to the ls call, making it look up file attributes for each file found (slow), to color the display. This...
<p>Lots of other good solutions here, but in the interest of completeness:</p> <pre><code>echo * </code></pre>
6,142
<p>I have a new Prusa i3 MK3 and I have noticed that my prints consistently turn out worse on 0.05 mm layer heights than on 0.10 mm. The edges of the 0.05 mm prints turn out rough and sometimes stringy.</p> <p><a href="https://i.stack.imgur.com/KOLcv.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/KOLcv.jpg"...
<p>When printing at small layer heights (high resolution), you probably need to do some test prints first to see if your normal settings work for the lower layer height. You are most probably experiencing an increased pressure build-up in the nozzle due to the nozzle being closer to the bed. A test that might be useful...
<p>One thing that I have learned in my extensive youtubing is that sometimes the hot end can soften the previous layers. Though, take the following advice with a grain of salt as the following is just conceptual for me (I'm still waiting for my first printer to arrive to follow this advice).</p> <p>Tomb of 3D Printed ...
1,097
<p>Is it possible to host a Maven repository that serves the artifacts (at least the jar files) from SourceForge's file release system (since they are already there and SF provides download statistics and such)? </p> <p>All the repositories I have seen use the same directory layout, but is that a must? Download URLs w...
<p>Yes you can. But it's a bit convoluted:</p> <p>If you look at a project like this <a href="http://jwebunit.sourceforge.net/m2-repo/" rel="nofollow noreferrer">http://jwebunit.sourceforge.net/m2-repo/</a> you'll see that they are exposing a perfectly legal maven repo. These are the steps to do it:</p> <p>Theoretica...
<p>Very nice solution, thanks to krosenvold. Additionally, you can try to generate checksums with this part of pom:</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-install-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; ...
47,254
<p>Have had to write my first "proper" multithreaded coded recently, and realised just how little I knew about how "imperative-style" (ie, concurrency models used by C++/C#/Java, and the like) concurrent programming techniques.</p> <p>What resources are there (both books and online tutorials, etc) in order to learn mo...
<p><a href="http://www.justsoftwaresolutions.co.uk/reviews/patterns_for_parallel_programming_review.html" rel="noreferrer">Patterns for Parallel Porgramming</a> is a good general book on concurrent programming techniques. It uses Java threads, OpenMP in C and MPI in C for the examples.</p> <p>Pretty much any decent bo...
<p>You might find my <a href="http://refcardz.dzone.com/refcardz/core-java-concurrency" rel="nofollow noreferrer">Java Concurrency refcard</a> a useful short reference for Java-specific questions.</p>
23,015
<p>I have a working linker script. I want to add another data section whose contents is pulled directly from a file (ld shouldn't parse it and extract the sections and so on). How can I do that?</p> <pre><code>OUTPUT_FORMAT("elf32-i386") ENTRY(start) SECTIONS { .text 0x100000 : { *(.multiboot) *(.text) *...
<p>You could try using <code>objcopy</code> to convert it to a normal object you can link in, and then reference its symbols in the linker script like you would do to a normal object. From the <a href="http://linux.die.net/man/1/objcopy" rel="noreferrer"><code>objcopy</code> manual page</a>:</p> <blockquote> <p>-B b...
<p>Another way with just the linker is to use <a href="https://sourceware.org/binutils/docs/ld/Format-Commands.html" rel="nofollow noreferrer">TARGET</a> and <a href="https://sourceware.org/binutils/docs/ld/File-Commands.html" rel="nofollow noreferrer">INPUT</a> commands.</p> <pre> <b>TARGET(binary)</b> <b>INPU...
42,461
<p>Is it possible to set an iPhone Xcode project to skip the 'CompressResources' build step?</p> <p>Specifically, I want to skip the stage where it runs pngcrush on all of my .png files, many of which don't survive the experience in a form which my app can read.</p> <p><strong>Edit:</strong> the version of pngcrush u...
<p>You can add "IPHONE_OPTIMIZE_OPTIONS=-skip-PNGs" to your project settings to prevent the png mangling, but be careful with it, you might need to optimize the icon and Default.png separately then.</p>
<p>That might be another issue all together. In many cases the problem has to do with naming and can be solved very easily.</p> <p>read this: <a href="http://cocoapi.wordpress.com/2009/03/22/iphone-images-not-appearing-in-real-iphone-this-is-why/" rel="nofollow noreferrer">http://cocoapi.wordpress.com/2009/03/22/iphon...
21,339
<p>I'm having a couple of problems with the JQuery <a href="http://tablesorter.com/docs/" rel="noreferrer">tablesorter</a> plugin. If you click on a column header, it should sort the data by this column, but there are a couple of problems:</p> <ol> <li>The rows are not properly sorted (1, 1, 2183, 236)</li> <li>The to...
<p>The first problem is due to the fact that the table sorter auto detects the column to a 'text'-column (probably because the empty cells). To solve this use this code to initialize the tablesorter and set all the field to either digit or currency depending on the data:</p> <pre><code>&lt;script type="text/javascript...
<ol> <li><p>Blank fields could be a problem (e.g they are not 0), try using custom parser which removes any non-numericals and forces values to integers (example: <a href="http://paste.pocoo.org/show/90863/" rel="nofollow noreferrer">http://paste.pocoo.org/show/90863/</a> )</p></li> <li><p>Put your 'total' row inside a...
38,889
<p>What is the string concatenation operator in Oracle SQL? </p> <p>Are there any "interesting" features I should be careful of? </p> <p>(This seems obvious, but I couldn't find a previous question asking it). </p>
<p>It is <code>||</code>, for example:</p> <pre><code>select 'Mr ' || ename from emp; </code></pre> <p>The only "interesting" feature I can think of is that <code>'x' || null</code> returns <code>'x'</code>, not <code>null</code> as you might perhaps expect.</p>
<p>Using <code>CONCAT(CONCAT(,),)</code> worked for me when concatenating more than two strings. </p> <p>My problem required working with date strings (only) and creating <code>YYYYMMDD</code> from <code>YYYY-MM-DD</code> as follows (i.e. without converting to date format):</p> <pre><code>CONCAT(CONCAT(SUBSTR(DATECOL...
35,125
<p>I am wondering if there are any well-known algorithms that I should be aware of for spacing objects visually.</p> <p>For instance, a LINQ to SQL diagram has many tables but automatically spaces them for readability. Is this pretty much a "place randomly and move if too close/overlap" type algorithm or is there mor...
<p>Roughly, you can perform a "connectedness" analysis on your graph of objects, to determine which is (are) more central; i.e. which have a higher degree of connectivity to other objects. Those go in the center. Figure out your individual sizing of objects, determine the amount of space left, divide that by the numb...
<p>Take a look at <a href="http://www.graphviz.org/" rel="nofollow noreferrer">GraphViz</a>. It might be usable right off the shelf or might be a good starting point.</p>
38,543
<p>I have a gridview containing some data from db, and after a check I want to see a small cross/tick image in each row, due to the result of the check.How can I change the image url dynamically? </p>
<p>You could either use inline statement like <br/> <code>&lt;%#Eval("check").ToString() == "1" ? "images/checked.gif" : "images/unchceked.gif")%&gt;</code></p> <p>or use a function to get the result as follows:</p> <pre><code>&lt;%# getImageUrl(Eval("value")) %&gt; Public Function getImageUrl(ByVal value As Integer)...
<pre><code>&lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:Image ID="check" runat="server" ImageUrl='&lt;%#If(Eval("check") = 1,"images/checked.gif","images/unchceked.gif") %&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; </code></...
28,455
<p>Is it possible to somehow change the look/feel of NetBeans? I know it uses Swing and that usually apps using Swing for its UI can usually have their UI scheme changed.</p> <p>The default appearence for OSX is vomitastic and would even settle for just some sort of barebones <code>default</code> look. The whole look ...
<p>Looks like this might be what I was looking for:</p> <p><a href="http://wiki.netbeans.org/FaqCustomLaf" rel="nofollow noreferrer">http://wiki.netbeans.org/FaqCustomLaf</a></p>
<p>Looks like this might be what I was looking for:</p> <p><a href="http://wiki.netbeans.org/FaqCustomLaf" rel="nofollow noreferrer">http://wiki.netbeans.org/FaqCustomLaf</a></p>
38,942
<p>Is there a way to limit the rows returned at the Oracle datasource level in a Tomcat application?</p> <p>It seems <code>maxRows</code> is only available if you set it on the datasource in the Java code. Putting <code>maxRows="2"</code> on the datasource doesn't apply.</p> <p>Is there any other way limit the rows r...
<p>It isn't something that is available at the configuration level. You may want to double check that it does what you want it to do anyway: <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#setMaxRows(int)" rel="nofollow noreferrer">see the javadoc for setMaxRows</a>. With Oracle it is still goi...
<p>If you know you will be dealing with only one table, then define a view with rownum in the where statement to limit the number of rows. In this way, the number of rows is controlled at the DB and does not need to be specified as part of any query from a client application. If you want to change the number of rows re...
41,432
<p>I am writing an application that needs to bring window of an external app to the foreground, and not necessarily steal focus (there is a setting the user can toggle to steal/not steal focus).</p> <p>What is the best way to go about this using the win32 API? I have tried SetForeground() but it always steals focus a...
<p>SetForegroundWindow is supposed to steal focus and there are certain cases where it will fail.</p> <blockquote> <p>The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window</p> </blockquote> <p>Try cap...
<p>You could use FindWindow to get the HWND of the window, then use the BringWindowToTop function found in the Win32 API.</p>
2,511
<p>I was looking into <a href="https://stackoverflow.com/questions/120936/can-i-add-custom-version-strings-to-a-net-dll">embedding custom version strings</a> using in assemblies a while back, and one approach that the documentation suggested was to embed a windows resource.</p> <p>The only way I can see to create a wi...
<p>It seems that you don't have VS2005 or VS2008 and are looking to create windows resources. Yes, the ".resources" files are binary, but you can create a XML file or a text file which gets converted to this binary file. Take a look at the documentation of the <a href="http://msdn.microsoft.com/en-us/library/ccec7sz1(V...
<p>In VisualStudio 2005 or 2008 (at least), you can add a new "Resources File" item to the project (located under "General" in the "Add new item" dialog). This is a simple XML file, which is perfectly human-editable - all within VisualStudio. I don't know how SubWCRev works, but if it manipulates text files, this shoul...
24,462
<p>I'd like to develop an ecommerce site where I could allow others to sell items, things like pictures, videos, flash, etc. I want to be able to keep a percentage, and pay the rest back to the seller.</p> <p>Is there anything available, DotNetNuke, etc. that would do this or help get this started. If not what's a goo...
<p>You should have a look at <a href="http://www.oscommerce.com/" rel="nofollow noreferrer">osCommerce</a>. </p>
<p>You could use DotNetNuke, or another similar framework if you have additional content that you need to include other than the shopping.</p> <p>If you went with DotNetNuke, you could look at the Catalook store which I believe supports your desired format for selling. It isn't perfect, but it does work, eventually w...
28,885
<p>Perhaps this question is not very clear but I didn't find better words for the heading, which describes the problem I like to deal with shortly.</p> <p>I want to restrict access from a java desktop application to postgres. </p> <p><strong>The background:</strong></p> <p>Suppose you have 2 apps running and the fir...
<p>Why not use <a href="http://www.postgresql.org/docs/8.3/static/mvcc.html" rel="nofollow noreferrer">transactions</a> in your operations? The database has features to maintain data integrity itself, rather than resorting to a brute operation such as a total-database lock.</p> <p>This locking mechanism you describe s...
<p>Year i thought about transactions but in this case i can't use them. I'm sorry i didn't mention it exactly. So assume the follow easy case: A calculation closes one area of responsibility. After calc a new one is opened and new inserts are dedicated to it. But while calculation-process a insert or update or delete i...
28,533
<p>I am looking for a piece of software that I can schedule to check that our web apps are up and running. I've used HP open view years ago, but remember it being quite expensive, I'm looking for something open source or cheap. </p> <p>So it would login in and do some simple actions maybe submit form and check for so...
<p>Decided on site24x7 does login and has a rest api to call to get stats - <a href="http://site24x7.com/index.html" rel="nofollow">site24x7.com/index.html</a> </p>
<p>You can use cron to perform the tests. Cron will run the tests after a specified amount of time such as once per hour.</p> <p>Cron is available in Linux but there are Windows alternatives which you can download. Or you can use Windows' task scheduler.</p>
29,633
<p>I have some C# / asp.net code I inherited which has a textbox which I want to make multiline. I did so by adding textmode="multiline" but when I try to insert a newline, the enter key instead submits the form :P</p> <p>I googled around and it seems like the default behavior should be for enter (or control-enter) to...
<p>It turns out this is a bug with Firefox + ASP.NET where the generated javascript for the defaultButton stuff doesn't work in Firefox. I had to put a replacement for the WebForm_FireDefatultButton function as described <a href="http://forums.asp.net/t/1294544.aspx" rel="nofollow noreferrer">here</a>:</p> <pre><code>...
<p>you can use \n for enter key i.e. [a-zA-Z 0-9/.\n]{20,500}</p>
5,011
<p>i'm using ASP.net with .NET 3.5 on IIS7 (Vista) with the URL Rewrite Module from Microsoft.</p> <p>This means, that i have a </p> <pre><code>&lt;system.webServer&gt; &lt;rewrite&gt;...&lt;/rewrite&gt; ... &lt;/system.webServer&gt; </code></pre> <p>section within the web.config, but i get a warning, that w...
<p>I was able to get this working in Visual Studio 2010.</p> <p>Start with Ruslan's post <a href="http://ruslany.net/2010/04/visual-studio-xml-intellisense-for-url-rewrite-2-0/" rel="noreferrer">here</a> and download the 2.0 IntelliSense file. Then, just follow the directions he posted previously <a href="http://rusl...
<p>I believe you need to have the URL Rewrite Module "installed" within the web.config file on your system.</p> <p>You either need to install the module on your application via the IIS 7.0 interface or have your hosting firm do it for you.</p>
47,425
<p>I have a strongly typed user control ("partial") and I'd like to be able to pass it some additional information from its containing view. For example, I have view that's bound to a product class and i have a partial that also is strongly typed to that same model, but I also need to pass an additional parameter for ...
<p>Change the type of the partial model:</p> <pre><code>class PartialModel { public int ImageSize { get; set; } public ParentModelType ParentModel { get; set; } } </code></pre> <p>Now pass it:</p> <pre><code>&lt;% Html.RenderPartial("_ProductImage", new PartialModel() { ImageSize = 100, ParentModel = V...
<p>I use a generic class model - which is similar in concept to the approach suggested by Craig.</p> <p>I kind of wish MS would create an overload to <code>RenderPartial</code> to give us the same functionality. Just an additional <code>object data</code> parameter would be fine.</p> <p>Anyway, my approach is to crea...
48,273
<p>I'm working on an application that needs to quickly render simple 3D scenes on the server, and then return them as a JPEG via HTTP. Basically, I want to be able to simply include a dynamic 3D scene in an HTML page, by doing something like:</p> <pre><code>&lt;img src="http://www.myserver.com/renderimage?scene=1&amp;...
<p>RealityServer by mental images is designed to do precisely what is described here. More details are available on the product page (including a downloadable Developer Edition).</p> <p><a href="http://www.migenius.com/doc/realityserver/latest/" rel="nofollow noreferrer">RealityServer docs</a></p>
<p>Check out <a href="http://www.wgpu.net" rel="nofollow">wgpu.net</a>.</p> <p>I think it's very helpful.</p>
8,982
<p>Which is better to use in PHP, a 2D array or a class? I've included an example of what I mean by this.</p> <pre><code>// Using a class class someClass { public $name; public $height; public $weight; function __construct($name, $height, $weight) { $this -&gt; name = $name; ...
<p>The "class" that you've constructed above is what most people would use a <em>struct</em> for in other languages. I'm not sure what the performance implications are in PHP, though I suspect instantiating the objects is probably more costly here, if only by a little bit.</p> <p>That being said, if the cost is relati...
<p>If your code uses lot of functions that operate on those attributes (name/height/weight), then using class could be a good option.</p>
4,388
<p>I'm interested: What is C#'s analog of <code>std::pair</code> in C++? I found <code>System.Web.UI.Pair</code> class, but I'd prefer something template-based.</p> <p>Thank you!</p>
<p>Tuples <a href="http://msdn.microsoft.com/en-us/library/system.tuple(v=vs.110).aspx" rel="noreferrer">are available since .NET4.0</a> and support generics:</p> <pre><code>Tuple&lt;string, int&gt; t = new Tuple&lt;string, int&gt;("Hello", 4); </code></pre> <hr> <p>In previous versions you can use <code>System.Coll...
<p>On order to get the above to work (I needed a pair as the key of a dictionary). I had to add:</p> <pre><code> public override Boolean Equals(Object o) { Pair&lt;T, U&gt; that = o as Pair&lt;T, U&gt;; if (that == null) return false; else return this.First.Equals...
20,056
<p>In javascript, we can do:</p> <pre><code>["a string", 10, {x : 1}, function() {}].push("another value"); </code></pre> <p>What is the Scala equivalent?</p>
<p>Arrays in Scala are very much homogeneous. This is because Scala is a statically typed language. If you really need pseudo-heterogeneous features, you need to use an immutable data structure that is parametrized covariantly (most immutable data structures are). <code>List</code> is the canonical example there, bu...
<p>Scala might get the ability for a "heterogeneous" list soon: <a href="http://jnordenberg.blogspot.com/2008/09/hlist-in-scala-revisited-or-scala.html" rel="nofollow noreferrer">HList in Scala</a></p>
22,499
<p>I do mostly Java and C/C++ development, but I'm starting to do more web development (PHP, Rails) and Eiffel (learning a new language is always good).</p> <p>Currently, I use Eclipse for Java, C/C++, and Ruby (not Rails). Since I know the environment, I'm thinking that it would be easier for me to find a plugin and ...
<p>I have used many many IDE's and in most cases to me it breaks down to personal preferences. Sometimes the language specific ones have some addins/addons/features that are nice but unless they are things you can not live without you should go with what is most comfortable for you.</p> <p>I would think that if you ar...
<p>It entirely depends on the user and the language itself, if you are comfortable with the keyboard shortcuts then you can consider the plugin else you can go for a IDE . However most of the IDE comes with a cross-functional key maps so you use the key maps which u are more comfortable with.... </p>
7,292
<p>How do I launch an app and capture the output via stdout and maybe stderr?</p> <p>I am writing an automated build system and I need to capture the output to analyze. I'd like to update the svn repo and grab the revision number so I can move the files in autobuild/revNumber/ if successful. I also would like to build...
<p>In real shells (meaning, not sea shells - I mean, not in C Shell or its derivatives), then:</p> <pre><code>program arg1 arg2 &gt;/tmp/log.file 2&gt;&amp;1 </code></pre> <p>This runs program with the given arguments, and redirects the stdout to /tmp/log.file; the notation (<del>hieroglyph</del>) '<code>2&gt;&amp;1<...
<p>Microsoft's CRTs and the MSDN library do include the system function and the _popen function.</p>
38,553
<p>I have two threads, one updating an int and one reading it. This is a statistic value where the order of the reads and writes is irrelevant.</p> <p>My question is, do I need to synchronize access to this multi-byte value anyway? Or, put another way, can part of the write be complete and get interrupted, and then t...
<p>At first one might think that reads and writes of the native machine size are atomic but there are a number of issues to deal with including cache coherency between processors/cores. Use atomic operations like Interlocked* on Windows and the equivalent on Linux. C++0x will have an "atomic" template to wrap these i...
<p>The only portable way is to use the sig_atomic_t type defined in signal.h header for your compiler. In most C and C++ implementations, that is an int. Then declare your variable as "volatile sig_atomic_t."</p>
7,779
<p>For general code, do I really need to dispose an object? Can I just ignore it for the most part or is it a good idea to always dispose an object when your 100% sure you don't need it anymore? </p>
<p>Dispose of an object the instant your are done with it. Disposable objects represent objects holding a valuable resource which the CLR is not intrinsically aware of. Consequently the GC is also unaware of the resources and is unable to make intelligent decisions as to when it should collect a disposable object and ...
<p>Relying on the GC 'works' in most instances. The classic exception is when you have a resource heavy interaction - in that instance it is best to explicilty dispose.</p> <p>obvious eg.</p> <pre><code>using (var conn = new SqlConnection(connString)) {} </code></pre> <p>'Using' blocks are definitely the cleanest an...
30,504
<p>In oracle, I want to create a delete sproc that returns an integer based on the outcome of the deletion.</p> <p>this is what i have so far.</p> <pre><code>create or replace PROCEDURE Testing ( iKey IN VARCHAR2 ) AS BEGIN delete from MyTable WHERE TheKey = iKey; END Testing; </code></pre> <p>i've tried p...
<p>A procedure does not return a value. A function returns a value, but you shouldn't be doing DML in a function (otherwise you cannot do things like reference the function in a SQL statement, you confuse permission grants since normally DBAs want to be able to grant read-only users access to all the functions so that...
<p>You are probably looking for a function instead. </p> <pre><code>FUNCTION TESTING (iKEY IN VARCHAR2) RETURN NUMBER IS v_count NUMBER; yourNumber NUMBER; BEGIN SELECT COUNT(*) INTO v_count FROM MyTable WHERE TheKey = iKey; IF v_count &gt; 0 THEN DELETE FROM MyTable WHERE TheKey = iKe...
32,826
<p>I assist in maintaining an enterprise web-based system (programmed in J2EE, but this is a more general question) and I'd like to know: what good tools are out there to measure the "health" of an enterprise system? For instance, tools to check memory space on servers, check the status of batch runs, the number of re...
<p><a href="https://www.opennms.org/en/opennms/the-platform" rel="nofollow noreferrer">OpenNMS</a> is a nice monitoring tool. Out of the box it can monitor various aspects of a server, mostly things like memory, network usage, disk space. But it's open source, and can be extended to monitor other things. </p> <p>We...
<p>+1 for OpenNMS. In addition to its out-of-the-box system-level monitoring, it can be easily extended with JMX, so your applications can expose their innards as JMX attributes, and OpenNMS can monitor them, graph them, raise alerts based on them, etc.</p> <p>We've also extended OpenNMS to send SMS alerts when thing...
16,995
<p>What's the easiest way of me converting the simpler regex format that most users are used to into the correct re python regex string?</p> <p>As an example, I need to convert this:</p> <pre><code>string = "*abc+de?" </code></pre> <p>to this:</p> <pre><code>string = ".*abc.+de.?" </code></pre> <p>Of course I coul...
<p>Those don't look like regexps you're trying to translate, they look more like unix shell globs. Python has a <a href="http://www.python.org/doc/2.5.2/lib/module-fnmatch.html" rel="nofollow noreferrer">module</a> for doing this already. It doesn't know about the "+" syntax you used, but neither does my shell, and I...
<p>I'd use <a href="http://www.python.org/doc/2.5.2/lib/string-methods.html#l2h-255" rel="nofollow noreferrer"><code>replace</code></a>:</p> <pre><code>def wildcard_to_regex(str): return str.replace("*", ".*").replace("?", .?").replace("#", "\d") </code></pre> <p>This probably isn't the most efficient way but it ...
26,784
<p>Is it possible to detect, on the client side, whether the user is using an encrypted page or not?</p> <p>Put another way -- I want to know if the URL of the current page starts with http or https.</p>
<p>Use <code>window.location.protocol</code> to check if it is <code>https:</code></p> <pre><code>function isSecure() { return window.location.protocol == 'https:'; } </code></pre> <p>Alternatively you can omit specifying "window" if you don't have a locally scoped location.</p> <pre><code>function isSecure() { ...
<p>Second method for newest browsers: </p> <pre><code>var secure = window.isSecureContext; </code></pre> <p>or just get isSecureContext:</p> <pre><code>if (isSecureContext) { ... } </code></pre> <p>More here: <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts#Feature_detection#Feature...
35,766
<p>I am trying to read an XML-file from another server. However the the company that's hosting me seems to have turned of the file_get_contents function from retrieving files for files from other servers (and their support is not very bright and it takes forever for them to answer). So I need a work around in some way....
<p>You could use <a href="http://www.php.net/curl" rel="nofollow noreferrer">cURL</a> (if that's not been disabled). Something like this:</p> <pre><code>$c = curl_init($url); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $xmlstr = curl_exec($c); </code></pre>
<p>The ini var you're referring to is <code>allow_url_fopen</code>. To check, run this script:</p> <pre><code>var_dump(ini_get('allow_url_fopen')); </code></pre> <p>Ask your host to turn that ini value on (if it's disabled - it's on by default).</p> <p>You should not be able to access any remote url without that ini...
30,265
<p>Does anyone happen to know if there is a token I can add to my csv for a certain field so Excel doesn't try to convert it to a date?</p> <p>I'm trying to write a .csv file from my application and one of the values happens to look enough like a date that Excel is automatically converting it from text to a date. I'v...
<p>I have found that putting an '=' before the double quotes will accomplish what you want. It forces the data to be text.</p> <p>eg. ="2008-10-03",="more text"</p> <p><strong>EDIT (according to other posts)</strong>: because of the <a href="https://stackoverflow.com/a/4412775/684229">Excel 2007 bug noted by Jeffieki...
<p>If you put an inverted comma at the start of the field, it will be interpreted as text.</p> <p>Example: <code>25/12/2008</code> becomes <code>'25/12/2008</code></p> <p>You are also able to select the field type when importing.</p>
19,948
<p>I am currently tasked with developing a tool to use JMX to monitor JVMs for things like, but not limited too, memory usage, heap size, thread count. The desired tool is one that can display many graphs for each jvm next to each other (example below). </p> <p>So the question is it best to build your own? Use anoth...
<p>Sounds like what both jConsole and VisualVM do - both are distributed with JDK-6.</p>
<p><a href="http://jcp.org/en/jsr/detail?id=262" rel="nofollow noreferrer">Web Services Connector for Java Management Extensions (JMX) Agents</a>, which seem to be planned for Java 7, offer an easy way to implement such a tool in any language. It is a web service / http based JMX agent standard, and can also be used to...
41,064
<p>How should I store (and present) the text on a website intended for worldwide use, with several languages? The content is mostly in the form of 500+ word articles, although I will need to translate tiny snippets of text on each page too (such as "print this article" or "back to menu").</p> <p>I know there are sever...
<p>Firstly put all code for all languages under one domain - it will help your google-rank.</p> <p>We have a fully multi-lingual system, with localisations stored in a database but cached with the web application.</p> <p>Wherever we want a localisation to appear we use:</p> <pre><code>&lt;%$ Resources: LanguageProvi...
<p>If you're just worried about the article content being translated, and do not need a fully integrated option, I have used <a href="http://www.google.com/language_tools" rel="nofollow noreferrer">google translation</a> in the past and it works great on a smaller scale.</p>
9,802
<p>We have a WinForms application which runs on a touch-screen on a bit of industrial equipment. For historical reasons which are not up for changing today, the displayed form has a normal Windows title bar. </p> <p>We would like to stop people using the mouse (i.e. touchscreen) from moving the window by dragging the...
<p>Nc messages are still the go I think. Syncfusion's windows form faq has the code you need. I'd paste a link, but I'm on an iPhone with no copy paste (grumble, grumble!)</p>
<p>How about modify the main form event's LocationChanged, SizeChanged, etc...</p>
28,889
<p>I know what MVC is and I work in webforms but I don't know how MVC will be that much different. I guess the code behind model will be different. So will it be like webforms minus the code behind and instead having it in a controller?</p> <p>I see there are other related posts but I don't they address this.</p>
<p>For starters, MVC does not use the &lt;asp:control&gt; controls, in preference for good old standard &lt;input&gt;'s and the like. Thus, you don't attach "events" to a control that get executed in a code-behind like you would in ASP. It relies on the standard http POST to do that.</p> <p>It does not use the viewsta...
<p>Asp.Net Web Forms:</p> <ol> <li>Asp.Net Web Form follows a traditional event driven development model. </li> <li>Asp.Net Web Form has server controls.</li> </ol> <p>Asp.Net MVC model:</p> <ol> <li>Asp.Net MVC is a lightweight and follow MVC (Model, View, and Controller) pattern based development model.Asp....
17,183
<p>Just updated build server with rc0 and surprise no chiron. Wondering how you package up a xap file without chiron.</p>
<p>Hey Brian, you can get chiron from <a href="http://www.codeplex.com/sdlsdk" rel="nofollow noreferrer">http://www.codeplex.com/sdlsdk</a> -- it was decided to be removed from the SL SDK core tools, but is still a part of the DLR SDK which is available.</p>
<p>More specifically you can still use MSBuild. The targets should be located at C:\program files\MSBuild\Microsoft\Silverlight\v2.0 if you need to look at them or modify...your .csproj(or.vbproj) can also have pre/post build tasks for MSBuild as well.</p>
21,832
<p>Is there a control out in the world that allows a user to log in to a website with MS Passport (Windows Live ID, whatever), Facebook, OpenID, etc. all in one control?</p> <p>Thanks, everyone!</p>
<p>I am not aware of any control that allows all of them, but the API's are pretty simple that would allow you to implement it yourself.</p>
<p>I am not aware of any control that allows all of them, but the API's are pretty simple that would allow you to implement it yourself.</p>
25,645
<p>I have a large quantity of clearcase data which needs to be migrated into perforce. The revisions span the better part of a decade and I need to preserve as much branch and tag information as possible. Additionally we make extensive use of symbolic links, supported in clearcase but not in perforce. What advice or...
<p>The first step is to decide if you need to migrate everything, or just certain key versions. If you only migrate the important versions (releases and major milestones) you'll end up with a much simpler history in Perforce, without losing anything important. Then ClearCase can be keep as a historical archive in cas...
<p>What you also have to keep in mind is the fact, that your importerscript may slightly commit in another sequence than the clearcase commits(maybe you are traversing dir, may be histories of files, etc.) </p> <p>So, unless you gather all version information into a (large) database and sort them afterwards, you will ...
14,501
<p>I have a CompositeDataBoundControl and im trying to add a ItemCommand to it, ala the System.Web.UI.WebControls.Repeater - so like a numpty, I just thought if I reflector'ed and added the code like so, it should work:</p> <pre><code>private static readonly object EventItemCommand = new object(); protected override ...
<p>In the case of the Repeater control the RepeaterItem object is actually raising the bubble event and supplying the RepeaterCommandEventArgs:</p> <pre><code>protected override bool OnBubbleEvent(object source, EventArgs e) { if (e is CommandEventArgs) { RepeaterCommandEventArgs args = new RepeaterCom...
<p>Im using a custom "RepeaterItem" (eg. RecipeItem) - I cant seem to get the OnBubbleEvent (have overriden it and stole things from RepeaterItem) to fire in the item.</p> <p>Nevermind, im an idiot. Commented out a DataBind();!</p>
38,445
<p>Could you recommend me a way to place a coundown timer on ASP.NET page?</p> <p>Now I use this code:</p> <p><strong>Default.aspx</strong></p> <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTempla...
<p>OK, finally I ended with</p> <pre><code>&lt;span id="timerLabel" runat="server"&gt;&lt;/span&gt; &lt;script type="text/javascript"&gt; function countdown() { seconds = document.getElementById("timerLabel").innerHTML; if (seconds &gt; 0) { document.getElementById("time...
<p>use this javascript code----</p> <pre><code>var sec=0 ; var min=0; var hour=0; var t; function display(){ if (sec&lt;=0){ sec+=1; } if(sec==60) { sec=0; min+=1; } if(min==60){ hour+=1; min=0; } if (min&lt;=-1){ sec=0; min+=1; } else sec+=1 ; document.getElementById("&lt;%=TextBox1.Cl...
13,432
<p>In our Sharepoint implementation users have been granted site collection admin rights. On a few occasions they've managed to delete a subsite or even the entire site collection. I'd like to be able to block this but not being a developer I'm finding it pretty tricky.</p> <p>I've had a look at <a href="http://www.co...
<p>Change the user permissions may be the best way to go. site collection admin is a crazy level of access for normal users.</p>
<p>A Site Collection administrator has the permission to delete sites and it should stay that way. We have modified MSIT to do additional stuff</p> <p>The best way to limit user privileges is to put users in the right SharePoint group (ie) Owners, Members, Visitors or you could create a new group with right permission...
30,197
<p>What is the accepted practice for indenting SQL statements? For example, consider the following SQL statement:</p> <pre><code>SELECT column1, column2 FROM table1 WHERE column3 IN ( SELECT TOP(1) column4 FROM table2 INNER JOIN table3 ON table2.column1 = table3.column1 ) </code></pre> <p>How should this be indented...
<pre><code>SELECT column1 , column2 FROM table1 WHERE column3 IN ( SELECT TOP(1) column4 FROM table2 INNER JOIN table3 ON table2.column1 = table3.column1 ) </code></pre> <p>I like to have all <strong>"," in front</strong>, this way I never search them when an error at line X from the SQL editor.</...
<p>That's how we would do it here:</p> <pre> select COLUMN1, COLUMN2, case when COLUMN5 = 'X' and COLUMN6 = 'Y' then 'one' when COLUMN5 in ( 'AAA', ...
34,263
<p>I need to add some simple image renders of STL files to a document. I currently open the STL files in Preview or one of the slicers and grab a screen shot.</p> <p>Is there an easier or automatic way to generate PNG images from STL files on a Mac?</p>
<p>If you have <a href="http://www.openscad.org" rel="noreferrer">OpenSCAD</a> installed, this shell script will generate 100x100 pixel PNG images for each STL file in your current directory.</p> <pre><code>for i in *.stl; do T=__tmp__<span class="math-container">$i b=`basename $</span>i` echo import\(\"<span cl...
<p>You can use OpenSCAD, as stated in the accepted answer. Here is a version of that script that works for Windows for anyone who needs it, as I did.</p> <pre><code># Change height and width to the desired output image dimensions, in pixels. # The path to openscad.exe may also have to be adjusted based on your instal...
915
<p>I am getting a runtime error 13 at the end of the following code:</p> <pre><code>Sub plausibilitaet_check() Dim rs As DAO.Recordset Dim rs2 As ADODB.Recordset Dim db As database Dim strsql As String Dim strsql2 As String Dim tdf As TableDef Set db = opendatabase("C:\Codebook.mdb") Set rs = db.OpenRecordset("pl...
<p>You are mixing up ADO and DAO. In this case rs2 should be a DAO recordset.</p> <pre><code>Sub plausibilitaet_check() Dim rs As DAO.Recordset Dim rs2 As DAO.Recordset Dim db As database Dim strsql As String Dim strsql2 As String Dim tdf As TableDef Set db = opendatabase("C:\Codebook.mdb") Set rs = db.OpenRecordset...
<p>CurrentDB.OpenRecordset returns an instance of DAO.Recordset. You are trying to assign the result to ADODB.Recordset</p> <p>Change the rs2 definition to</p> <p><code> dim rs2 as DAO.Recordset </code></p>
42,132
<p>I have a home project that really needs to be in Source Control. I tried installing Subversion, which I have some experience with, but couldn't get it working. I don't particularly want to use SourceSafe. I'm a bit nervous about Git/Mercury as being somewhat cryptic, although this is only based on opinion rather ...
<p>I know you mentioned you already tried Subversion and had some issues but you really can't beat the easy install &amp; configuration of</p> <h3><a href="http://www.visualsvn.com/server/" rel="noreferrer">VisualSVN Server</a></h3> <p>Insanely easy to setup &amp; maintain.</p> <hr /> <p>Use VisualSVN for the back-end ...
<p>The only options I'm aware of that meet your requirements are CVS and SVN. Of those 2, I would recommend SVN. I know you've already tried it without success, so perhaps you should try posting another question describing exactly what the problem was.</p> <p>Our glorious leader posted a step-by-step guide describing ...
26,884
<p>I'm looking for a builder for <a href="http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html" rel="noreferrer">HQL</a> in Java. I want to get rid of things like:</p> <pre><code>StringBuilder builder = new StringBuilder() .append("select stock from ") .append( Stock.class.getName() ) .append(...
<p>@<a href="https://stackoverflow.com/questions/56843/looking-for-an-hql-builder-hibernate-query-language#57001">Sébastien Rocca-Serra</a><br> Now we're getting somewhere concrete. The sort of join you're trying to do isn't really possible through the Criteria API, but a sub-query should accomplish the same thing. Fir...
<p>Now are also available the standard <a href="http://www.ibm.com/developerworks/library/j-typesafejpa/" rel="nofollow">JPA Type Safe</a> query and an less standard but also good <a href="https://www.objectquery.org/" rel="nofollow">Object Query</a></p> <p>Examples:</p> <p>JPA Type Safe</p> <pre><code>EntityManager...
8,095
<p>I am developing a web page code, which fetches dynamically the content from the server and then places this content to container nodes using something like</p> <pre><code>container.innerHTML = content; </code></pre> <p>Sometimes I have to overwrite some previous content in this node. This works fine, until it happ...
<p>The easiest solution that I have found would be to place an anchor tag <code>&lt;a&gt;</code> at the top of the <code>div</code> you are editing:</p> <pre><code>&lt;a name="ajax-div"&gt;&lt;/a&gt; </code></pre> <p>Then when you change the content of the <code>div</code>, you can do this to have the browser jump to...
<p>It sounds like you are having a problem with the browser itself. Does this problem only occur in one browser?</p> <p>One thing you might try is using a lightweight library like <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>. It handles browser differences fairly nicely. To set the inner HTML f...
8,913
<p>Can't seem to rename an existing Verity collection in ColdFusion without deleting, recreating, and rebuilding the collection. Problem is, I have some very large collections I'd rather not have to delete and rebuild from scratch. Any one have a handy trick for this conundrum?</p>
<p>I don't believe that there is an easy way to rename a Verity collection. You can always use </p> <pre><code>&lt;cfcollection action="map" ...&gt; </code></pre> <p>to assign an alias to an existing collection, provided you do not need to re-use the original name.</p>
<p>Looks like this is not possible. Deleting and re-creating the collection with the desired name appears to be the only approach available.</p>
18,855
<p>Dendrogram is not a regular diagram. Should I use any component from javax.swing.* library, or just draw it with java.awt.Graphics?</p>
<p>Might also be worth checking: <a href="http://www.yworks.com/en/index.html" rel="nofollow noreferrer">yWorks</a> and <a href="http://www.jgraph.com/" rel="nofollow noreferrer">JGraph</a></p>
<p>I don't think there is a standard component for this. Unless some component vendor has done one, you should go the Java 2D way...</p> <p>If you don't want to do the hard work, perhaps one of the above mentioned libraries might help you. Otherwise, GraphViz is good at making this kind of diagram, and has a <a href="...
34,432
<p>I'm look for a GIS/Mapping tool that will give me easy SERVER-SIDE access to route information (specifically, trip time and distance) in an ASP.NET web application.</p> <p>From what I can tell, Google and Yahoo maps do everything client-side in javascript, but neither provide services to retrieve just the route inf...
<p>We've had success with using the web services from Map24 (<a href="http://developer.navteq.com/site/global/zones/ms/index.jsp" rel="nofollow noreferrer">http://developer.navteq.com/site/global/zones/ms/index.jsp</a>) to do some GIS-y type things. They have a web service for doing routing (<a href="http://developer.n...
<p>Arc Web Services is going away and is now becoming ArcGIS online. </p> <p>This means a whole new updated sdk for developing arc web applications for web sites. </p> <p>If you need a really advanced routing system developed a company called routesmart makes dll based route solver solutions for client server apps an...
15,389
<p>We are upgrading our servers to SQL Server 2005 from SQL Server 2000. We currently use the jtds drivers.</p> <p>I'm interested to know what peoples opinions are of the different jdbc drivers available (in particular the latest Microsoft driver), how they perform with SQL Server 2005 and any other lessons from your ...
<p>I have used the MS provided driver, the jtds driver, as well as the driver from jnetdirect.</p> <p>Unfortunately none of them is perfect, and all have their own bugs (including of course Microsofts own). The MS provided drivers of course have support for the newest features before the other vendors, but I must say...
<p>We tried using Microsoft JDBC Driver 2.0 with SQL Server 2005. The problem we were running into was - when calling a stored procedure, the driver was generating the following sql statements - </p> <pre><code>declare @P1 int set @P1=1 exec sp_prepexec @P1 output, N'@P0 int', N'EXEC getEmployeeManagers @P0', 50 selec...
44,354
<p>here is what a I'm doing: </p> <pre><code>object ReturnMatch(System.Type type) { foreach(object obj in myObjects) { if (obj == type) { return obj; } } } </code></pre> <p>However, if obj is a subclass of <code>type</code>, it will not match. But I w...
<p>I've used the IsAssignableFrom method when faced with this problem.</p> <pre><code>Type theTypeWeWant; // From argument or whatever foreach (object o in myCollection) { if (theTypeWeWant.IsAssignableFrom(o.GetType)) return o; } </code></pre> <p>Another approach that may or may not work with your probl...
<p>the is operator indicates whether or not it would be 'safe' to cast one object as another obeject (often a super class).</p> <pre><code>if(obj is type) </code></pre> <p>if obj is of type 'type' or a subclass thereof, then the if statement will succeede as it is 'safe' to cast obj as (type)obj.</p> <p>see: <a href...
9,798
<p>Out of curiosity, anyone knows the particulars of the internal implementation of </p> <pre><code>ListControl.SelectedIndex = (int) &lt;new valueIndex&gt; </code></pre> <p>VS </p> <pre><code>ListControl.SelectedValue = &lt;new value&gt;.ToString() </code></pre> <p>I'm having difficulties with a custom validation ...
<p>Following Jeb's suggeston in a comment, I created a <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-tags" rel="nofollow noreferrer">custom template tag</a>.</p> <p>I replaced <code>{{ forloop.counter }}</code> with <code>{% counter %}</code>, a tag that simply print...
<p>I think you can use forloop.parentloop.counter inside of the inner loop to achieve the numbering you're after.</p>
37,016
<p>We're looking for a package to help identify and automatically rotate faxed TIFF images based on a watermark or logo. </p> <p>We use libtiff for rotation currently, but don't know of any other libraries or packages I can use for detecting this logo and determining how to rotate the images.</p> <p>I have done som...
<p>You are in the right place using OpenCV, it is an excellent utility. For example, <a href="http://www.nashruddin.com/template-matching-in-opencv-with-example.html" rel="nofollow noreferrer">this guy</a> used it for template matching, which is fairly similar to what you need to do. Also, the link Roddy specified look...
<p>The Intel Performance Primitives (IPP) library has a lot of very efficient algorithms that help with this kind of a task. The library is callable from C/C++ and we have found it to be very fast. I should also note that it's not limited to just Intel hardware.</p>
5,263
<p>This is sort of a follow-up to <a href="https://stackoverflow.com/questions/223678">this question</a>.</p> <p>If there are multiple blobs with the same contents, they are only stored once in the git repository because their SHA-1's will be identical. How would one go about finding all duplicate files for a given t...
<pre><code>[alias] # find duplicate files from root alldupes = !"git ls-tree -r HEAD | cut -c 13- | sort | uniq -D -w 40" # find duplicate files from the current folder (can also be root) dupes = !"cd `pwd`/$GIT_PREFIX &amp;&amp; git ls-tree -r HEAD | cut -c 13- | sort | uniq -D -w 40" </code></pre>
<p>More general:</p> <pre><code>( for f in `find .`; do test -f $f &amp;&amp; echo $(wc -c &lt;$f) $(md5 -q $f) ; done ) |sort |uniq -c |grep -vE '^\s*1\b' |sed 's/.* //' &gt; ~/dup.md5 ; \ ( for f in `find .`; do test -f $f &amp;&amp; echo $(wc -c &lt;$f) $(md5 -q $f) $f; done ) |fgrep -f ~/dup.md5 |sort </code></p...
27,768
<p>I have C++ project (VS2005) which includes header file with version number in #define directive. Now I need to include exactly the same number in twin C# project. What is the best way to do it?</p> <p>I'm thinking about including this file as a resource, then parse it at a runtime with regex to recover version numb...
<p>You can achieve what you want in just a few steps:</p> <ol> <li>Create a MSBuild Task - <a href="http://msdn.microsoft.com/en-us/library/t9883dzc.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/t9883dzc.aspx</a></li> <li>Update the project file to include a call to the task created prior to ...
<p>I wrote a python script that converts #define FOO "bar" into something usable in C# and I'm using it in a pre-build step in my C# project. It works. </p> <pre><code># translate the #defines in messages.h file into consts in MessagesDotH.cs import re import os import stat def convert_h_to_cs(fin, fout): for...
12,617
<p>Ok we have a number of solutions all with a lot of shared binaries:</p> <p>what we do is the following.</p> <p>In a shared drive we have this following layout where there is a directory for every binary dependency and a sub directory for every version</p> <p>BinaryDep1<br> -----------Volatile<br> -----------1.0<b...
<p>What about the same struture in all developer machines?</p> <p>Like:</p> <p>d:/projects<br> d:/projects/ext (the shared libraries you need here)<br> d:/projects/project1<br> d:/projects/project2<br> d:/projects/project3<br> d:/projects/project4<br> ...</p> <p>ps: I love conventions.</p>
<p>Is any <a href="http://en.wikipedia.org/wiki/Global_Assembly_Cache#Pitfalls" rel="nofollow noreferrer">reason</a> for not putting shared assemblies to <a href="http://msdn.microsoft.com/en-us/library/yf1d93sz.aspx" rel="nofollow noreferrer">GAC</a>?</p>
46,651
<pre><code>echo $_POST["name"]; //returns the value a user typed into the "name" field </code></pre> <p>I would like to be able to also return the text of the key. In this example, I want to return the text "name". Can I do this?</p>
<p>Check out the array_keys() function assuming this is PHP.</p> <p><a href="http://us2.php.net/array_keys" rel="noreferrer">http://us2.php.net/array_keys</a></p>
<pre><code>array_keys($_POST) </code></pre> <p><a href="http://de.php.net/array_keys" rel="nofollow noreferrer">Manual</a></p>
22,238
<p>I am trying to set myself up on a mac to learn Ruby on Rails, however I seem to be having some problems. If I try to run commands such as ./script/server, i get this: </p> <blockquote> <p>Rails requires RubyGems >= 0.9.4 (you have 0.9.2). Please <code>gem update --system</code> and try again.</p> </blockquote> <...
<p>got it. </p> <p>sudo gem update --system </p>
<p>Starting with El Capitan, Apple prevents user applications to modify <code>/usr/bin</code> for security reasons. So better install/update rubygems in the recommended folder, <code>/usr/local/bin</code>:</p> <pre><code>sudo gem update -n /usr/local/bin --system </code></pre> <p>(recommendation taken from <a href="h...
20,544
<p>I am writing a key record look up where the I have an index between the key and the rec number. This is sorted on the key. Is there away to do this better that what I have for speed optimization?</p> <pre><code>typedef struct { char key[MAX_KEYLEN]; int rec; } KeyRecPair; typedef struct { KeyRecPair...
<p>A good chunk of your time will be spent in the strncmp.</p> <p>I suggest forcing that to be <a href="http://en.wikipedia.org/wiki/Inlining" rel="nofollow noreferrer">inlined</a>, or rewriting it inline, to avoid the function call over head.</p> <p>If you are feeling brave it may be possible to <a href="http://en.w...
<p>The only potential optimization that I can think of is to use something similar to golden ratio in calculating <code>half</code> instead of dividing the remaining subset to two halves with equal number of elements, that is</p> <pre><code> if (cmpValue &gt; 0) { /*top stays*/ ...
46,542
<p>As popular as Ruby and Rails are, it seems like this problem would already be solved. JRuby and mod_rails are all fine and dandy, but why isn't there an Apache mod for just straight Ruby?</p>
<p>There is <a href="http://www.modrails.com/" rel="nofollow noreferrer">Phusion Passenger</a>, a robust Apache module that can run <a href="http://rack.rubyforge.org/" rel="nofollow noreferrer">Rack</a> applications with minimum configuration. It's becoming appealing to shared hosts, and turning any program into a Rac...
<p>There is <a href="http://www.modrails.com/" rel="nofollow noreferrer">mod_rails</a> and it can run <a href="http://rack.rubyforge.org/" rel="nofollow noreferrer">Rack</a> applications, what more can you need?</p>
10,062
<p>I was looking for a way to remove text from and RTF string and I found the following regex:</p> <pre><code>({\\)(.+?)(})|(\\)(.+?)(\b) </code></pre> <p>However the resulting string has two right angle brackets "}"</p> <p><strong>Before:</strong> <code>{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fc...
<p>In RTF, { and } marks a group. Groups can be nested. \ marks beginning of a control word. Control words end with either a space or a non alphabetic character. A control word can have a numeric parameter following, without any delimiter in between. Some control words also take text parameters, separated by ';'. Those...
<p>None of the answers were sufficient, so my solution was to use the RichTextBox control (yes, even in a non-Winform app) to extract text from RTF</p>
22,862
<p>We need to reliably get the Quick Launch folder for both All and Current users under both Vista and XP. I'm developing in C++, but this is probably more of a general Windows API question.</p> <p>For reference, here is code to get the Application Data folder under both systems:</p> <pre><code> HRESULT hres; ...
<p>AppData on vista refers to C:\Users\xxxx\AppData\Roaming not the C:\Users\xxxx\AppData folder it's self.</p> <p>Also this artical <a href="http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0901.mspx" rel="nofollow noreferrer">http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05...
<p>Great question! </p> <p>Whatever you do, <strong>don't</strong> give into the temptation to <a href="http://blogs.msdn.com/oldnewthing/archive/2003/11/03/55532.aspx" rel="nofollow noreferrer">dig into the registry</a> to find this info!</p> <p>Also, we must resist the temptation to hard code some path, even partia...
10,172