instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I am wondering what primers/guides/tutorials/etc. are out there for learning to rewrite URLs using Apache/.htaccess? Where is a good place to start?</p> <p>My primary interest is learning how to point certain directories to others, and how to use portions of a URL as parameters to a script (i.e. "/some/subdirs/like...
<p>I found this to be pretty useful: <a href="http://www.addedbytes.com/apache/url-rewriting-for-beginners/" rel="noreferrer">http://www.addedbytes.com/apache/url-rewriting-for-beginners/</a></p>
<p>What's wrong with <a href="http://httpd.apache.org/docs/2.2/rewrite/rewrite_intro.html" rel="nofollow noreferrer">the manual</a>?</p>
14,837
<p>I have this wing design that I want to print:</p> <p><a href="https://i.stack.imgur.com/EF87K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EF87K.png" alt="wing"></a></p> <p>You can notice that its walls have a thickness, which is 1.0&nbsp;mm. I want to print it so that the perimeters are insi...
<p>I found a great solution!</p> <p>In Cura, there is a setting under <strong>Shell</strong> called <strong>Horizontal Expansion</strong>. What this does is it controls the distance between the two perimeters. A negative value in this field will make them come closer together, thus removing the gap between them.</p> ...
<p>Consider to create a test print using the settings you've presented in the sliced output rendering. It could be something as small as a 4 or 5 mm tall cross section, enough to get clear of the bed and establish a stable base. You may find that your goal is achieved.</p> <p>Also consider that a common nozzle diamete...
618
<p>To make click-able divs, I do:</p> <pre><code>&lt;div class="clickable" url="http://google.com"&gt; blah blah &lt;/div&gt; </code></pre> <p>and then </p> <pre><code>$("div.clickable").click( function() { window.location = $(this).attr("url"); }); </code></pre> <p>I don't know if this is the best way, but...
<p>If you return "false" from your function it'll stop the event bubbling, so only your first event handler will get triggered (ie. your anchor will not see the click).</p> <pre><code>$("div.clickable").click( function() { window.location = $(this).attr("url"); return false; }); </code></pre> <p>See <a href="...
<pre><code>&lt;div class="info"&gt; &lt;h2&gt;Takvim&lt;/h2&gt; &lt;a href="item-list.php"&gt; Click Me !&lt;/a&gt; &lt;/div&gt; $(document).delegate("div.info", "click", function() { window.location = $(this).find("a").attr("href"); }); </code></pre>
21,736
<p>There's a lot of questions on here regarding various niche build needs (.NET, continuous integration, etc) but, of course, my niche need is different.</p> <p>Rather than asking a very specific question right now, I'd like a survey of available build tools (such as make, ant, etc) so I can ask a follow up question m...
<p><a href="http://www.scons.org/" rel="nofollow noreferrer">SCons</a></p> <p>Build scripts are Python scripts. Supposed to work on Linux, Windows, Mac OS X.</p>
<p><strong>NUBuild</strong> (pronounced "New-Build")</p> <p>This is the latest and pretty advanced .Net build tool (a very intelligent one) called NUBuild that allows you to build VB.Net and C# projects. Its extremely lightweight, open source and at the same time easy to setup and provides almost no-touch maintenance....
30,724
<p>I'm setting up my first 3D Printer, a Prusa i3 MK2 clone. When I try to heat the bed, nothing happens. Then Marlin throws this error after a while: </p> <pre><code>Bed Heating Failed PRINTER HALTED Please reset </code></pre> <p>In Pronterface I see this in the console:</p> <pre><code>Error:Heating failed, syste...
<p>If you are sure that PID is enabled (and not using bang-bang heating, as this gives a very similar heating profile) and did not fix the fluctuations, the best guess for this phenomenon is that the printer board has incorrect capacitors installed on the printer board. This is not very uncommon and can be found on the...
<h1>Software</h1> <p>You might want to look at your firmware. When running a PID tune, the firmware decides on a smoothing.</p> <p>in Marlin, <code>configuration.h</code> contains a line that determines how much the machine shall try to work out the curves. For my ender 3 it reads:</p> <pre><code>#define PID_K1 0.95 ...
1,131
<p>I have a SQL table with news stories and Unix timestamps. I'd like to only keep the 50 newest stories. How would I write an SQL statement to delete any amount of older stories?</p>
<p>I ended up using two queries since MySQL5 doesn't yet support LIMIT's in subqueries</p> <pre><code>SELECT unixTime FROM entries ORDER BY unixTime DESC LIMIT 49, 1; DELETE FROM entries WHERE unixTime &lt; $sqlResult; </code></pre>
<p>Maybe not the most efficient, but this should work:</p> <pre><code>DELETE FROM _table_ WHERE _date_ NOT IN (SELECT _date_ FROM _table_ ORDER BY _date_ DESC LIMIT 50) </code></pre>
17,645
<p>When designing user table what would be the must have fields from the security/user authentication point of view for a Web based Application (.NET and SqlServer 2005)</p> <p>I came with with the following fields:</p> <pre><code>userID username -- preferably email passwordHash onceUsePassword -- to indicate that t...
<p>Why not just use the built-in SQL Membership Provider if you're using SQL Server anyway? It's much better than rolling your own since it's been tested by a lot of people. </p> <p>In any case, you should think about adding a salt field your table.</p> <p><a href="http://en.wikipedia.org/wiki/Salt_(cryptography)" re...
<p>You should add a "salt" field to use <a href="http://en.wikipedia.org/wiki/Password_salting" rel="nofollow noreferrer">password salting</a> to avoid dictionary attacks with <a href="http://en.wikipedia.org/wiki/Rainbow_table" rel="nofollow noreferrer">rainbow tables</a> if your database ever got compromised.</p> <p...
31,566
<p>We are making a Ruby On Rails webapp where every customer gets their own database.<br> The database needs to be created after they fill out a form on our website.</p> <p>We have a template database that has all of the tables and columns that we need to copy. How can I do this in programatically from ruby on rails?...
<p>From any controller, you can define the following method.</p> <pre><code> def copy_template_database template_name = "customerdb1" # Database to copy from new_name = "temp" #database to create &amp; copy to #connect to template database to copy. Note that this will override any previous ...
<p>You could put your template schema creation code into a script which contains all of the required table/index/view/procedure creation statements, call it "template_schema.sql" or whatever and then just run the script on the database of your choice (from Ruby, if that's what you're after) and you're done.</p> <p>The...
21,739
<p>Developing a website and just trying to get back into the swing of (clever) SQL queries etc, my mind had totally gone tonight!</p> <p>There is a website <a href="http://www.ufindus.com/" rel="nofollow noreferrer">http://www.ufindus.com/</a> which has a textbox allowing you to enter either a place name or a postcode...
<p>You could use an "OR" to get the job done. For example,</p> <p>place = 'YORK' or postcode = 'YORK'</p> <p>You might also do better using the LIKE statement, as in </p> <p>WHERE place LIKE 'YORK%' or postcode LIKE 'YORK%'</p> <p>(this assumes both place and postcode are character-based columns)</p>
<p>What's wrong with attempting to match on the place and postcode? If I put in 'York' and (somewhere) that happens to be a valid postcode, I should get that result. As for preventing the same thing being entered twice, well, you can handle that on the validation prior to doing the database call.</p> <p>Ah. Guess I w...
34,009
<p>Is there any way to follow a URL in JavaScript without setting the <code>document.location.href</code>?</p> <p>I have a page that displays a list of objects and each object may have a file download associated with it, which is accessed via a hyperlink. Clicking the link initiates an AJAX request that ultimately lea...
<p>you could open a new window with the new url? or try setting an iframe's url to the new url, both should present a file download (the latter being the better option)</p>
<p>You could use a hidden iframe - set the src of that to the file to download.</p>
42,030
<p>Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D control) looks extremely ugly because it is by default not antialiased as the rest of the WPF graphics are. Especially at lower resolution the experience is so bad that it can not be used in production code.</p> <p>I have managed ...
<p>Have you tried this (from your thread on MSDN forums)?</p> <blockquote> <p>Well, it seems the reference in the MSDN link above incorrectly specify the affected registry root key. In MSDN it is specified as HKEY_CURRENT_USER, while the correct root key should be HKEY_LOCAL_MACHINE. I've tried setting up the HKEY_L...
<p>Does your video card support Shader 2.0? You can refer <a href="http://en.wikipedia.org/wiki/Pixel_shader" rel="nofollow noreferrer">to this wiki page</a> to see if it does...</p>
6,050
<p>I need to launch a media file from a URL from within my c# .NET application. Is there any way to do this natively in .NET? I don't need an embedded player, I just need the default player to launch. I have tried </p> <pre><code>System.Diagnostics.Process.Start("File URL"); </code></pre> <p>but it launches the defau...
<p>If you enter an URL it will be handled with the program registered to that URL format, in your case the default web browser.</p> <p>What format are the media in? You can get associated program for an extension and then run that program with the url as parameter. See: <a href="https://stackoverflow.com/questions/249...
<p>Another way to handle this is to temporary download the file to the local file system and then run your </p> <pre><code>System.Diagnostics.Process.Start("Local File"); </code></pre> <p>Then it should work as you expect. </p>
40,910
<p>I have a large collection of data in an excel file (and csv files). The data needs to be placed into a database (mysql). However, before it goes into the database it needs to be processed..for example if columns 1 is less than column 3 add 4 to column 2. There are quite a few rules that must be followed before the i...
<p>If I didn't care to do this in 1 step (as Oli mentions), I'd probably use a <a href="http://www.eaipatterns.com/PipesAndFilters.html" rel="nofollow noreferrer">pipe and filters</a> design. Since your rules are relatively simple, I'd probably do a couple delegate based classes. For instance (C# code, but Java should ...
<p>A class for each rule? <em>Really?</em> Perhaps I'm not understanding the quantity or complexity of these rules, but I would (semi-pseudo-code):</p> <pre><code>public class ALine { private int col1; private int col2; private int coln; // ... public ALine(string line) { // read row into...
23,595
<p>I am using the link-report option in Flex Builder 3 to try to track down dependencies in my Flex application's modules.</p> <p>However a different report is generated for each module and they all use the same filename so they end up overwriting each other!</p> <p>Is there a way to generate separate files for each ...
<p>I agree, this is annoying, and should be supported by the compiler.</p> <p>A not-so-elegant approach (assuming that your modules and main swf are all in the same project), is to create a project, and point the source folder back to the source folder of the existing project, but with a different output folder.</p> ...
<p>I think you are using dependent modules . If you use independent modules then they will have there own classes and do not share with the main application and that may give you the desired results .</p>
35,838
<p>Part of our app parses RTF documents and we've come across a special character that is not translating well. When viewed in Word the character is an elipsis (...), and it's encoded in the RTF as ('85).</p> <p>In our vb code we converted the hex (85) to int(133) and then did Chr(133) to return (...)</p> <p>Here's ...
<p>This looks like a character encoding issue to me. Unicode doesn't include any characters with numbers in the upper-ASCII 128-255 range, so trying to convert character 133 will fail.</p> <p>Need to convert it first to a character using the proper decoding, Convert.toChar appears to be using UTF-16.</p> <p>Sometimes...
<pre><code>private static int HexStringToInt(string hexString) { try { return Convert.ToChar(hexString); } catch (FormatException ex) { throw new ArgumentException("Is not a valid hex character.", "hexString", ex); } // Convert.ToChar() will throw an ArgumentException also ...
13,134
<p>In JavaScript, what is the best way to determine if a date provided falls within a valid range?</p> <p>An example of this might be checking to see if the user input <code>requestedDate</code> is part of the next valid work week. Note that this is not just checking to see if one date is larger than another as a vali...
<p>This is actually a problem that I have seen come up before a lot in my works and the following bit of code is my answer to the problem.</p> <pre><code>// checkDateRange - Checks to ensure that the values entered are dates and // are of a valid range. By this, the dates must be no more than the // built-in...
<p>So if i understand currenctly, you need to look if one date is bigger than the other.</p> <pre><code>function ValidRange(date1,date2) { return date2.getTime() &gt; date1.getTime(); } </code></pre> <p>You then need to parse the strings you are getting from the UI, with Date.parse, like this:</p> <pre><code>Vali...
9,970
<p>I have read a lot that LISP can redefine syntax on the fly, presumably with macros. I am curious how far does this actually go? Can you redefine the language structure so much that it borderline becomes a compiler for another language? For example, could you change the functional nature of LISP into a more object...
<p>That's a really good question.</p> <p>I think it's nuanced but definitely answerable:</p> <p>Macros are not stuck in s-expressions. See the LOOP macro for a very complex language written using keywords (symbols). So, while you may start and end the loop with parentheses, inside it has its own syntax.</p> <p>Exa...
<p>@sparkes</p> <p>Sometimes LISP is the clear language choice, namely Emacs extensions. I'm sure I could use Ruby to extend Emacs if I wanted to, but Emacs was designed to be extended with LISP, so it seems to make sense to use it in that situation.</p>
2,420
<p>In Eclipse 3.2.2 on Linux content assist is not finding classes within the same project. Upgrading above 3.2 is not an option as SWT is not available above 3.2 for Solaris.</p> <p>I have seen suggestions to clean the workspace, reopen the workspace, run eclipse with the <code>-clean</code> command, none of which ha...
<p>Go to Java/Editor/Content Assist/Advanced in Preferences, and make sure that the correct proposal kinds are selected. Same kind of thing happened to me when I first moved to 3.4.</p>
<p>I sometimes find I "lose" content assist because the "content assist computers" get disabled.</p> <p>This is in:</p> <pre><code>[Workspace]\.metadata\.plugins\org.eclipse.core.runtime\.settings org.eclipse.jdt.ui.prefs </code></pre> <p>and I just have to remove this property: content_assist_disabled_computers=</...
4,832
<p>This is a bit of a long question, but here we go. There is a version of FormatDateTime that is said to be thread safe in that you use </p> <pre><code>GetLocaleFormatSettings(3081, FormatSettings); </code></pre> <p>to get a value and then you can use it like so; </p> <pre><code>FormatDateTime('yyyy', 0, FormatSet...
<p>I am not sure if it is good form to post an "Answer" to my own question but it seemed logical, let me know if that is uncool. </p> <p>I think I have found the problem, the thread local storage idea lead me to follow a bunch of leads and I found this magical line;</p> <p>IsMultiThread := True;</p> <p>From the help...
<p>I wonder if the RTL/VCL calls you're making are expecting access to some thread-local storage (TLS) variables that aren't correctly set up whn you invoke your code via the timer queue?</p> <p>This isn't the answer to your problem, but are you aware that TTimer OnTimer events just run as part of the normal message l...
45,910
<p>More out of interest than anything else, but can you compile a DirectX app under linux?</p> <p>Obviously there's no official SDK, but I was thinking it might be possible with wine.</p> <p>Presumably wine has an implementation of the DirectX interface in order to run games? Is it possible to link against that? (edi...
<p>I've had some luck with this. I've managed to compile <a href="http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B5.aspx" rel="nofollow noreferrer">this simple Direct3D example</a>.</p> <p>I used winelib for this (wine-dev package on Ubuntu). Thanks to <a href="https://stackoverflow.com/users/9554/alasta...
<p>There is currently no way to compile DirectX code to directly target Linux. You would build your application like you normally would, then run it using a compatibility layer like Wine/Cedega.</p>
7,032
<p>I wanted to derive a class from Predicate&lt;IMyInterface>, but it appears as if Predicate&lt;> is sealed. In my case I wanted to simply return the inverted (!) result of the designated function. I have other ways to accomplish the goal. My question is what might the MS designers have been thinking when deciding to ...
<p><code>Predicate&lt;T&gt;</code> is a delegate type. You can never derive from delegates.</p> <p>To be honest, it doesn't sound like inheritance is really appropriate here anyway - just write a method which returns an inverse of the original. It's as simple as this:</p> <pre><code>public static Predicate&lt;T&gt; I...
<p>Predicate is a delegate. You can not inherit from a delegate type. If you want to get the inverted value, use the following:</p> <pre><code>Predicate&lt;T&gt; p; Predicate&lt;T&gt; inverted = t =&gt; !p(t); </code></pre>
26,443
<p>In Git, how could I search for a file or directory by path across a number of branches?</p> <p>I've written something in a branch, but I don't remember which one. Now I need to find it.</p> <p><strong>Clarification</strong>: I'm looking for a file which I created on one of my branches. I'd like to find it by pa...
<p><code>git log</code> + <code>git branch</code> will find it for you:</p> <pre><code>% git log --all -- somefile commit 55d2069a092e07c56a6b4d321509ba7620664c63 Author: Dustin Sallings &lt;dustin@spy.net&gt; Date: Tue Dec 16 14:16:22 2008 -0800 added somefile % git branch -a --contains 55d2069 otherbranc...
<p>A quite decent implementation of the <code>find</code> command for Git repositories can be found here: </p> <p><a href="https://github.com/mirabilos/git-find" rel="nofollow noreferrer">https://github.com/mirabilos/git-find</a></p>
48,694
<p>Are there any existing solutions for remote execution of commands on a windows server from Java natively? psexec.exe is not an option since the java application has to be cross platform.</p> <p>Even a preexisting solution using Java RM would be sufficient.</p> <p>Currently, I'm using an SSH client library to ssh t...
<p>Check out the <a href="http://www.elusiva.com/opensource/" rel="nofollow noreferrer">Java RDP Client</a>. Not really out of the box, but with little digging you should be able to trim it down to what you need.</p> <p>Since it uses getopt, I would assume it's GPL'd.</p>
<p>It'll require some work, but the remoting library in Hudson has very good support for running commands and doing file operations over the network on remote computers.</p> <p>see <a href="https://jenkins.io/projects/remoting/" rel="nofollow noreferrer">https://jenkins.io/projects/remoting/</a> (you'll have to dive i...
25,745
<p>In CSS, you can specify the spacing between table cells using the border-spacing property of a table.</p> <p>However, this results in uniform spacing between columns and rows, and I am finding more situations where the designs I am using call for gaps between rows, but not columns, or visa versa.</p> <p>If I have ...
<p>You <em>can</em> specify different spacings for horizontal and vertical edges for <code>border-spacing</code> or related properties. Just specify more than one measurement. e.g.,</p> <pre><code>border-spacing: 1px 2px; </code></pre>
<p>In the <strong><em>general case</em></strong> where you may specify calues thayt may be applied globally or individually on a property (for example, "padding"), follow a simple pattern.</p> <ul> <li><p>If you specify a single value (e.g. padding:2px; ) the value is applied to the top, bottom, left and right of the ...
31,548
<p>I have user control named DateTimeUC which has two textboxes on its markup:</p> <pre><code>&lt;asp:TextBox ID="dateTextBox" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;asp:TextBox ID="timeTextBox" runat="server"&gt;&lt;/asp:TextBox&gt; </code></pre> <p>I am dynamically creating this control in another user control:...
<p>You must use the <code>LoadControl( "your_user_control_app_relative_path.ascx" )</code> method instead of "DateTimeUC uc = new DateTimeUC();"</p>
<p>I ran into this problem myself a while back. You need to use the LoadControl() method. Check out <a href="http://www.dotnetjunkies.com/WebLog/leon/archive/2004/08/28/23559.aspx" rel="nofollow noreferrer">this page</a> on it.</p>
15,504
<p>This is my first 3D printer so I'm not entirely sure what could be the cause of this issue.</p> <p>I recently got a SUNLU S8 3D printer and have been trying to print the first test file, however, the layers end up stringy (for lack of a better word -- if anyone knows whether this is called something else, I'd apprec...
<p>In the video, there is this still from <a href="https://youtu.be/bKsGNrEKx9M?t=32" rel="nofollow noreferrer">0:32</a>:</p> <p><a href="https://youtu.be/bKsGNrEKx9M?t=32" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jf2F8.png" alt="enter image description here" /></a></p> <p>The labeling is iPro 8000...
<p>If you look at the video at 37 seconds, it appears to be SLA or DLP.</p> <p>Further reading: <a href="https://www.solidprint3d.co.uk/wp-content/uploads/2019/04/SLA_vs_DLP.pdf" rel="nofollow noreferrer">https://www.solidprint3d.co.uk/wp-content/uploads/2019/04/SLA_vs_DLP.pdf</a></p>
1,877
<p><strong>"It is not possible to check out a single file. The finest level of checkouts you can do is at the directory level."</strong></p> <p>How do I get around this issue when using Subversion?</p> <p>We have this folder in Subversion where we keep all our images. I just want to check out one file (image) from th...
<p>The simple answer is that you <code>svn export</code> the file instead of checking it out.</p> <p>But that might not be what you want. You might want to work on the file and check it back in, without having to download GB of junk you don't need.</p> <p>If you have Subversion 1.5+, then do a sparse checkout:</p> <...
<p>If you just want to export the file, and you won't need to update it later, you can do it without having to use SVN commands.</p> <p>Using <strong>TortoiseSVN Repository Browser</strong>, select the file, right click, and then select "<strong>Copy URL to clipboard</strong>". Paste that URL to your browser, and afte...
14,843
<p>I've got a column in a database table (SQL Server 2005) that contains data like this:</p> <pre><code>TQ7394 SZ910284 T r1534 su8472 </code></pre> <p>I would like to update this column so that the first two characters are uppercase. I would also like to remove any spaces between the first two characters. So <code>T...
<p>Here is a solution:</p> <p><strong>EDIT:</strong> <strong>Updated to support replacement of multiple spaces between the first and the second non-space characters</strong></p> <pre><code>/* TEST TABLE */ DECLARE @T AS TABLE(code Varchar(20)) INSERT INTO @T SELECT 'ab1234x1' UNION SELECT ' ab1234x2' UNIO...
<pre><code>update Table set Column = case when len(rtrim(substring (Column , 1 , 2))) &lt; 2 then UPPER(substring (Column , 1 , 1) + substring (Column , 3 , 1)) + substring(Column , 4, len(Column) else UPPER(substring (Column , 1 , 2)) + substring(Column , 3, len(Column) end </code></pre> <p>T...
22,041
<p>I am having issues with validators not firing (No expected error messages showing) when using Page.Validate() from code behind. The validators are placed inside an Ajax updatepanel.</p> <p>It seems there are downloadable Ajax versions of the validators. I am not sure if I need these or if VS 2008 SP1 has them alrea...
<p>Yes, validators do work inside an UpdatePanel, but you need to use at least SP1 of ASP.NET 2.0. If you use SP1, you do not need and should not use the "ajax version" of the validators.</p> <p>More details on this subject are available here:</p> <p><a href="https://stackoverflow.com/questions/32814/aspnet-validator...
<p>Did you call Update on your updatepanel?</p>
15,113
<p>Where can I find an online interactive console for programming language or api?</p> <ul> <li><a href="http://tryruby.org/" rel="nofollow noreferrer">Ruby</a></li> <li><a href="http://shell.appspot.com/" rel="nofollow noreferrer">Python</a></li> <li><a href="http://groovyconsole.appspot.com/" rel="nofollow noreferre...
<p>@kuszi Put a great answer as a comment to the question, but I almost missed it because it was a comment rather than the answer.</p> <p><a href="http://joel.franusic.com/w/page/26128430/Online-REPs-and-REPLs">This link</a> goes to a huuuge list of REPs and REPLs for tons of languages.</p>
<p><a href="http://getfirebug.com/lite" rel="nofollow noreferrer">Firebug Lite</a> for Javascript. And, <a href="http://vimeo.com/10499321" rel="nofollow noreferrer">Rainbow 9</a> was one of the first examples of online REPLs.</p>
7,150
<p>I'm in the design stage for an app which will utilize a REST web service and sort of have a dilemma in as far as using asynchronous vs synchronous vs threading. Here's the scenario.</p> <p>Say you have three options to drill down into, each one having its own REST-based resource. I can either lazily load each one w...
<p>I don't think that there's a "right" answer. It seems that you understand the compromises involved and you just need to make your design around those.</p> <p>A few extra random points: sometimes your application forces a particular approach. For example, many of the convenience (i.e., synchronous) methods won't all...
<p>Why can't you use an asynchronous request like so:</p> <pre><code>- (NSArray *)users { if(users == nil &amp;&amp; !didLaunchRequestAlready ) users = do_async_request // Looks good to me return users; } </code></pre> <p>Asynchronous is absolutely the only option - the only real question is if you...
48,572
<p>I have a table of data sorted by date, from which a user can select a set of data by supplying a start and end date. The data itself is non-continuous, in that I don't have data for weekends and public holidays. </p> <p>I would like to be able to list all the days that I don't have data for in the extracted dataset...
<p>You could create a temp list and x it as needed.</p> <p>(Not actual Java. Sorry, my memory of it is horrible.)</p> <pre><code>dates = [...]; // list you have now; // build list unused = []; for (Date i = startdate; i &lt; enddate; i += day) { unused.push(i); } // remove used dates for (int j = 0; j &lt; date...
<p>You can either create a list of all possible dates between start and end date and then remove dates which appear in the list of given data (works best when most dates are missing), or you can start with an empty list of dates and add ones that don't appear in the given data.</p> <p>Either way, you basically iterate...
45,244
<p>I'm new to SVN and I'd like to know what methods are available for backing up repositories in a Windows environment?</p>
<p>You could use something like (Linux):</p> <pre><code>svnadmin dump repositorypath | gzip &gt; backupname.svn.gz </code></pre> <p>Since Windows does not support GZip it is just:</p> <pre><code>svnadmin dump repositorypath &gt; backupname.svn </code></pre>
<p>as others have said, hot-backup.py from the Subversion team has some nice features over just plain <code>svnadmin hotcopy</code></p> <p>I run a scheduled task on a python script that spiders for all my repositories on the machine, and uses hotbackup to keep several days worth of hotcopies (paranoid of corruption) a...
5,302
<p>I came from Java, and now I am working more with Ruby. </p> <p>One language feature I am not familiar with is the <code>module</code>. I am wondering what exactly is a <code>module</code> and when do you use one, and why use a <code>module</code> over a <code>class</code>?</p>
<p>The first answer is good and gives some structural answers, but another approach is to think about what you're doing. Modules are about providing methods that you can use across multiple classes - think about them as "libraries" (as you would see in a Rails app). Classes are about objects; modules are about function...
<p><strong>Class</strong> </p> <p>When you define a class, you define a blueprint for a data type. class hold data, have method that interact with that data and are used to instantiate objects.</p> <p><strong>Module</strong></p> <ul> <li><p>Modules are a way of grouping together methods, classes, and constants.</p...
18,258
<p>I've to admin a small website for my alumni group which is hosted by my ISV. The url is something like www.myIsv.com/myWebSite/ which is quite ugly and very forgetable. The main admin of the webserver has registered a domain name www.mysmallwebsite.com and put a index.html with this content:</p> <pre><code>&lt;html...
<p>Sessions are tied to the server <strong>AND</strong> the domain. Using frameset across domain will cause all kind of breakage because that's just not how it was designed to do. </p> <p>Try using apache mod rewrite to create a "passthrough redirection", the "<strong>proxy</strong>" flag ([P]) in the rule is the magi...
<p>What do you mean? Are you saying that when you go from www.mysmallwebsite.com to www.myIsv.com/myWebSite/ then the PHP session is lost?</p> <p>PHP recognizes the session with an ID (alpha-numeric hash generated on the server). The ID is passed from request to request using a cookie called PHPSESSID or something lik...
5,929
<p>I'm interesting in learning about the different layers of abstraction available for making graphical applications.</p> <p>I see a lot of terms thrown around: At the highest level of abstraction, I hear about things like C#, .NET, pyglet and pygame. Further down, I hear about DirectX and OpenGL. Then there's Dire...
<p><a href="http://www.drdobbs.com/high-performance-computing/184404919" rel="noreferrer">Michael Abrash's Graphics Programming 'Black Book'</a> is a great place to start. Plus you can download it for free!</p>
<p>Vulkan api is an api which gives you very low level access to most if not all features of the gpu, computational and graphical, it works on amd and Nvidia gpus (not all) </p> <p>you can also use CUDA, but it only works on Nvidia gpus and has access to computational features only, no video output. </p>
29,185
<p>I assume it doesn't connect to anything (other than the satelite I guess), is this right? Or it does and has some kind of charge?</p>
<p>GPS, the Global Positioning System run by the United States Military, is free for civilian use, though the reality is that we're paying for it with tax dollars.</p> <p>However, GPS on cell phones is a bit more murky. In general, it won't cost you anything to turn on the GPS in your cell phone, but when you get a l...
<p>There's 3 satellites at least that you must be able to receive from of the 24-32 out there, and they each broadcast a time from a synchronized atomic clock. The differences in those times that you receive at any one time tell you how long the broadcast took to reach you, and thus where you are in relation to the sat...
5,371
<p>I am trying to install the starling gem on my Windows machine. But, whenever I try to install it I get this error:</p> <pre><code>Building native extensions. This could take a while... ERROR: Error installing starling: ERROR: Failed to build gem native extension. c:/ruby/bin/ruby.exe extconf.rb in...
<p>Gems <strike>is <a href="https://stackoverflow.com/questions/134581/gem-update-on-windows-is-it-broken">somewhat broken</a> on Windows at present</strike> was at the time broken on Windows, but it's fixed now. The following workaround applies to the old One-Click Installer version of Ruby; you should really update t...
<p>The install seems to be stuck on installing the eventmachine gem. The easiest approach here may be to download and install the eventmachine binary gem for windows <a href="http://rubyforge.org/frs/?group_id=1555&amp;release_id=22647" rel="nofollow noreferrer">here</a></p> <p>Otherwise you will need a compiler. (whi...
19,991
<p>I just saw the anouncement for the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=922B4655-93D0-4476-BDA4-94CF5F8D4814&amp;displaylang=en" rel="nofollow noreferrer">Visual Studio CTP</a> today, and am currently waiting for all those files to download...</p> <p>Have you already tried the CTP, or m...
<p>Downloaded, running, looking at the walk throughs, here are some of the things I've seen so far.</p> <ul> <li>Customisable Start page in XAML (don't know if I'd bother)</li> <li>Zoomable code editor (I bet this was a feature request from MS evangelists)</li> <li>Highlight current line in editor (YES! the SlickEdit ...
<p>I've downloaded it, but didn't have enough space to unpack it :-)</p> <p>But I've heard rumors <a href="http://www.heise-online.co.uk/news/PDC-Visual-Studio-2010-gets-a-new-WPF-interface--/111833" rel="nofollow noreferrer">that VS2010 gets a WCF interface</a>. That would be awesome, but it would also antiquate the ...
30,019
<p>The <code>JPA</code> (Java Persistence API) specification has 2 different ways to specify entity composite keys: <code>@IdClass</code> and <code>@EmbeddedId</code>. </p> <p>I'm using both annotations on my mapped entities, but it turns out to be a big mess to people who aren't very familiar with <code>JPA</code>. <...
<p>I consider that <code>@EmbeddedId</code> is probably more verbose because with <code>@IdClass</code> you cannot access the entire primary key object using any field access operator. Using the <code>@EmbeddedId</code> you can do like this:</p> <pre><code>@Embeddable class EmployeeId { name, dataOfBirth } @Entity cla...
<p>With EmbeddedId you can use the IN clause in HQL, for example : <code>FROM Entity WHERE id IN :ids</code> where id is an EmbeddedId whereas it's pain to achieve the same result with IdClass you will want to do something like <code>FROM Entity WHERE idPartA = :idPartA0 AND idPartB = :idPartB0 .... OR idPartA = :idPar...
26,099
<p>I want to perform cascade delete for some tables in my database, but I'm interested in what happens in case there's a failure when deleting something. Will everything rollback?</p>
<p>In general¹, yes, cascade deletes are done in the same transaction (or subtransaction) as your original delete. You should read the documentation of your SQL server, though.</p> <p>¹ The exception is if you're using a database that doesn't support transactions, like MySQL with MyISAM tables.</p>
<p>It's worth pointing out that <em>any</em> cascading event should be atomic (i.e. with in a transaction). But, as Joel Coehoorn points out, check the documentation for your database. </p>
13,934
<p>I have a sorted list that contains the column headers, how do I rearrange my datagridview so it is in the same order as my sorted list?</p> <p>I've tried the code below but this doesn't always work, some columns are not sorted correctly. Thanks for any help with this.</p> <pre><code>sortedColumnNames.Sort(); ...
<p>I can't tell if your problem is that <code>SortedColumnNames</code> isn't sorted properly (which it's not), or if the columns are being assigned a different order than what appears in the list.</p> <p>If it's the latter, it could <em>conceivably</em> be because you're modifying the order of items in the collection ...
<p>Seems like that should work. I just wrote a quick app to test and it worked fine. Can you nail down exactly when it's working and when it isn't? When you say they don't work, is it always the same columns that are out of order?</p>
45,335
<p>I'm hosting a custom editing control in a <code>DataGridView</code>, which for the record is a <code>TextBox</code> and <code>Button</code> together in a <code>UserControl</code>. I have inherited from <code>DataGridViewColumn</code> for the new column and <code>DataGridViewTextBoxCell</code> for the new cell.</p> ...
<p>Try setting the KeyPreview of the user control to true. Then check if the key which starts the editing process fires the keydown even for the user control. If it does, you can simply store and assign the character once the text control enters edit mode.</p>
<p>Hi Today I had the same problem. My solution is to override KeyEntersEditMode in CustomCell and put there some algorithm to convert or to determine if a character is valid for passing to the editing control. Then I store this value as a private variable. I override the InitializeEditingControl method and use my stor...
48,886
<p>In TFS whats the easiest way of linking a backlog item to a large number of other backlog items, without doing them one at a time?</p> <p>I do not have access to the underlying database so am unable to write a query to do it.</p>
<p>I'd stay away from the SQL Query. Instead, I'd either use the API or Web Services. Here's an example API call to retrieve and edit a work item:</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb130323.aspx" rel="nofollow noreferrer"><a href="http://msdn.microsoft.com/en-us/library/bb130323.aspx" rel="nofoll...
<p>Depends on your definition of easy, but you could write a SQL Update linking the backlog item(s) to the correct backlog items.</p> <p>(If there is no field in the backlog item to connect it to another backlog item, you would have to extend backlog item and the views showing them yourself)</p>
6,077
<p>If I have an HTML helper like so:</p> <pre><code>Name:&lt;br /&gt; &lt;%=Html.TextBox("txtName",20) %&gt;&lt;br /&gt; </code></pre> <p>How do I apply a CSS class to it? Do I have to wrap it in a span? Or do I need to somehow utilize the HtmlAttributes property of the helper?</p>
<p>You can pass it into the TextBox call as a parameter.</p> <pre><code>Name:&lt;br/&gt; &lt;%= Html.TextBox("txtName", "20", new { @class = "hello" }) %&gt; </code></pre> <p>This line will create a text box with the value 20 and assign the class attribute with the value hello. I put the @ character in front of ...
<p></p> <p>Is it that much more work? </p>
6,209
<p>Looking at learning some C since i saw in <a href="https://web.archive.org/web/20111127143032if_/http://stackoverflow.com/questions/296/should-i-learn-c" rel="nofollow noreferrer">another SO question</a> that is good to learn for the language and for the historical experience.</p> <p>Wondering about what IDE's prof...
<p>I have always been fond of <a href="http://www.codeblocks.org" rel="nofollow noreferrer">Code::Blocks</a> It's a wonderful C/C++ IDE, with several helpful addons. As for a compiler I've always used MingW but I hear <a href="http://www.digitalmars.com" rel="nofollow noreferrer">DigitalMars C/C++</a> compiler is good....
<p><a href="http://www.netbeans.org/features/cpp/" rel="nofollow noreferrer">Netbeans</a> provides a fairly slick C/C++ development environment. Excellent for anyone who is already familiar with NB for Java, Ruby, or PHP development. Provides many of the same features as Visual Studio, Borland, or CodeWarrior (are they...
18,189
<p>Why are the code-behind pages for an ASP.NET web application locked at run time? I have older projects (probably defined as "web sites" instead of "web apps") where I can edit the code behind, refresh the browser, and see my changes. With the web app, I have to continually close and reopen the browser if I want to s...
<p>You can enable Edit and Continue in the project properties. Right click the project in the solution explorer, select the Web tab and check Enable Edit and Continue. </p> <p>Now you can edit your sources, but you have to pause the debugger to do so.</p>
<p>When using IIS as your development server, Edit and continue is not currently available for Visual Studio for ASP.NET. </p> <p>See this <a href="http://whyiamright.wordpress.com/2007/12/20/aspnet-edit-and-continue-in-visual-studio-2005/" rel="nofollow noreferrer">blog entry</a>, however, that shows it is possible f...
39,489
<p>Basically the question is how to get from this:</p> <pre> foo_id foo_name 1 A 1 B 2 C </pre> <p>to this:</p> <pre> foo_id foo_name 1 A B 2 C </pre>
<pre><code>SELECT id, GROUP_CONCAT(name SEPARATOR ' ') FROM table GROUP BY id; </code></pre> <p><a href="https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat" rel="noreferrer">https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat</a></p> <p>From the lin...
<pre><code>SELECT id, GROUP_CONCAT(CAST(name as CHAR)) FROM table GROUP BY id </code></pre> <p>Will give you a comma-delimited string</p>
18,043
<p>Mapping a collection of enums with NHibernate</p> <p>Specifically, using Attributes for the mappings.</p> <p>Currently I have this working mapping the collection as type Int32 and NH seems to take care of it, but it's not exactly ideal.</p> <p>The error I receive is "Unable to determine type" when trying to map t...
<p>You will need to map your CEnum type directly. In XML mappings this would mean creating a new class mapping element in your NHibernate XML mappings file.</p> <p><code><pre></p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="YourAssembly" auto-import="true" default-lazy="false"&gt;...
<p>This is the way i do it. There's probably an easier way but this works for me.</p> <p>Edit: sorry, i overlooked that you want it as a list. I don't know how to do that...</p> <p>Edit2: maybe you can map it as a protected IList[string], and convert to public IList[EAction] just as i do with a simple property.</p> ...
10,429
<p>I am just embarking on my first large-scale refactor, and need to split an (unfortunately large) class into two, which then communicate only via an interface. (My Presenter has turned out to be a Controller, and needs to split GUI logic from App logic). Using C# in VisualStudio 2008 and Resharper, what is the easies...
<p>Baby steps.</p> <p>Step 1: Make a small change using Resharper's excellent Refactoring.<br> Step 2: Test (preferably unit test) to ensure the code still works<br> Step 3: Commit to source control </p> <p>Repeat these 3 steps many times.</p> <p>Maybe this won't work if you are doing one of the those "must be a bi...
<p>Short answer here first, I'm going to write blog post about it, thanks for an idea!</p> <p>So, let's assume we have this:</p> <pre><code>class PresenterAndController { public void Control() { Present(); } public void Present() { // present something } } </code></pre> <p>Fi...
28,401
<p>I am building out a solution that will be deployed in multiple data centers in multiple regions around the world, with each data center having a replicated copy of data actively updated in each region. I will have a combination of multiple databases and file systems in each data center, the state of which must be ke...
<p>Lotus/ Domino is your answer. I've been working with it for ten years and its exactly what you need. It may not be trendy (a perception that I would challenge) but its powerful, adaptable and very secure, The latest version R8 is the best yet.</p>
<p>You dont give enough specifics to be certain of your needs but I think you should check out SQL Server Merge replication. It allows for asynchronous replication of multiple databases with full conflict resolution. You will need to designate a Global master and all the other databases will replicate to that one, but ...
9,172
<p>Is there a free API or some other way to determine what carrier a cell phone number is registered with?</p> <p>I'd like my application to broadcast text messages without them picking their carrier from a list.</p> <p><strong>UPDATE:</strong> Interestingly, a coworker found the answer: <a href="http://developer.whi...
<p>Data24-7 offers an API for looking up the carrier for wireless phone numbers. It also returns the email addresses to send SMS and MMS messages to the phone. It's not free, it's $12 per month and $0.006 per lookup. </p> <p>The link is: <a href="http://www.data24-7.com" rel="noreferrer">http://www.data24-7.com</a></...
<p>I recently wrote one in Ruby that interfaces with the aforementioned FoneFinder.net</p> <p><a href="https://rubygems.org/gems/FoneFinder" rel="nofollow">https://rubygems.org/gems/FoneFinder</a> --> Ruby Gem page <br> <a href="https://github.com/evinugur/FoneFinder.rb/" rel="nofollow">https://github.com/evinugur/Fon...
41,736
<p>I want to make a table in SqlServer that will add, on insert, a auto incremented primary key. This should be an autoincremented id similar to MySql auto_increment functionality. (Below)</p> <pre><code>create table foo ( user_id int not null auto_increment, name varchar(50) ) </code></pre> <p>Is there a ...
<p>Like this</p> <pre><code>create table foo ( user_id int not null identity, name varchar(50) ) </code></pre>
<p>As others have said, just set the Identity option.</p>
11,057
<p>I have a <a href="http://en.wikipedia.org/wiki/VBScript" rel="nofollow noreferrer">VBScript</a> script that starts a cmd prompt, telnets into a device and <a href="http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol" rel="nofollow noreferrer">TFTP</a>'s the configuration to a server. It works when I am logge...
<p>Add a scheduled task that runs the script with your credentials. Remind yourself that you need to update the credentials on the task every time you change your password. It be a good idea to have the script "phone home" via email or something every time it is run so that you can tell if it is being executed.</p> ...
<p>Batch files don't work in Windows with Telnet (works fine in UNIX -- again, way to go Microsoft). As already mentioned here, sendkeys does not work in vba when not logged on.</p> <p>Sorry I don't have the "this does work" solution for you....I'm stuck on the same problem</p>
36,053
<p>In C#, I'm trying to build an extension method for StringBuilder called AppendCollection() that would let me do this:</p> <pre><code>var sb1 = new StringBuilder(); var sb2 = new StringBuilder(); var people = new List&lt;Person&gt;() { ...init people here... }; var orders = new List&lt;Orders&gt;() { ...init orders ...
<p>Use the <code>Func&lt;T,string&gt;</code> delegate.</p> <pre><code>public static void AppendCollection&lt;T&gt;(this StringBuilder sb, IEnumerable&lt;T&gt; collection, Func&lt;T, string&gt; method) { foreach(T x in collection) sb.AppendLine(method(x)); } </code></p...
<p>What is this method suppose to return? I can see a string, but why, if you are appending to a StringBuilder?</p> <p>What you are trying to do is rather easy, but you need to explain exactly what you want.</p> <p><strong>Update:</strong> </p> <p>Here's my take. Using an extension method for this is stupid and poin...
46,093
<p>I have only a basic knowledge of css, is it possible to inherit a property from one style into another style. So for instance I could inherit the font size specified in my default paragrah tag settings into my hyperlink tags.</p> <p>The reason I want to do this is to make it easier to maintain multiple styles.</p>
<p>You can define common styles for two elements at once like so:</p> <pre><code>p, a { font-size: 1em; } </code></pre> <p>And then extend each one with their individual properties as you want:</p> <pre><code>p { color: red; } a { font-weight: bold; } </code></pre> <p><strong>Keep in mind:</strong> Style...
<p>CSS will automatically inherit from the parent style. For example, if you say in your body style that all text should be <code>#EEE</code> and your background should be <code>#000</code> then all text, whether it’s in a div or a span will always be <code>#EEE</code>. </p> <p>There has been quite a bit of talk about...
24,350
<p>When it comes to organizing python modules, my Mac OS X system is a mess. I've packages lying around everywhere on my hdd and no particular system to organize them.</p> <p>How do you keep everything manageable?</p>
<p>My advice:</p> <ul> <li>Read <a href="http://docs.python.org/install/index.html" rel="noreferrer">Installing Python Modules</a>.</li> <li>Read <a href="http://docs.python.org/distutils/index.html" rel="noreferrer">Distributing Python Modules</a>.</li> <li>Start using easy_install from <a href="http://peak.telecommu...
<p><a href="http://www.python.org/doc/2.5.2/tut/node8.html" rel="nofollow noreferrer">The "Modules" Python documentation page</a> is a useful guide on organising code, specifically the "packages" sections</p>
20,710
<p>I am using USRP with DBSRX daughter board. I need a very high sample frequency. Currently, the USRP can give me maximum sample frequency of 64M/8 in I and Q, and the data type is short, which takes 2 bytes.</p> <p>So can I decrease the length of the output data? for example save the data as char which takes 1 byte...
<p>$ usrp_rx_cfile.py --help</p> <p>See the -8 option which gets you 8-bit I &amp; Q and allows a minimum decimation factor of 4.</p>
<p>You can do this in different ways, one is the was user19899 explained. The more 'difficult' way is to modify the FPGA code of the USRP and add a loss-less compression before the UHD interface. On the driver side, you must add an extra layer to your code to to the opposite. </p> <p>I did that for another platform wh...
13,595
<p><strong>Update: Please read this question in the context of design principles, elegance, expression of intent, and especially the "signals" sent to other programmers by design choices.</strong></p> <p>I have two "views" of a set of objects. One is a dictionary/map indexing the objects by a string value. The other i...
<p>I would create a class that has (at least) two collections. </p> <ul> <li>A version of the collection that is sorted by string </li> <li>A version of the collection that is sorted by ordinal</li> <li>(Optional) A master collection</li> </ul> <p>The class would handle the nitty gritty management:</p> <ul> <li...
<p>If both dictionaries contain references to every object, the count should be the same for both of them, correct? If so, just pick one and be consistent.</p>
39,922
<p>Any suggestions for tools to monitor page load times/errors and other performance metrics for a PHP application?</p> <p>I am aware of the FireBug and YSlow tools, but this is for more server monitoring.</p>
<p>There is the classic 'ab' (apachebench) program. More power comes from <a href="http://jakarta.apache.org/jmeter/" rel="nofollow noreferrer">JMmeter</a>. For server health, I recommend Munin, which can painlessly capture data from several systems and aggregate it on one page. </p>
<p>Try <a href="http://www.nagios.org/" rel="nofollow noreferrer">Nagios</a>, it's the default tool to monitor servers. You can write plugins to report just about any data. </p>
9,485
<p>Everyone managing open-source-software runs into the problem, that with the time the process of releasing a new version gets more and more work. You have to tag the release in your version-control, create the distributions (that should be easy with automated builds), upload them to your website and/or open-source-ho...
<p>Well, you <em>are</em> spending more data to store numbers that you will never really reach.</p> <p>bigint goes up to 9,223,372,036,854,775,807 in 8 Bytes</p> <p>int goes up to 2,147,483,647 in 4 bytes</p> <p>A NUMERIC(38,0) is going to take, if I am doing the math right, 17 bytes.</p> <p>Not a huge difference, ...
<p>Barring the storage considerations and some initial confusion from future DBAs, I don't see any reason why NUMERIC(38,0) would be a bad idea. You're allowing for up to 9.99 x 10^38 records in your table, which you will certainly never reach. My quick digging into this didn't turn up any glaring reason not to use it....
36,317
<p>I'd like to know when i should and shouldn't be wrapping things in a USING block.</p> <p>From what I understand, the compiler translates it into a try/finally, where the finally calls Dispose() on the object.</p> <p>I always use a USING around database connections and file access, but its more out of habit rather ...
<p>No, <code>IDisposable</code> items are not disposed when they go out of scope. It is for precisely this reason that we need <code>IDisposable</code> - for deterministic cleanup.</p> <p>They will <em>eventually</em> get garbage collected, and if there is a finalizer it will (maybe) be called - but that could be a lo...
<p>To add to the other answers, you should use <code>using</code> (or an explicit Dispose) whenever an object holds any resources other than managed memory. Examples would be things like files, sockets, database connections, or even GDI drawing handles.</p> <p>The garbage collector would eventually finalise these obje...
40,967
<p>Pardon my ASP ignorance, but what's the difference?</p>
<p>These are somewhat informally referred to as "bee stings". There are 4 types:</p> <p><code>&lt;%# %&gt;</code> is invoked during the DataBinding phase.</p> <p><code>&lt;%= %&gt;</code> is used to get values from code to the UI layer. Meant for backward compatibility with ASP applications. Shouldn't use in .NET.</p...
<p>javascript in .aspx that uses a master page.</p> <pre><code>var e = document.getElementById('&lt;%= lblDescription.ClientID %&gt;'); e.innerHTML = 'getElementById(\'lblDescription\') will be null'; </code></pre>
19,361
<p>I'm trying to figure out how to pass arguments to an anonymous function in JavaScript.</p> <p>Check out this sample code and I think you will see what I mean:</p> <pre><code>&lt;input type="button" value="Click me" id="myButton" /&gt; &lt;script type="text/javascript"&gt; var myButton = document.getElementByI...
<p>Your specific case can simply be corrected to be working:</p> <pre><code>&lt;script type="text/javascript"&gt; var myButton = document.getElementById("myButton"); var myMessage = "it's working"; myButton.onclick = function() { alert(myMessage); }; &lt;/script&gt; </code></pre> <p>This example will work becau...
<p>What you have done is created a new anonymous function that takes a single parameter which then gets assigned to the local variable myMessage inside the function. Since no arguments are actually passed, and arguments which aren't passed a value become null, your function just does alert(null).</p>
27,791
<p>I'm stuck trying to create a dynamic linq extension method that returns a string in JSON format - I'm using System.Linq.Dynamic and Newtonsoft.Json and I can't get the Linq.Dynamic to parse the "cell=new object[]" part. Perhaps too complex? Any ideas? : </p> <p><strong>My Main method:</strong></p> <pre><code>stat...
<p>This is really ugly and there may be some issues with the string replacement, but it produces the expected results:</p> <pre><code>public static class JSonify { public static string GetJsonTable&lt;T&gt;( this IQueryable&lt;T&gt; query, int pageNumber, int pageSize, string IDColumnName, string[] columnN...
<pre><code>static void Main(string[] args) { NorthwindDataContext db = new NorthwindDataContext(); var query = db.Customers; string json = query.GetJsonTable&lt;Customer&gt;(2, 10, "CustomerID", new string[] {"CustomerID", "CompanyName", "City", "Country", "Orders.Count" }); } public static class JSonif...
7,297
<p>I've got a bracelet concept that I've sketched up as a flat design. I'm trying to found a route by which I can extrude this into a 3d object (depth map?), curve it into a bracelet, then ultimately create a STL file out of it. I'm having trouble finding a way to do this that allows me to "warp" the flat object into a...
<p>This may not be your cuppa tea, but if you're willing to learn to use <a href="http://www.openscad.org/" rel="nofollow noreferrer">OpenSCAD</a> or already know how, there's a <a href="https://www.thingiverse.com/thing:1668883/" rel="nofollow noreferrer">Thingiverse</a> post that appears to directly address your obje...
<p>This is the best and simplest way I've found to transform a flat design into a 3D object that you can then save as an STL file: <a href="https://www.youtube.com/watch?v=ows2QTiMRPg" rel="nofollow noreferrer">Blender-Converting 2D Image to 3D Object</a></p> <p>This solution requires you to use <a href="https://www.b...
1,031
<p>I'm looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down miserably here as it checks for locale changes on every call to isdigit(). Our current best is derived from the best of perl + tcl's atof implemen...
<p>What is your accuracy requirement? If you truly need it "correct" (always gets the nearest floating-point value to the decimal specified), it will probably be hard to beat the standard library versions (other than removing locale support, which you've already done), since this requires doing arbitrary precision ari...
<p>Have you considered looking into having the GPU do this work? If you can load the strings into GPU memory and have it process them all you may find a good algorithm that will run significantly faster than your processor.</p> <p>Alternately, do it in an FPGA - There are FPGA PCI-E boards that you can use to make ar...
12,391
<p>This is not a technical problem, but very annoying.</p> <p>Does anyone know how to turn off or change the color for the name highlight in phpEclipse?</p> <p>I use white-on-black scheme and this highlight has a white background which makes it unreadable and very ugly.</p> <p>To better explain which highlight I'm r...
<p>For Java in Eclipse it is: </p> <blockquote> <p>Window > Preferences > Java > Editor > Mark Occurrences.</p> </blockquote> <p>My ruby plug-in has the same option. Do a search in the preferences window for 'Mark Occurrences' and hopefully the php plug-in has the same option.</p>
<p>From Eclipse, go to Window > Preference, use the filter field ("type filter text") to search for "color". It will show all the config options related to the colors.</p> <p>I suppose it's not a problem with phpEclipse, but an incompatibility with another Eclipse plugin.</p> <p>PS: When you fix the problem please te...
32,783
<p>First of all, sorry for my poor english. I would try to explain my problem. </p> <p>I am using psexec within a script to restart a cluster as follows: </p> <p>script1 in node1: perform a lot of tasks (shutdown services, check status, etc..) in the node1 and after completing all task launch with psexec the script2 ...
<p>Finally I have decided to use a watchdog process in the second script, so the script will be launched by this process instead of being launched by psexec.</p> <p>Thanks a lot for your help and your time devoted to help me.</p> <p>Best regards</p>
<p>It may be related with an issue that one gets from too many linked server hops using integrated authentication - a <a href="http://support.microsoft.com/kb/887682" rel="nofollow noreferrer"><strong>double-hop Kerberos problem</strong></a>.</p> <p>Since Integrated Windows Authentication covers two separate authentic...
46,844
<p>In a <code>CakePHP 1.2</code> app, I'm using </p> <pre><code>&lt;?php $session-&gt;flash();?&gt; </code></pre> <p>to output messages like "Record edited". It's working great.</p> <p>However, I want to add a link called "Dismiss" that will fade out the message. I know how to construct the link, but I don't know ho...
<p>Figured this out: Create a new layout in your layouts folder:</p> <pre><code>layouts/message.ctp </code></pre> <p>In that layout, include the call to output the content:</p> <pre><code>&lt;?php echo $content_for_layout; ?&gt; </code></pre> <p>Then when you set the flash message, specify the layout to use:</p> <...
<p>the default way to do is is to create a flash.ctp in your /app/views/layouts. This will override the default flash.ctp you can find in /cake/libs/view/layouts. So you don't need to use the additional param.</p> <p>btw: this works for all CakePHP standard views and layouts.</p>
15,578
<p>I was intending to have a play with git, and was wondering if anyone had used the <a href="http://www.eclipse.org/egit/" rel="noreferrer">git plugin for eclipse</a></p> <p>I see it's at version 0.3.1, and was wondering if anyone knew how stable it was / any gotchas?</p> <hr> <p>Update:</p> <p>If you are using a ...
<p><a href="http://github.com/blog/232-github-and-eclipse" rel="noreferrer">Github blog</a> spoke yesterday about Egit plugin:</p> <p><a href="http://freshmeat.net/projects/jgit/" rel="noreferrer">http://freshmeat.net/projects/jgit/</a></p>
<p>There is also <a href="http://gitclipse.sourceforge.net/index.php" rel="nofollow noreferrer">gitclipse</a>(based on JavaGit), but seems dead.</p>
38,778
<p>I'm looking for a Python library for creating canvases for manipulating geometric shapes. Specifically I need the ability to create arbitrary polygons and place them on the canvas, the polygons need to have the ability to be transparent/have an alpha channel, I need to be able to edit polygons that are currently on ...
<p>I think <a href="http://cairographics.org/" rel="noreferrer">cairo</a> will do a lot of what you want. They have <a href="http://www.cairographics.org/pycairo/" rel="noreferrer">python bindings</a>, too.</p> <p>The one requirement that that won't help you with is modifying previously-drawn polygons, but I don't kno...
<p>I believe the HTML canvas lets you modify elements, which makes me believe there might be another canvas that can as well. However, if there is not that would basically require me to keep a separate list of all the polygons and when I wanted to make a change, alter the item in the list and then create a new canvas,...
47,233
<p>Oracle purchased BEA and their WebLogic suite of tools. They still have a competing product in their own 10gAS Application Server. Both are <a href="http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition" rel="nofollow noreferrer">Java EE</a>, enterprise grade, servers. While it make take some time due to ma...
<p>You can go through a (rather long) <a href="http://download.oracle.com/products/middleware/oracle-middleware-strategy-briefing-072008.pdf" rel="noreferrer">PDF strategy briefing</a> from Oracle. The key slide, though, is probably #48. Oracle has put BEA Weblogic on the "Strategic Products" list and the Oracle Appl...
<p>As you say, it would be unusual for them to maintain two products within the same architectural space. I don't know Java application servers, but given the climate of financial markets, and that it would probably take lots of money to maintain two such application servers, I would say it's a foregone conclusion that...
28,694
<p>I studied TSP in college in the context of NP Completeness. I have never actually had a situation where it would apply to a practical problem. A little bit of research shows that it has been used to pick the cheapest path to move a drill around, that is making holes in circuit boards. That is pretty much all I...
<p>I've never personally used it, but another application besides drilling circuit boards is if you want to go to a number of different places, say to sell vacuums. You could use a solution of the problem to decide the cheapest way to visit everywhere exactly once.</p>
<p>Wouldn't Google Maps (And every other Map based routing software) be using some kind of travelling salesman to solve driving directions?</p>
33,070
<p>I'm quite new to 3D CAD and printing. I own a Dremel 3D45 and I use FreeCad / Ultimaker Cura as softwares.</p> <p>My question is pretty simple. Say you have to make one object with a pin and another with a hole. They should be coupled together. Of course if you set the diameters of the pin and the hole equal the won...
<blockquote> <p>I guess this tolerance (0.4 mm in my example) depends on a lot of variables: 3D printer settings, material, etc... so it may change using different setup.</p> </blockquote> <p>Tolerances required <strong>depend on the geometry you're printing</strong>. A hole that is horizontal, vertical, or diagonal wi...
<blockquote> <p>I guess this tolerance (0.4 mm in my example) depends on a lot of variables: 3D printer settings, material, etc... so it may change using different setup.</p> </blockquote> <p>Yes, this is true, you need to find out for yourself on your rig. Fine tune the printer. Note that filament also shrinks, althou...
2,182
<p>I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update?</p> <p>Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text fi...
<p>woo! solved it on my own.</p> <p>Use </p> <pre><code>self.combo['selection'] </code></pre> <p>instead of</p> <pre><code>self.combo['value'] </code></pre>
<p><i>NOTE: copy of Moe's answer that can be selected as chosen answer</i></p> <p>woo! solved it on my own.</p> <p>Use </p> <pre><code>self.combo['selection'] </code></pre> <p>instead of</p> <pre><code>self.combo['value'] </code></pre>
14,275
<p>Is there a way to emulate a disk drive in .NET, intercepting read/write/lock operations?<br /> I would like to create something with a front-end similar to <a href="http://en.wikipedia.org/wiki/GMail_Drive" rel="nofollow noreferrer">GMail Drive</a> in C#.</p> <p>Thanks, Tom</p>
<p>On Linux you can use the Mono.Fuse API (<a href="http://www.jprl.com/Projects/mono-fuse.html" rel="nofollow noreferrer">http://www.jprl.com/Projects/mono-fuse.html</a>) to implement .NET-based file systems with user-land code.</p>
<p>Not really, .Net sits on top of OS functionality like disk access to give you things like managed file accessors.You could write all of it in managed C#, but you'd need unmanaged calls to make the OS treat it like another drive.</p> <p>All the shell extension stuff is COM: <a href="http://msdn.microsoft.com/en-us/l...
16,704
<p>How do I remove the urls of repositories that no longer exist in the dropdown in the TortoiseSvn repo-browser?</p>
<p>Just move the mouse over the item you want to remove and press <kbd>Shift</kbd>+<kbd>Del</kbd>.</p>
<p>If you go to your Program menu and find TortoiseSVN > Setting</p> <p>There is "Saved Data" tab. From there you can remove all of the items in the list which may be more than you wanted to get rid of. I'm not sure where this is stored and if there is an option for removing individual items.</p>
41,787
<p>Given that I only have one monitor, what's the best way to debug a program which uses the entire screen (such as a DirectX application)? Tools such as the step-by-step debugger seem useless in this context. Also, printing to the console isn't as effective, since you can only look at the console once the application ...
<p>Remote debugging is no option?</p> <p>Else you can possibly borrow a second monitor (with video card).</p> <p>And if all else fails you can go back to beep signals.</p> <p>(Or find yourself an old matrix printer and write each line to the printer ;-) )</p>
<p>printf debugging is slow, painful and fool proof.</p> <p>fill your code full of tracing lines like</p> <pre><code>fprint(logfile,"%s:%d\n",__FILE__,__LINE__); </code></pre> <p>or waterer you need for your language and run it. after your done, you can walk through what it did. Make sure you have lots of time and h...
42,366
<p>In a ASP.NET application that I am writing I need to use connections to a specific server (something like a DB but... different). The connections are quite expensive to establish (a few seconds, literally) so I'm trying to write a pool to improve scalability. </p> <p>Everything is pretty simple, up to one point - r...
<p>You would not need to wrapper every class and function, just the actions that you need to perform. So you might need a method to fetch some data and a method to update some data, this would translate in the service as a series of calls to the various functions as required. The front-end logic would be simplified and...
<p>You could write a WCF service that wrappers the service you are trying to call and then communicate with this mysterious service only through your WCF service application.</p> <p>WCF has various models to handle pooling and cleanup.</p>
41,906
<h2>Question</h2> <p>I'm looking for a Java in-memory object caching API. Any recommendations? What solutions have you used in the past?</p> <h2>Current</h2> <p>Right now, I'm just using a Map:</p> <pre><code>Map cache = new HashMap&lt;String, Object&gt;(); cache.put("key", value); </code></pre> <h2>Requirements</...
<p><a href="http://ehcache.sourceforge.net/" rel="noreferrer">EHCache</a> is very nice. You can create an in memory cache. Check out their <a href="http://ehcache.sourceforge.net/documentation/samples.html" rel="noreferrer">code samples</a> for an example of creating an in memory cache. You can specify a max size, an...
<p>memcached has client for Java. <a href="http://www.danga.com/memcached/" rel="nofollow noreferrer">http://www.danga.com/memcached/</a> Requires separate process to be a caching server, but powerful thing.</p>
28,552
<p>I am trying to find a way to disable Design / Split views from appearing in Visual Studio. I figure there's no way to completely disable it, but I still can't seem to find a way to remove the shortcut (F7), or remove the buttons from the bottom bar.</p>
<p>The best I found was:</p> <p>for HTML/ASPX - Options -> HTML Designer -> start pages in source view</p> <p>for XAML -> Options -> Text Editor -> XAML -> Misc -> Always open documents in full XAML view</p>
<p>You should be able to delete the keyboard assignment for F7 in the Keyboard Customization screen. All hotkey assignments are customizable AFAIK.</p> <p>I doubt there's any way to get rid of the buttons on the UI.</p>
14,920
<p>We have a few applications that use the same Linq 2 SQL DataContext. One of those Apps wil do massive inserts (it's a convertor from an old system). Is it possible to change the UpdateCheck of the TimeStamp column of each table at runtime ? Only for this one app we'd like to set it to Never, all the other apps sh...
<p>AFAIK you can not change it (at least with simple means) at runtime, because it is auto-generated as attribute in the properties of the domain classes. E.g.</p> <pre><code>[Column(Name="ITM_CREATE_DATE", Storage="_ITM_CREATE_DATE", DbType="DateTime NOT NULL", UpdateCheck=UpdateCheck.Never)] public System.DateTime C...
<p>UpdateCheck is not used for Insert operations, only for update.</p>
33,283
<p>I have a requirement to be able to provide a flex component in English and several asian languages. I have looked at the flex documentation and it seems that I have to build several swf's, which feels wrong. </p> <p>Does anyone know of a straightforward and practical way of bundling string resources in different ...
<p>I guess you know the basics of how to localize a Flex application, but if you would like to know more there's a good and thorough description here: <a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:_Runtime_Localization" rel="nofollow noreferrer">Runtime Localization</a>.</p> <p>In Flex 3 y...
<p>We use Flex for the client part of our application and support I18N via <a href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;file=l10n_076_4.html" rel="nofollow noreferrer"><code>ResourceBundle</code></a>s. </p>
18,949
<p>What is the best way to retire a currently active project? I've been working on this one for a while now and I think its time to let go. Without going into too much detail, there are other projects and technologies that are way ahead now and I don't see much value in investing in it any further.</p> <p>What have yo...
<p>As operating systems, compilers, etc. change, it can be difficult to rebuild old projects.</p> <p>Consider creating a virtual machine that is configured to build it again, in case you need to update it for some reason in the future. Archive that VM along with the source code, etc.</p>
<p>Is this a personal, community, or commercial/professional project? </p> <p>I have had a professional prject go sour due to lack of feedback form the client. Bascially they were going at a slower pace than they should have and it got to a point where the software would be more expensive to contine than to get a preb...
14,425
<p>Using C#, I want to get the total amount of RAM that my computer has. With the PerformanceCounter I can get the amount of Available ram, by setting:</p> <pre><code>counter.CategoryName = "Memory"; counter.Countername = "Available MBytes"; </code></pre> <p>But I can't seem to find a way to get the total amount of m...
<p>Add a reference to <code>Microsoft.VisualBasic</code> and a <code>using Microsoft.VisualBasic.Devices;</code>.</p> <p>The <code>ComputerInfo</code> class has all the information that you need. </p>
<pre><code>/*The simplest way to get/display total physical memory in VB.net (Tested) public sub get_total_physical_mem() dim total_physical_memory as integer total_physical_memory=CInt((My.Computer.Info.TotalPhysicalMemory) / (1024 * 1024)) MsgBox("Total Physical Memory" + CInt((My.Computer.Info.TotalPh...
13,064
<p>I would like Visual Studio to break when a handled exception happens (i.e. I don't just want to see a "First chance" message, I want to debug the actual exception).</p> <p>e.g. I want the debugger to break at the exception:</p> <pre><code>try { System.IO.File.Delete(someFilename); } catch (Exception) { //we ...
<p>With a solution open, go to the Debug - Windows - Exception Settings (<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>E</kbd>) menu option. From there you can choose to break on <em>Thrown</em> or <em>User-unhandled</em> exceptions.</p> <p>EDIT: My instance is set up with the C# &quot;profile&quot; perhaps it isn't there for o...
<p>The online documentation seems a little unclear, so I just performed a little test. Choosing to break on Thrown from the Exceptions dialog box causes the program execution to break on <em>any</em> exception, handled or unhandled. If you want to break on handled exceptions only, it seems your only recourse is to go t...
14,241
<p>When @RadioServiceGroup is set to NULL, I want to return all the records from the sbi_l_radioservicecodes table which has about 120 records. However, when I execute the following procedure and set the @RadioServiceGroup to NULL, it returns no records. Here is the stored proc:</p> <pre><code>CREATE PROCEDURE [dbo]...
<p>Try "IS NULL" instead of "= NULL"</p>
<p>You can cut out the <code>If</code> completely. Try this:</p> <pre><code>CREATE PROCEDURE [dbo].[GetRadioServiceCodes] @RadioServiceGroup nvarchar(1000) = NULL AS BEGIN SELECT rsc.RadioService FROM sbi_l_radioservicecodes rsc WHERE rsc.RadioServiceGroup = @RadioServiceGroup ...
33,290
<p>I am writing my first serious wxWidgets program. I'd like to use the wxConfig facility to make the program's user options persistent. However I <em>don't</em> want wxConfigBase to automatically use the Windows registry. Even though I'm initially targeting Windows, I'd prefer to use a configuration (eg .ini) file. Do...
<p>Don't do it!</p> <p>Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros:</p> <pre><code>attr_writer :bar attr_reader :baz attr_accessor :foo </code></pre> <p>Okay, now that you have been warned, here's how to do i...
<p>If there's no hope of changing the canonical names, you could alias the getters and setters manually:</p> <pre><code>def variable_name send 'variable.name' end def variable_name=(value) send 'variable.name=', value end </code></pre>
7,174
<p>Can anyone suggest a good way of detecting if a database is empty from Java (needs to support at least Microsoft SQL Server, Derby and Oracle)?</p> <p>By empty I mean in the state it would be if the database were freshly created with a new create database statement, though the check need not be 100% perfect if cove...
<p>There are some cross-database SQL-92 schema query standards - mileage for this of course varies according to vendor</p> <pre><code>SELECT COUNT(*) FROM [INFORMATION_SCHEMA].[TABLES] WHERE [TABLE_TYPE] = &lt;tabletype&gt; </code></pre> <p>Support for these varies by vendor, as does the content of the columns for th...
<p>Are you always checking databases created in the same way? If so you might be able to simply select from a subset of tables that you are familiar with to look for data.</p> <p>You also might need to be concerned about static data perhaps added to a lookup table that looks like 'data' from a cursory glance, but mig...
14,480
<p>Does anyone have any experience with a good wpf pivot table control?</p>
<p><a href="http://www.devexpress.com/Products/NET/Controls/WPF/Grid/" rel="noreferrer">DevExpress Grid control</a> has good pivot functionality. Used it for Winforms a lot. I think the WPF version is also available.</p>
<p>I am a consultant at Infragistics and I've been working exclusively the last few weeks with the Infragistics XamPivotGrid. We've been working to make this control fast and memory efficient. As a user and a developer, I am highly impressed with the usability of this control. You can check out this control in the WPF ...
7,881
<p>I've got an array of objects in json format: </p> <pre><code>[ { "name": "obj1", "list": [ "elem1", "elem2", "elem3" ] }, { "name": "obj2", "list": [ "elem4", "elem5", "elem6" ] } ...
<p>This works, but it's not pure regex:</p> <pre><code>var str = '[{"name":"obj1", "list":["elem1", "elem2", "elem3"]},' + '{"name":"obj2", "list":["elem4", "elem5", "elem6"]}]'; str = str.replace(/"list":\[[^\]]+\]/g, function (match) { return '"list":' + match.substring(7, match.length).replace(/([^\\])"...
<p>This should solve the problem as you described it:</p> <pre><code>str = str.replace(/"(?=[^\[]*\])/g, ''); </code></pre> <p>After matching a quotation mark, the lookahead checks that there's a closing square bracket up ahead, but no opening bracket between it and the current position. If the JSON is well-formed, ...
43,895
<p>I have a large number of files in a .tar.gz archive. Checking the file type with the command</p> <pre><code>file SMS.tar.gz </code></pre> <p>gives the response</p> <pre><code>gzip compressed data - deflate method , max compression </code></pre> <p>When I try to extract the archive with gunzip, after a delay I r...
<p>Are you sure that it is a gzip file? I would first run 'file SMS.tar.gz' to validate that.</p> <p>Then I would read the <a href="http://www.urbanophile.com/arenn/coding/gzrt/gzrt.html" rel="nofollow noreferrer">The gzip Recovery Toolkit</a> page.</p>
<p>Here is one possible scenario that we encountered. We had a tar.gz file that would not decompress, trying to unzip gave the error:</p> <pre><code>gzip -d A.tar.gz gzip: A.tar.gz: invalid compressed data--format violated </code></pre> <p>I figured out that the file <em>may</em> been originally uploaded over a non b...
24,590
<p>My function is pretty much a standard search function... I've included it below.</p> <p>In the function I have 1 line of code responsible for weeding out Repart NTFS points. </p> <pre><code>if (attributes.ToString().IndexOf("ReparsePoint") == -1) </code></pre> <p>The problem is now I am getting an error <code>Ac...
<p>I'm not sure what the answer to the question is, but <em>please</em> change your attribute check to use proper bitwise operations!</p> <pre><code>if (attributes.ToString().IndexOf("ReparsePoint") == -1) </code></pre> <p>... is much more correctly written as ...</p> <pre><code>if ((attributes &amp; FileAttributes....
<p>Once you get past permissions, and really want to test for junction points, <a href="https://www.codeproject.com/script/articles/viewdownloads.aspx?aid=15633&amp;zep=junctionpoint.cs&amp;rzp=%2Fkb%2Ffiles%2Fjunctionpointsnet%2F%2Fjunctionpointsnet_src.zip" rel="nofollow noreferrer">this class</a> provides testing fo...
43,060
<p>So yesterday I got my power supply in the mail and I thought, let's check it out!</p> <p>I put all the wires in correctly (as shown in this YouTube video, <a href="https://www.youtube.com/watch?v=X8GhVKG2Nno" rel="nofollow noreferrer">Anet A8 power supply unit fuse blown</a>, I just searched really quickly, this per...
<p>You need to closely look at how to connect to the output connectors. In this case it appears that you have wired it correctly according to the stamped in markings above the connectors. You have chosen not to connect the earth, this is strongly advised.</p> <p>Did you check if the power switch matches the voltage of...
<h3>Unless you know what you're doing, do not remove the covers from a PSU. The components can store a lethal charge long after power is removed, even if the fuse is blown.</h3> <p>My guess is something loose (now vapourised) in the PSU. Electronics have a tendancy of failing either quite soon after manufacture, or las...
1,214
<p>In my C# program, I have a thread that represents a running test, which can be aborted by a click on a button labeled "Interrupt execution". In order for the thread (and therefore the test) to terminate in an elegant manner (and do some vital work beforehand), this button is enabled only in some well-defined moments...
<p>The situations under which a ThreadAbortException will be generated can be complex. A better option might be to ask why you are using ThreadAbortExceptions at all.</p> <p>A better pattern would be to simply use a flag to indicate to the running thread that it should abort, and then test the flag regularly while it ...
<p>Use <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.begincriticalregion.aspx" rel="nofollow noreferrer">Thread.BeginCriticalRegion()</a> </p> <blockquote> <p>Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception mig...
6,932
<p>I understand that this is probably more of an electronics question, but was hoping that someone with experience of using an Anet A6 in the UK (or a country outside of the US/China) may be able to help... or alternatively, someone knowledgeable in electronics!</p> <p>I recently bought and assembled an Anet A6. I am ...
<p>The UK uses 230&nbsp;V mains voltage. The 220&nbsp;V designation is from the past, Europe is now using 230&nbsp;V. You do not have to worry about the frequency.</p> <p>You should place the switch to 220&nbsp;V and plug the cord into the socket. The printer should start immediately booting (cycling) the printer firm...
<p>@Oscar was correct, so long as the switch is set at 220 V, the printer will turn on. I am adding this answer to help anyone else who has a similar problem.</p> <p>I strongly recommend that you buy a multimeter if you have any power supply issues, as this helped me to figure out what was wrong.</p> <p>There were th...
1,551
<p>I have a unique development situation and would like some input from others.</p> <p>I have a situation where I need to load loose xaml files within a rich client application. A given loose xaml file may have references to an assembly not currently loaded in memory so the referenced assembly is loaded before the lo...
<p>I'm guessing that you are already doing dynamic assembly resolution and loading? If so, then you could try substituting a fake assembly name in place of the real assembly name i n the Xaml - you can then use that in your assembly resolution code to load up and return the right assembly. e.g. if your original source ...
<p>I haven't confirmed if this would work, but I believe that it may. You could use the XmlnsDefinitionAttribute (at assembly level). E.g.</p> <p>Assembly V1 -> AssemblyInfo.cs</p> <pre><code>[assembly: XmlnsDefinition( "http://schema.mycompany.com/myproject/v1", "MyCompany.MyProject" )] </code></pre> <p>Assembly V2...
32,979
<p>I have a module in the parent directory of my script and I would like to 'use' it.</p> <p>If I do</p> <pre><code>use '../Foo.pm'; </code></pre> <p>I get syntax errors.</p> <p>I tried to do:</p> <pre><code>push @INC, '..'; use EPMS; </code></pre> <p>and .. apparently doesn't show up in @INC</p> <p>I'm going cr...
<p><code>use</code> takes place at compile-time, so this would work:</p> <pre><code>BEGIN {push @INC, '..'} use EPMS; </code></pre> <p>But the better solution is to <code>use lib</code>, which is a nicer way of writing the above:</p> <pre><code>use lib '..'; use EPMS; </code></pre> <p>In case you are running from a...
<p>Some IDEs don't work correctly with 'use lib', the favored answer. I found 'use lib::relative' works with my IDE, JetBrains' WebStorm.</p> <p>see <a href="https://metacpan.org/pod/lib::relative" rel="nofollow noreferrer">POD for lib::relative</a></p>
22,388
<p>Given a simple switch statement</p> <pre><code>switch (int) { case 1 : { printf("1\n"); break; } case 2 : { printf("2\n"); } case 3 : { printf("3\n"); } } </code></pre> <p>The absence of a break statement in case 2, implies that execution will...
<p>Many answers seem to focus on the ability to fall through as the <em>reason</em> for requiring the <code>break</code> statement.</p> <p>I believe it was simply a mistake, due largely because when C was designed there was not nearly as much experience with how these constructs would be used.</p> <p>Peter Van der Li...
<p>As many here have specified, it's to allow a single block of code to work for multiple cases. This <strong>should</strong> be a more common occurrence for your switch statements than the "block of code per case" you specify in your example.</p> <p>If you have a block of code per case without fall-through, perhaps...
31,454