instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Do they set <code>display: none</code> or <code>visibility: hidden</code>?</p> <p>I'm pretty sure <code>display: none</code> takes the element out of the normal flow, whilst <code>visibility: hidden</code> just hides the element but still has a reserved space for it.</p> <p>Should I just go download the unpacked v...
<p>It uses <code>display</code>.</p> <p>Edit: And from John Sheehan's comment on this answer, which I agree with:</p> <blockquote> <p>You should go view the unpacked source anyway just to familiarize yourself with it</p> </blockquote> <p>Edit 2: Comments have mentioned using Firebug to discover what is happening. ...
<p>It uses display, and for this type of thing you can use Firebug to actually examine what happens to the DOM. </p>
29,594
<p>I have the following HTML</p> <pre><code>&lt;div&gt; &lt;img id="image1" src="http://valleywag.com/assets/resources/2008/03/BlackGoogleLogo.jpg" alt="Why doesn't this float correcly?" style="border-width: 0px; float: left;" /&gt; &lt;div id="divText" style="font-family: Arial, He...
<p>The text does float around the image for me in IE6 and FireFox2. Is there any CSS that you're leaving out for us to test?</p> <p>Here is what I see: </p> <p><a href="http://img214.imageshack.us/img214/6906/ff2topie6bottomhz5.gif" rel="nofollow noreferrer">Example 1 http://img214.imageshack.us/img214/6906/ff2topie6...
<p>The text is wrapping around the image for me in Firefox2. Can you maybe post a screenshot so I understand the problem better?</p> <p>If you mean the bullets overlap the image (which I do notice) then the best I can suggest is margin-right on the image or disable the bullet-style:</p>
46,722
<p>I have an input which at some points happens to have the focus. If the user click in the "background" of the page, the input loses its focus. I was trying to simulate the click on the background with the following code, but this doesn't work (you will notice that the input still has the focus). Any suggestion on how...
<p>I would imagine using <code>blur()</code> would do the trick:</p> <pre><code>&lt;script type="text/javascript"&gt; YAHOO.util.Event.onDOMReady(function() { document.getElementById("input").focus(); document.getElementById("input").blur(); }); &lt;/script&gt; </code></pre>
<p>Your idea is right, but there is a little problem.</p> <pre><code>document.getElementById(&quot;main&quot;).focus(); &lt;div id=&quot;main&quot;&gt; </code></pre> <p>as shown in your code, actually the div HTMLElement doesn't have a focus method.</p> <p>so you can call other elements that have a focus method or cal...
27,154
<p>By default, I think my vimrc setttings enable the auto-wrapping. However, sometimes, I would like to see text lines are not wrapped. Is there any command I toggle the text line wrapping enabled and disabled? This would avoid me to exit and to change settings.</p>
<p>I think what you want is:</p> <pre><code>:set wrap! </code></pre> <p>This will toggle line wrapping.</p> <p>More about using ! (bang) to alter commands can be found at:</p> <pre><code>:help :_! </code></pre>
<p>I happen to like tpope’s unimpaired plugin, where <code>yow</code> will toggle wrap settings. </p>
30,824
<p>I've used HttpWebRequests to post data to HTTPS websites before, and I've never had todo anything different than a regular HTTP Post.</p> <p>Does anyone know if there are any tricks involved that I missed to ensure that this is done properly?</p>
<p>Check for certification errors, this i a common issue <a href="http://www.west-wind.com/weblog/posts/48909.aspx" rel="nofollow noreferrer">http://www.west-wind.com/weblog/posts/48909.aspx</a></p>
<p>HTTPS requests are the same as HTTP (only using SSL certificates).</p> <p>However you should manually ensure that the certificates do not have errors (even warnings), or the request will probably fail.</p>
30,248
<p>How can UTF-8 strings (i.e. 8-bit string) be converted to/from XML-compatible 7-bit strings (i.e. printable ASCII with numeric entities)?</p> <p>i.e. an <code>encode()</code> function such that:</p> <pre><code>encode("“£”") -&gt; "&amp;#8220;&amp;#163;&amp;#8221;" </code></pre> <p><code>decode()</code> would also...
<p><a href="http://php.net/manual/en/function.mb-encode-numericentity.php" rel="noreferrer"><code>mb_encode_numericentity</code></a> does that exactly.</p>
<p>It's a bit of a workaround, but I read a bit about <code>iconv()</code> and i don't think it'll give you numeric entities (not put to the test)</p> <pre><code>function decode( $string ) { $doc = new DOMDocument( "1.0", "UTF-8" ); $doc-&gt;LoadXML( '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'."\n".'&lt;x /&gt...
14,401
<p>I've read the Wikipedia articles for both <a href="http://en.wikipedia.org/wiki/Procedural_programming" rel="noreferrer">procedural programming</a> and <a href="http://en.wikipedia.org/wiki/Functional_programming" rel="noreferrer">functional programming</a>, but I'm still slightly confused. Could someone boil it dow...
<p>A functional language (ideally) allows you to write a mathematical function, i.e. a function that takes <em>n</em> arguments and returns a value. If the program is executed, this function is logically evaluated as needed.<sup>1</sup></p> <p>A procedural language, on the other hand, performs a series of <em>sequenti...
<p>To Understand the difference, one needs to to understand that "the godfather" paradigm of both procedural and functional programming is the <strong>imperative programming</strong>.</p> <p>Basically procedural programming is merely a way of structuring imperative programs in which the primary method of abstraction i...
4,327
<p>I have a table with say 3 columns. There's no primary key so there can be duplicate rows. I need to just keep one and delete the others. Any idea how to do this is Sql Server?</p>
<p>I'd SELECT DISTINCT the rows and throw them into a temporary table, then drop the source table and copy back the data from the temp. <strong>EDIT:</strong> now with code snippet!</p> <pre><code>INSERT INTO TABLE_2 SELECT DISTINCT * FROM TABLE_1 GO DELETE FROM TABLE_1 GO INSERT INTO TABLE_1 SELECT * FROM TABLE_2 GO...
<p>I'm not sure if this works with DELETE statements, but this is a way to find duplicate rows:</p> <pre><code> SELECT * FROM myTable t1, myTable t2 WHERE t1.field = t2.field AND t1.id &gt; t2.id </code></pre> <p>I'm not sure if you can just change the "SELECT" to a "DELETE" <em>(someone wanna let me know?)</em>, b...
11,721
<p>I've got C# code that accesses MySQL through ODBC.</p> <p>It creates a transaction, does a few thousand insert commands, and then commits. Now my question is how many "round trips", so to speak, happen against the DB server? I mean, does it simply transmit every insert command to the DB server, or does it cache/buf...
<p>MySQL has an extended SQL style that can be used, where mass inserts are put in several at a time:</p> <pre><code>INSERT INTO `table` (`id`, `event`) VALUES (1, 94263), (2, 75015), (3, 75015); </code></pre> <p>I will usually collect a few hundred insert-parts into a string before running the SQL query itself. Th...
<p>When using MySQL 4.x a few years ago, we ran into a hard limit on query size that was not configurable. </p> <p>This probably won't help you much as:</p> <ol> <li>I don't remember what the hard limit was.</li> <li>You're probably not using MySQL 4.x. </li> <li>We weren't using transactions.</li> </ol> <p>Good luc...
13,608
<p>What characters are valid in a Java class name? What other rules govern Java class names (for instance, Java class names cannot begin with a number)?</p>
<p>You can have almost any character, including most Unicode characters! The exact definition is in <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8" rel="noreferrer">the Java Language Specification under section 3.8: Identifiers</a>.</p> <blockquote> <p>An <em>identifier</em> is an unlimit...
<p>Class names should be nouns in UpperCamelCase, with the first letter of every word capitalised. Use whole words — avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML). The naming conventions can be read over here:</p> <p><a href="http://www.orac...
9,121
<p>I have a need to close a parent form from within child form from a Windows application. What would be the best way to do this?</p>
<p>When you close form in WinForms it disposes all of it's children. So it's not a good idea. You need to do it asynchronously, for example you can send a message to parent form.</p>
<p>The Form class doesn't provide any kind of reference to the 'parent' Form, so there's no direct way to access the parent (unless it happens to be the MDI parent as well, in which case you could access it through the MDIParent property). You'd have to pass a reference to the parent in the constructor of the child, or...
6,223
<p>I upgraded to an Mk9 dual extruder, and it came with thermocouples installed instead of the thermistors I had before. </p> <p>No matter what I did with the thermocouples, the indicated temperature jumped around by as much as 30C or more. In short, after several weeks of fiddling I never got the thermocouples to wor...
<p>Thermocouples work by passively generating VERY small voltages via the Seebeck effect -- usually a few tens of millivolts. They're literally just a pair of wires made from two different special alloys, electrically connected together at the "hot" end. That wire junction can be mounted inside whatever kind of attachm...
<p>It sound like you just have a defective thermocouple. But, I just did a google search for "Why are thermocouples inaccurate" and found <a href="http://www.temprel.com/support/troubleshoot-thermocouple.aspx" rel="nofollow">this article</a> on identifying bad thermocouples and preventative maintenance. I never thought...
126
<p>What, if any, considerations (HTML, CSS, JavaScript) should you take when designing for Google Chrome? </p>
<p>Chrome uses Webkit, the same engine as is used by Safari, OmniWeb, iCab and more. Just code everything based on the standards and verify in each browser.</p>
<p>Are you designing specifically <em>for</em> Chrome, or do you want to make sure your pages work well with Chrome?</p> <p>Assuming it's the latter, then just use the same design considerations you'd do for any browser. If applicable, keep in mind that many phones and video game consoles have web browsers now.</p> <...
6,785
<p>I'm writing a number of articles meant to teach beginning programming concepts through the use of poker-related topics. Currently, I'm working on the subject of shuffling.</p> <p>As <a href="http://www.codinghorror.com/blog/archives/001015.html" rel="nofollow noreferrer" title="The Danger of Naivete">Jeff Atwood po...
<p>The knuth shuffle is an insignificant change compared to the naive shuffle: Just swap with any card in the remaining (unshuffled) section of the deck instead of anywhere in the entire deck. If you think of it as repeatedly choosing the next card in order from the remaining unchosen cards, it's pretty intuitive, too....
<p>Subjective.</p> <blockquote> <p>It seems like it would be infinitesimally small.</p> </blockquote> <p>Agree.</p>
12,234
<p>What is the best way to handle large numeric inputs in C++ (for example <code>10^100</code>)? </p> <p>For algorithms I usually switch over to ruby and I sometimes use strings.</p> <p>Any other good methods?</p>
<p>It sounds like you're looking for a way to enter Arbitrary Precision numbers. here are two libraries you could use: <a href="http://gmplib.org/" rel="nofollow noreferrer">GMP</a> and <a href="https://github.com/LuaDist/mapm" rel="nofollow noreferrer">MAPM</a></p>
<p>Well I think the best way to do such arithmetic calculation is by using strings. Give input as command line arguments and then manipulate the whole logic using string functions like <code>atoi()</code> and <code>itoa()</code>! But, hey can this be done for multiplication and Division? I think in this way <code>strle...
14,303
<p>Suppose the following:</p> <pre><code>&gt;&gt;&gt; s = set([1, 2, 3]) </code></pre> <p>How do I get a value (any value) out of <code>s</code> without doing <code>s.pop()</code>? I want to leave the item in the set until I am sure I can remove it - something I can only be sure of after an asynchronous call to anoth...
<p>Two options that don't require copying the whole set:</p> <pre><code>for e in s: break # e is now an element from s </code></pre> <p>Or...</p> <pre><code>e = next(iter(s)) </code></pre> <p>But in general, sets don't support indexing or slicing.</p>
<p>Another option is to use a dictionary with values you don't care about. E.g.,</p> <pre><code> poor_man_set = {} poor_man_set[1] = None poor_man_set[2] = None poor_man_set[3] = None ... </code></pre> <p>You can treat the keys as a set except that they're just an array:</p> <pre><code> keys = poor_man_set.keys() p...
8,455
<p>I have a composite control that adds a TextBox and a Label control to its Controls collection. When i try to set the Label's AssociatedControlID to the ClientID of the Textbox i get this error</p> <pre><code>Unable to find control with id 'ctl00_MainContentPlaceholder_MatrixSetControl_mec50_tb' that is associated ...
<p>I think you <strong>mustn't use the ClientID</strong> property of the ElementTextBox, but the <strong>ID</strong>. ClientID is the page-unique ID you'd have to use in Javascript, e.g. in the document.getElementyById and is not the same as the server-side ID - especially if you have a masterpage and/or controls in co...
<p>Possibly helpful to other readers that encounter the error:</p> <p>Note that setting AssociatedControlID fails too if you're associating the label with an input control at runtime without explicitly setting the ID of the input control first. This is an issue that requires attention if you are creating multiple text...
27,765
<p>I'm trying to disable a bunch of controls with JavaScript (so that they post back values). All the controls work fine except for my radio buttons as they lose their value. In the below code which is called via a recursive function to disable all child controls the Second else (else if (control is <code>RadioButton</...
<p>I found 2 ways to get this to work, the below code correctly distinguishes between the RadioButton and Checkbox controls.</p> <pre><code> private static void DisableControl(WebControl control) { Type controlType = control.GetType(); if (controlType == typeof(CheckBox)) { ...
<p>Off the top of my head, I think you have to check the "type" attribute of the checkbox to determine if it's a radio button.</p>
5,211
<p>I am preparing to use continuous integration for the first time. I will be using Nant for the automated build and testing tasks, and am trying to find the appropriate CI tool to poll the repository and execute the Nant script.</p> <p>I have so far loosely researched the following:</p> <ul> <li>Hudson</li> <li>Cru...
<p>We use <a href="http://confluence.public.thoughtworks.org/display/CCNET" rel="nofollow noreferrer">CruiseControl.NET</a> as our CI server along with our full build system being in NAnt. It has worked exceptionally well over the past 5 years. I've since looked into other alternatives and have not been able to find an...
<p>I can't speak for the applications listed, but I'm a huge fan of buildbot: <br><a href="http://buildbot.net/trac" rel="nofollow noreferrer">http://buildbot.net/trac</a></p> <p>It will build/test on any platform that runs Python (so if your software is supposed to work on multiple OS's each can be covered), it is ve...
22,746
<p>I'm just learning how to use a 3D printer, I have an Anycubic Mega Zero 2.0.</p> <p>When I start printing the PLA filament doesn't want to adhere very well. I have leveled it out and all of my corners on my test print adhere well. However, when I go to print anything besides the test print I get basically a small be...
<p>If you look at the multiple lines of the skirt, you see that none of the printed lines are touching the other laid down lines. This is an indication for under extrusion or a too large of a gap between the nozzle and the bed (or both). Considering you are talking about a bead/drop/blob of hot filament not adhering to...
<p>If the print bed is contaminated with oil or fat, print bed adhesion may be too low. Cleaning with alcohol might help.</p>
2,001
<p>If I have the LINQ objects:</p> <pre><code>public class SampleDataContext : DataContext { public Table&lt;Customer&gt; Customers { get { return this.GetTable&lt;Customer&gt;(); } } public SampleDataContext( string connectionString ) : base( connectionString ) { } } [Table( Name="dbo.tblCustomers" )] public...
<p>Kevin - I feel your pain... when you are building business logic around your business objects, there are times when you simply <em>have</em> to have access to the DataContext to which an object belongs, since not knowing the DataContext menas having to put your code in places that reduce the maintainability of your ...
<p>The simplest thing to do is to pass the DataContext into your method.</p> <p>However, you may also consider changing your design so that you follow the rule that "a single method should have only one purpose", in which case you wouldn't want to "Save" in the same method that you "Modify".</p>
34,871
<p>Does anyone know if there is an implementation of <code>javax.jms.QueueConnectionFactory</code> for WebSphere MQ and where to get it? I Googled it and searched IBM website but couldn't find anything. I don't want to retrieve the connection or factory from Websphere MQ via JNDI, I need my own connection factory.</p>
<p>I think you need three jars</p> <pre><code>com.ibm.mq.jar com.ibm.mqbind.jar com.ibm.mqjms.jar </code></pre> <p>You instantiate a <em>MQQueueConnectionFactory</em> and i hope you can take it from there.</p> <p>And here's more info: <a href="http://www.ibm.com/developerworks/websphere/techjournal/0502_woolf/0502_w...
<p>Although Bobby's article referenced in the other response is good, I would want to use a more current version of the JMS classes than from 2005! Most of the development has been in enhancing JMS function and performance. The classes have been simplified and repackaged into fewer jars as well so it's easier to depl...
35,996
<p>on KDE, there's a possibility to execute a command when some event happen. for example one can execute a script when kmail receives a mail or when a akregator fetches a new feed.</p> <p>I want to execute the script on a way I can retrieve the mail/feed subject in my script. is there a possibility to specify the pro...
<p>With my <a href="http://pd.acm.org/" rel="noreferrer">ACM membership</a>, I get access to both Safari and Books24x7 (this includes Apress).</p> <p>The selection is reduced from the total offering of those sites (600 in Safari only available to professional members and 500 in Books24x7 available to both student and ...
<p>Here in Santa Clara county, California, we can access the library e-resources, including Safari, from the library's website.</p>
21,639
<p>I have a const char arr[] parameter that I am trying to iterate over,</p> <pre><code>char *ptr; for (ptr= arr; *ptr!= '\0'; ptr++) /* some code*/ </code></pre> <p>I get an error: assignment discards qualifiers from pointer target type</p> <p>Are const char [] handled differently than non-const?</p>
<p>Switch the declaration of *ptr to be.</p> <pre><code>const char* ptr; </code></pre> <p>The problem is you are essentially assigning a const char* to a char*. This is a violation of const since you're going from a const to a non-const. </p>
<p>The const declaration grabs whatever is to the left. If there is nothing it looks right.</p>
32,117
<p>In my specific case, I have two kinds of "messages" that I need to retrive and paginate.</p> <p>Let's omit the details, and just say that the first kind is in a model called Msg1 and the other is called Msg2</p> <p>The fields of these two models are completely different, the only fields that are common to the two ...
<p>I would suggest that you use <a href="http://docs.djangoproject.com/en/dev/topics/db/models/#id4" rel="noreferrer">Model inheritance</a>. </p> <p>Create a base model that contains date and title. Subclass Msg1 and Msg2 off it as described. Do all your queries (to fill a page) using the base model and then switch to...
<p>"combine these two queries into one query, sort it by date, and paginate it?"</p> <ol> <li><p>That's the SQL union. Leave the Django ORM and use a SQL union. It's not brilliantly fast because SQL has to create a temporary result, which it sorts.</p></li> <li><p>Create the temporary result, which can be sorted. ...
40,365
<p>Suppose you have several applications which share the same code and most of the other resources, but have a somewhat different look and feel, some labels change, etc. (think branding). If each web app is to go in its own WAR file, where do you put the shared resources?</p> <p>I already use the classpath to share c...
<p>You can deploy both WARs in the same EAR and put common resources in the EAR. Then put the appropriate dependencies in the manifest of the web apps to link to the jar files in the ear.</p>
<p>Thanks for the replies so far, but I'm afraid I forgot to mention that the WARs will be deployed in different environments that are completely isolated from each other.</p> <p>So maybe having a common WAR deployed next to the actual application is the only option. I think I'll go with the following:</p> <ul> <li>W...
43,364
<p>I'm using a RichTextBox in WinForms 3.5 and I found that when I programmatically edit the contained text, those changes are no longer available to the built in undo functionality.</p> <p>Is there a way to make it so these changes are available for undo/redo?</p>
<p>Here's just some code I decided to mess around with:</p> <pre><code> string buffer = String.Empty; string buffer2 = String.Empty; public Form3() { InitializeComponent(); this.richTextBox1.KeyDown += new KeyEventHandler(richTextBox1_KeyDown); this.ri...
<p>Instead of replacing the text, you need to replace the selected text:</p> <pre><code>richTextBox.SelectAll(); richTextBox.SelectedText = NewText; </code></pre> <p>This was however tested with a current version of winforms, which has the same issue.</p>
34,725
<p>Can you think of a preferably cheap solution for me? I need a machine that pumps air out of my 3d printing enclosure, about 4 meters of pipe length. (From enclosure to window) What kind of pump or fan can pump air out of the enclosure (4m pipe length) at the lowest possible price and low volume?</p> <p>I need it fo...
<p>Air flows from places of higher pressure to those of less.</p> <h2>Minimal setup</h2> <p>I propose to look at a very simple setup which works for short lengths of pipe:</p> <ul> <li>Choose if you want a radial fan of a direct passing fan. get one, measure the intake and the outlet side holes</li> <li>cut a fan inlet...
<p>Well you can get a centrifugal fan and put it at either end of the pipe. You didn't specify a pipe diameter so I'll assume it's 1 inch. Just hook the pipe up to the exhaust. You will have to design and print an adapter.</p> <p><a href="https://i.stack.imgur.com/bHByf.jpg" rel="nofollow noreferrer"><img src="https:/...
1,253
<p>We use MKS Integrity for our source control. I have no control over that -- I just have to use it. </p> <p>What are some "gotchas" that I should know about and avoid? And, are there any neat things about the software that will allow me to use it better?</p> <p>I've already hit cases where the tree structure in ...
<p>I have used Source Control since 1999. It's pretty reliable, we have never lost change history. We don't do anything fancy with branches so I can't answer your question.</p> <p>I assume you did resynchronize (F6) and update to head (F7).</p> <p>SI is built upon a command-line design. You might have more consistent...
<p>I have used Source Control since 1999. It's pretty reliable, we have never lost change history. We don't do anything fancy with branches so I can't answer your question.</p> <p>I assume you did resynchronize (F6) and update to head (F7).</p> <p>SI is built upon a command-line design. You might have more consistent...
45,749
<p>I am trying to localize a desktop app (C#) in VS2008.</p> <p>I have mastered localizing the forms for multiple languages and I also have a project resource file for general strings but I cannot fathom out how to create multiple language versions of this file! </p> <p>It doesn't seem to be documented anywhere. </p>...
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/ms165653.aspx" rel="nofollow noreferrer">Satellite Resource DLLs</a> (note: I've only used them in C++).<BR> This is a system where you can have a different resource DLL for each language that you want to support. There will be no more resources inside th...
<p>Actually Visual Studio has this built in. On your form you wish to localize for a language change the property Localizable to true.</p> <p>Then change the Language property to the language you wish to set up a resource file for. In your case, choose German.</p> <p>Change all the text on the form to the German text...
46,361
<p>One of the few annoying things about the Eclipse Java plug-in is the absence of a keyboard shortcut to build the project associated with the current resource. Anyone know how to go about it?</p>
<p>In the Preferences dialog box, under the General section is a dialog box called "Keys". This lets you attach key bindings to many events, including Build Project.</p>
<p>I believe <kbd>Ctrl</kbd>+<kbd>B</kbd> is already configured for this by default. Just need to have an edit window with focus.</p>
20,335
<p>If I'm deploying to servers with WebSphere 6.1 (Java 1.5), should I use IBM's JDK on my build box? Or will Sun's JDK compile to the same binary?</p> <p>If I should use IBM's, where can I get the Windows x64 version?</p>
<p>I would as much as possible try to keep development as close to production as possible. Ibm and Sun's JDK's certainly both satisfy the SDK certification, but they are by no means identical. Their instrumentation and memory management are at least slightly different. If nothing else, the bugs in the JDK will be di...
<p>They should compile to the same bytecode specification, although they may compile different bytecode (much as in the same way different C compilers generate different machine code). I don't think there would be any problems in running the resulting code - I've compiled Java 1.4 on a Mac and then deployed to IBM's J9...
14,047
<p>I purchased two DQ542MA drivers in order to run two NEMA 17 steppers. After about five days of use I noticed that the green indicator light had gone out on both drivers. </p> <p>The DQ542MA driver running my NEMA 23 High Torque stepper was still running and it has been connected to that stepper for five months now....
<p>There are a lot of problems with the CH340 chipset drivers to be found on 3D SE and various forums on the internet. To use this cheap CH340 chip that is used by a number of Arduino compatible (clone) boards to provide USB connectivity (a USB bus converter chip that converts USB bus signals to serial interface) you n...
<p>What Cura version do you have? Cura only works with the Anet A8 via USB on versions 2.3 and lower according to this <a href="https://www.thingiverse.com/groups/anet-a8-prusa-i3/forums/general/topic:12212" rel="nofollow noreferrer">page</a>. The page is from thingiverse(A 3d printing forum + print files page)</p>
940
<p>I have been trying to change the background color of Eclipse's windows to black and customize the font colors. There doesn't seem to be a way to do this, at least not in an obvious way. I am using version 3.3.</p> <p>How do I do this or are there any plugin's that might be able to assist in doing this?</p>
<h3>To change background colour</h3> <ol> <li>Open menu *Windows → <em>Preferences</em> → <em>General</em> → <em>Editors</em> → <em>Text Editors</em> <ul> <li>Browse Appearance color options</li> <li>Select background color options, uncheck default, change to black</li> <li>Select background color options, uncheck de...
<p>On Windows or Mac, you can find this setting under the <em>General</em> → <em>Editors</em> → <em>Text Editors</em> menu.</p>
22,521
<p>I launch a child process in Java as follows:</p> <pre><code>final String[] cmd = {"&lt;childProcessName&gt;"}; Process process = Runtime.getRuntime().exec(cmd); </code></pre> <p>It now runs in the background. All good and fine. </p> <p>If my program now crashes (it <em>is</em> still in dev :-)) the child process ...
<p>As you said, <a href="https://web.archive.org/web/20080310051714/http://www.onjava.com/pub/a/onjava/2003/03/26/shutdownhook.html?page=2" rel="nofollow noreferrer">addShutdownHook</a> is the way to go.</p> <p>BUT:</p> <ul> <li><p>There's no real guarantee that your shutdown hooks are executed if the program terminate...
<p>Adding shutdown hook is not a reliable method to kill the child processes. This is because Shutdown hook might not necessarily be executed when a force kill is performed from Task Manager.</p> <p>One approach would be that the child process can periodically monitor the PID of its parent. This way, Child process can ...
32,646
<p>Our clients use a vb6 version of our software.</p> <p>We are upgrading them to a .NET application written in C#...</p> <p>Is there less bulk using .net 2.0 than .net 3.5?</p> <p>My definition of less bulk would be: Smaller size, smaller installation time, etc.</p> <p>Most of them probably already have 2.0 anyway...
<p>For taking advantage of LINQ, you need 3.5 (unless you want to use <a href="http://www.albahari.com/nutshell/linqbridge.aspx" rel="nofollow noreferrer">LINQBridge</a> with 2.0).</p> <p>For a smaller installer, .Net 3.5 <strong>Sp1</strong> has a new feature called "<a href="http://weblogs.asp.net/scottgu/archive/20...
<p>I would suggest that you go straight with visual studio 2008 and .net 3.5 sp1, 2.0 is the basis of 3.5 and you can easily start using 2.0 and then start to use 3.5 functionalities.</p> <p>Furthermore 3.5 SP1 also brings tweaks to the 2.0 framework which are nice to have.</p>
26,958
<p>I've got 2 monitors, and most of the time I've got some reference material open on one screen, and Visual Studio on the other. To really get in the zone, though, I need my code to be the only thing I see. Does anyone know if it's possible to have multiple code windows in Visual Studio? So far the best I can do is pu...
<p>If you right click on the file tabs, there's an option for "New Vertical Tab group" Just maximize across both monitors and put the divider on the monitor divide and I think that's what you're after.</p>
<p>Instead of enlarging the VS2008 window to span the two monitors, you can display the 'Code Definition Window' on another monitor: just drag it outside the main window! I find this very handy to avoid switching between code windows: it is very often that one is interested in the definition of the symbol under the cu...
12,721
<p>I created a windows service that's basically a file watcher that wont run unless a user is logged into the machine its on. The service is running on a Windows Server 2003 machine. It is designed to move the files that are put into one directory into a different directory based on keywords in the file names, but no...
<p>You probably have to set the service to log on as a spesific user, try going into services, doubleclick the service and select "log in as account", and then provide your account details (domain\username and password).</p> <p>The LocalService account has extensive rights, but may lack the rights to spesific users fi...
<p>There has to be some setup problem with your service. Windows Server doesn't have a problem running applications without a user logged in (otherwise, scheduled tasks would be a lot less useful).</p> <p>How did you <em>install</em> the service?</p>
46,869
<p>I have just imported a WAR file from an external site, which is basically a servlet into Eclipse IDE (the project runs on Apache-Tomcat). </p> <p>When I import it it has a folder called <strong>Web App Libraries</strong>. So here are a few of my newbie questions:</p> <ol> <li><p>I am unsure about what the exact p...
<p>I assume this is a screenshot from the 'Project Explorer' view. It does not display exact folders and files structure, is adds a few candy constructed from project's metadata.</p> <ul> <li>To see real structure of your project, try switching to the 'Navigator' view.</li> <li>During a WAR file import, Eclipse basic...
<p>Its simple, eclipse provides multiple view to your project structure. The view you are looking at is definitely the Package Explorer view. In that view, everything that has a special icon in front is a helper item which is there to help you out by simplifying access to certain stuff like external libraries (which ar...
45,546
<p>Can we convert a hex string to a byte array using a built-in function in C# or do I have to make a custom method for this?</p>
<p>Here's a nice fun LINQ example.</p> <pre><code>public static byte[] StringToByteArray(string hex) { return Enumerable.Range(0, hex.Length) .Where(x =&gt; x % 2 == 0) .Select(x =&gt; Convert.ToByte(hex.Substring(x, 2), 16)) .ToArray(); } </code></pre...
<p>I think this may work.</p> <pre><code>public static byte[] StrToByteArray(string str) { Dictionary&lt;string, byte&gt; hexindex = new Dictionary&lt;string, byte&gt;(); for (int i = 0; i &lt;= 255; i++) hexindex.Add(i.ToString("X2"), (byte)i); List&lt;byte&gt; hexres = new Li...
41,591
<p>I'm trying to use the Kowalski graph algorithm for resolution theorem proving. The description of the algorithm at <a href="http://www.doc.ic.ac.uk/~rak/" rel="nofollow noreferrer">http://www.doc.ic.ac.uk/~rak/</a> is silent on what to do about the large number of duplicate clauses it generates. I'm wondering if the...
<p>Is the list of types fixed or does it change?</p> <p>If fixed, I would encapsulate it in an enum:</p> <pre><code>public enum FilmType { Horror = 1, Comedy = 2 } </code></pre> <p>Then just cast. You can use attributes (and a few lines of bespoke code) to store an extra description per enum item.</p> <p>If t...
<p>I always store my code look ups inside Enumeration files similar to this</p> <pre><code>public enum ReportStatus { [Description("Reports that are running")] Running, [Description("Reports that are pending to run")] Pending, [Description("Reports that have errored while running")] Error, [Description...
47,538
<p>I'm trying to grab an image from a web site using simpleXML and am getting a PHP error saying that I'm trying to call to a member function <code>xpath()</code> on a non-object.</p> <p>Below are the lines I'm trying to use to get the image's source tag: </p> <pre><code>$xpath = '/html/body/div/div/div[5]/div/div/di...
<p>Try this code to first make sure that the document is being parsed correctly.</p> <pre><code>$xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img'; $html = new DOMDocument(); @$html-&gt;loadHTMLFile($target_URL); $xml = simplexml_import_dom($html); if (!$xml) { echo 'Error while parsin...
<p>Problem solved. Was funning xpath on an empty string.</p>
45,835
<p>I have a method which takes params object[] such as:</p> <pre><code>void Foo(params object[] items) { Console.WriteLine(items[0]); } </code></pre> <p>When I pass two object arrays to this method, it works fine:</p> <pre><code>Foo(new object[]{ (object)"1", (object)"2" }, new object[]{ (object)"3", (object)"4"...
<p>A simple typecast will ensure the compiler knows what you mean in this case.</p> <pre><code>Foo((object)new object[]{ (object)"1", (object)"2" })); </code></pre> <p>As an array is a subtype of object, this all works out. Bit of an odd solution though, I'll agree.</p>
<p>One option is you can wrap it into another array:</p> <pre><code>Foo(new object[]{ new object[]{ (object)"1", (object)"2" } }); </code></pre> <p>Kind of ugly, but since each item is an array, you can't just cast it to make the problem go away... such as if it were Foo(params object items), then you could just do:<...
5,701
<p>Could someone please explain? I couldn't find anything on the internet, everything talks about how to go about it in some way, but nothing says exactly what it is. </p> <p>Also, what is a fully trusted assembly and how do they differ from one another?</p> <p>I have a MS certification exam and this is the only topi...
<p>A <a href="http://blogs.msdn.com/eugene_bobukh/archive/2005/05/06/415217.aspx" rel="nofollow noreferrer">full-trust assembly</a> has an unrestricted set of <a href="http://msdn.microsoft.com/en-us/library/930b76w0.aspx" rel="nofollow noreferrer">code access security</a> permissions, which allows the code to access a...
<p>Maybe some context will help.</p> <p>Think about something like browsing stackoverflow. There is the code off the browser itself that can do anything on your computer (delete files for example ) and there is the javascript code of the site. The javascript code can't do anything to your computer except the nifty ...
49,212
<p>Is there a fast and clean way of returning a JSON hash back from any node in a Ruby on Rails' acts_as_nested_set without using recursion?</p> <p>Here's the recursive solution for reference:</p> <pre><code>class Node &lt; ActiveRecord::Base has_many :products def json_hash if children.size &gt; 0 chil...
<p>There is a <a href="http://en.wikipedia.org/wiki/Tree_traversal" rel="nofollow noreferrer">wikipedia article</a> on tree traversal which shows different alternatives to the recursive solution you are using. It may be tricky to use them in your specific case, but it should be possible.</p> <p>However, my question t...
<p>JSONifier!</p> <pre><code>node.to_json(:include=&gt;{:products=&gt;{:include=&gt;:product_parts}}) </code></pre>
6,249
<p>I'm playing with the wonderful <a href="http://hudson.gotdns.com/wiki/display/HUDSON/FindBugs+Plugin" rel="nofollow noreferrer">FindBugs plugin</a> for <a href="http://hudson-ci.org/" rel="nofollow noreferrer">Hudson</a>. Ideally, I'd like to have the build fail if FindBugs finds any problems. Is this possible?</p> ...
<p>Maybe you've already seen this option, but it can at least set your build to unstable when you have greater than X warnings. On your job configuration page, right below the Findbugs results input field where you specify your findbugs file pattern, should be an 'advanced' button. This will expand and give you an "Uns...
<p>You can not rely on find bugs so much , it is just an expert system that tells you that something <strong>may</strong> be wrong with your program during runtime. Personally I have seen a lot of warning generated by findbugs because it was not able to figure out the correctness of code (in fact).</p> <p>One example ...
12,660
<p>I have a situation where in a web application a user may need a variable list of PDFs to be printed. That is, given a large list of PDFs, the user may choose an arbitrary subset of that list to print. These PDFs are stored on the file system. I need a method to allow users to print these batches of PDFs relatively e...
<p>The best solution I have for you is number 1. There are plenty of libraries that will merge documents. From the one I've used the numbering should not be an issue since all the pages are all ready rendered. </p> <p>If you go with ActiveX you are going to limit yourself to IE which might be acceptable. The only othe...
<p>I agree with #1. You could do some tests to see what the performance hit would be like. </p>
47,621
<p>I want to build an Axis2 client (I'm only accessing a remote web service, I'm <em>not</em> implementing one!) with Maven2 and I don't want to add 21MB of JARs to my project. What do I have to put in my pom.xml to compile the code when I've converted the WSDL with ADB?</p>
<p>(<strong>Note:</strong> This response was provided by Aaron Digulla himself. What follows is the exact text of his own answer.)</p> <p>In maven2, the minimum dependency set to make an ADB client work ("ADB" as in the way you created the Java classes from the WSDL) is this:</p> <pre><code> &lt;dependency&gt; ...
<p>For those using <strong>Gradle</strong>, here I exclude unnecessary libraries:</p> <pre><code>dependencies { ext.compileEx = { lib, exModules, exGroups -&gt; compile (lib) { exModules.each { exclude module : "$it" } exGroups.each { exclude group: "$it" } } } Li...
41,411
<p>The following code fails to compile stating "A local variable named 'st' cannot be declared in this scope because it would give a different meaning to 'st', which is already used in a 'child' scope to denote something else": </p> <pre><code> var l = new List&lt;string&gt;(); l.Find(st =&gt; st.EndsW...
<p>Yes, the compiler is enforcing scope. Note that the scope of a variable is the lexical block it's part of - not just from the point of declaration onwards, but the whole scope. </p> <p>The compiler is complaining because the assignment to <code>postParent</code> is outside its scope (which is only the nested braces...
<p>You're declaring a variable in a limited scope and trying to use it outside of that scope. The compiler assumes you don’t want access to it so you can declare a variable with the same name somewhere else in the file. Your trying to do the old C trick of assuming the variable will live immediately outside of the scop...
37,952
<p>In C# I can use the FileSystemWatcher object to watch for a specific file and raise an event when it is created, modified, etc.</p> <p>The problem I have with this class is that it raises the event the moment the file becomes created, even if the process which created the file is still in the process of writing. I ...
<p>You can use a file system watcher to check when the file has been changed. It only becomes "changed" after whichever program had the file previously closes the file. I know you asked for C#, but my VB.Net is much better. Hope you or someone else can translate.</p> <p>It tries to open the file, if it isn't availab...
<p>Not sure if there is a way of an event actually being raised by the standard class, but I eas experiencing similar problems on some recent work I was doing.</p> <p>In short, I was trying to write to a file that was locked at the time. I ended up wrapping the write method up so it would automatically try the write a...
4,404
<p>At the XmlSerializer constructor line the below causes an InvalidOperationException which also complains about not having a default accesor implemented for the generic type.</p> <pre><code>Queue&lt;MyData&gt; myDataQueue = new Queue&lt;MyData&gt;(); // Populate the queue here XmlSerializer mySerializer = new X...
<p>It would be easier (and more appropriate IMO) to serialize the <em>data</em> from the queue - perhaps in a flat array or <code>List&lt;T&gt;</code>. Since <code>Queue&lt;T&gt;</code> implements <code>IEnumerable&lt;T&gt;</code>, you should be able to use:</p> <pre><code>List&lt;T&gt; list = new List&lt;T&gt;(queue)...
<p>if you want to use the built in serialization you need to play by its rules, which means default ctor, and public get/set properties for the members you want to serialize (and presumably deserialize ) on the data type you want to serialize (MyData)</p>
39,965
<p>I'd like to commit just a part of a file using TortoiseSVN, is there some way to do that?</p> <p>I'll give an example to make it clearer why I want to do that.</p> <p>I have a file with some defines that are replaced in the build process, something like this:</p> <pre><code>#define SOME_PATH "[SOME_PATH]" </code>...
<p>The top voted answer is out-of-date.</p> <p>From the tortoiseSVN website: <a href="http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-dug-commit.html" rel="noreferrer">http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-dug-commit.html</a></p> <blockquote> <p>Commit only parts of files</p> <p>Some...
<p>What you are looking for is a feature of various distributed version-control systems such as <a href="http://darcs.net/" rel="nofollow noreferrer">darcs</a>.</p>
40,518
<p>Is there a way or tool for Vista I can use to search for content in Java files? (I do not have an Eclipse project set up for it) </p> <p>I used to be able to do it easily in the windows search tool when I had Windows 2000.</p> <p>Edit: I have already enabled "search file contents" and added additional file types a...
<p>Personally, I just use <a href="http://www.baremetalsoft.com/baregrep/" rel="nofollow noreferrer" title="BareGrep">BareGrep</a> (and previously, <a href="http://www.mythicsoft.com/agentransack/" rel="nofollow noreferrer" title="Agent Ransack">Agent Ransack</a>), which is fast, supports regexes and show lines that ma...
<p>There are tons of search tools. Simplest and smallest is the GNU grep.</p> <p>I personnally use Far (for many things, not just search).</p>
41,118
<p>I have a gradient image as a background for a table header(9x18pix). This image is called through a selector class. When the header content grows to 2 lines(vertical height increases), the bg image is tiling vertically and looks ugly. How can I stretch the bg image vertically without tiling?</p>
<p>You can't stretch it. Well not without some nasty CSS hacks, that will not really work in all available browsers. I wouldn't use them (unless your HTML code only targets a single browser, e.g. if it's a page for internal use and the browser being used is known). You can make it repeat in just one direction, though. ...
<p>First of all, I'm assuming you're using CSS to place this background image. You probably need to clarify that part of your answer. </p> <p>I don't believe there is a css function that you can use to make your background image stretch. As Mecki says, you can use background-repeat to tile the image horizontally, but ...
33,181
<p>In many places, <code>(1,2,3)</code> (a tuple) and <code>[1,2,3]</code> (a list) can be used interchangeably.</p> <p>When should I use one or the other, and why?</p>
<p>From the <a href="http://www.python.org/doc/faq/general/#why-are-there-separate-tuple-and-list-data-types" rel="noreferrer">Python FAQ</a>:</p> <blockquote> <p>Lists and tuples, while similar in many respects, are generally used in fundamentally different ways. Tuples can be thought of as being similar to Pascal rec...
<p><code>(1,2,3)</code> is a tuple while <code>[1,2,3]</code> is a list. A tuple is an immutable object while a list is mutable.</p>
2,419
<p>I am trying to update an old JavaScript function used to detect support for AJAX (i.e. the XmlHttpRequest object). I've looked online (including SO) and found various solutions but I'm not sure which is the most efficient for simply detecting support.</p> <p>The current function is:</p> <pre><code> function IsS...
<p><strong>Don't!</strong></p> <p>Or rather, don't waste time doing what many other people have done better.</p> <p>Try grabbing the source of jQuery or somesuch and "borrow" their methods; they've already invested the time to supporting as many browsers as possible (especially true in jQuery's case) so save yourself...
<p><strong>Don't!</strong></p> <p>Or rather, don't waste time doing what many other people have done better.</p> <p>Try grabbing the source of jQuery or somesuch and "borrow" their methods; they've already invested the time to supporting as many browsers as possible (especially true in jQuery's case) so save yourself...
39,354
<p>I know that a SQL Server full text index can not index more than one table. But, I have relationships in tables that I would like to implement full text indexes on.</p> <p>Take the 3 tables below...</p> <pre><code>Vehicle Veh_ID - int (Primary Key) FK_Atr_VehicleColor - int Veh_Make - nvarchar(20) Veh_Model - nvar...
<p>I believe it's a common practice to have separate denormalized table specifically for full-text indexing. This table is then updated by triggers or, as it was in our case, by SQL Server's scheduled task.</p> <p>This was SQL Server 2000. In SQL Server you can have an <a href="http://www.microsoft.com/technet/prodtec...
<p>As I understand it (I've used SQL Server a lot but never full-text indexing) SQL Server 2005 allows you to create full text indexes against a view. So you could create a view on</p> <pre><code>SELECT Vehicle.VehID, ..., Color.Atr_Name AS ColorName FROM Vehicle LEFT OUTER JOIN Attributes AS Color ON (Vehicle....
15,040
<p>I'm looking for your best solutions for creating a new message instance based on a pre-defined XSD schema to be used within a Biztalk orchestration.</p> <p>Extra votes go to answers with clear &amp; efficient examples or answers with quality referenced links.</p>
<p>There are several options when wanting to create a new instance of a message in a BizTalk orchestration.</p> <p>I've described the three I usually end up using as well as adding some links at the bottom of the answer.</p> <p>How to define which is the best method really depends - the XMLDocument method is in some ...
<p>Check out my blog post - <a href="http://www.sabratech.co.uk/blogs/yossidahan/2008/10/fun-with-message-creation-in-biztalk.html" rel="nofollow noreferrer">Fun with Message Creation in BizTalk</a> - for a basic performance comparison between various options.</p>
40,384
<p>This is a very basic problem that's frustrating me at the moment. Let's say within a single solution, I have two projects. Let's call the first project SimpleMath. It has one header file "Add.h" which has </p> <pre><code>int add(int i, int j) </code></pre> <p>and the implementation "Add.cpp" which has</p> <pre><c...
<p>The reason for the error you're getting is that by including the header file you're telling the compiler that there is a symbol</p> <pre><code>int add (int, int) </code></pre> <p>That will be present during linkage, but you haven't actually included that symbol (the code for the function) in your project. A quick ...
<p>I just had this problem <strong>within the same project</strong>... After looking closely at my code I notices that the code trying to call the function was <strong>using an interface</strong> (through a pure virtual method call = 0). However, <strong>I forgot to add the "virtual" word</strong> in the interface cla...
22,552
<p>In my user model, I have an attribute called "nickname" and validates as such:</p> <blockquote> <p>validates_format_of :nickname, :with => /[a-zA-Z0-9]$/, :allow_nil => true</p> </blockquote> <p>However, it is currently letting this string pass as valid:</p> <p>a?c</p> <p>I only want to accept alphanumeric str...
<p>You need to anchor the pattern on both sides:</p> <pre><code>/^[a-zA-Z0-9]+$/ </code></pre>
<p>You need to anchor the pattern on both sides:</p> <pre><code>/^[a-zA-Z0-9]+$/ </code></pre>
24,748
<p>After reading <a href="https://stackoverflow.com/questions/63668/confessions-of-your-worst-wtf-moment-what-not-to-do#63730">this answer</a>, I wonder if there's a way to get a "testing" credit card number. One that you can experiment with but that doesn't actually charge anything.</p>
<pre><code>MasterCard: 5431111111111111 Amex: 341111111111111 Discover: 6011601160116611 American Express (15 digits) 378282246310005 American Express (15 digits) 371449635398431 American Express Corporate (15 digits) 378734493671000 Diners Club (14 digits) 30569309025904 Diners Club (14 digits) 38520000023237 Disc...
<p>Most payment processors provide either a testing number (PayPal does this) or the ability to go into testing mode (in which no transactions actually get processed). Consult the documentation.</p>
9,242
<p>I'm trying to do a very simple button that changes color based on mouseover, mouseout and click, I'm doing this in prototype and the weird thing is if I used mouseover and mouseout, after I clicked on the button, the button wouldn't change to white, seems like it is because of the mouseout, here's my code</p> <pre>...
<p>Unless there's something else happening in mouse over and out, why not use css? </p> <pre><code>#izzy:hover { color: '#FFFFFF'; } </code></pre> <p>However, I'm a little confused as to what exactly you want to happen. Assuming you want the button white if it has been clicked or if the mouse is over it. I'd have the...
<p>If you move the cursor away from the button after clicking on it, the last event is mouseout, so it happens no matter if you click or not.</p> <p>If you want to avoid the mouseout effect when it is clicked, try setting a flag when clicking and abortind the mouseout event if the flag is set.</p>
33,375
<p>I'm looking for a clear, concise and accurate answer. </p> <p>Ideally as the actual answer, although links to good explanations welcome.</p> <p>This also applies to VB.Net, but the keywords are different - <code>ByRef</code> and <code>ByVal</code>.</p>
<p>By default (in C#), passing an object to a function actually passes a copy of the reference to that object. Changing the parameter itself only changes the value in the parameter, and not the variable that was specified.</p> <pre><code>void Test1(string param) { param = "new value"; } string s1 = "initial value...
<p><code>out</code> means that the parameter will be initialised by the method:</p> <pre><code>int result; //not initialised if( int.TryParse( "123", out result ) ) //result is now 123 else //if TryParse failed result has still be // initialised to its default value (0) </code></pre> <p><code>ref</code> wi...
3,410
<p>Are there any things to be careful about when defining the <code>method_missing</code> method in Ruby? I'm wondering whether there are some not-so-obvious interactions from inheritance, exception throwing, performance, or anything else.</p>
<p>A somewhat obvious one: always redefine <code>respond_to?</code> if you redefine <code>method_missing</code>. If <code>method_missing(:sym)</code> works, <code>respond_to?(:sym)</code> should always return true. There are many libraries that rely on this.</p> <p><em>Later:</em></p> <p>An example:</p> <pre><code...
<p>Another gotcha:</p> <p><code>method_missing</code> behaves differently between <code>obj.call_method</code> and <code>obj.send(:call_method)</code>. Essentially the former one miss all private and non-defined methods, while later one doesn't miss private methods.</p> <p>So you <code>method_missing</code> will neve...
37,127
<p>I've been trying to find a free database creator for mac os, and i'm not being able to find any. Anyone know of a free one i could download?</p> <p>EDIT: I need that the application generate the sql (mysql in this case) also :)</p> <p>ty</p>
<p><a href="http://ondras.zarovi.cz/sql/demo/" rel="nofollow noreferrer">SQL Designer</a> is web-based.</p> <p>There's also more options at <a href="https://stackoverflow.com/questions/30474/database-schema-diagram-design-tool">this question</a>.</p>
<p>I think the <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdBasics.html#//apple_ref/doc/uid/TP40001650" rel="nofollow noreferrer">Entity modeling stuff in XCode</a> might be of us to you...</p>
28,919
<p>WebKit/Safari supports the console object, which is similar to what Firebug does. But what exactly is supported? There is a <a href="http://getfirebug.com/wiki/index.php/Console_API" rel="noreferrer">console documentation for Firebug</a>, but where can I find the console documentation for Safari/WebKit?</p>
<p>Supported methods were originally:</p> <ul> <li><code>console.log()</code></li> <li><code>console.error()</code></li> <li><code>console.warn()</code></li> <li><code>console.info()</code></li> </ul> <p>Newer versions of WebKit also add the following methods making the WebKit console API almost identical to <a href=...
<p>The Console object appearantly has a built-in 'API', in the form of a 'private property' you can reveal by doing this in the Webkit javascript-console</p> <pre><code>&gt; for(o in console) console.dir(o) _commandLineAPI log warn … </code></pre> <p>_commandLineAPI:</p> <pre><code>&gt; console.dir(_...
7,944
<p>With Linux/GCC/C++, I'd like to record something to stderr whenever malloc/free/new/delete are called. I'm trying to understand a library's memory allocations, and so I'd like to generate this output while I'm running unit tests. I use valgrind for mem leak detection, but I can't find an option to make it just log...
<p>You can trace calls to malloc/free with ltrace:</p> <pre><code>#include &lt;stdlib.h&gt; int main (void) { void *ptr = malloc(10); free(ptr); return 0; } $ g++ test.cpp -o test $ ltrace -e malloc,free ./test malloc(10) = 0x804a008 free(0x804a008) ...
<p>I have not tested this myself, but I am pretty sure these would work:</p> <ul> <li><p>Since you do not want to re-compile the library, giving meaningful output (vs. just "new called for 23 bytes") may require getting a stack trace. I remember using functions to navigate the stack, but I cannot find them right now....
37,272
<p>I'm looking for a reasonable way to represent searches as a RESTful URLs.</p> <p>The setup: I have two models, Cars and Garages, where Cars can be in Garages. So my urls look like:</p> <pre><code>/car/xxxx xxx == car id returns car with given id /garage/yyy yyy = garage id returns garage with given id </c...
<p>For the searching, use querystrings. This is perfectly RESTful:</p> <pre><code>/cars?color=blue&amp;type=sedan&amp;doors=4 </code></pre> <p>An advantage to regular querystrings is that they are standard and widely understood and that they can be generated from form-get.</p>
<p>My advice would be this:</p> <pre><code>/garages Returns list of garages (think JSON array here) /garages/yyy Returns specific garage /garage/yyy/cars Returns list of cars in garage /garages/cars Returns list of all cars in all garages (may not be practical of course) /cars Returns list of all cars /cars/...
25,418
<p>How do I preview a url using ajax? I have seen this done with search engine plug ins and would like to learn how to do this. Specifically, I would like to be able to mouse over a link and see the preview of the webpage using ajax.</p>
<p>There's the <strong>easy</strong> solution, the <strong>hard</strong> solution, and the <strong>use-a-library</strong> solution.</p> <p><strong>use-a-library</strong> : I prefer always doing the use-a-library solution unless you have a darn good reason otherwise. One possible site which wraps the "hard solution" a...
<p>I think I know what he's driving at. What happens is that he wants a windows to appear on hover over a hyperlink (javascript), and for that windows to display a snapshot image of the website being referenced by the hyperlink.</p> <p>The ajax part connects to the server where you are hosting your site, asynchronousl...
10,577
<p>I have compression enabled within IIS7 and it works as expected on all responses except for those constructed by ASP.NET AJAX. I have a web service that provides data to the client. When the web service is called directly, it is properly compressed. However, when it is called via ASP.NET AJAX, the JSON response i...
<p>This should work out of the box. To verify that my ASP.NET AJAX JSON responses use GZip compression:</p> <ol> <li><p>Download Fiddler (version 2.1.9 is the latest)</p></li> <li><p>Enable Fiddler in IE 7: Tools -> Fiddler2</p></li> <li><p>As all traffic is routed through the proxy, you need to set Fiddler to apply ...
<p>You need to check that the .asmx file extension is on the the list of file types to compress, this is where the ajax json comes from. </p>
30,236
<p>I'd like to define a generic type, whose actual type parameter can only be</p> <ol> <li>One of the numeric primitive wrapper classes (<code>Long</code>, <code>Integer</code>, <code>Float</code>, <code>Double</code>)</li> <li><code>String</code></li> </ol> <p>I can meet the first requirement with a definition like ...
<p>Java generics does not support union types (this parameter can be A OR B).</p> <p>On a related note that may be of interest to some, it does support multiple bounds, if you want to enforce multiple restrictions. Here's an example from the JDK mentioned in the Java <a href="http://java.sun.com/j2se/1.5/pdf/generics...
<p>Interesting question, it boggled me a bit. However apparently this is impossible. I tried several different hacks, none really work.</p>
47,081
<p>Is there any performance gain using a CTE over a derived table?</p>
<p>Hah, got it!</p> <pre><code>Object[] ni = (Object[])nDoc.Items; string names_values = ""; for (int x = 0; x &lt; ni.Length; x++) { NotesItem item = (NotesItem)ni[x]; if (!string.IsNullOrEmpty(item.Name)) names_values += x.ToString() + ": " + item.Name + "\t\t" + item.Text + "\r\n"; } </code></pre> <p>This returned...
<p>It may not work depending on how your environment is set up, but the easiest way to deal with mail in domino is to leave them as MIME and get at the values via the NotesMIMEEntity and NotesMIMEHeader. This will only work if the mail came in from the web rather than native Notes and the environment has been set up t...
39,420
<p>I need to be able to load the entire contents of a text file and load it into a variable for further processing. </p> <p>How can I do that?</p> <hr> <p>Here's what I did thanks to Roman Odaisky's answer.</p> <pre><code>SetLocal EnableDelayedExpansion set content= for /F "delims=" %%i in (test.txt) do set conten...
<p>If your <code>set</code> command supports the <code>/p</code> switch, then you can pipe input that way.</p> <pre><code>set /p VAR1=&lt;test.txt set /? |find "/P" </code></pre> <blockquote> <p>The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified...
<p>Create a file called "SetFile.bat" that contains the following line with <strong>no carriage return</strong> at the end of it...</p> <pre><code>set FileContents= </code></pre> <p>Then in your batch file do something like this...</p> <pre><code> @echo off copy SetFile.bat + %1 $tmp$.bat &gt; nul call $tmp$...
16,220
<p>I have recently written an application(vb.net) that stores and allows searching for old council plans. Now while the application works well, the other day I was having a look at the routine that I use to generate the SQL string to pass the database and frankly, it was bad.<br> I was just posting a question here to ...
<p>I have never encountered a C#->Java conversion tool. The syntax would be easy enough, but the frameworks are dramatically different. Even if there were a tool, I would strongly advise against it. I have worked on several "migration" projects, and can't say emphatically enough that while conversion seems like a go...
<p>Why not write it in Haxe (<a href="http://haxe.org/" rel="nofollow noreferrer">http://haxe.org/</a>) and convert it to whatever you want it to be?</p>
10,422
<p>In the course of my career I've noticed that developers working on new functionality are, as a rule, more cheerful than these assigned to troubleshooting and fixing bugs.</p> <p>Good tips on keeping business support a happy? Organising business support in the way that team's morale isn’t hurt?</p>
<p>If we start with the assumption that the reason for new function developers being happier is that they get to feel proactive or in control and the troubleshooters are reactive and pushed around by the users one answer comes to mind:</p> <p>Create a model for those doing troubleshooting to fixes to generalise these ...
<p>Following Bell's suggestion, consider letting new or junior developers cut their teeth on fixes. Promote them from maintenance to the feature team based on their performance and ability.</p> <p>Healthy competition is also a good motivator, but it must be managed to remain a positive influence.</p>
25,493
<p>How can I change the title of the command prompt window every time I execute a dos-based program by double clicking it, in c language. Should I use the Windows API?</p>
<p>Try <a href="http://msdn.microsoft.com/en-us/library/ms686050.aspx" rel="nofollow noreferrer">SetConsoleTitle</a>.</p>
<p>you can do </p> <p>%comspec% /c start "testtest" %comspec%</p> <p>at application launcher of Windows+R </p>
6,715
<p>So im working on a game in XNA and i need it to get a server list off our site. </p> <p>so i just need to do a http request to <a href="http://play.feedthezombie.com/?want=servers&amp;enc=xml" rel="nofollow noreferrer">http://play.feedthezombie.com/?want=servers&amp;enc=xml</a> and get the contest as either a stri...
<p>Use <a href="http://msdn.microsoft.com/en-us/library/875kz807.aspx" rel="nofollow noreferrer">XmlDocument.Load</a> method. It can load XML from an URL.</p>
<p>You can call any .NET framework classes you like on Windows, including ones that do network access and XML handling. On Xbox you are limited to what XNA provides to you which is a subset of the .NET framework and the only network access is through the Xbox Live APIs.</p>
24,703
<p>How do you get the max value of an enum?</p>
<p>Enum.GetValues() seems to return the values in order, so you can do something like this:</p> <pre><code>// given this enum: public enum Foo { Fizz = 3, Bar = 1, Bang = 2 } // this gets Fizz var lastFoo = Enum.GetValues(typeof(Foo)).Cast&lt;Foo&gt;().Last(); </code></pre> <p><strong>Edit</strong></p> ...
<p>In F#, with a helper function to convert the enum to a sequence:</p> <pre><code>type Foo = | Fizz = 3 | Bang = 2 // Helper function to convert enum to a sequence. This is also useful for iterating. // stackoverflow.com/questions/972307/can-you-loop-through-all-enum-values-c let ToSeq (a : 'A when 'A : en...
24,882
<p>You can use command <strong>lsof</strong> to get file descriptors for all running processes, but what I would like to do is to close some of those descriptors without being inside that process. This can be done on Windows, so you can easily unblock some application.</p> <p>Is there any command or function for that?...
<p>I don't know why you are trying to do this, but you should be able to attach to the process using gdb and then call close() on the fd. Example:</p> <p>In one shell: cat</p> <p>In another shell:</p> <pre><code>$pidof cat 7213 $gdb -p 7213 ... lots of output ... (gdb) </code></pre> <p>Now you tell gdb to execut...
<p>I doubt it. File descriptors are process-local, <code>stdout</code> is 1 to all processes, yet they still reference unique streams of course.</p> <p>Perhaps more detail would be useful, about the blocking problem you're trying to solve.</p>
41,820
<p>I've got a grid (dojox.grid v1.2) that I don't want to be sortable. How can I disable that?</p>
<p>Found it:</p> <p><a href="http://dojotoolkit.org/forum/dojox-dojox/dojox-grid-support/disable-sorting-specific-column-0" rel="nofollow noreferrer">http://dojotoolkit.org/forum/dojox-dojox/dojox-grid-support/disable-sorting-specific-column-0</a></p> <p>To save linking:</p> <p>In your onload, or postrender add code...
<p>If you are creating your grid programatically you can do the following:</p> <pre><code>var grid = new dojox.grid.DataGrid({ ..., canSort: function(col) { return col != 3; } }); </code></pre>
49,662
<p>I know there are <a href="https://stackoverflow.com/questions/11737/net-library-to-unzip-zip-and-rar-files">libraries out there for working with ZIP files</a>. And, you can alternatively <a href="https://stackoverflow.com/questions/30211/windows-built-in-zip-compression-script-able">use the functionality built into ...
<p>MSDN has a complete <a href="http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx" rel="noreferrer">example</a> <a href="http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx</a>...
<p>Yes, I've used it in the past. I sub-classed <a href="http://msdn.microsoft.com/en-us/library/system.data.dataset.aspx" rel="nofollow noreferrer">DataSet</a> once to support persisting itself out to a file (via the <a href="http://msdn.microsoft.com/en-us/library/system.data.dataset.readxml.aspx" rel="nofollow nore...
22,287
<p>We have a Linux application that makes use of OpenSSL's Python bindings and I suspect it is causing random crashes. Occasionally, we see it crash with the message: </p> <blockquote> <p>Python Fatal Error: GC Object already tracked</p> </blockquote> <p>which would appear to be either a programming error on the pa...
<p>Yes, you can do this kind of thing:</p> <pre><code>(gdb) print PyRun_SimpleString("import traceback; traceback.print_stack()") File "&lt;string&gt;", line 1, in &lt;module&gt; File "/var/tmp/foo.py", line 2, in &lt;module&gt; i**2 File "&lt;string&gt;", line 1, in &lt;module&gt; $1 = 0 </code></pre> <p>I...
<p>If you're using CDLL to wrap a C library in python, and this is 64-bit linux, there's a good chance that you're CDLL wrapper is misconfigured. CDLL defaults to int return types on all platforms (should be a long long on 64-bit systems) and just expects you to pass the right arguments in. You may need to verify the...
34,386
<p>I have a repeater control with a check box, if I check the box then my delete functionality will delete an item in the underlying table.</p> <p>When I test the delete functionality on an aspx page with a code behind page, everything works fine. Hooray!</p> <p>However, when I take the repeater and put it into a Use...
<p>I think the problem is that when the delete button is clicked the Page_Load is fired again and since its a postback it does not execute the ItemsGet method and hence the repeater does not have the data.</p> <p>Try putting the ItemsGet method call in the OnPreRender event instead of Page_Load.</p> <p>Jomit</p>
<p>So it binds to the repeater and displays all the items correctly but when repeating through the list of items on postback nothing is found?</p> <p>Is the delete event definately being fired? What is visible after you have hit the delete button? (e.g. is the table empty or does it still display all the items)</p> <...
49,875
<p>I'm looking for the specific density of the GEL-LAY and LAYWOO 3D materials by manufacturer CC Products.</p> <p>It isn't noted on their website or on the spool or the box the spools came in. I've looked for hours on Google and various websites, from resellers to people who tested it, without being able to find it.<...
<p>I can't provide the end answer, but if you already have the material, you should be able to measure this yourself quite simply.</p> <p>Measure and cut a sample of filament, and weigh it. For example, a 10 meter length with a 1.75 mm diameter will have a volume of:</p> <blockquote> <p>v = pi * r<sup>2</sup> * l</...
<p>Indeed, the properties of this filament are kept rather secret, so to find out what the density is, you need to either contact the filament supplier or the manufacturer for accessing the data sheet or calculate this yourself. The answer below expands on the "<em>calculate it yourself</em>".</p> <p>Density is define...
1,094
<p>Now that it's clear <a href="https://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python">what a metaclass is</a>, there is an associated concept that I use all the time without knowing what it really means. </p> <p>I suppose everybody made once a mistake with parenthesis, resulting in an "object is n...
<p>A callable is anything that can be called. </p> <p>The <a href="http://svn.python.org/projects/python/trunk/Objects/object.c" rel="noreferrer">built-in <em>callable</em> (PyCallable_Check in objects.c)</a> checks if the argument is either:</p> <ul> <li>an instance of a class with a <code>__call__</code> method or<...
<p>Callable is a type or class of &quot;Build-in function or Method&quot; with a method <strong>call</strong></p> <pre><code>&gt;&gt;&gt; type(callable) &lt;class 'builtin_function_or_method'&gt; &gt;&gt;&gt; </code></pre> <p>Example: <strong>print</strong> is a callable object. With a build-in function <strong><strong...
13,637
<p>So I am trying to get the XSD-Schema from this object. When I open the File I just get something like this code (snippet):</p> <pre><code>¸†2¡Q·2ºyƒeCã2ï…w ïÀ|¼ðAøä[0Ÿ |&gt;‚|ó‘å2²ºFƒ¼Æò1ùàåcj@Þ`ùиÌ{áÈ;0/|¾ ùÌ'Ÿ„ Á|d½¬¬¯Õ ¯±|l¾…­Œo@Þ`ùиÌ{áÈ;0/|¾ùÌ'Ÿ„ Á|d½œ¬¯Ó ¯±|h\æ­Œo@Þ`ù¸| ßBs¦5–Œ~ôè»­£(™c´“Ç£[yp1:æ'Éc4Jó U...
<p>Three likely culprit:</p> <ul> <li><strong>The file is compressed but your machine can't detect it</strong>. So for example the 3MF model has been zipped, and what you are trying to do is opening the zip archive in the text editor, rather than the file that is in the zip archive. Solution: try to see if common de...
<p>Seems to be your are trying to edit a file with the wrong file editor.</p> <p>If you have Microsoft® Windows® 8.1, you can print directly using the 3MF format included. Simply set the print options in the 3D Print PropertyManager and print to the 3D printer. A preview of the print bed and the model's location withi...
794
<p>From the reading that I have done, Core Audio relies heavily on callbacks (and C++, but that's another story). </p> <p>I understand the concept (sort of) of setting up a function that is called by another function repeatedly to accomplish a task. I just don't understand how they get set up and how they actually w...
<p>There is no "callback" in C - not more than any other generic programming concept.</p> <p>They're implemented using function pointers. Here's an example:</p> <pre><code>void populate_array(int *array, size_t arraySize, int (*getNextValue)(void)) { for (size_t i=0; i&lt;arraySize; i++) array[i] = getNex...
<p>Usually this can be done by using a function pointer, that is a special variable that points to the memory location of a function. You can then use this to call the function with specific arguments. So there will probably be a function that sets the callback function. This will accept a function pointer and then sto...
17,253
<p>I've inherited a hoary old piece of code (by hoary, I mean warty with lots of undocumented bug fixes than WTF-y) and there's one part that's giving me a bit of trouble. Here's how it connects to the remote registry to get the add/remove programs key:</p> <pre><code>try { remoteKey = RegistryKey.OpenRemoteBaseKe...
<p>You probably have to use impersonation to change the credentials of the thread that calls the remote registry methods. See here (<a href="http://msdn.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext.aspx" rel="nofollow noreferrer">linky</a>) for some information on MSDN. Basically,...
<p>You probably have to use impersonation to change the credentials of the thread that calls the remote registry methods. See here (<a href="http://msdn.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext.aspx" rel="nofollow noreferrer">linky</a>) for some information on MSDN. Basically,...
7,162
<p>I am building a medium-sized printer which needs to produce super-precise parts at a moderately fast print time. I frankly don't want to deal with belts or their tension issues but on the other hand, having ball screws on each axis will increase inertia...right?. I'm using Rexroth rails and will use (depending on wh...
<p>The size of the nozzle usually isn't the main factor for how close you can put nozzles together. To keep the filament drive gear system from being the limiting factor, you would need Bowden extruders. &quot;Then, the heat sinks and fans would be your limiting factor. Have you considered a single nozzle with three ...
<p>One of the thinnest hotends I've seen are those from a Chinese factory Mellow Store, the heatsink is smaller than the top flange to mount the hotend. I don't know the quality of these hotends, the image below shows the basic layouts of available options:</p> <p><a href="https://i.stack.imgur.com/MsvUL.jpg" rel="nofo...
1,703
<p>I have a JS function that may occasionally get used on some pages. It is dependent on another JS file (swfObject.js), but I'd like to avoid having to include this file all over the place, as thats a wasted request most of the time.</p> <p>Instead, I'd like to create a generic function that can inject a script refer...
<p>If you're using a higher level framework such as JQuery, you could check out the <code>$.getScript(url, callback)</code> function.</p>
<p>Checkout the YUI Loader utility. It's super handy, unobtrusive javascript for loading scripts on-demand.</p> <p>Here's a link to an example using non-YUI scripts:</p> <p><a href="http://developer.yahoo.com/yui/examples/yuiloader/yl-addmodule.html" rel="nofollow noreferrer">http://developer.yahoo.com/yui/examples/...
24,844
<p>I am using NetBeans for PHP 6.5.</p> <p>In my code I frequently use the following type of command:</p> <pre><code>if (($row = $db-&gt;get_row($sql))) { return $row-&gt;folder; } else { return FALSE; } </code></pre> <p>Netbeans tells me that I should not be using assignments in the IF state...
<p>They are not bad, but they can lead to dangerous mistakes.</p> <p>In c like languages, where an assignment is an expression, (to support for example a=b=c=1;) a common error is:</p> <pre><code>if (a = 1) { .. } </code></pre> <p>But you wanted to have </p> <pre><code>if (a == 1) { .. } </code></pre> <p>Some deve...
<p>I use them all the time, with loops (not sure why that would make a difference), like:</p> <pre><code>$counter = 0; while( $getWhateverDataObj = mysql_fetch_object( $sqlResult )) { $getWhateverObj-&gt;firstName[$counter] = $getWhateverDataObj-&gt;firstName; $getWhateverObj-&gt;lastName[$counter] = $getWhatev...
40,976
<p>Let's say I'm modeling a simple box with a lid. Just as an example, we'll say the <strong>outer</strong> edge along the top of the box is 50 mm x 50 mm. With 3D modeling software, it's easy to build a lid for this box to surround the top with an <strong>inner</strong> edge size of also exactly 50 mm x 50 mm ...but t...
<p>I use my clearance values according to my rule of thumb: 0.1 mm - to fit with some force, 0.2 mm - just fit edge to edge without force.</p> <p>Examples:</p> <ol> <li><p>3 mm metal cylinder to be pressed into plastic part needs <span class="math-container">$3\ mm+0.1\ mm*2=3.2\ mm$</span> diameter printed hole (clear...
<p>Since you said nozzle, I expect you mean FDM 3d printing. Typically you would use one (1) outline of gap between the parts. An outline is usually equal to the size of the nozzle. The corners of a 3d printed square object are rounded. The radius of that rounding would be half your nozzle diameter (i.e. the nozzle's r...
990
<p>I am looking for troubleshooting help on my printer. Recently the hot end just can muster the courage to go past about 70 °C.</p> <p>The hardware - Ender 3V2 with a E3D V6 hot end. 24 volts</p> <p>I changed the thermistor to a new one. Before heating, it registers an appropriate 10 °C in line with the bed temp senso...
<h2>TL;DR:</h2> <p>Print more PLA on top of them, and pull it off together.</p> <h2>Preparation</h2> <p>First, of course, clean it well with IPA. This will both ensure there's no oil or other material on top of the PLA that will prevent it from bonding well with new PLA, and start to work underneath it to get it loose....
<p>If you can feel it with your finger, then you can scrape it off. Just be careful. Keep the scraper closer to horizontal and don't dig in. It doesn't really need much effort.</p> <p>If you can't feel it with your finger then it doesn't matter. Just clean as normal and carry on printing over it.</p>
2,117
<p>I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 items each, so maybe the brute force method of traversing each and then looking at the values of the 8 properties is t...
<p>EDIT: You cannot overload operators in current, common browser-based implementations of JavaScript interpreters.</p> <p>To answer the original question, one way you could do this, and mind you, this is a bit of a hack, simply <a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="noreferrer...
<p>comparing with json is pretty bad. try this package to compare nested arrays and get the difference.</p> <blockquote> <p><a href="https://www.npmjs.com/package/deep-object-diff" rel="nofollow noreferrer">https://www.npmjs.com/package/deep-object-diff</a></p> </blockquote>
4,667
<p>I'm porting an existing .NET 3.5 application into a plug-in for Eclipse.</p> <p>I want to have my custom UserControl, written in C#, embedded within Eclipse; I've exported it successfully as a COM Control, and it works well in Eclipse Europa.</p> <p>In Ganymede, it seems the OLE load code has changed, and what ori...
<p>If anyone is still having this problem, then please report it on <a href="http://connect.microsoft.com/visualstudio/" rel="nofollow noreferrer">Connect</a>. When done reporting, please post the URL of the bug report here, so people who read this post can vote on it.</p> <p>If this is still a bug, it would be nice t...
<p>I've come across similar problems with hosting .NET controls in non .NET environments. There have been problems with how some of my user controls have exposed to COM. </p> <p>Following the example on this site solved my problem, perhaps it will help you too!</p> <p><a href="http://blogs.msdn.com/calvin_hsia/archiv...
21,407
<p>Since I've started using NetBeans, I've learned of some <a href="http://www.netbeans.org/kb/60/java/gui-db.html" rel="nofollow noreferrer">powerful ways</a> to abstract away the process of creating Java database applications with automatically generated UI, beans bindings, and a bunch of other stuff I only vaguely u...
<p>The <a href="http://java.sun.com/docs/books/tutorial/jdbc/index.html" rel="nofollow noreferrer">JDBC Tutorial</a> is a good starting point</p> <p>A snippet from the intro</p> <pre> The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database. JDBC helps you...
<p>After reading jdbc tutorials take some attention to the base concepts: - connection - statement - query - resultset</p> <p>Db authorisation belongs to conntection, query is the description of "what to do" - fetch data or update, resultset could be updatable(!) in some cases.</p>
37,319
<p>The following code illustrates an object literal being assigned, but with no semicolon afterwards:</p> <pre><code>var literal = { say: function(msg) { alert(msg); } } literal.say("hello world!"); </code></pre> <p>This appears to be legal, and doesn't issue a warning (at least in Firefox&nbsp;3). Is this comple...
<p>Not technically, JavaScript has semicolons as optional in many situations. </p> <p>But, as a general rule, use them at the end of any statement. Why? Because if you ever want to compress the script, it will save you from countless hours of frustration.</p> <p>Automatic semicolon insertion is performed by the inter...
<p>This is not valid (see clarification below) JavaScript code, since the assignment is just a regular statement, no different from</p> <pre><code>var foo = "bar"; </code></pre> <p>The semicolon can be left out since JavaScript interpreters attempt to add a semicolon to fix syntax errors, but this is an extra and unn...
6,368
<p>I've inherited someone else's monster of a BASH script. The script was written in such a way that it uses a ridiculous amount of memory (around 1GB). I can run it from a shell with out issue, but if I run it from cron I crashes with a sig fault. </p> <p>Apart from digging into the poorly commented behemoth, is t...
<p>When you run something using cron you'll encounter issues with the environment variables being different or simply not set as compared to your own variables when you manually execute. Often things like the PATH aren't set properly when cron executes something, so it's important to supply full paths to executables wi...
<p>try making sure stdout and stderr have somewhere to go</p> <pre><code>/path/to/bigscript.sh &amp;&gt; /dev/null </code></pre> <p>[Edit] you may want to use a file other than /dev/null, especially if your running it in debug mode ;)</p> <p>Being so huge, I'm not if running in debug would help but you can try. In b...
33,355
<p>I'm trying to have an XSLT that copies most of the tags but removes empty "<code>&lt;b/&gt;</code>" tags. That is, it should copy as-is "<code>&lt;b&gt; &lt;/b&gt;</code>" or "<code>&lt;b&gt;toto&lt;/b&gt;</code>" but completely remove "<code>&lt;b/&gt;</code>".</p> <p>I think the template would look like :</p> <p...
<p>I wonder if this will work?</p> <pre><code>&lt;xsl:template match="b"&gt; &lt;xsl:if test="b/text()"&gt; ... </code></pre>
<p>If you have access to update the original XML, you could try using use <strong>xml:space=preserve</strong> on the root element</p> <pre><code>&lt;html xml:space="preserve"&gt; ... &lt;/html&gt; </code></pre> <p>This way, the space in the empty &lt;b&gt; &lt;/b&gt; tag is preserved, and so can be distinguished from...
38,288
<p>I have a listening port on my server that I'm connecting to using a Java class and the <code>Socket</code> interface, i.e.</p> <pre><code>Socket mySocket = new Socket(host,port); </code></pre> <p>I then grab an <code>OutputStream</code>, decorate with a <code>PrintWriter</code> in autoflush mode and I'm laughing -...
<p>Set a short timeout?</p> <p>Does <code>isOutputShutdown()</code> not get you what you want?</p> <p>You could always build a <code>SocketWatcher</code> class that spins up in its own <code>Thread</code> and repeatedly tries to write empty strings to the <code>Socket</code> until that raises a <code>SocketClosedExce...
<p>Set a different thread to reading from the socket. It will block until the socket is closed, and then an exception will be thrown. Catch that exception to detect the close immediately.</p>
4,276