instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I used Visual Studio's Application Wizard to create a skeleton MFC program with a multi-document interface. When I start this program, it automatically creates a child frame, which I don't want it to do - I need the main frame's client area to be empty until the user chooses to open a file.</p> <p>The debugger tel...
<p>This worked for me -- change</p> <pre><code>if (!ProcessShellCommand(cmdInfo)) </code></pre> <p>to</p> <pre><code>if (cmdInfo.m_nShellCommand != CCommandLineInfo::FileNew &amp;&amp; !ProcessShellCommand(cmdInfo)) </code></pre> <p>in your app's InitInstance() function.</p>
<p>Skipping the ProcessShellCommand() call (in case of FileNew) in InitInstance() is indeed the way to go.</p>
22,722
<p>Since I have lots of PETG, I ran tuning to 230 °C (average temp for my filaments). What is it good for, in terms of temperature ranges?</p> <p>For the same printer configuration, and just different filaments, will I need to run it again and again? Let's assume that I'll be printing between 200 °C and 240 °C.</p> <p>...
<p>PID tuning can be performed multiple times and the results saved for future use, since the question is about &quot;what are the usable ranges for PID tuning&quot;, based on my experience</p> <ol> <li>a slightly suboptimal tuning will not make the temperature oscillate more than 2-3 degrees, which is more than enough...
<p>It's not a straight answer, but you don't have to run PID tuning every time you decide to print with different temperature. (Until you change something in a hardware near or related to the hotend.)</p> <p>You can tune PID for different temperatures and grab necessary values, for example:</p> <pre><code>M303 C16 D1 E...
1,857
<p>I need to retrieve all rows from a table where 2 columns combined are all different. So I want all the sales that do not have any other sales that happened on the same day for the same price. The sales that are unique based on day and price will get updated to an active status.</p> <p>So I'm thinking:</p> <pre><co...
<pre><code>SELECT DISTINCT a,b,c FROM t </code></pre> <p>is <em>roughly</em> equivalent to: </p> <pre><code>SELECT a,b,c FROM t GROUP BY a,b,c </code></pre> <p>It's a good idea to get used to the GROUP BY syntax, as it's more powerful. </p> <p>For your query, I'd do it like this:</p> <pre><code>UPDATE sales SET ...
<p>I want to select the distinct values from one column 'GrondOfLucht' but they should be sorted in the order as given in the column 'sortering'. I cannot get the distinct values of just one column using</p> <pre><code>Select distinct GrondOfLucht,sortering from CorWijzeVanAanleg order by sortering </code></pre> <p>I...
7,802
<p>I started to use silverlight/flex and immediately bumped into the asynchronous service calling. I'm used to solving the data access problems in an OO-way with one server fetch mechanism or another.</p> <p>I have the following trivial code example:</p> <pre><code>public double ComputeOrderTotal(Order order) { ...
<p>Yes I must agree that O/R mapping is usually done on the server-side of your application. In SilverLight asynchronous way of execution is the desired pattern to use when working with services. Why services? Because as I said before there is no O/R mapping tool at the moment that could be used on the client-side (Sil...
<p>Silverlight is a client technology and the Object - Relational mapping happens completely in the server. So you have to forgot about the ORM in Silverlight. </p> <p>Following your example what you have to do is to create a webservice (SOAP, REST...) that can give your silverlight client the complete "Order" object....
46,321
<p>The subject pretty much explains it all. I start on frame one of a MovieClip with just a Bitmap covering the whole stage.</p> <p>Then when a user clicks a button, it goes to frame two and a vector shape is on the stage covering part of the image. At the same time, through code, I place an input Textfield on the sta...
<p>I recommend that you take a look at dependency injection. One thing is using mock objects, but unless you're using something like TypeMock, which basically lets you modify you code on the fly, you want to have a way to inject the instances your class depends on if you want to get rid of the dependencies. So in examp...
<p>Have you tried deriving a UTMyClass from MyClass? </p>
39,496
<p>I want some particular urls like "springer.com" to automatically convert to "springer.com.proxy1.mycollege.edu". The second url takes me to springer site through my college library gateway; I am able to access some parts that would otherwise be restricted.</p> <p>Is there some way to convert the url as above automa...
<p>Could use your hosts file to trick firefox into looking for springer.com in the right place.</p> <p><a href="http://en.wikipedia.org/wiki/Hosts_file" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Hosts_file</a></p>
<p>You can use Greasemonkey for such task.</p>
29,439
<p>I want to implement an "automatic update" system for a windows application. Right now I'm semi-manually creating an <a href="http://connectedflow.com/appcasting/" rel="noreferrer">"appcast"</a> which my program checks, and notifies the user that a new version is available. (I'm using <a href="http://nsis.sourcefo...
<p>There is no solution quite as smooth as Sparkle (that I know of).</p> <p>If you need an easy means of deployment and updating applications, <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="noreferrer">ClickOnce</a> is an option. Unfortunately, it's inflexible (e.g., no per-machine installation instead of per-u...
<p>Just came here from an answer to my own question on the same subject - I mention one other <a href="http://windowsclient.net/articles/appupdater.aspx" rel="nofollow noreferrer">updating solution</a> in my <a href="https://stackoverflow.com/questions/49747/autoupdating-net-applications">question</a>. It uses a stub ...
5,766
<p>I just started to learn Ruby and as a .Net developer, I'm wondering if I should just go straight ahead and use IronRuby, without trying some pure Ruby first.</p> <p>What do you think? Will I be missing anything?</p> <p>-- rauchy</p>
<p>I would use pure ruby (Matz Ruby Interpreter (MRI)) to start off. My understanding is that iron ruby is not quite ready yet.</p> <p>If you are looking for a good book my current favorite (over pickaxe) is <a href="https://rads.stackoverflow.com/amzn/click/com/0596516177" rel="nofollow noreferrer" rel="nofollow nor...
<p>I know this is an old question, but I'd like to say that four years later (today), the JRuby implementation is certainly far enough advanced to be worth starting with.</p>
9,482
<p>Do you know if it's possible to build an application for the LinkedIn platform?</p>
<p>While LinkedIn has promised a public API for a very long time now, they have yet to deliver. </p> <p>No, there is no <strong>public</strong> LinkedIn API yet. </p> <p>IMO, their widgets (which there are only two of at the moment, which are very limited) don't count. </p> <p>They say that they are open to bein...
<p>Yes, Linkedin has an API:</p> <ul> <li><a href="http://www.programmableweb.com/api/linkedin" rel="nofollow noreferrer">http://www.programmableweb.com/api/linkedin</a></li> <li><a href="http://blog.linkedin.com/blog/2007/12/the-intelligent.html" rel="nofollow noreferrer">http://blog.linkedin.com/blog/2007/12/the-int...
6,225
<p>I'm cloning a TClientDataSet and I want to copy all the fields to the clone (which is a new DataSet), I know I can loop through the Fields and copy the info, or make 2 instances of my class and just clone the cursor, but is there some better way? Something like create a new DataSet and assign the fields info?</p> <...
<p>If you just want to copy the field definitions you can do the following:</p> <pre><code>ds2.FieldDefs.Assign(ds1.FieldDefs); ds2.CreateDataSet; ds2.Open; </code></pre> <p>Of course this assumes you created FieldDefs for ds1.</p>
<p>NON-PROGRAMMABLE METHOD</p> <ul> <li><p>first tclientdataset: open fields editor. add all fields if not already shown. select all fields. copy to clipboard.</p></li> <li><p>second tclientdataset: open fields editor. paste clipboard in fields editor. done</p></li> </ul> <p>you should now see identical fieldDefs f...
49,613
<p>I got myself a Creality Ender 3 and just finished assembling it and I noticed that the home position is at the right instead of the left. It also is about about 3&nbsp;mm in front of the right corner.</p> <p>Anyone could maybe help me to understand what is wrong?</p>
<p>Homing is the process where the machine finds all the limits of the 3 axis (at the endstop switches), to have a common reference point for each axis. From the endstops, firmware defined values exist to give the printer head the offset to the home position, also known as origin (X=0, Y=0). If the origin position is i...
<p>Did you make sure that the x,y,z and other cords / connectors, were connected to the right areas? TO clarify, the things that connect into the motors.<a href="https://i.stack.imgur.com/05zAt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/05zAt.jpg" alt="What I was trying to explain. Apologies for...
1,192
<p>I am wondering - of course if the 3D printer's bed big enough - printing multiple copies of the same print could save me significant amount of time in a small production line, excluding minor wastage such as setup time, post-processing time, etc.</p> <p><a href="https://i.stack.imgur.com/aQ1Zt.png" rel="noreferrer"...
<p>Actually no. It will take slightly more for each addition. You also then have the point of failure, where one gets knocked off and ruins all the prints.</p> <p>The fastest way to print multiple objects is one at a time. In fact slic3r lets you do just that with their <a href="http://manual.slic3r.org/advanced/sequen...
<p>Actually the answer is yes and no. So I had to print 12 of the same small objects for a science experiment. Just some rocks I made from domes with some displaced faces, anyway my printers minimum wall width is 0.5 mm. The objects were 2 cm³. The first print failed because of them being disconnected but then I connec...
534
<p>Sometime I see many application such as msn, windows media player etc that are single instance applications (when user executes while application is running a new application instance will not created).</p> <p>In C#, I use <code>Mutex</code> class for this but I don't know how to do this in Java.</p>
<p>If I believe this <a href="http://www.rbgrn.net/blog/2008/05/java-single-application-instance.html" rel="noreferrer">article</a>, by :</p> <blockquote> <p>having the first instance attempt to open a listening socket on the localhost interface. If it's able to open the socket, it is assumed that this is the first...
<pre> public class SingleInstance { public static final String LOCK = System.getProperty("user.home") + File.separator + "test.lock"; public static final String PIPE = System.getProperty("user.home") + File.separator + "test.pipe"; private static JFrame frame = null; public static void main(String[] a...
21,342
<p>I had a problem with committing changes after merging two branches of my project using TortoiseSVN.</p> <p>Here are details:</p> <p>I did a merge branch to trunk of <em>project</em> which I am working on. </p> <p><em>Project</em> includes main repository and libraries joint to main repository as <em>svn external<...
<p><strong><em>svn:external</em></strong> will cause Subversion to combine different repository paths on check-out, but ultimately those paths are still 'disjoint', so you have to do two commits to get the changes applied.</p> <p>Here's the relevant quote from <a href="http://svnbook.red-bean.com/en/1.5/svn-book.html#...
<p>I think I remember reading about a bug relating to this in TortoiseSVN that's been fixed in the latest release. Check the latest <a href="http://tortoisesvn.tigris.org/tsvn_1.5_releasenotes.html" rel="nofollow noreferrer">release notes</a>.</p>
27,579
<p>I've searched for the solution to change the background color on the Compact Framework's MainMenu control, and the only answer I've found is that you need to create a custom control. Does anyone have example code for this?</p>
<p>I did something vaguely similar where I wanted to handle the WM_EXITMENULOOP message which was not available as an event in .NETCF. </p> <p>The solution was to "subclass" the Main Menu, an old MFC trick where you replace the WndProc function with your own, handle any windows messages (WM_EXITMENULOOP in my case) an...
<p>I tried to do something similar a while back and discovered that you have to write your own menu; essentially from scratch. I gave up because the project I was working on couldn't afford the expense. I also discovered that <a href="http://www.opennetcf.com/" rel="nofollow noreferrer">OpenNETCF</a> has a pretty awe...
19,933
<p>I'm attempting to use Assembly.GetType("MyCompany.Class1.Class2") to dynamically get a type from a string.</p> <pre><code>Assembly.GetType("MyCompany.Class1"); </code></pre> <p>works as expected.</p> <p>If I embed a class within another class such as:</p> <pre><code>namespace MyCompany { public class Class1 ...
<p>You need the Plus sign to get Nested Classes to be mapped using Assembly.GeType.</p> <pre><code> Assembly.GetType("MyCompany.Class1+Class2"); </code></pre>
<p>You need to use plus signs. Something like "MyAssembly.Class1+NestedClass".</p>
49,222
<p>Is there a way to deploy a given war file on Tomcat server? I want to do this without using the web interface.</p>
<p>There are several ways to deploy a Tomcat webapp:</p> <ul> <li>Dropping into $CATALINA_HOME/webapps, as was already mentioned.</li> <li>Using your build scripts to deploy automatically via the manager interface (that comes with Tomcat). Here are the two ways <ul> <li>for <em>Maven</em>: use the tomcat plugin. You ...
<p>The Tomcat <a href="http://tomcat.apache.org/tomcat-5.5-doc/deployer-howto.html#Deploying%20using%20the%20Client%20Deployer%20Package" rel="nofollow noreferrer">Client Deployer Package</a> looks to be what you need to deploy to a remote server from the command line. From the page:</p> <blockquote> <p>This is a p...
17,229
<p>I have a temp table with the exact structure of a concrete table <code>T</code>. It was created like this: </p> <pre><code>select top 0 * into #tmp from T </code></pre> <p>After processing and filling in content into <code>#tmp</code>, I want to copy the content back to <code>T</code> like this: </p> <pre><code...
<p>SET IDENTITY_INSERT ON</p> <p>INSERT command</p> <p>SET IDENTITY_INSERT OFF</p>
<blockquote> <ol> <li>it gives me a chance to preview the data before I do the insert </li> <li>I have joins between temp tables as part of my calculation; temp tables allows me to focus on the exact set data that I am working with. I think that was it. Any suggestions/comments?</li> </ol> </blockquote> <p>For...
14,917
<p>Normally you can do this:</p> <pre><code>&lt;select size="3"&gt; &lt;option&gt;blah&lt;/option&gt; &lt;option&gt;blah&lt;/option&gt; &lt;option&gt;blah&lt;/option&gt; &lt;/select&gt; </code></pre> <p>And it would render as a selectionbox where all three options are visible (without dropping down)<br> I...
<p>There ins't an option for setting the size, but if you do set the size some browsers will let you set the width/height properties to whatever you want via CSS.</p> <p>Some = Firefox, Chrome, Safari, Opera.</p> <p>Not much works in IE though (no surprise)</p> <p>You could though, if you wanted, use CSS expressions...
<p>I do not believe this is possible no</p>
14,587
<p>** Dup: <a href="https://stackoverflow.com/questions/226002/whats-the-difference-between-x-x-vs-x">What&#39;s the difference between X = X++; vs X++;?</a> **</p> <p>So, even though I know you would never actually do this in code, I'm still curious:</p> <pre><code>public static void main(String[] args) { int in...
<p>this is a duplicate question. </p> <p><b>EDIT:</b> I can't seem to find the original :P oh well</p> <p>a = a++ uses the postincrement, which your compiler interprets as:</p> <pre><code>a = function() { var old_value = a; a++; return old_value; } </code></pre> <p><b>EDIT 2:</b> <a href="https://stackover...
<p>The answer to <a href="https://stackoverflow.com/questions/226002/whats-the-difference-between-x-x-vs-x">this</a> question should help. The post increment does update the value of index but it returns the value before the update.</p>
46,167
<p>In the code below I use <code>mpf_add</code> to add the string representation of two floating values. What I don't understand at this point is why <code>2.2 + 3.2 = 5.39999999999999999999999999999999999999</code>. I would have thought that <code>gmp</code> was smart enough to give <code>5.4</code>. </p> <p>What am ...
<p>This is because of the inherent error of using floating-point arithmetic in a binary environment.</p> <p>See the <a href="http://en.wikipedia.org/wiki/IEEE_754" rel="nofollow noreferrer">IEEE 754</a> standard for more information.</p>
<p>What <a href="https://stackoverflow.com/users/4418/warren">warren</a> <a href="https://stackoverflow.com/questions/178952/adding-floats-with-gmp-gives-correct-results-sort-of#178978">said</a>.</p> <p>You might have better results if you use binary coded decimal instead of floating point numbers, although I can't re...
21,578
<p>Does filling out HTML meta description/keyword tags matter for SEO?</p>
<p><a href="http://searchengineland.com/070905-194221.php" rel="nofollow noreferrer">This article</a> has some info on it.</p> <p>A quick summary for keywords is:</p> <p>Google and Microsoft: No</p> <p>Yahoo and Ask: Yes</p> <p>Edit: As noted below, the meta description is used by Google to describe your site to po...
<p>Those are two of the things that are used by search engines. The exact weight of each changes frequently, they are generally regarded; however, as being fairly important.</p> <p>One thing to note, care should be taken when entering values. The more relevant the keywords and description are to the textual content ...
7,650
<p>How is it that Ruby allows a class access methods outside of the class implicitly?</p> <p>Example:</p> <pre><code>class Candy def land homer end end def homer puts "Hello" end Candy.new.land #Outputs Hello </code></pre>
<p>The definition of the "homer" method is adding the method to the Object class. It is not defining a free function.</p> <p>Class Candy implicitly inherits from Object, and so has access to the methods in Object. When you call "homer" in the "land" method, the method resolution can't find a definition in the curre...
<p>Ruby has no free-floating functions. Every method belongs to some object. Methods that you <code>def</code> at the top level are actually becoming instance methods of class <code>Object</code>. Because everything is an <code>Object</code> at some level, all objects have access to <code>Object</code>'s instance metho...
18,918
<p>I've written a new application in a network I haven't worked in before, and am running into a problem.</p> <p>If I have the following C# code:</p> <pre><code>FileStream fs = File.Create(@"\\MyServer\MyShare\testing.txt"); fs.Close(); </code></pre> <p>In a console application, this code executes correctly.</p> <p...
<p><strong>Update:</strong></p> <p>So I think I posted this too soon... The reason it was failing on my localhost was due to the directory being set as allow anonymous access (so the page wasn't impersonating; the user was '').</p> <p>It also started working on the server as well; however, nothing was changed there.....
<p>The issue is that with identity impersonate set to false the ASP.NET worker process account is trying to write to the share, typically that is the NETWORK SERVICE or ASPNET account. Depending on which version of windows you are running.</p> <p>setting impersonate to true, without specifying a username or password ...
48,670
<p>How do I write a clean implementation of the strategy pattern in Perl? I want to do it in a way that leverages Perl's features.</p>
<p>It really depends on what you mean by "clean implementation". As in any other language, you can use Perl's object system with polymorphism to do this for you. However, since Perl has first class functions, this pattern isn't normally coded explicitly. Leon Timmermans' example of</p> <pre><code>sort { lc($a) cmp lc(...
<p>Use sub references, and closures. A good perlish example of this</p> <pre><code>sort { lc($a) cmp lc($b) } @items </code></pre>
10,375
<p>Is it more performant to have a bidimensional array (<code>type[,]</code>) or an array of arrays (<code>type[][]</code>) in C#?</p> <p>Particularly for initial allocation and item access</p>
<p>Of course, if all else fails... test it! Following gives (in "Release", at the console):</p> <pre><code>Size 1000, Repeat 1000 int[,] set: 3460 int[,] get: 4036 (chk=1304808064) int[][] set: 2441 int[][] get: 1283 (chk=1304808064) </code></pre> <p>So a jagged array is quicker, at least in this test...
<p>type[,] will work faster. Not only because of less offset calculations. Mainly because of less constraint checking, less memory allocation and greater localization in memory. type[][] is not a single object -- it's 1 + N objects that must be allocated and can be away from each other.</p>
20,385
<p><strong>Edit</strong>: Let me completely rephrase this, because I'm not sure there's an XML way like I was originally describing.</p> <p><strong>Yet another edit</strong>: This needs to be a repeatable process, and it has to be able to be set up in a way that it can be called in C# code.</p> <p>In database A, I h...
<p>I think the SQL Server utility <a href="http://weblogs.sqlteam.com/mladenp/archive/2007/03/03/60125.aspx" rel="nofollow noreferrer">tablediff.exe</a> might be what you are looking for.</p> <p>See also <a href="https://stackoverflow.com/questions/121243/hidden-features-of-sql-server">this thread</a>.</p>
<p>Dump the XML approach and use the import wizard / SSIS.</p>
8,392
<p>When creating links for an an html based email, how critical is it to use absolute links? Also, What are the benefits in using relative links in general?</p>
<p>Relative links allow you use less code to traverse your structure, and they allow you to move domains without having to do any extra work. You simply copy your directory structure to the new domain, and it works. </p> <p>As a lesser consideration, Absolute links don't make you worry about the position of your docu...
<p>I would have to agree with balexandre. Although there are pros to using absolute links like less possibilities that a search engine messing something up etc, the advantages of using Relative links are greater for me because I won't have to change all the links if I copy whole portions of a site to another site, or e...
44,563
<p>So I've looked at <a href="http://mjtemplate.org/examples/freebase/names.html?name=%EB%A1%9C%EB%A7%88&amp;lang=ko" rel="nofollow noreferrer">this use</a> of the <a href="http://freebase.com" rel="nofollow noreferrer">freebase</a> API and I was really impressed with the translations of the name that it found. IE Rome...
<p>I'll second the vote for <a href="http://www.telerik.com" rel="nofollow noreferrer">Telerik</a>. Their controls for the most part &quot;just work&quot; and their support has been excellent. I primarily use their forums and I still receive a response within a day (unlike some other vendors who barely seem to notice t...
<p><a href="http://www.componentart.com" rel="nofollow noreferrer">ComponentArt</a> has some pretty cool controls. You might want to check out <a href="http://www.telerik.com" rel="nofollow noreferrer">Telerik</a> as well. Both companies offer pretty easy to use controls that look nice.</p>
5,357
<p>I am using Spring Forms for my web application. For nested properties, the form tag generates the input elements having id / name in form of .</p> <p>For example, Person is the command class and Address is contained into its address field then the city element would be,</p> <pre><code>&lt;input type="text" id="add...
<p>Try this:</p> <pre><code>$("#address\\.city").val(); </code></pre> <p>From <a href="http://docs.jquery.com/Selectors" rel="noreferrer">the documentation</a>:</p> <blockquote> <p>Note: if you wish to use any of the meta-characters described above as a literal part of a name, you must escape the character with tw...
<pre><code>$('[id="address.city"]') </code></pre> <p>will also work</p>
25,523
<p>I did my homework reading similar questions, like <a href="https://3dprinting.stackexchange.com/questions/8296/petg-sticking-to-nozzle">this</a>, <a href="https://3dprinting.stackexchange.com/questions/7122/petg-filament-doesnt-stick-reliably-to-fake-buildtak-surface">this</a> and <a href="https://3dprinting.stackex...
<p>Your nozzle is very much too high to properly print just about any filament. If the filament sticks to the nozzle after it is positioned closer to the bed, you have two problems. The first is the initial layer position, sometimes called z-offset. The second is bed adhesion.</p> <p>While the bed is cool, clean it car...
<p>With one brand of PETG I used 110 degrees on the build plate and 240 for the nozzle. Couldn't get a decent first layer before that.</p>
2,190
<p>I'm writing an application to start and monitor other applications in C#. I'm using the System.Diagnostics.Process class to start applications and then monitor the applications using the Process.Responding property to poll the state of the application every 100 milisecs. I use Process.CloseMainWindow to stop the app...
<p>Now, I need to check this out later, but I am sure there is a method that tells the thread to wait until it is ready for input. Are you monitoring GUI processes only?</p> <p>Isn't <a href="http://msdn.microsoft.com/en-us/library/kcdbkyt4.aspx" rel="noreferrer">Process.WaitForInputIdle</a> of any help to you? Or am ...
<p>I too noticed that in a project about 2 years ago. I called .Refresh() before requesting certain prop values. IT was a trial-and-error approach to find when I needed to call .Refresh().</p>
15,315
<p>How do I fix that error once and for all? I just want to be able to do unions in MySQL. </p> <p>(I'm looking for a shortcut, like an option to make MySQL ignore that issue or take it's best guess, not looking to change collations on 100s of tables ... at least not today)</p>
<p>Not sure about mySQL but in MSSQL you can change the collation in the query so for example if you have 2 tables with different collation and you want to join them or as in you situation crate UNION you can do</p> <pre><code>select column1 from tableWithProperCollation union all select column1 COLLATE SQL_Latin1_Gen...
<p>A fix I found that seems to be an easy fix is to alter the entire database that's giving you problems. I'm thinking this might not be the best way to do it, but it works for me and it's easy. I rune this command in MySQL:</p> <pre><code>ALTER DATABASE databasename COLLATE utf8_unicode_ci; </code></pre>
22,177
<p>I recently downloaded Mono 2 for my new MacBook. I'm trying to figure out how to compile Visual Studio solutions with xbuild, which is included in Mono. Any ideas?</p>
<p>Update: xbuild supports solution files now. see <a href="http://www.mono-project.com/Microsoft.Build" rel="noreferrer">xbuild</a></p>
<p>The last time I checked, solutions weren't supported by xbuild (they use a different file format), but *.*proj files are.</p> <p>If you have a relatively simple solution, you may be able to get away with using xbuild on each project separately, but if your solution is very complex (with interdependencies between pr...
31,777
<p>I have several stored procedures in my database that are used to load data from a datamart that is housed in a separate database. These procedures are, generally, in the form:</p> <pre><code> CREATE PROCEDURE load_stuff WITH EXECUTE AS OWNER AS INSERT INTO my_db.dbo.report_table ( column_a ) SELECT column_b FR...
<p>Why not remove EXECUTE AS OWNER?</p> <p>Usually, my user executing the SP would have appropriate rights in both databases, and I don't have to do that at all.</p>
<p>Actually, DBO is a role (you can consider it as a group of users), not a user in himself. (Unless you can connect to SQL SERVER using dbo:passwordfordbo it's not a user).</p> <p>Usually, in the wonderful world of SQL Server, if you grant userX right to execute storedprocY then X gets the right to perform all the ta...
18,050
<p>I find AWK really useful. Here is a one liner I put together to manipulate data.</p> <pre><code>ls | awk '{ print "awk " "'"'"'" " {print $1,$2,$3} " "'"'"'" " " $1 ".old_ext &gt; " $1 ".new_ext" }' &gt; file.csh </code></pre> <p>I used this AWK to make a script file that would rename some files and only pr...
<p>The <a href="https://archive.org/details/pdfy-MgN0H1joIoDVoIC7" rel="nofollow noreferrer">AWK book</a> is full of great examples. They used to be collected for download from <a href="http://cm.bell-labs.com/cm/cs/who/bwk/awkcode.txt" rel="nofollow noreferrer">Kernighan's webpage</a> (404s now).</p>
<p>Count memory used by httpd</p> <pre><code>ps -ylC httpd | awk '/[0-9]/ {SUM += $8} END {print SUM/1024}' </code></pre> <p>Or any other process by replacing httpd. Dividing by 1024 to get output in MB.</p>
34,481
<p>I'm a big fan of the way Visual Studio will give you the comment documentation / parameter names when completing code that you have written and ALSO code that you are referencing (various libraries/assemblies).</p> <p>Is there an easy way to get inline javadoc/parameter names in Eclipse when doing code complete or ...
<p>Short answer would be yes.</p> <p>You can attach source using the properties for a project.</p> <p>Go to Properties (for the Project) -> Java Build Path -> Libraries</p> <p>Select the Library you want to attach source/javadoc for and then expand it, you'll see a list like so:</p> <pre><code>Source Attachment: (n...
<p>It may seem like overkill, but if you use maven and include source, the mvn eclipse plugin will generate all the source configuration needed to give you all the in-line documentation you could ask for.</p>
14,851
<p>What is the "cleanest" way to implement an command-line UI, similar to git's, for example:</p> <pre><code>git push origin/master git remote add origin git://example.com master </code></pre> <p>Ideally also allowing the more flexible parsing, for example,</p> <pre><code>jump_to_folder app theappname v2 jump_to_fol...
<p><a href="http://docs.python.org/library/argparse.html#sub-commands" rel="noreferrer">argparse</a> is perfect for this, specifically <a href="http://docs.python.org/library/argparse.html#sub-commands" rel="noreferrer">"sub-commands"</a> and positional args</p> <pre><code>import argparse def main(): arger = arg...
<p>Here's my suggestion.</p> <ol> <li><p>Change your grammar slightly.</p></li> <li><p>Use optparse.</p></li> </ol> <p>Ideally also allowing the more flexible parsing, for example,</p> <pre><code>jump_to_folder -n theappname -v2 cmd jump_to_folder -n theappname cmd source jump_to_folder -n theappname -v2 cmd sourc...
47,299
<p>I am wondering if anyone can help me achieve a good 3d print using polypropylene. I am trying to print custom insoles for shoes and I'm getting some bad warping/lifting (see image).</p> <p><a href="https://i.stack.imgur.com/ZKi1R.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ZKi1R.jpg" alt="example of w...
<p>You should enable the "brim" functionality of your slicer. This adds additional perimeters to the first layer, expanding the base of the model. The larger surface area gives more adhesion.</p>
<p>One thing that seemed to help is making sure the heated bed was 100C. I was able to do this on my Prusa by turning off the front fan (for the whole print). If I have both the fan on and the heated bed at 100C I get the "Heatbed Thermal Runaway" error.</p> <p>This produced a print that was better but still a bit war...
670
<p>I have a list of articles, and each article belongs to a section.</p> <pre><code>class Section(models.Model): name = models.CharField(max_length=200) def __unicode__(self): return self.name class Article(models.Model): section = models.ForeignKey(Section) headline = models.CharField(max_length=200) ...
<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,015
<p>I get an error when I compile this code:</p> <pre><code>using System; public struct Vector2 { public event EventHandler trigger; public float X; public float Y; public Vector2 func() { Vector2 vector; vector.X = 1; vector.Y = 2; return vector; // error CS0165:...
<p>In C# you still need to 'new' a struct to call a constructor unless you are initializing <strong>all</strong> the fields. You left EventHandler member 'trigger' unassigned.</p> <p>Try either assigning to 'trigger' or using:</p> <pre><code>Vector2 vector = new Vector2() </code></pre> <p>The new object is <strong>...
<p>Rob Walker has a better response, since he started from the docs and then reasoned to the code (whereas I went the other way around).</p> <p>If you compile the sample code with the trigger field commented out, and then run IlAsm to get the resulting MSIL, you'll see that there is no <code>initobj</code> opcode for ...
38,066
<p>The IE Developer Toolbar is a plugin that can dock or separate from the browser. I understand its much more difficult to do this in IE than in Firefox.</p> <ul> <li>How does one create an IE plugin?</li> <li>What languages are available for this task?</li> <li>How can I make a Hello World plugin?</li> </ul>
<p>Here are a few resources that might help you in your quest to create browser helper objects (BHO).</p> <p><a href="http://wayback.archive.org/web/20110923191120/http://petesearch.com/wiki" rel="nofollow noreferrer">http://petesearch.com/wiki/ (archived)</a></p> <p><a href="http://www.hackszine.com/blog/archive/200...
<p>See <a href="http://www.enhanceie.com/ie/dev.asp" rel="noreferrer">http://www.enhanceie.com/ie/dev.asp</a> for my favorite resources on this topic.</p>
6,105
<p>Inspired by another question asking about the missing <code>Zip</code> function:</p> <p>Why is there no <code>ForEach</code> extension method on the <code>IEnumerable</code> interface? Or anywhere? The only class that gets a <code>ForEach</code> method is <code>List&lt;&gt;</code>. Is there a reason why it's missing...
<p>There is already a <code>foreach</code> statement included in the language that does the job most of the time.</p> <p>I'd hate to see the following:</p> <pre><code>list.ForEach( item =&gt; { item.DoSomething(); } ); </code></pre> <p>Instead of:</p> <pre><code>foreach(Item item in list) { item.DoSomething();...
<p>No one has yet pointed out that ForEach&lt;T&gt; results in compile time type checking where the foreach keyword is runtime checked.</p> <p>Having done some refactoring where both methods were used in the code, I favor .ForEach, as I had to hunt down test failures / runtime failures to find the foreach problems.</p...
12,668
<p>I'm reviewing some code for a friend and say that he was using a return statement inside of a try-finally block. Does the code in the Finally section still fire even though the rest of the try block doesn't?</p> <p>Example:</p> <pre><code>public bool someMethod() { try { return true; throw new Excepti...
<p>Simple answer: Yes.</p>
<p>99% of the scenarios it will be guaranteed that the code inside the <code>finally</code> block will run, however, think of this scenario: You have a thread that has a <code>try</code>-><code>finally</code> block (no <code>catch</code>) and you get an unhandled exception within that thread. In this case, the thread w...
44,899
<p>Using the .net framework you have the option to create temporary files with</p> <pre><code>Path.GetTempFileName(); </code></pre> <p>The MSDN doesn't tell us what happens to temporary files. I remember reading somewhere that they are deleted by the OS when it gets a restart. Is this true?</p> <p>If the files aren...
<p>The short answer: they don't get deleted.</p> <p>The long answer: The managed <a href="http://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename.aspx" rel="noreferrer"><code>Path.GetTempFileName()</code></a> method calls the native Win32API <a href="http://msdn.microsoft.com/en-us/library/aa364991.asp...
<p>I've read on the internet a lot of times that people don't want to use <code>Path.GetTempFileName</code> because they say it could return an already existing file, to solve the problem you can make a filename based on a GUID. </p> <p>This Function solves that Problem: Iterates until it finds a nonexistent file nam...
41,956
<p>How can I get MSBuild to evaluate and print in a <code>&lt;Message /&gt;</code> task an absolute path given a relative path?</p> <p><strong>Property Group</strong></p> <pre><code>&lt;Source_Dir&gt;..\..\..\Public\Server\&lt;/Source_Dir&gt; &lt;Program_Dir&gt;c:\Program Files (x86)\Program\&lt;/Program_Dir&gt; </co...
<p><strong>In MSBuild 4.0</strong>, the easiest way is the following:</p> <pre><code>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\your\path')) </code></pre> <p>This method works even if the script is <code>&lt;Import&gt;</code>ed into another script; the path is relative to the file containing the abo...
<p>If you need to convert Properties to Items you have two options. With msbuild 2, you can use the <strong>CreateItem</strong> task</p> <pre><code> &lt;Target Name='Build'&gt; &lt;CreateItem Include='$(Source_Dir)'&gt; &lt;Output ItemName='SRCDIR' TaskParameter='Include' /&gt; &lt;/CreateItem&gt; </cod...
21,312
<p>So I was listening to the latest Stackoverflow podcast (<a href="https://blog.stackoverflow.com/2008/08/podcast-19/">episode 19</a>), and Jeff and Joel talked a bit about scaling server hardware as a website grows. From what Joel was saying, the first few steps are pretty standard:</p> <ol> <li>One server running b...
<p>A reasonable setup supporting an "average" web application might evolve as follows:</p> <ol> <li>Single combined application/database server</li> <li>Separate database on a different machine</li> <li>Second application server with DNS round-robin (poor man's load balancing) or, e.g. <a href="http://www.danga.com/pe...
<p>If your interested in caching and using .Net, look into the <a href="http://msdn.microsoft.com/en-us/library/cc309103.aspx" rel="nofollow noreferrer">application caching block</a> in enterprise library (of course use this along with the other points above).</p>
5,714
<p>Is there a reasonable way to access FoxPro databases using LINQ?</p>
<p>One the blessing/curses of .NET is that the answer is rarely "no" to any .NET programming question.</p> <p>For example, this guy (thanks Sergey and Larry) shows a way to access FoxPro-type DBs with LINQ: <a href="http://blogs.msdn.com/calvin_hsia/archive/2007/11/30/6620133.aspx" rel="nofollow noreferrer">http://blo...
<p>I'm working in this general area at the moment - trying to connect Silverlight to legacy data in VFP9 tables and so on.</p> <p>You might find it easier to take a Web Services approach. This would involve creating a COM server DLL using Visual FoxPro that has methods to access the VFP data and return them using Curs...
43,438
<p>What kind of collection I should use to convert NameValue collection to be bindable to GridView? When doing directly it didn't work.</p> <p><strong>Code in aspx.cs</strong></p> <pre><code> private void BindList(NameValueCollection nvpList) { resultGV.DataSource = list; resultGV.DataBind(); } </code>...
<p>Can you use Dictionary&lt;string,string&gt; instead of NameValueCollection. Since Dictionary&lt;T,T&gt; implements IEnumerable you could use LINQ as so:</p> <pre><code>resultGV.DataSource = from item in nvpDictionary select new { Key = item.Key, Value = item.Value }; resultGV.DataBind(); </co...
<p>I had a similar problem involving binding a Dictionary (SortedDictionary really) to a GridView and wanting to rename the columns. What ended up working for me is some thing a little easier to read.</p> <pre><code>&lt;asp:GridView ID="gv" runat="server" AutoGenerateColumns="False"&gt; &lt;Columns&gt; &lt;asp:T...
26,712
<p>I am trying to create a service with C# that launches a process that can be displayed on the Windows XP Logon screen.</p> <p>I found some code that is doing this in C++. The C++ code is for a service that creates another process with STARTUPINFO.lpDesktop set to "WinSta0\WinLogon". The created process is then dis...
<p>The solution was to call the C++ Win32 API function CreateProcess from kernel32.dll from the C# code. This site was very helpful in getting the correct function signature for C#:</p> <p><a href="http://www.pinvoke.net/default.aspx/kernel32/CreateProcess.html" rel="nofollow noreferrer">http://www.pinvoke.net/defaul...
<p>I think you'll have to write it in C++, compile that to a DLL and then call the DLL from your managed code.</p>
12,900
<p>I expected the two <code>span</code> tags in the following sample to display next to each other, instead they display one below the other. If I set the <code>width</code> of the class <code>span</code>.right to 49% they display next to each other. I am not able to figure out why the right span is pushed down like th...
<pre><code>float: left; </code></pre> <p>Try adding that to span.left</p> <p>It will cause it to float to the left (as suggested by the syntax).</p> <hr> <p>I am not a CSS expert by any means so please don't take this as unarguable fact but I find that when something is floated, it makes no difference to the vertic...
<p>I don't like this hack but it seems to do the job both in Firefox and IE6:</p> <pre class="lang-css prettyprint-override"><code>span.right { vertical-align:top; display:inline-block; text-align:right; height:80px; width:50%; *width:100%; background-color:red; } </code></pre> <p>Note the <code>*width...
5,489
<p>I have a web form that has multiple ListBoxes, TextBoxes, DropDowns. If I put one UpdatePanel around the whole page, I noticed the page is slower. Is this because, every control is being updated? If I put different UpdatePanels around each control, I noticed the page has a better response. Is it right to assume ...
<p>each update panel generates a round-trip to the server (i assume you're using a timer or something to cause this)</p> <p>the general rule would be to group controls in an update panel that <em>must</em> change together, otherwise separate update panels makes more sense</p>
<p>I use update panels with a set of related functions in mind. I find that for my apps when there are related pieces of content on a page, such as a search tool, it is best to be placed in its own update panel. Be careful putting too many update panels however on your page as the client will have to download more co...
34,012
<p>I've been handed a table with about 18000 rows. Each record describes the location of one customer. The issue is, that when the person created the table, they did not add a field for "Company Name", only "Location Name," and one company can have many locations.</p> <p>For example, here are some records that describ...
<p>Please update the question, do you have a list of CompanyNames available to you? I ask because you maybe able to use Levenshtein algo to find a relationship between your list of CompanyNames and LocationNames.</p> <hr> <p><strong>Update</strong></p> <blockquote> <p>There is not a list of Company Names, I will h...
<p>I was going to recommend some complicated token matching algorithm but it's really tricky to get right and if you're data does not have a lot of correlation (typos, etc) then it's not going to give very good results.</p> <p>I would recommend you submit a job to the <a href="http://www.mturk.com/mturk/welcome" rel="...
2,791
<p>I use <code>x != null</code> to avoid <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/NullPointerException.html" rel="noreferrer"><code>NullPointerException</code></a>. Is there an alternative?</p> <pre class="lang-java prettyprint-override"><code>if (x != null) { // ... } </code></pre>
<p>This to me sounds like a reasonably common problem that junior to intermediate developers tend to face at some point: they either don't know or don't trust the contracts they are participating in and defensively overcheck for nulls. Additionally, when writing their own code, they tend to rely on returning nulls to ...
<p>Another suggestion is to program defensively - where your classes/functions provide default values that are known and safe, and where null is reserved for true errors/exceptions.</p> <p>For example, instead of functions that return Strings returning null when there is a problem (say converting a number to a string)...
34,149
<p>In Ruby you can easily set a default value for a variable </p> <pre><code>x ||= "default" </code></pre> <p>The above statement will set the value of x to "default" if x is nil or false</p> <p>Is there a similar shortcut in PHP or do I have to use the longer form:</p> <pre><code>$x = (isset($x))? $x : "default"; ...
<p>As of PHP 5.3 you can use the ternary operator while omitting the middle argument:</p> <pre><code>$x = $x ?: 'default'; </code></pre>
<p>I think your longer form is already the shortcut for php... and I wouldn't use it, because it is not good to read</p> <p>Some notice: In the symfony framework most of the "get"-Methods have a second parameter to define a default value...</p>
19,721
<p>It's really all in the title, but here's a breakdown for anyone who is interested in Evolutionary Algorithms:</p> <p>In an EA, the basic premise is that you randomly generate a certain number of organisms (which are really just sets of parameters), run them against a problem, and then let the top performers survive...
<p>I initially tried to model what I thought organic systems were like. Ultimately decided that was no good, and went more aggressive, with 10% kept, 20% mutated, 60% crossbred, and 10% random.</p> <p>Then I noticed my top 10% were all roughly identical. So I increased the random to 30%. That helped some, but not much...
<p>You know what you could do... You could write a genetic algorithm to determine that optimal distribution.</p> <p>But, usually I keep the top 12%, and 28% crossbreeds; with 30% each for the others.</p>
15,930
<p>Can you do ajax on ASP.net webform without using ajax toolkit? (Please post a example link)</p>
<p>yes... see my example in this post</p> <p><a href="https://stackoverflow.com/questions/85500/ajax-how-to-pass-value-back-to-server#86520">AJAX - How to Pass value back to server</a></p> <p>This can perform much better than ASP.NET ajax, but does take longer to code. </p>
<p>Certainly you can! What I did in .NET 1.1 (before ASP.Net Ajax was released) was to define an <code>HttpHandler</code> to listen on calls to <code>ajax.aspx</code>, run the appropriate methods, and spit back out the result. I used the <a href="http://prototypejs.org" rel="nofollow noreferrer">Prototype library</a> t...
29,099
<p>Studying emergence, it's quite useful to have a development framework to build upon to quickly test out new ideas. 3d with physics collision would be nice, and open-source would be a big plus. For this purpose 'breve' looks quite promising, but I was wondering if anyone had used it or knows of any other suitable eng...
<p>For quick development, breve does look appropriate. If you want to write something more from scratch, <a href="http://www.ode.org/" rel="nofollow noreferrer">ODE</a>, <a href="http://code.google.com/p/bullet/" rel="nofollow noreferrer">Bullet</a> and <a href="http://www.tokamakphysics.com/" rel="nofollow noreferrer"...
<p>I asked a <a href="https://stackoverflow.com/questions/3700567/open-source-pure-java-physics-dynamics-library">similar question</a> recently with respect to robotics simulation.</p> <p><a href="http://jbullet.advel.cz/" rel="nofollow noreferrer">JBullet</a> (a Java port of the Bullet Physics engine) came out as the...
12,487
<p>I have an error occuring frequently from our community server installation whenever the googlesitemap.ashx is traversed on a specific sectionID. I suspect that a username has been amended but the posts havn't recached to reflect this.</p> <p>Is there a way a can check the data integruity by performing a select stat...
<p><a href="http://en.wikipedia.org/wiki/SourceForge" rel="noreferrer">SourceForge</a> uses an <code>&lt;iframe&gt;</code> element with the <code>src=""</code> attribute pointing to the file to download.</p> <pre><code>&lt;iframe width="1" height="1" frameborder="0" src="[File location]"&gt;&lt;/iframe&gt; </code></pr...
<p>Nice jquery solution:</p> <pre><code>jQuery('a.auto-start').get(0).click(); </code></pre> <p>You can even set different file name for download inside <code>&lt;a&gt;</code> tag:</p> <pre><code>Your download should start shortly. If not - you can use &lt;a href="/attachments-31-3d4c8970.zip" download="attachments-...
18,955
<p>My goal is to make a Button that has two Content values. </p> <p>Imagine a Scrabble tile as a button: it has the large letter in the center and a small number in the lower right. This is the effect I am going for.</p> <p>I made a button that has two ContentPresenter objects in it, and I have given each of the Co...
<p>Bah... I think I know what to do now. I should be making my own control rather than modifying a Button. This would have been obvious to me had I been working in WinForms, but for some reason all this Xaml is making me stupid.</p>
<p>I delaled with creating UserControl with multiple 'content slots' <a href="https://stackoverflow.com/questions/1029955/wpf-template-or-usercontrol-with-2-or-more-contentpresenters-to-present-conte">here</a> - it's better than deriving from HeaderedControl as you aren't limited in the number of slots.</p> <p>Sample ...
47,514
<p>Does anyone know of any method in Rails by which an associated object may be frozen. The problem I am having is that I have an order model with many line items which in turn belong to a product or service. When the order is paid for, I need to freeze the details of the ordered items so that when the price is changed...
<p>I worked on an online purchase system before. What you want to do is have an Order class and a LineItem class. LineItems store product details like price, quantity, and maybe some other information you need to keep for records. It's more complicated but it's the only way I know to lock in the details. </p> <p>An Or...
<p>Shouldn't the prices already be frozen when the items are added to the order? Say I put a widget into my shopping basket thinking it costs $1 and by the time I'm at the register, it costs $5 because you changed the price. </p> <p>Back to your problem: I don't think it's a language issue, but a functional one. Inste...
36,472
<p>I'm trying to find SQL statements that timed out using the SQL 2005 profiler. Is there a way to set such a filter?</p>
<p>In Profiler, you can add the event "Attention" under "Errors and Warnings". It's definition is </p> <blockquote> <p>Collects all attention events, such as client interrupt request or when a client connection is broken.</p> </blockquote> <p>As far as other errors (deadlocks, contraints, etc), try "Execution ...
<p>One option, if you know what your client configured timeouts are set to (ie. 30 seconds by default), you can set a filter on your trace to only collect events with a duration greater than or equal to your timeout (minus a second or two). </p>
35,245
<p>Why is it that advertised disk space is almost always higher than the disk space reported by the UI? For example, I have an "80 gb" hard drive, but the iTunes UI indicates only 74. I usually see this as well with hard disks and the amount reported with the drive letter.</p>
<p>There are 3 reasons why the amount of space you can actually use is different from that listed for the drive, <em>all</em> of which work against you:</p> <ol> <li>Hard drive manufacturers treat 1GB as one billion bytes, while the operating system calls it 1,073,741,824 bytes (1000 * 1000 * 1000 vs 1024 * 1024 * 102...
<p>Usually due to some partitioned space that the OS or some software takes and hides for backup or system purposes.</p>
21,121
<ol> <li><strong>When an object is instantiated in Java, what is really going into memory?</strong></li> <li>Are copies of parent constructors included?</li> <li>Why do hidden data members behave differently than overridden methods when casting?</li> </ol> <p>I understand the abstract explanations that are typically g...
<p>When an object is instantiated, only the non-static data is actually "Created", along with a reference to the type of object that created it.</p> <p>None of the methods are ever copied.</p> <p>The "Reference" to the class that created it is actually a pointer dispatch table. One pointer exists for each method tha...
<ol> <li><p>Memory is allocated from heap to hold all instance variables and implementation-specific data of the object and itssuperclasses. Implementation-specific data includes pointers to class and method data. </p></li> <li><p>The instance variables of the objects are initialized to their default values. </p></li> ...
27,100
<p>I've got this ASP.NET drop down control that displays other textbox controls when the value is not UK (this is to help find UK addresses using postcodes). When UK is reselected I will like to hide the other controls. I've enabled view state and AutoPostBack to true. I have an <code>onSelectedIndexChanged</code> even...
<p>Every time I've ever had something like this happen it's been because of validation controls. Do those additional textboxes have validators attached to them that could be suppressing the postback? A quick way to tell would be to set CausesValidation="false" on the dropdownlist.</p>
<p>How are you attaching the event? Are you using doing it code behind like:</p> <pre><code>this.dropDownList.SelectedIndexChanged += new EventHandler(dropDownList_SelectedIndexChanged); </code></pre> <p>Or are you assigning it in the ASPX/ ASCX?</p> <p>If it's the former make sure that you are not assigning it with...
30,096
<p>I have a sproc that puts 750K records into a temp table through a query as one of its first actions. If I create indexes on the temp table before filling it, the item takes about twice as long to run compared to when I index after filling the table. (The index is an integer in a single column, the table being inde...
<p>If you create a clustered index, it affects the way the data is physically ordered on the disk. It's better to add the index after the fact and let the database engine reorder the rows when it knows how the data is distributed.</p> <p>For example, let's say you needed to build a brick wall with numbered bricks so t...
<p>this is because if the data you insert is not in the order of the index, SQL will have to split pages to make room for additional rows to keep them together logically</p>
4,851
<p>Either for comparisons or initialization of a new variable, does it make a difference which one of these you use?</p> <p>I know that BigDecimal.ZERO is a 1.5 feature, so that's a concern, but assuming I'm using 1.5 does it matter?</p> <p>Thanks.</p>
<p><code>BigDecimal.ZERO</code> is a predefined constant and therefore doesn't have to be evaluated from a string at runtime as <code>BigDecimal("0")</code> would be. It will be faster and won't require creation of a new object.</p> <p>If your code needs to run on pre-1.5, then you can use the (much maligned) Singleto...
<p>Out of curiosity I checked to constructor for BigDecimal and it doesn't have any optimizations for the "0" string. So definitely yes, there's a difference.</p>
33,881
<p>Sometimes, while I am debugging a c# application, I will hit a break point and when I try to continue, step or step into, it just does nothing. The yellow line highlighting the current line goes away, but it never reaches the next line. The app is still frozen like I am on a breakpoint and I can do nothing but hit...
<p>I've seen stalling problems where the debugger is trying to evaluate the variables shown in the Auto/Local windows. If the evaluation is complicated then it can cause significant stalls.</p> <p>You can turn the auto-evaluation off through Tools|Options and it does make a big difference.</p>
<p>My psychic debugger says that you're missing symbols for something and that VS is hitting the network trying to look them up. Try setting your symbol path to something weird like C:\foo.</p>
41,040
<p>We are currently looking to adopt some type of "standard" developer framework and have looked into using the Enterprise Library. Would you recommend using these blocks as the foundation for software development, or should we do something <em>home grown</em>?</p>
<p>Like all good answers to architecture and programming questions, the answer is "it depends".</p> <p>It depends on how unique your data access and object design needs are. It may also depend on how you plan on supporting your application in the long term. Finally, it greatly depends on the skill level of your deve...
<p>It really depends on what you need to do. Generally speaking, the bigger the niche is that your company is in, the better chance that you'll find a framework to properly support you. For smaller niches, you'll more than likely need to roll your own.</p> <p>The company I work for has several apps all geared twoard...
7,647
<p>I have a simple web app, with a few jsp pages, servlets and pojo's. I want to initialise the connection pool before any requests are made. What is the best way to do this? Can it be done when the app is first deployed or do you have to wait till the first request comes in?</p>
<p>Use a ServletContextListener and declare it properly in web.xml. This way is preferable to a startup servlet. It is more organized, and your intent is obvious. It is also guaranteed to run before any request. It also gives you a shutdown hook to clear the pool.</p> <p>Here is a snippet from my web.xml, for example:...
<p>What about a basic startup servlet to initialise the connection pool?</p>
40,134
<p>We maintain a RPM based software distribution at work so that we have a common set of software across all the platforms that we support. As a result we have to build a lot of third party software, and frequently find situations where we need to run autoconf/automake/libtoolize/etc to get it to build on Solaris or a...
<p>It is true that autotools can be brittle and version specific. But remember that you only need to use these tools on your development machines. Deploying the project to the <strong>target</strong> machine doesn't require that any of the tools are installed on the target. Even test machines don't need any of the t...
<p>Your experiences are not unusual. Autotools is brittle like that, specially for complex projects. There seems to be no alternative for having a lot of versions of it around, sadly.</p>
13,190
<p>Some websites have code to "break out" of <code>IFRAME</code> enclosures, meaning that if a page <code>A</code> is loaded as an <code>IFRAME</code> inside an parent page <code>P</code> some Javascript in <code>A</code> redirects the outer window to <code>A</code>.</p> <p>Typically this Javascript looks something li...
<p>With HTML5 the <a href="http://www.w3schools.com/tags/att_iframe_sandbox.asp" rel="noreferrer">iframe sandbox</a> attribute was added. At the time of writing this <a href="http://caniuse.com/iframe-sandbox" rel="noreferrer">works on Chrome, Safari, Firefox and recent versions of IE and Opera</a> but does pretty much...
<p>By doing so you'd be able to control any action of the framed page, which you cannot. <a href="http://en.wikipedia.org/wiki/Same_origin_policy" rel="nofollow noreferrer">Same-domain origin policy</a> applies.</p>
48,259
<p>I have an application where the contents of e-mails that get sent are stored in a .resx file.<br> This is an ASP.Net application, the .resx file lives in /App_GlobalResources </p> <p>When I need to send an e-mail, i'm reading this using: </p> <pre><code> HttpContext.GetGlobalResourceObject("MailContents", "EmailI...
<p>I think I answered my own question...<br> There's a ResXResourceReader class. I couldn't find it because it's in the Windows Forms namespace, which is not included in my current DLL references.</p> <p>Unfortunately, this will only let me iterate through results, so i'll implement some cute caching (read: memoizatio...
<p>Something is not right with your placement of resources.</p> <p>Either your resource belongs to the website and should be sent to the mailing method by parameter.</p> <p>Or, your resource belongs to the mailing API dll and should be kept there (.dll projects can have .resx files too). Then the mailing method shoul...
18,739
<p>I was reading about parsers and parser generators and found this statement in wikipedia's LR parsing -page:</p> <blockquote> <p>Many programming languages can be parsed using some variation of an LR parser. One notable exception is C++.</p> </blockquote> <p>Why is it so? What particular property of C++ causes it...
<p>There is an interesting thread on <a href="http://lambda-the-ultimate.org/" rel="noreferrer">Lambda the Ultimate</a> that discusses the <a href="http://lambda-the-ultimate.org/node/2158#comment-27800" rel="noreferrer">LALR grammar for C++</a>. </p> <p>It includes a link to a <a href="http://www.computing.surrey.ac....
<p>I think you are pretty close to the answer. </p> <p>LR(1) means that parsing from left to right needs only one token to look-ahead for the context, whereas LR(&infin;) means an infinite look-ahead. That is, the parser would have to know everything that was coming in order to figure out where it is now.</p>
30,154
<p>We all know (or should!) that the repeatability of common spring-arm limit switches is crappy at best. I'm looking to build &amp; install one of the precision height adjusters for the Z-axis limit switch, and noticed a post on some forum suggesting removing the arm and triggering the switch button directly (e.g. wi...
<p>While I haven't seen this on a Z axis for a printer personally, there is no reason it wouldn't work, and would improve your repeatability in theory. Removing the arm on the switch is taking away the lever. Going back to simple machine mechanics, the lever gives you a larger range of motion in which the button could ...
<p>No. Buy a better switch if it's an issue (see below).</p> <p>You would need to have some very tight tolerances to hit that micro button with whatever your arm is. If you had a machine with good tolerances you would not be considering this modification. That alone is why I would say this is not the greatest idea.</p...
422
<p>I have a user control that has several buttons.</p> <p>On <code>page_load</code>, I want to run a method unless a specific button was pressed.</p> <p>When I check the sender on <code>page_load</code> inside the user control, I just get the name of the user control and not the button itself.</p> <p>Is there a way ...
<p>I think you can check <code>Request.Form ("__EVENTTARGET")</code> - that should contain the <code>ClientID</code> of your control.</p> <p>This refers to the value of a hidden field the ASP.NET event handling framework uses to keep track of what the user clicked. When the user triggers a post-back, some JavaScript ...
<p>Can you create a property in your user control to return the clicked button (or set a flag or whatever), an set it in each button's click event inside the user control?</p>
38,074
<p>Is there a good external merge tool for tortoisesvn (I don't particularly like the built in Merge tool). I use WinMerge for diffs, but it doesn't work with the three way merge (maybe a better question would be is there a way to force tortoisesvn to merge like tortoisecvs?)</p> <p>[Edit]</p> <p>After trying all of...
<p><a href="https://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools" rel="noreferrer">Perforce Merge Tool</a> </p> <p>Even though Perforce is obviously not free the merge tool is. It's 100x better than the default TortoiseSvn one. To integrate with TortoiseSvn set the merge tool to:</p> <bloc...
<p>I like this one <a href="http://www.syntevo.com/smartsynchronize/index.html" rel="nofollow">SmartSynchronize</a> which is free for non-commercial use</p>
7,313
<p>I've been looking for a generic way to deal with bidirectional associations and a way to handle the inverse updates in manual written Java code.</p> <p>For those who don't know what I'm talking about, here is an example. Below it are my current results of (unsatisfying) solutions.</p> <pre><code>public class A { ...
<p>google collections (from google's internal code) -- <a href="http://code.google.com/p/google-collections/" rel="nofollow noreferrer">http://code.google.com/p/google-collections/</a> is Java Generics compatible(not only compatible, uses generics very well)</p> <p>Class BiMap -- <a href="http://google-collections.goo...
<p>Unless you abstract out the setters, you are going to have to provide some sort of event notification mechanism. If your objects are JavaBeans, then you are looking at using PropertyChangeSupport and firing property change events.</p> <p>If you do that (or have some other mechanism for detecting changes), then Gla...
20,452
<p>How do I Configuring DoxyGen to document ActionScript files?</p> <p>I've included the *.as and *.asi files in doxygen's search pattern, but the classes, functions and variables don't show there.</p>
<p>Instead of doxygen you should use a documentation generator that specifically supports the language. For ActionScript 2, you have a couple choices:</p> <ol> <li><a href="http://www.naturaldocs.org/" rel="noreferrer">NaturalDocs</a> (<a href="http://www.naturaldocs.org/example/showstyle.html?Default" rel="noreferrer...
<p>I've been able to produce SOME documentation with DoxyGen (What can I say - I like its features and capabilities) By doing the following:</p> <p>Add *.as and *.asi to the list of file types to input.</p> <p>Select:</p> <pre><code>OPTIMIZE_OUTPUT_JAVA = YES EXTRACT_ALL = YES HIDE_UNDOC_MEMBERS = N...
15,735
<p>I am having trouble setting the path to jquery in an mvc app. In my master page I have the script declared and jquery works at the root of my app. When I navigate to a content view page in my app jquery does not get loaded properly. Do I need to set the path in the content page as well or declare the path differentl...
<p>While using an absolute path will work for some installations, you'll have problems when installing in sub-directories. A safer solution is to use Url.Content which will always resolve the path correctly:</p> <pre><code>&lt;script src="&lt;%= Url.Content("~/Content/jquery-1.2.6.min.js") %&gt;" type="text/javascript...
<p>I would suggest using a helper method</p> <pre><code>public static class Helper { private static string ScriptsRoot = "~/views/scripts/"; public static string ScriptUrl (string scriptFile) { return VirtualPathUtility.ToAbsolute (ScriptsRoot + scriptFile); } } </code></pre> <p>And then refe...
40,409
<p>Lately I've be moving source files around in our source tree. For example placing a bunch of files into a common assembly. I've been doing this my deleting the file from CVS and then adding it again in the new spot. The problem is the revision number of the file resets back to 1.1. Is there some simple way to move ...
<p>The generally accepted way to achieve this effect is to perform the following steps. The technical term for this is a repocopy.</p> <ol> <li>Login on the server hosting the CVS repository and <strong>copy</strong> (don't move) the repository file from the location you want it to the new location.</li> <li>On the c...
<p>The <a href="http://www.cvsnt.org/manual/html/Moving-files.html" rel="nofollow noreferrer">online CVS manual</a> has some detail on how to do this:</p> <blockquote> <p>The normal way to move a file is to issue a cvs rename command.</p> <p>$ cvs rename old new<br> $ cvs commit -m "Renamed old to new"</p> ...
16,187
<p>I want to create a number of masked edit extenders from codebehind. Something like:</p> <pre><code>private MaskedEditExtender m_maskedEditExtender; protected override void OnLoad(EventArgs e) { base.OnLoad(e); m_maskedEditExtender = new MaskedEditExtender() { BehaviorID = "clientName" }; ...
<p>See <a href="http://msdn.microsoft.com/en-us/library/ms178472.aspx" rel="nofollow noreferrer">ASP.NET Page Life Cycle Overview</a> if this is in a Page subclass. If you scroll down to the event list, that page advises you to use the PreInit event to create any dynamic controls. It's necessary to do that early to ens...
<p>Provide the proper TargetControlID value to MaskedEditExtender</p>
10,851
<p>I have the vmware server with this error, anyone knows how to fix it?<a href="http://soporte.cardinalsystems.com.ar/errorvmwareserver.jpg" rel="nofollow noreferrer">VMware Server Error http://soporte.cardinalsystems.com.ar/errorvmwareserver.jpg</a></p>
<p>In the Network Connections on the host PC, you might try repairing the connections that are created by VMWare. Something like "VMWare Network Adapter VMnet1"</p> <p>I'm assuming that the network connections (to a LAN/Internet) are working on the host computer. If not, I'd start by fixing the host first.</p>
<p>There should be a vmware.log file or something similar in the directory that contains your vm. After you start the vm, are there any new errors in it? </p> <p>Also, is the network adapter enabled?</p>
6,604
<p>I apologize if this is in the wrong section, but it seems relevant.</p> <p>I am an absolute noob at 3D printing, but recently my need for a specific, small part intersected with access to a 3D printer at work (Zortrax M200), so I figured now was a good opportunity to get into printing.</p> <p>I am designing a clam...
<p>Many printers have a problem with inserting filament into the extruder. Cutting it at an angle is a huge help. It is also very possible that you have a cog or a bad extruder nozzle. </p> <p>This link could be of some help: <a href="https://www.thingiverse.com/groups/prusa-i3/topic:7469" rel="nofollow noreferrer">Ex...
<p>My first step would be to cut the filament at a bit of an angle. This will help the filament enter the extruder correctly. </p> <p>If you're still having trouble, you may have a clogged nozzle. This article by Lifewire -<a href="https://www.lifewire.com/3d-printer-extruder-nozzle-clogged-2289" rel="nofollow nore...
571
<p>If you read other people's source code, how do you approach the code? What patterns are you looking for (datatypes, loops, use of control flow, ... )? How long can you read other people's code without getting bored? What is the most exciting patterns that you have discovered so far?</p>
<p>At first, I ignore the urge to change the code. Which is sometimes hard to do. But understanding first and change later saves yourself a lot of nasty "learning experiences."</p> <p>Next if the format is bad, reformat. Use a code formatter if you have one. This is because you tend to look at the indentation and if t...
<p>It all depends on what type of code you are reading. Is it a web app, a service, a desktop app? When I do start reading other's code I usually start looking for design patterns used. Or for the framework-specific things. But again this is if you are doing a review. If you are reading for your own interest and to lea...
39,235
<p>Is there a way to alter the precision of an existing decimal column in Microsoft SQL Server?</p>
<pre><code>ALTER TABLE Testing ALTER COLUMN TestDec decimal(16,1) </code></pre> <p>Just put <code>decimal(precision, scale)</code>, replacing the precision and scale with your desired values.</p> <p>I haven't done any testing with this with data in the table, but if you alter the precision, you would be subject to lo...
<p>In Oracle 10G and later following statement will work.</p> <p><code>ALTER TABLE &lt;TABLE_NAME&gt; MODIFY &lt;COLUMN_NAME&gt; &lt;DATA_TYPE&gt;</code></p> <p>If the current data type is NUMBER(5,2) and you want to change it to NUMBER(10,2), following is the statement</p> <p><code>ALTER TABLE &lt;TABLE_NAME&gt; MODIF...
14,607
<p>I wanted to set a CSS class in my master page, which depends on the current controller and action. I can get to the current controller via <code>ViewContext.Controller.GetType().Name</code>, but how do I get the current action (e.g. <code>Index</code>, <code>Show</code> etc.)?</p>
<p>In the RC you can also extract route data like the action method name like this</p> <pre><code>ViewContext.Controller.ValueProvider["action"].RawValue ViewContext.Controller.ValueProvider["controller"].RawValue ViewContext.Controller.ValueProvider["id"].RawValue </code></pre> <hr> <h3>Update for MVC 3</h3> <pre>...
<p>Extending <a href="https://stackoverflow.com/questions/362514/asp-net-mvc-current-action/1408919#1408919">Dale Ragan's answer</a>, his example for reuse, create an ApplicationController class which derives from Controller, and in turn have all your other controllers derive from that ApplicationController class rathe...
47,316
<p>I need to do some quick-and-dirty Perl GUI building. I can't afford a Komodo License. What would people recommend as a free (as in beer) alternative. I don't care if it is UNIX or Windows or both. I would be using either Win32 Perl or Perl/Tk depending on what has the best solution. I would also look at any PM's tha...
<p>For Perl/Tk, there is <a href="http://www.perltk.org/index.php?option=content&amp;task=view&amp;id=28&amp;Itemid=29" rel="nofollow noreferrer">ZooZ</a>. </p> <p>Personally, I prefer to use <a href="http://glade.gnome.org/" rel="nofollow noreferrer">Glade</a> for the GUI design and <a href="http://search.cpan.org/d...
<p>The Perlmonks post <a href="http://www.perlmonks.org/?node_id=627282" rel="nofollow noreferrer">http://www.perlmonks.org/?node_id=627282</a> might help, as well as the google search for <a href="http://www.google.com/search?client=safari&amp;rls=en-us&amp;q=perl+gui+builder&amp;ie=UTF-8&amp;oe=UTF-8" rel="nofollow n...
37,404
<p>Do you know an easy and straight-forward method/sub/module which allows me to convert a number (say 1234567.89) to an easily readable form - something like 1.23M?</p> <p>Right now I can do this by making several comparisons, but I'm not happy with my method:</p> <pre><code>if($bytes &gt; 1000000000){ $bytes = ...
<p>The <a href="http://search.cpan.org/dist/Number-Bytes-Human" rel="noreferrer">Number::Bytes::Human</a> module should be able to help you out.</p> <p>An example of how to use it can be found in its synopsis:</p> <pre><code> use Number::Bytes::Human qw(format_bytes); $size = format_bytes(0); # '0' $size = form...
<p>This snippet is in PHP, and it's loosely based on some example someone else had on their website somewhere (sorry buddy, I can't remember).</p> <p>The basic concept is instead of using if, use a loop.</p> <pre><code>function formatNumberThousands($a,$dig) { $unim = array("","k","m","g"); $c = 0; while ...
18,455
<p>I have one text input and one button (see below). How can I use JavaScript to <strong>trigger the button's click event</strong> when the <kbd>Enter</kbd> key is pressed inside the text box?</p> <p>There is already a different submit button on my current page, so I can't simply make the button a submit button. And, ...
<p>In jQuery, the following would work:</p> <pre><code>$("#id_of_textbox").keyup(function(event) { if (event.keyCode === 13) { $("#id_of_button").click(); } }); </code></pre> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <...
<p>This also might help, a small JavaScript function, which works fine:</p> <pre><code>&lt;script type="text/javascript"&gt; function blank(a) { if(a.value == a.defaultValue) a.value = ""; } function unblank(a) { if(a.value == "") a.value = a.defaultValue; } &lt;/script&gt; &lt;input type="text" value="email goes he...
18,764
<p>Is there a way to hide radio buttons inside a RadioButtonList control programmatically?</p>
<p>Under the hood, you can access the attributes of the item and assign it a CSS style.</p> <p>So you should be able to then programmatically assign it by specifying:</p> <pre><code>RadioButtonList.Items(1).CssClass.Add("visibility", "hidden") </code></pre> <p>and get the job done.</p>
<p>If you mean with JavaScript, and if I remember correctly, you've got to dig out the ClientID properties of each &lt;input type="radio" ...&gt; tag.</p>
5,338
<p>I want to open a TCP client socket in Python. Do I have to go through all the low-level BSD create-socket-handle / connect-socket stuff or is there a simpler one-line way?</p>
<p>Opening sockets in python is pretty simple. You really just need something like this:</p> <pre><code>import socket sock = socket.socket() sock.connect((address, port)) </code></pre> <p>and then you can <code>send()</code> and <code>recv()</code> like any other socket</p>
<p>For developing portable network programs of any sort in Python, <a href="http://twistedmatrix.com" rel="noreferrer">Twisted</a> is quite useful. One of its benefits is providing a convenient layer above low-level socket APIs.</p>
9,432
<p>Over the last two days I have tried everything I could come up with to fix the following issues.</p> <p>It all started with bad bed adhesion.(pic.1) Solutions for these problems are readily available, so I calibrated my Z-axis (did the whole wizard from start to finish again) and started a calibration print over th...
<p>If you repeat a test and the problem occurs in the same location, then you probably have a problem with your bed or build plate. However, picture 3 suggests to me that you may have a partially clogged nozzle. Manually extrude some filament. It should fall straight down. If it curls as it comes out of the nozzle, the...
<p>The Prusa i3 is coated with a PEI sheet. PEI and other build plates stick to the build but don't like to be dirty. Fingerprints can build up and create an interference layer of fats that lessen the adhesion to a point the pieces spontaneously pop off.</p> <p>A good cleaning is often needed. For PEI Isopropylic Alco...
1,244
<p>I have several files that are in several different languages. I thought they were all encoded UTF-8, but now I'm not so sure. Some characters look fine, some do not. Is there a way that I can break out the strings and try to identify the character sets? Perhaps split on white space then identify each word? Fina...
<p>If you don't know the character set for sure You can only guess, basically. <a href="http://search.cpan.org/~rgarcia/perl-5.10.0/lib/utf8.pm" rel="noreferrer">utf8::valid</a> might help you with that, but you can't really know for sure. If you know that if it isn't unicode it must be a specific character set (Like L...
<p>Take a look at iconv</p> <p><a href="http://www.gnu.org/software/libiconv/" rel="nofollow noreferrer">http://www.gnu.org/software/libiconv/</a></p> <p><a href="http://metacpan.org/pod/Text::Iconv" rel="nofollow noreferrer">Text::Iconv</a></p>
41,251
<p>Suddenly my prints start having small strings and I'm not sure what to do to eliminate them.</p> <p>I have already tried to clean the filament tube, cleaned up the nozzle, and played with various retraction settings. Nothing seems to work and I still see these small strings.</p> <p><a href="https://i.stack.imgur.com...
<p>These artifacts can be either moisture, as explored by <a href="https://3dprinting.stackexchange.com/a/16007/8884">this answer</a> or problems with temperature/speed control or the Z-Axis:</p> <p>If the temperature is not hot enough, the filament might not get melted enough to squish down to the next layer nicely at...
<p>What you're seeing does not look like <em>stringing</em>, which I would characterize as material that exited the nozzle after extrusion was supposed to have stopped, usually due to missing or insufficient retraction, but like the extrusions along the concave contours <em>failed to bond</em> to the previous layer and...
1,909
<p>How is a breakpoint implemented on PPC (On OS X, to be specific)?</p> <p>For example, on x86 it's typically done with the INT 3 instruction (0xCC) -- is there an instruction comparable to this for ppc? Or is there some other way they're set/implemented?</p>
<p>With gdb and a function that hexdumps itself, I get 0x7fe00008. This appears to be the <a href="http://pic.dhe.ibm.com/infocenter/aix/v6r1/topic/com.ibm.aix.aixassem/doc/alangref/tw.htm#mj2a0ken" rel="noreferrer">tw instruction</a>:</p> <pre><code>0b01111111111000000000000000001000 011111 ...
<p>I'm told by a reliable (but currently inebriated, so take it with a grain of salt) source that it's a zero instruction which is illegal and causes some sort of system trap.</p> <p>EDIT: Made into community wiki in case my friend is so drunk that he's talking absolute rubbish :-)</p>
42,420
<p>For the past 10 years or so there have been a smattering of articles and papers referencing Christopher Alexander's newer work "The Nature of Order" and how it can be applied to software.</p> <p>Unfortunately, the only works I can find are from James Coplien and Richard Gabriel; there is nothing beyond that, at lea...
<p>For the sake of completeness I'll repeat the discussion on Reto's post over at the <a href="http://groups.google.com/group/android-developers/browse_thread/thread/36fe0648dabfe745#" rel="noreferrer">Android Groups here</a>.</p> <p>It seems that if you set the bounds on your drawable it does the trick:</p> <pre><co...
<p>try :</p> <pre><code>Drawable defaultMarker = r.getDrawable(R.drawable.icon); defaultMarker.setBounds(0, 0, defaultMarker.getIntrinsicWidth(), defaultMarker.getIntrinsicHeight()); MyItemizedOverlay markers = new MyItemizedOverlay(defaultMarker); overlays.add(markers); </code></pre>
4,593
<p>I have a div with <code>id="a"</code> that may have any number of classes attached to it, from several groups. Each group has a specific prefix. In the javascript, I don't know which class from the group is on the div. I want to be able to clear all classes with a given prefix and then add a new one. If I want to re...
<p>With jQuery, the actual DOM element is at index zero, this should work</p> <pre><code>$('#a')[0].className = $('#a')[0].className.replace(/\bbg.*?\b/g, ''); </code></pre>
<pre><code>$("#element").removeAttr("class").addClass("yourClass"); </code></pre>
8,223
<p>Given a file tree - a directory with directories in it etc, how would you write a script to create a diagram of the file-tree as a graphic file that I can embed in a word processor document. I prefer vector (SVG, EPS, EMF...) files. The tool must run on Windows, but preferably cross-platform. The tool may be commer...
<p>Copying and pasting from the MS-DOS <code>tree</code> command might also work for you. Examples: </p> <p><strong>tree</strong></p> <pre><code>C:\Foobar&gt;tree C:. ├───FooScripts ├───barconfig ├───Baz │ ├───BadBaz │ └───Drop ... </code></pre> <p><strong>tree /F</strong></p> <pre><code>C:\Foobar&gt;tree C:. ├...
<p>The advice to use Graphviz is good: you can generate the dot file and it will do the hard work of measuring strings, doing the layout, etc. Plus it can output the graphs in lot of formats, including vector ones.</p> <p>I found a Perl program doing precisely that, in a mailing list, but I just can't find it back! I ...
45,226
<p>I have been looking at various dependency injection frameworks for .NET as I feel the project I am working on would greatly benefit from it. While I think I have a good grasp of the <em>capabilities</em> of these frameworks, I am still a little unclear on how best to introduce them into a large system. Most demos (u...
<p>Well, while you can do this as described in other answers I believe there is more important thing to be answered regarding your example and that is that you are probably violating SRP principle with class having many dependencies.</p> <p>What I would consider in your example is breaking up the class in couple of mo...
<p>To partially answer my <strong>first</strong> question, I've just found a <a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/10/08/setter-injection-in-structuremap-2-5.aspx" rel="nofollow noreferrer">blog post</a> by Jeremy Miller, showing how Structure Map and setter injection can be used to auto-popul...
23,641