instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Given a date range, I need to know how many Mondays (or Tuesdays, Wednesdays, etc) are in that range.</p> <p>I am currently working in C#.</p>
<p>Try this:</p> <pre><code>static int CountDays(DayOfWeek day, DateTime start, DateTime end) { TimeSpan ts = end - start; // Total duration int count = (int)Math.Floor(ts.TotalDays / 7); // Number of whole weeks int remainder = (int)(ts.TotalDays % 7); // Number of remainin...
<p>I had a similar problem for a report. I needed the number of workdays between two dates. I could have cycled through the dates and counted but my discrete math training wouldn't let me. Here is a function I wrote in VBA to get the number of workdays between two dates. I'm sure .net has a similar WeekDay function....
30,848
<p>I am trying to let a piece of runtime state decide WHICH implementation of an interface to use, preferably solely by autowiring. </p> <p>I have tried making an object factory for the interface thet uses dynamic proxies, and I used qualifiers to coerce the @Autowired injections to use the factory. The qualifiers are...
<p>I'm assuming the field <code>test</code> is of a text type (varchar, char, or the like).</p> <p>First: Update the table to contain '0' where it contains 'default'.</p> <pre><code>UPDATE tblname SET test = '0' WHERE test = 'default' </code></pre> <p>Then: Select all rows with '0' in them. You can't leave off the q...
<p>I think you would be better using format strings</p> <pre><code>string myVar = "0"; string sql = String.Format(@"select * from tblname where test = \"{0}\"", myVar); </code></pre> <p>You should also ask yourself why you are generating inline SQL on the fly and not using stored procedures as this is how SQL injecti...
35,017
<p>Before reading anything else, please take time to read the <a href="https://stackoverflow.com/questions/1615/how-can-i-modify-xfdl-files-update-1">original thread</a>.</p> <p>Overview: a .xfdl file is a gzipped .xml file which has then been encoded in base64. I wish to de-encode the .xfdl into xml which I can the...
<p>As far as I know you cannot find the compression level of an already compressed file. When you are compressing the file you can specify the compression level with -# where the # is from 1 to 9 (1 being the fastest compression and 9 being the most compressed file). In practice you should never compare a compressed fi...
<p>Different implementations of the gzip algorithm will always produce slightly different but still correct files, also the compression level of the original file may be different then what you are running it at.</p>
2,850
<p>When I merge the trunk into a feature-branch, a delete that occurred on the trunk will not be replicated to my working copy.</p> <p>Why will a delete on trunk not delete the same file on a branch when merging? I'm using subversion 1.5 client and server.</p> <p>I'm assuming that changes to the file in the branch w...
<p>To the best of my understanding, what you've done is create a local conflict in file1. In your branch, it was modified. In your trunk, it was deleted. When you merge, it will be in conflict. So the file will still be around.</p> <p>I suggest 2 tests:</p> <ol> <li>After running the code above, include the resul...
<p>Are you sure that the file deleted on the trunk is still under version control after the merge? It may be unversioned, but still present, which is the expected behavior. Looking at the output of <code>svn status</code> will let you see whether the file is still under version control.</p> <p>You may wish to take a l...
29,764
<p>Is there a program or API I can code against to extract individual files from a Windows Vista Complete PC Backup image?</p> <p>I like the idea of having a complete image to restore from, but hate the idea that I have to make two backups, one for restoring individual files, and one for restoring my computer in the e...
<p>You can put this JavaScript in the page that can perform this task for you:</p> <pre><code>function forItems(a, f) { for (var i = 0; i &lt; a.length; i++) f(a.item(i)) } function classExists(className) { var pattern = new RegExp('\\.' + className + '\\b'), found = false try { forItems(document.styleShee...
<p><a href="http://www.jetbrains.com/idea/features/html_css_editor.html" rel="nofollow noreferrer" title="IntelliJ Idea">IntelliJ Idea</a> tool does that as well. </p>
10,463
<p>Had a conversation with a coworker the other day about this.</p> <p>There's the obvious using a constructor, but what are the other ways there?</p>
<p>There are four different ways to create objects in java:</p> <p><strong>A</strong>. Using <code>new</code> keyword<br> This is the most common way to create an object in java. Almost 99% of objects are created in this way.</p> <pre><code> MyObject object = new MyObject(); </code></pre> <p><strong>B</strong>. Usin...
<p>Depends exactly what you mean by create but some other ones are:</p> <ul> <li>Clone method</li> <li>Deserialization</li> <li>Reflection (Class.newInstance())</li> <li>Reflection (Constructor object)</li> </ul>
12,099
<p>I am using a native library which returns an IntPtr to a memory location, which contains the value of an attribute. I know what the type of the attribute is and I have a method for marshalling a value (taking the IntPtr and the type of the attribute) from the memory pointed at by the pointer. This method either ca...
<p>Check out the various overloads for <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.copy.aspx" rel="nofollow noreferrer">Marshal.Copy()</a> which will let you initialise values using your IntPtr.</p>
<p>If I understood correctly, you want to unit-test your logic of deserializing, given an IntPtr.<br> If that is the case, all you have to do is have copies of the different combinations of serialized output to test each unique path. For each test, obtain the IntPtr to a possible serialized entity, call your method and...
27,812
<p>I literally just started OpenSCAD today, so please take it easy on me, but is shell scripting possible with OpenSCAD? as in, to write a script in the OpenSCAD syntax, and have it output images, or animations? with or without having to render the image.</p> <p>I've been reading the man pages, and I'm not sure if that...
<p>The horizontal bands are 5mm apart, which is a common pitch for the screws often used for the Z axis.</p> <p>I would look for something that binds, moves, slips, or touches once per screw revolution. The movement repeats along the screw, so if it is a screw defect I would look for a scratch or bump that affects the...
<p>Try setting the z-seam to <em>random</em> in your slicer. In Slic3r it is <em>Seam position</em> under <em>Advanced</em> near the bottom of the <em>Layer and perimeters</em> page of the <em>Print Settings</em>.</p>
2,069
<p>I'm moving an old VBScript web site over to ASP.NET, so I'm starting to use master pages instead of #includeing lots of other files with server side VBScript in them. </p> <p>How can I stop the pages (as in the ones that are based on master pages) from being generated once and then stored? If I make a change to the...
<p>It sounds like you have <a href="http://msdn.microsoft.com/en-us/library/aa478965.aspx" rel="nofollow noreferrer">caching</a> enabled, as normal behaviour without caching is to regenrate.</p>
<p>That shouldn't be the case, are you sure it's not a caching issue?</p>
23,176
<p>If I have to make an injection mold (for resin based raw material) using 3D printing, what raw material should I choose – PLA, ABS, HIPS etc.</p>
<p>P20 mold steel is one standard. Hardened parts are required for long life, depending on the service and material (some materials are quite abrasive). </p> <p>You can get a small number of relatively poor quality shots out of epoxy if it is properly supported by a metal box. Your best bet if you want to include 3D p...
<p>P20 mold steel is one standard. Hardened parts are required for long life, depending on the service and material (some materials are quite abrasive). </p> <p>You can get a small number of relatively poor quality shots out of epoxy if it is properly supported by a metal box. Your best bet if you want to include 3D p...
896
<p>I just wanted to know what's the difference between clear() and str("");</p> <p>For example:</p> <pre><code>stringstream ss("Stack Overflow"); ss.clear(); ss.str(""); </code></pre> <p>I wanted to know the underlying technical difference.</p>
<p><code>clear()</code> clears the error state flags in the <code>stringstream</code>. That is to say it sets the error state to <code>goodbit</code>(which is equal to zero).</p> <p><code>str("")</code> sets the associated string object to the empty string.</p> <p>They actually do completely different things. The pec...
<pre><code>void clear ( iostate state = goodbit ) //clears and sets error flag passed as parameter string str ( ) const; //to get value from string stream void str ( const string &amp; s ); //to set value to string stream </code></pre>
45,887
<p>Whilst refactoring some legacy C++ code I found that I could potentially remove some code duplication by somehow defining a variable that could point to any class method that shared the same signature. After a little digging, I found that I could do something like the following:</p> <pre><code>class MyClass { prot...
<p>What you have there is a pointer-to-member-function. It will solve your problem. I am surprised that your "TestSwitch" function compiles, as the calling syntax is slightly different to what you might expect. It should be:</p> <pre><code>bool res = (this-&gt;*CaseMethod)( 999, "hello world" ); </code></pre> <p>Howe...
<p>There's nothing intrinsically wrong with the localised example you've given here, but class method pointers can often be tricky to keep 'safe' if you use them in a wider context, such as outside the class they're a pointer of, or in conjunction with a complex inheritance tree. The way compilers typically manage meth...
7,998
<p>I am working on an embedded application where the device is controlled through a command interface. I mocked the command dispatcher in VC and had it working to my satisfaction; but when I then moved the code over to the embedded environment, I found out that the compiler has a broken implementation of pointer-to-fu...
<p>You should try changing your <code>struct command</code> so the function pointers have the actual type:</p> <pre><code>typedef struct command { const char *code; set_fn_t set_dispatcher; get_fn_t get_dispatcher; const char *_description; } command_t; </code></pre> <p>Unfortunately, function pointers are no...
<p>try this syntax:</p> <p>return (*((get_fn_t)commands[i].get_dispatcher))(pc);</p> <p>It's been awhile since I've done C &amp; function pointers, but I believe the original C syntax required the * when dereferencing function pointers but most compilers would let you get away without it.</p>
36,170
<p><strong>I want to read the contents of a URL but don't want to "hang" if the URL is unresponsive. I've created a BufferedReader using the URL...</strong></p> <pre><code>URL theURL = new URL(url); URLConnection urlConn = theURL.openConnection(); urlConn.setDoOutput(true); BufferedReader urlReader = new BufferedRead...
<p>I think URLConnection.setReadTimeout is what you are looking for.</p>
<p>I have been working on this issue in a JVM 1.4 environment just recently. The stock answer is to use the system properties sun.net.client.defaultReadTimeout (read timeout) and/or sun.net.client.defaultConnectTimeout. These are documented at <a href="http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html" rel=...
11,887
<p>We are experiencing a strange bug on our website which we think is related to the software installed on user's computers. We have an e-mail link on a lot of pages, which is created using Javascript (so spambots won't get it).</p> <p>It seems the link is "clicked" automatically on some user's machines. Some users th...
<p>Could something in the browser be prefetching the links? For example, the Firefox extension <a href="http://fasterfox.mozdev.org/" rel="nofollow noreferrer">Fasterfox</a> does that (which is the reason why I don't use it). I seem to remember Google at one time also had brought out a browser accelerator using the sa...
<p>My only suggestion would indeed be that some program (browser, extension, bot, indexer) reads the page and then opens the link and sends the mail, but I've never seen that before. </p> <p>Is there anything you can see from the mail messages you get? Recurring IP addresses or X-Mailer?</p> <p>Perhaps you can ask on...
35,944
<p>I am new to MySQL and PHP(as you can probably tell) and I was wondering if anybody knew an easy way to import a CSV file into a MySQL table.</p> <blockquote> <p>"There are any number of ways to input csv into mysql depending in what kind of access you have, if you can use the mysql client directly there is ...
<p>here's the step-by-step to extend Mrgreen's answer :</p> <ol> <li>install phpmyadmin</li> <li>choose your database</li> <li>choose your table</li> <li>'Import'</li> <li>select your CSV file</li> <li>set 'Format of imported file' to CSV</li> </ol>
<p>If you're getting to MySQL and PHP a nice way I started was with <a href="http://www.apachefriends.org/en/index.html" rel="nofollow noreferrer">XAMPP</a>.</p> <blockquote> <p>XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. XAMPP is really very easy to install and to use - jus...
27,640
<p>I'm near the end of the build of a i3 MK2 clone and have run into a problem with the Z-axis motors. Specifically, the Z-axis will move down (and trigger the endstop) but it will only make a quick noise if I try to move it up.</p> <p><code>M119</code> shows all endstops open. Min software stops are currently disabl...
<p>UPDATE: Turns out to have been a faulty RAMPS. Replaced the card and made NO changes; z-axis is now behaving properly. Thank you all.</p>
<p>This sounds similar to <a href="https://3dprinting.stackexchange.com/questions/4158/prusa-i3-z-axis-only-goes-down-even-on-up-command">Prusa i3 Z axis only goes down (even on up command)</a> and <a href="https://3dprinting.stackexchange.com/questions/4090/my-prusa-i3s-z-axis-will-only-go-up">My Prusa i3's z-axis wil...
621
<p>I have 6 sound files (1.wav 2.wav etc..) of which 3 different ones have to be heard each time the web page opens. The numbers are selected randomly. I have tried multiple "embeds" but only the last sound selected gets produced. I have also tried javascript routines that fiddle the bgsound attribute, however, I was n...
<p>A simple Flash would do the trick better than anything else. However please consider that unless you develop your page for the Intranet application and the feature was specifically requested by the users it will most likely go against the best usability practices for web. Most users consider the pages which produce ...
<p>A browser will split page loading into multiple items and thus it's likely to load all sounds at once using multiple threads. I think what you're trying to accomplish is impossible.</p>
10,784
<p>If I import a library to use a method, would it be worth it? Does importing take up a lot of memory?</p>
<p>borrowed from <a href="http://www.perlmonks.org/?node_id=95456" rel="noreferrer">here</a></p> <pre><code>%mon2num = qw( jan 1 feb 2 mar 3 apr 4 may 5 jun 6 jul 7 aug 8 sep 9 oct 10 nov 11 dec 12 ); </code></pre> <p>and to retrieve</p> <pre><code>$mon2num{"jan"} </code></pre>
<p>Definitely a hash, as suggested by others.</p>
29,906
<p>I've created a web page that lets you input some information and then draws an image in a canvas element based on that info. I have it pretty much working the way I want except for the printing.</p> <p>Is there a way to print out the canvas element or is creating a new window to draw in, the only way to do it?</p>...
<p>You could try something like this:</p> <pre><code>@media print { * { display:none; } #SOME-CANVAS-ID { display:block; } } </code></pre> <p>I'm not sure if a canvas is block by default, but you could try something along the lines of that and see if it works. The idea is that it will hide everything...
<p>You can try to create a canvas just for printing:</p> <pre><code>this.Print = function () { var printCanvas = $('#printCanvas'); printCanvas.attr("width", mainCanvas.width); printCanvas.attr("height", mainCanvas.height); var printCanvasContext = printCanvas.get(0).getContext('2d'); window.print(...
20,772
<p>My usage-scenario may seem a bit unusual, but here it is: When using vim (it's one of about 4 different editors I use regularly), I use it in two different situations. The first is via the GUI, in which I'll have multiple buffers and have some settings different than when I use it from the command-line (by testing "...
<p>do your session magic in your <code>.gvimrc</code> and everything else in your <code>.vimrc</code>. The GUI will source both, but the CL version will only source the <code>.vimrc</code>.</p> <p>The session magic is to set up autocommands to write your session to a file on exit, and reload it by sourcing the file u...
<p>You may want to add a ! to mksession so that you won't get an override error message upon exiting everytime.</p> <pre><code>au VimLeave * mksession! ~/.gvimsession au VimEnter * source ~/.gvimsession </code></pre>
42,824
<p>Is it possible to embed a windows form within another windows form?</p> <p>I have created a windows form in Visual Studio along with all its associated behaviour.</p> <p>I now want to create another windows form containing a tab view, and I want to embed the first windows form into the tab view. Is this possible?...
<p>Not directly. You can create a usercontrol, move all of the code from your form to the usercontrol and use this in both forms. You might need to change some of the code from your form but probably not much.</p>
<p>You could try the SetParent() API call, although I have not verified that it would work myself. If that does not work, Mendlet's solution above is probably your best option.</p>
38,719
<p>Outlook 2007 shows pictures of contacts on the right hand side of the mail form. This only works for your personal contacts and if you have photos.</p> <p>Is there a way to hook that picture up to the GAL or AD for the company so that all employees photos show automatically? Hopefully without having to write and d...
<p>To store a photo in AD, you can use the <code>jpegPhoto</code> attribute (see <a href="http://msdn.microsoft.com/en-us/library/ms676813(VS.85).aspx" rel="nofollow noreferrer">formal description in MSDN</a>). Here is <a href="http://www.arricc.net/active-directory-photos-sharepoint.php#" rel="nofollow noreferrer">a w...
<p>Outlook will only display the photo from a personal contact, not the GAL or AD. Making a new form is not as option.</p> <p>I have managed to use the PersonName smart tag to add a menu option to the context menu which looks up and displays the photo in a browser. Not optimal. Anyone got other ideas?</p>
35,029
<p>What would be the best way to fill a C# struct from a byte[] array where the data was from a C/C++ struct? The C struct would look something like this (my C is very rusty):</p> <pre><code>typedef OldStuff { CHAR Name[8]; UInt32 User; CHAR Location[8]; UInt32 TimeStamp; UInt32 Sequence; CHAR...
<p>From what I can see in that context, you don't need to copy <code>SomeByteArray</code> into a buffer. You simply need to get the handle from <code>SomeByteArray</code>, pin it, copy the <code>IntPtr</code> data using <code>PtrToStructure</code> and then release. No need for a copy.</p> <p>That would be:</p> <pre><...
<p>If you have a byte[] you should be able to use the BinaryReader class and set values on NewStuff using the available ReadX methods.</p>
2,500
<p>I have a website where all requests are redirected silently (via <code>.htaccess</code>) to <code>index.php</code> and then PHP is used to show the correct page (by parsing the <code>REQUEST_URI</code>).</p> <p>I was wondering if it's possible to submit POST data to a fake address too?</p> <p>I've currently got my...
<p>Try this:</p> <pre><code># redirect mail posting to index RewriteRule send-mail index.php?send-mail [NC,P] </code></pre> <p>&quot;P&quot; acts like &quot;L&quot; in that it stops processing rules but it also tells the module that the request should be passed off to the proxy module intact (meaning POST data is prese...
<p>As long as you are only using an internal rewrite, not an HTTP redirect, you should not lose POST data. Here is the rule I use on my site:</p> <pre><code>RewriteRule ^(.*)$ index.php/$1 [L] </code></pre> <p>Try using the HTTPLiveHeaders extension for Firefox (or something similar) and track the entire page request...
46,719
<p>I have a problem with Visual C++ 2008. I have installed opencv and I've created a new program and I build it with no errors. However, it complains about not finding MSVCR90D.dll when debugging. In release mode there is no problem at all. </p> <p>I do have MSVCR90D.dll in one of Winsxs folders. Does anyone know a ge...
<p>There are several potential solutions described in this <a href="http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/8f08777b-1c4d-4e10-89a2-f7bc95cf5e98/" rel="noreferrer">forum post</a>. See if any of those help.</p> <p>One hint from there:</p> <blockquote> <p>Go to %System Drive%\Windows\WinSxS a...
<p>This is one of the reasons that I statically link; bigger EXEs but I have never had a dependency issue like this before. Probably worth a question in itself though...</p>
26,917
<p>Every time I write "Cura" in a question or answer, it gets edited to "Ultimaker Cura", <a href="https://3dprinting.stackexchange.com/a/10940/11157">most recently</a> resulting in awkward verbose repetition that required additional edits to fix. I don't see any justification for requiring use of official verbose name...
<h1>Laundry list:</h1> <h2>Open</h2> <ul> <li><a href="https://3dprinting.meta.stackexchange.com/a/438">e3d</a></li> <li><a href="https://3dprinting.meta.stackexchange.com/a/436">Creality</a></li> <li><a href="https://3dprinting.meta.stackexchange.com/a/434">Filled PLA</a></li> </ul> <h2>Done</h2> <ul> <li><a href=...
<h1>Manufacturer: Monoprice</h1> <p>Status: <strong>Done</strong></p> <p>This tag (<a href="https://3dprinting.stackexchange.com/questions/tagged/monprice" class="post-tag" title="show questions tagged &#39;monprice&#39;" rel="tag">monprice</a>) is used for tagging questions regarding various printer types while the ta...
71
<p>HI All,</p> <p>I have a piece of javaScript that removes commas from a provided string (in my case currency values)</p> <p>It is:</p> <pre><code> function replaceCommaInCurrency(myField, val) { var re = /,/g; document.net1003Form.myField.value=val.replace(re, ''); } </code></pre> <p>'...
<p>You can use eval to make your code snippet work:</p> <pre><code>eval("document.net1003Form." + myField + ".value=val.replace(re, '');"); </code></pre> <p>As mentioned below, the square brackets work (and don't suck like eval), stupid me for forgetting about those:</p> <pre><code>document.net1003Form[myField].valu...
<pre><code> function removeCommaInCurrency(myField) { var re = /,/g; myField.value=myField.value.replace(re, ''); } </code></pre> <p>-- and then call it like this:</p> <pre><code>&lt;input type="text" name="..." onchange="removeCommaInCurrency(this);"&gt; </code></pre>
35,342
<p>I've been trying to find a good video that I can show at a "Lunch and Learn" on Agile Development / Scrum. Our organization is primarily Waterfall and most people have never even heard of Agile development let alone have any concrete knowledge of the topic. There are plenty of great resources out there that talk abo...
<p>The <strong>Autumn of Agile</strong> video-cast series is exactly what you're looking for. </p> <p>It's produced by Steve, who blogs at <a href="http://unhandled-exceptions.com/" rel="nofollow noreferrer">http://unhandled-exceptions.com</a>. </p> <p><strong><a href="http://www.autumnofagile.net/" rel="nofollow n...
<p>I don't have any links for you, but I do have one piece of advice that applies when you can't find the resource you need: create it yourself.</p> <p>If you look long and hard and can't find any video that is right for your group, you can always invest some of your time to create that video. Then make sure it is pr...
46,997
<p>I am using a DropDownList as </p> <pre><code>&lt;asp:DropDownList ID="ddlLocationName" runat="server" DataValueField="Guid" DataTextField="LocationName" AppendDataBoundItems="false" AutoPostBack="false" onchange="LocationChange()" &gt;&lt;/asp:DropDownList&gt; </code></pre> <p>and when I selec...
<p>The DataValueField will populate the html <code>&lt;option /&gt;</code> tags value property, while the DataTextField will populate the text property.</p> <p>When you <em>don't</em> specify a DataValueField the DataTextField is used for both (and vice-versa IIRC).</p> <p>So in JavaScript you'll want to have the fol...
<p>Thanks for your replys. I found answer.</p> <pre><code>function LocationChange() { document.getElementById ("ctl00_mainContent_ctl02_txtEventLocation").value = document.getElementById ('ctl00_mainContent_ctl02_ddlLocationName')[document.getElementById ('ctl00_mainContent_ctl02_ddlLocationName').selectedIndex]...
48,474
<p>What is the most straightforward way to create a hash table (or associative array...) in Java? My google-fu has turned up a couple examples, but is there a standard way to do this?</p> <p>And is there a way to populate the table with a list of key->value pairs without individually calling an add method on the obje...
<pre><code>Map map = new HashMap(); Hashtable ht = new Hashtable(); </code></pre> <p>Both classes can be found from the java.util package. The difference between the 2 is explained in the following <a href="http://www.jguru.com/faq/view.jsp?EID=430247" rel="noreferrer">jGuru FAQ entry</a>.</p>
<pre><code>Hashtable&lt;Object, Double&gt; hashTable = new Hashtable&lt;&gt;(); </code></pre> <p><strong>put values</strong> ...</p> <p><strong>get max</strong></p> <pre><code>Optional&lt;Double&gt; optionalMax = hashTable.values().stream().max(Comparator.naturalOrder()); if (optionalMax.isPresent()) System.out.pr...
4,897
<p>I'am working on a PHP + MySQL Social Networking application, now i need to setup different access control (read,create,edit,delete) for global (all items) and/or self items (item which created by themselves) for each module to group or specific user.</p> <p>Does anyone has suggestions in doing this (table structure...
<p>That's a pretty broad question, so you're likely to only get very broad answers.</p> <p>Most CMS systems have a table that lists the types of content that can be produced on the system.</p> <p>Another table describes how each type of content is displayed (on the front page, on individual blog pages, etc).</p> <p>...
<p>I like to use a kind of firewall rules approach or similarly a mysql tables rules approach: you can grant users or groups of users certain rights on certain objects or groups of objects. Make each rule be a row in your rules table. When you need to do an action like edit, you can inner join on your rules table for...
27,144
<p>I'm tasked with building a .NET client app to detect silence in a WAV files.</p> <p>Is this possible with the built-in Windows APIs? Or alternately, any good libraries out there to help with this?</p>
<p>Audio analysis is a difficult thing requiring a lot of complex math (think Fourier Transforms). The question you have to ask is "what is silence". If the audio that you are trying to edit is captured from an analog source, the chances are that there isn't any silence... they will only be areas of soft noise (line hu...
<p>See code below from <a href="http://alvas.net/alvas.audio,tips.aspx#tip117" rel="nofollow">Detecting audio silence in WAV files using C#</a></p> <pre><code>private static void SkipSilent(string fileName, short silentLevel) { WaveReader wr = new WaveReader(File.OpenRead(fileName)); IntPtr format = wr.ReadFor...
3,979
<p>The above error message comes up just before SQL Server marks the database as "Suspect" and refuses to open it. Does anyone know what the message means and how to fix it? I think it's a matter of grabbing the backup, but would be nice if it was possible to recover the data.</p> <p>I've had a look at the <a href="ht...
<p>It appears that it means your distributed transaction coordinator failed to start correctly when bringing the SQL Server online.</p> <p>please refer to this <a href="http://forums.asp.net/p/1122541/1756522.aspx" rel="nofollow noreferrer">ASP.NET forum post</a> and <a href="http://support.microsoft.com/kb/306366" re...
<p>run checkdb to find out why it's been marked as suspect and see if it can be recovered without any data loss (win)</p>
12,702
<p>i have code like, sorry i dont have the exact code now. but its valid.</p> <pre><code>&lt;iframe src="..." borderframe="0" scrolling="no" width=728px" height="90px"&gt;&lt;/iframe&gt; </code></pre> <p>the target is a html file that contains code for a banner. everything displays well. but when i resize browser or...
<p>I have an idea, but you haven't given us the whole picture, so I might be way off. </p> <p>I would guess that the iframe is positioned with a percentage or some sort of division calculation like 40% left of parent. Then at certain browser widths this number doesn divide evenly and gets truncated. Say it is at 10...
<p>the code is put "plain" in a div container.</p> <p>there is no percentage or relative width. :(</p>
42,691
<p>I am new to C++ on MacOS. I got an error when I used <code>kbhit()</code> in my program.</p> <p>I used <code>#include&lt;conio.h&gt;</code> but got error too, so I searched and test with <code>#include&lt;curses.h&gt;</code> but error is still remained.</p>
<p>No idea if this would work on Mac, but here's some code that I've used to get a single keypress on Linux.</p> <pre><code>int mygetch() { char ch; int error; static struct termios Otty, Ntty; fflush(stdout); tcgetattr(0, &amp;Otty); Ntty = Otty; Ntty.c_iflag = 0; /* input mode ...
<p>kbhit() is non-standard. In fact, I don't believe there is a standard function for detecting keyboard input. The best you can do is read a character from stdin using e.g. fgetc, and hope it's not redirected from somewhere else.</p>
40,233
<p>I'm trying to convert a Web Site to the Web Application project model and I'm running into compile errors that do not seem to be covered by the guidance I found at <a href="http://msdn.microsoft.com/en-us/library/aa983476.aspx" rel="nofollow noreferrer">Converting a Web Site Project to a Web Application Project</a>....
<p>You really shouldn't. If your program needs to know what class an object is, that usually indicates a design flaw. See if you can get the behavior you want using virtual functions. Also, more information about what you are trying to do would help.</p> <p>I am assuming you have a situation like this:</p> <pre><c...
<p>In c# you can simply say:</p> <pre><code>if (myObj is Car) { } </code></pre>
39,625
<p>I need to reproduce a bug, and a guy from the other team has sent me a .mdf and .ldf files from his sql server 2005 instance. When I attach the database, all I get is empty tables, even though file is 2 mb large. The db contains 2 tables that have, among other thing, a varbinary(max) field. At the same time another ...
<p>Any view data items that are not listed in the route are automatically mapped to the querystring, so if you map "items/search.xhtml" to an action:</p> <pre><code>Search(string term, int page) </code></pre> <p>Then you should get the results you are looking for.</p>
<p>I was also having trouble passing an encoded URL to a route as a route parameter.</p> <p>You can't use url encoded chars in a URL, but you can in a query string.</p> <p>Therefore I needed my route to also have a query string element to it.</p> <p>Say I have a route:</p> <pre><code>MapPageRoute("myroute", "myrout...
25,188
<p>I have a table that has redundant data and I'm trying to identify all rows that have duplicate sub-rows (for lack of a better word). By sub-rows I mean considering <code>COL1</code> and <code>COL2</code> only. </p> <p>So let's say I have something like this:</p> <pre><code> COL1 COL2 COL3 --------------------...
<p>Does this work for you?</p> <pre><code>select t.* from table t left join ( select col1, col2, count(*) as count from table group by col1, col2 ) c on t.col1=c.col1 and t.col2=c.col2 where c.count &gt; 1 </code></pre>
<p>select COL1,COL2,COL3</p> <p>from table </p> <p>group by COL1,COL2,COL3</p> <p>having count(*)>1 </p>
15,907
<p>i have a flow panel that i'm adding extra items to it at runtime based on whether they have chosen to show all the items. that's all works fine; the expansion is controlled by a toolbar button.</p> <p>the trouble is we'd like the user to be able to move his mouse over the "+" sign to expand the section.</p> <p><i...
<p>I always liked the approach used by the <a href="http://www.modelmakertools.com/code-explorer/index.html" rel="nofollow noreferrer">ModelMaker Code Explorer</a>.</p> <p>For example, when you're adding a new method, some rarely-used stuff is displayed collapsed ('Options and Directives' in the image below).</p> <p>...
<p>Actually, I think that using a TImage in this situation is pretty conventional. I have seen many people suggest using the TImage, when either the TButton, or any of its associates did not have the right amount of control for whatever the developer was trying to do.</p> <p>Have you tried a TBitBtn? I think when you ...
19,266
<p>We have created a VSTO addin for Outlook Meetings.</p> <p>As part of this we trap on the <code>SendEvent</code> of the message on the <code>FormRegionShowing</code> event:</p> <pre><code>_apptEvents.Send += new Microsoft.Office.Interop.Outlook.ItemEvents_SendEventHandler(_apptEvents_Send); </code></pre> <p>The me...
<p>Have you verified that the value that gets stored in the database is actually U+003f (question mark)? There are all sorts of conventions for how to display characters that don't exist in the chosen font, and displaying them as ?' is fairly common.</p> <p>So most likely, the character gets stored correctly, and for ...
<p>I don't know about the problems, but it's <a href="http://unicode.org/cgi-bin/GetUnihanData.pl?codepoint=9996" rel="nofollow noreferrer">definitely a valid Unicode character</a> (and has been since Unicode 1.1).</p>
44,513
<p>I have a LinkedList, where Entry has a member called id. I want to remove the Entry from the list where id matches a search value. What's the best way to do this? I don't want to use Remove(), because Entry.Equals will compare other members, and I only want to match on id. I'm hoping to do something kind of like...
<pre><code>list.Remove(list.First(e =&gt; e.id == searchId)); </code></pre>
<p>Just use the Where extension method. You will get a new list (IIRC).</p>
16,158
<p>I'd like to view historical data for guest cpu/memory/IO usage, rather than just current usage.</p>
<p>Try <a href="http://www.nagios.org/" rel="nofollow noreferrer">Nagios</a>, or <a href="http://www.howtoforge.com/server_monitoring_monit_munin" rel="nofollow noreferrer">Munin</a>.</p>
<p>Both Nagios and Munin seem to have plugins/support for Xen data collection.</p> <p><a href="http://www.novell.com/coolsolutions/feature/19490.html" rel="nofollow noreferrer">A Xen Virtual Machine Monitor Plugin for Nagios</a></p> <p><a href="http://munin.projects.linpro.no/wiki/PluginCat#Xen" rel="nofollow norefer...
12,264
<p>In response to a rightMouse event I want to call a function that displays a context menu, runs it, and responds to the selected menu item. In Windows I can use TrackPopupMenu with the TPM_RETURNCMD flag.</p> <p>What is the easiest way to implement this in Cocoa? It seems NSMenu:popUpContextMenu wants to post an e...
<p>The 'proper' way to do this in Cocoa is to have your menu item's target and action perform the required method. However, if you must do it within your initial call, you can use <code>[NSView nextEventMatchingMask:]</code> to continually fetch new events that interest you, handle them, and loop. Here's an example whi...
<p>There is no direct equivalent, except in Carbon, which is deprecated.</p> <p>For detecting the right-click, follow <a href="http://boredzo.org/blog/archives/2007-01-07/how-to-detect-a-click" rel="nofollow noreferrer">these instructions</a>. They ensure that you will properly detect right-clicks and right-holds and ...
28,208
<p>We get a large amount of data from our clients in pdf files in varying formats [layout-wise], these files are typically report output, and are typically properly annotated [they don't usually need OCR], but not formatted well enough that simply copying several hundred pages of text out of acrobat is not going to wor...
<p>We use <a href="http://www.foolabs.com/xpdf/about.html" rel="nofollow noreferrer">Xpdf</a> in one of our applications. Its a c++ library which is primarily used for pdf rendering, although it does have a text extractor which could be useful for this project.</p>
<p>Have you looked at Aspose? We're using it for an ASP.net app and I've seen some examples of vbscript using it as well. It's not particularly expensive either.</p> <p><a href="http://www.aspose.com/" rel="nofollow noreferrer">http://www.aspose.com/</a></p>
4,517
<p>I am trying to set the background color for a double spin box, and I am not sure what function I should use.</p> <p>I saw some function called <code>SetBackgroundRole</code> which accepts a <code>Qt::ColorRole</code>, but I am not sure how to use this one as well.</p> <p>Kindly let me know, what's the simple way t...
<p>Using a <code>QPalette</code> isn't guaranteed to work for all styles, because style authors are restricted by the different platforms' guidelines and by the native theme engine.</p> <p>To make sure your background color will be correct, I would suggest to use the <a href="http://doc.qt.io/qt-4.8/stylesheet.html" r...
<pre><code>comboBox-&gt;setPalette( QPalette( Qt::blue ) ); </code></pre> <p>Works fine for me! </p>
21,424
<p>I would like to simulate filesystem corruption for the purpose of testing how our embedded systems react to it and ultimately have them fail as gracefully as possible. We use different kinds of block device emulated flash storage for data which is modified often and unsuitable for storage in NAND/NOR.</p> <p>Since ...
<p>There's a research JVM by Andreas Gal called <a href="http://HotPath.Org/" rel="nofollow noreferrer">HotPath</a>, and some people from his team are currently working on adding nested trace tree based JITting to <a href="http://Research.Sun.Com/projects/maxine/" rel="nofollow noreferrer">Maxine</a> (Sun's new researc...
<p>The only possible answer to this is: <strong>Hopefully!</strong></p>
16,971
<p>What would be the benefit of using decimal.compare vs. just using a > or &lt; to compare to variables? </p>
<p>For one thing it makes it really easier to build a <a href="http://msdn.microsoft.com/en-us/library/tfakywbh.aspx" rel="noreferrer"><code>Comparison&lt;decimal&gt;</code></a> delegate instance:</p> <pre><code>Comparison&lt;decimal&gt; foo = decimal.Compare; </code></pre> <p>This is handy to pass into things which ...
<p>In the CLI, decimal is not a native type like Int32, String, and others are. I am guessing that C# uses Compare behind the scenes to implement the comparison operators.</p> <p>Also, you can pass Compare as a parameter to a sort routine without creating a delegate, reducing the method-nesting levels inside the sort....
43,362
<p>When querying ntp servers with the command <strong>ntpdate</strong>, I can use the <strong>-u</strong> argument to make the source port an unrestricted port (port 1024 and above).</p> <p>With ntpd, which is meant to run in the background, I can't seem to find a way to turn this option on. So the source port is alwa...
<p>Doesn't sound look this is possible...see the <a href="http://support.ntp.org/bin/view/Support/TroubleshootingNTP#Section_9.8." rel="noreferrer">ntp troubleshooting page</a>:</p> <blockquote> <p>If you're going to run ntpd, you need to fix your network/firewall/NAT so that ntpd can have full unrestricted access to U...
<p>You cannot change the NTP port but you can add an iptables cmd to redirect it through a VPN port.</p> <p>Details: <a href="http://openvpn.net/archive/openvpn-users/2007-11/msg00223.html" rel="nofollow">http://openvpn.net/archive/openvpn-users/2007-11/msg00223.html</a></p>
28,801
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/2647/split-string-in-sql">Split string in SQL</a> </p> </blockquote> <p>I have seen <a href="https://stackoverflow.com/questions/tagged/concatenation+sql">a couple of questions related to string concatenation</...
<p>There are a wide varieties of solutions to this problem <a href="http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648" rel="noreferrer">documented here</a>, including this little gem:</p> <pre><code>CREATE FUNCTION dbo.Split (@sep char(1), @s varchar(512)) RETURNS table AS RETURN ( WITH Pieces(pn, start, stop...
<p>I usually do this with the following code:</p> <pre><code>create function [dbo].[Split](@string varchar(max), @separator varchar(10)) returns @splited table ( stringPart varchar(max) ) with execute as caller as begin declare @stringPart varchar(max); set @stringPart = ''; while charindex(@separator, @s...
40,639
<p>From reading here and around the net, I'm close to assuming the answer is "no", but...</p> <p>Let's say I have an ASP.Net page that sometimes has a query string parameter. If the page has the query string parameter, I want to strip it off before, during, or after postback. The page already has a lot of client-side ...
<p>iam not sure this is what you are looking for, but if understand correctly you could do this:</p> <p>-on page load check for the QS value, if its not there use a hidden input field.</p> <p>-first time page loads with QS, do your normal processing and store QS value in a hidden input field. </p> <p>-if no QS then ...
<p>It is probably bad practice, but in those cases (and ones I just need to 'reset' the page), I simply do a Response.Redirect to the same page.</p>
45,997
<p>I have a simple iphone app that's based on the CrashLanding sample app. So basically you tap the title screen and do some stuff... all on the same "view". I want to add an "options" screen/page/view whatever with a few UISwitches. What's the easiest way to do this?</p> <p>Cheers!</p>
<p>Dunno if this will help I'm a bit new to objective-c and iPhone api.</p> <p>Maybe u can do something like this: Use the interface builder: just type "Interface Builder" on the Spotlight (top right corner) to generate like "myOptions.xib"</p> <p>And then just implement it: like</p> <pre><code>@implementation myOpt...
<p>Use the Interface Builder to open MainWindow.xib. Add a new View to the XIB. Refer to the Interface Builder User Guide for more details.</p> <p><a href="http://developer.apple.com/documentation/DeveloperTools/InterfaceBuilder-date.html#doclist" rel="nofollow noreferrer">http://developer.apple.com/documentation/De...
21,876
<p>Our application takes significantly more time to launch after a reboot (cold start) than if it was already opened once (warm start). </p> <p>Most (if not all) the difference seems to come from loading DLLs, when the DLLs' are in cached memory pages they load much faster. We tried using <a href="http://mypchell.com/...
<p>As for simulating reboots, have you considered running your app from a <a href="http://en.wikipedia.org/wiki/Virtual_machine" rel="noreferrer">virtual PC</a>? Using virtualization you can conveniently replicate a set of conditions over and over again.</p> <p>I would also consider some type of <a href="http://en.wik...
<p>If your application is not very complicated, you can just copy all the executables to another directory, it should be similar to a reboot. (Cut and Paste seems not work, Windows is smart enough to know the files move to another folder is cached in the memory)</p>
15,458
<p>In C#, can I convert a string value to a string literal, the way I would see it in code? I would like to replace tabs, newlines, etc. with their escape sequences.</p> <p>If this code:</p> <pre><code>Console.WriteLine(someString); </code></pre> <p>produces:</p> <pre><code>Hello World! </code></pre> <p>I want this cod...
<p>A long time ago, I found this:</p> <pre><code>private static string ToLiteral(string input) { using (var writer = new StringWriter()) { using (var provider = CodeDomProvider.CreateProvider(&quot;CSharp&quot;)) { provider.GenerateCodeFromExpression(new CodePrimitiveExpression(input...
<p><strong>Code:</strong></p> <pre><code>string someString1 = &quot;\tHello\r\n\tWorld!\r\n&quot;; string someString2 = @&quot;\tHello\r\n\tWorld!\r\n&quot;; Console.WriteLine(someString1); Console.WriteLine(someString2); </code></pre> <p><strong>Output:</strong></p> <pre><code> Hello World! \tHello\r\n\tWorld...
41,900
<p>I was about to add an extra signal handler to an app we have here and I noticed that the author had used <code>sigaction()</code> to set up the other signal handlers. I was going to use <code>signal()</code>. To follow convention I should use <code>sigaction()</code> but if I was writing from scratch, which should I...
<p>Use <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html" rel="noreferrer"><code>sigaction()</code></a> unless you've got very compelling reasons not to do so.</p> <p>The <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/signal.html" rel="noreferrer"><code>signal()</code...
<p>I'd use signal() since it's more portable, in theory at least. I'll vote up any commenter who can come up with a modern system that doesn't have a POSIX compatibility layer and supports signal().</p> <p>Quoting from the <a href="http://www.gnu.org/software/libtool/manual/libc/Signal-and-Sigaction.html" rel="nofoll...
28,709
<p>what I'm after is something I can feed a number into and it will return the highest order bit. I'm sure there's a simple way. Below is an example output (left is the input)</p> <pre>1 -> 1 2 -> 2 3 -> 2 4 -> 4 5 -> 4 6 -> 4 7 -> 4 8 -> 8 9 -> 8 ... 63 -> 32</pre>
<p>From Hacker's Delight:</p> <pre><code>int hibit(unsigned int n) { n |= (n &gt;&gt; 1); n |= (n &gt;&gt; 2); n |= (n &gt;&gt; 4); n |= (n &gt;&gt; 8); n |= (n &gt;&gt; 16); return n - (n &gt;&gt; 1); } </code></pre> <p>This version is for 32-bit ints, but the logic can be extended for 64...
<p>A nifty solution I came up with is to binary search the bits.</p> <pre><code>uint64_t highestBit(uint64_t a, uint64_t bit_min, uint64_t bit_max, uint16_t bit_shift){ if(a == 0) return 0; if(bit_min &gt;= bit_max){ if((a &amp; bit_min) != 0) return bit_min; return 0; } uin...
7,659
<p>Given this XML, what XPath returns all elements whose <code>prop</code> attribute contains <code>Foo</code> (the first three nodes):</p> <pre><code>&lt;bla&gt; &lt;a prop="Foo1"/&gt; &lt;a prop="Foo2"/&gt; &lt;a prop="3Foo"/&gt; &lt;a prop="Bar"/&gt; &lt;/bla&gt; </code></pre>
<pre><code>//a[contains(@prop,'Foo')] </code></pre> <p>Works if I use this XML to get results back.</p> <pre><code>&lt;bla&gt; &lt;a prop="Foo1"&gt;a&lt;/a&gt; &lt;a prop="Foo2"&gt;b&lt;/a&gt; &lt;a prop="3Foo"&gt;c&lt;/a&gt; &lt;a prop="Bar"&gt;a&lt;/a&gt; &lt;/bla&gt; </code></pre> <p>Edit: Another thing to n...
<p>For the code above... //*[contains(@prop,'foo')] </p>
12,888
<p>When using Linq to SQL and stored procedures, the class generated to describe the proc's result set uses char properties to represent char(1) columns in the SQL proc. I'd rather these be strings - is there any easy way to make this happen?</p>
<p>You could modify the {database}.designer.cs file. I don't have one handy to check, but I believe it's fairly straight forward --- you'll just have to plow through a lot of code, and remember to re-apply the change if you ever regenerate it.</p> <p>Alternately, you could create your own class and handle it in the s...
<p>Not sure why you'd want to do that. The underlying data type can't store more than one char, by representing it as a string variable you introduce the need to check lengths before committing to the db, where as if you leave it as is you can just call ToString() on the char to get a string</p>
9,889
<p>I am writing a VC++ MFC dialog based app which requires Microsoft MapPoint embedding in it. To do this I'm using MS VC++ .NET 2003 and MapPoint Europe 2006 to do this but am having problems as when I select "Insert ActiveX Control" no MapPoint control appears in the list of options. I have tried manually registering...
<p>I've found some benefits to makefiles with large projects, mainly related to unifying the location of the project settings. It's somewhat easier to manage the list of source files, include paths, preprocessor defines and so on, if they're all in a makefile or other build config file. With multiple configurations, ...
<p>You can use nant to build the projects individually thus replacing the solution and have 1 coding solution and no build solutions.</p> <p>1 thing to keep in mind, is that the solution and csproj files from vs 2005 and up are msbuild scripts. So if you get acquainted with msbuild you might be able to wield the exist...
7,507
<p>I'm trying to run PHP from the command line under <a href="https://en.wikipedia.org/wiki/Windows_XP" rel="nofollow noreferrer">Windows XP</a>.</p> <p>That works, except for the fact that I am not able to provide parameters to my PHP script.</p> <p>My test case:</p> <pre><code>echo &quot;param = &quot; . $param . &qu...
<p>Why do you have any expectation that <em>param</em> will be set to the value?</p> <p>You're responsible for parsing the command line in the fashion you desire, from the <em>$argv</em> array.</p>
<p>You can use the $argv array. Like this:</p> <pre><code>&lt;?php echo $argv[1]; ?&gt; </code></pre> <p>Remember that the first member of the <em>$argv</em> array (which is <em>$argv[0]</em>) is the name of the script itself, so in order to use the parameters for the application, you should start using members of ...
9,095
<p>I managed to tear my build plate trying to get some very stubborn plastic off it.</p> <p><a href="https://i.stack.imgur.com/fDqad.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fDqad.jpg" alt="Torn build plate"></a></p> <p>I'll need to buy a new one, what characteristics are important for me to...
<p>If your printer's heated bed still works, but the sticker has been ripped in some places:</p> <ul> <li>You can try and remove the rest of the sticker, clean the metal plate under the sticker (perhaps with isopropyl alcohol) and then apply a new sticker once there is no adhesive remaining on the heated bed.</li> <li...
<p>I would say put a glass bed on it and you won't have to worry about tearing it ever again. Many places which sell picture frames can cut out a piece of 3&nbsp;mm glass for very little (like 1-2 dollars). I've had a normal 3&nbsp;mm glass bed (no expensive "heat glass" or anything) that's worked fine for 2 years of p...
1,162
<p>What are the coolest new features that you guys are looking for, or that you've heard are releasing in c# 4.0.</p>
<p>The dynamic stuff sounds cool <em>if you need it</em> but I don't expect to use it very often.</p> <p>The generic variance for delegates and interfaces is similar - the lack of variance is a headache at the moment, but many of the places where it's a pain won't be covered by the limited variance available in C# 4.<...
<p>Ability to write asynchronous code in synchronous fashion with <strong>async</strong> and <strong>await</strong> is cool.</p>
37,291
<p>I know that when you add/change/remove methods in a COM interface you're supposed to change the interface/coclass GUID but what about type libraries. When should you change the type library's GUID? Do you change it if a GUID inside the type library has changed? Or should you only change it when something that doesn...
<p>The basic principle is that COM interfaces and Type Libraries should be immutable (that is, they shouldn't ever change). If you change one item inside a COM interface, then the new version needs to be a completely separate entity from the previous version. The only way to do this is to change the GUID for every in...
<p>I've got a similar question. </p> <p>I had an original control with CLSID_A that implemented interface IID_A in some 1.0 type library with GUID_A </p> <p>Later on, I decided to add a new interface to the original control. It would then implement both IID_A and IID_B interfaces. I figured that I should probably kee...
36,574
<p>I would like to create a javascript modal pop up window to get some values from a user in a ASP.Net 2.0 webpage.</p> <p>The basic idea is this. When a user clicks a button, a modal window will come up and ask 3 or 4 questions. The asp.net page will not be able to be changed while this window is up. Once the questio...
<p>Have you looked at the ModalPopupExtender?</p> <p><a href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx" rel="noreferrer">http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx</a></p>
<p>You could use the javascript function 'window.showModalDialog', but it only works in Internet Explorer.</p> <p>You can pass in and return any number of variables by wrapping them up into an object.</p>
25,877
<p>I need to be able to use https to connect to a server and I'm wondering if there's <em>recommended</em> way of doing this on the iPhone that's NOT: - an undocumented api call - does not require manually storing certificates in the app bundle</p> <p>Thanks all.</p>
<p>NSURLRequest and NSURLConnection are what you're looking for. Start with the docs for those.</p>
<p>What's the problem you have with using https? The URL Loading System (i.e. NSURLConnection) and WebKit both support it out-of-the-box. The only issue I know of is with using untrusted certificates, and the only solution I know of to that is (unfortunately) to use a private API call. But you shouldn't be shipping an ...
47,043
<p>Every time I publish the application in <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="nofollow noreferrer">ClickOnce</a> I get get it to update the revision number by one. Is there a way to get this change automatically to change the version number in AssemblyInfo.cs file (all our error reporting looks at th...
<p>We use Team Foundation Server Team Build and have added a block to the TFSBuild.proj's <code>AfterCompile</code> target to trigger the ClickOnce publish with our preferred version number:</p> <pre class="lang-xml prettyprint-override"><code>&lt;MSBuild Projects="$(SolutionRoot)\MyProject\Myproject.csproj" ...
<p>You'll probably need to create a piece of code that updates AssemblyInfo.cs according to the version number stored in the .csproj file. (The ClickOnce deploy version is stored inside an XML tag.)</p> <p>You'd then change your .csproj file to run this bit of code when Publish|Release build is performed. The MSBuild ...
6,623
<p>I'm using .net's PrintPreviewDialog and whenever it's generating a preview, it locks up my GUI in the background and makes it look like it has crashed until the preview is finished. Seeing how the .net's page progress window that pops up isn't a dialog, the back ground can be selected which then comes to the front i...
<p>the ShowDialog method creates a modal window, it blocks the main thread. the Show method creates a nonmodal window, it doesn't block the main thread.</p> <p>When you call </p> <blockquote> <p>this.printDocument.Print();</p> </blockquote> <p>it again does its work in the main thread.</p> <p>To do that in a back...
<p>Dot Net Rocks TV (dnrtv) covers how to run things in a background thread to keep the GUI thread free in <a href="http://www.dnrtv.com/default.aspx?showNum=16" rel="nofollow noreferrer">episode 16</a>. </p>
44,533
<p>I have a .NET 2.0 windows forms app, which makes heavy use of the <code>ListView</code> control.</p> <p>I've subclassed the <code>ListView</code> class into a templated <code>SortableListView&lt;T&gt;</code> class, so it can be a bit smarter about how it displays things, and sort itself.</p> <p>Unfortunately this ...
<p>It happened to me because of x86 / x64 architecture.</p> <p>Since Visual Studio (the development tool itself) has no x64 version, it's not possible to load x64 control into GUI designer.</p> <p>The best approach for this might be tuning GUI under x86, and compile it for x64 when necessary.</p>
<p>In my case the problem was the folder's name of my project! Why I think this: I use SVN and in the 'trunk\SGIMovel' works perfectly. But in a branch folder named as 'OS#125\SGIMovel' I can't open the designer for a form that uses a custom control and works in the trunk folder.</p> <p>Just get off the # and works nic...
3,074
<p>Basically, I've written an API to www.thetvdb.com in Python. The current code can be found <a href="http://github.com/dbr/tvdb_api/tree/master/tvdb_api.py" rel="noreferrer">here</a>.</p> <p>It grabs data from the API as requested, and has to store the data somehow, and make it available by doing:</p> <pre><code>pr...
<p>OK, what you need is <code>classobj</code> from new module. That would allow you to construct exception classes dynamically (<code>classobj</code> takes a string as an argument for the class name). </p> <pre><code>import new myexc=new.classobj("ExcName",(Exception,),{}) i=myexc("This is the exc msg!") raise i </cod...
<p>I have done something similar in the past and used an in-memory XML document as a quick and dirty hierarchical database for storage. You can store each show/season/episode as an element (nested appropriately) and attributes of these things as xml attributes on the elements. Then you can use XQuery to get info back o...
2,783
<p>Basically, I would like a brief explanation of how I can access a SQL database in C# code. I gather that a connection and a command is required, but what's going on? I guess what I'm asking is for someone to de-mystify the process a bit. Thanks.</p> <p>For clarity, in my case I'm doing web apps, e-commerce stuff. I...
<p>MSDN has a pretty good writeup here:</p> <p><a href="http://msdn.microsoft.com/en-us/library/s7ee2dwt(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/s7ee2dwt(VS.71).aspx</a></p> <p>You should take a look at the data-reader for simple select-statements. Sample from the <a href="http:...
<p>topics to look at:</p> <ol> <li>ADO.NET basics</li> <li>LINQ to SQL</li> <li>Managed database providers</li> </ol>
11,586
<p>I need to create a directory on a mapped network drive. I am using a code:</p> <pre><code>DirectoryInfo targetDirectory = new DirectoryInfo(path); if (targetDirectory != null) { targetDirectory.Create(); } </code></pre> <p>If I specify the path like "\\\\ServerName\\Directory", it all goes OK. If I map the "\\...
<p>Mapped network drives are user specific, so if the app is running under a different identity than the user that created the mapped drive letter (z:) it won't work.</p>
<p>I had the same problem on Win Server 2012. The disabling UAC solved it.</p>
16,175
<p>I'm trying to select data from a table defined similar to the following :</p> <pre><code>Column | Data Type ------------------------- Id | Int DataType | Int LoggedData | XML </code></pre> <p>but I only want to select those rows with a specific DataType value, and that contain a string (o...
<p>If you want to filter by a <em>searchterm</em> (like a SQL variable) you will probably need to use something like this:</p> <pre><code>Select Id, LoggedData From myTable Where DataType = 29 And LoggedData.exist('RootNode/ns1:ChildNode[@value=sql:variable("@searchterm")]')=1 </code></pre> <p>where @searchterm is y...
<p>Is this not doing the trick for you?</p> <pre><code>SELECT Id, LoggedData FROM myTable WHERE DataType = 29 AND LoggedData.exist('RootNode/ns1:ChildNode[@value="searchterm"]') = 1 </code></pre>
23,964
<p>What are the characteristics of a good UI designer? How much does one have to have graphical design abilities these days as opposed to interaction design abilities. I see this of growing importance with the advent of WPF and Silverlight.</p> <p>I personally consider myself good at interaction design, but would like...
<p>Try the <a href="https://rads.stackoverflow.com/amzn/click/com/1566091594" rel="noreferrer" rel="nofollow noreferrer">Non-designer's design book</a>.</p> <p>In my experience, interface design is a skill all in itself. Graphic designers are good at making wonderfully beautiful but completely confusing and unusable i...
<p><a href="http://www.cooper.com/insights/books/" rel="nofollow noreferrer">About Face</a> is a nice book too. </p> <p><strong>Subtlety</strong> is always something good to watch out. Harsh gradients and some color combinations are just a pain.</p>
32,553
<p>Any good reason why $("p").html(0) makes all paragraphs empty as opposed to contain the character '0'?</p> <p>Instead of assuming I found a bug in jQuery, it's probably a misunderstanding on my part.</p>
<p>jQuery only accepts a string as an argument for the <code>val</code> parameter of the <code>html()</code> method. If you pass a number like you are it will call the <code>html()</code> method override that sets the contents of the element but the value of the argument will end up being null or an empty string.</p> ...
<p>I geuss you missed part of how jQuery works,</p> <pre><code>$('p') </code></pre> <p>returns all paragraphs and the html( val ) function: </p> <pre> Set the html contents of every matched element. This property is not available on XML documents (although it will work for XHTML documents). </pre> <p><a href="htt...
40,065
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/361635/debugging-javascript-in-ie7">Debugging JavaScript in IE7</a> </p> </blockquote> <p>Firefox has Web Developer plugin and Firebug for troubleshooting html/css/javascript issues. Google Chrome and Safari ha...
<p>Yes - The Internet Explorer Developer Toolbar</p> <p><a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=95E06CBE-4940-4218-B75D-B8856FCED535&amp;displaylang=en" rel="noreferrer">Download details: Internet Explorer Developer Toolbar</a></p>
<p>Actually, the best add-on for developers to IE would be <a href="http://www.fiddlertool.com/fiddler/version.asp" rel="nofollow noreferrer">Fiddler</a>. It has a number of features that the other browsers possess.</p>
8,057
<p>We're creating a Interaction design pattern website for a class. We've been using google docs to create the patterns list during the classes, sharing it with the teacher for evaluation.</p> <p>So the environment is this:</p> <ul> <li>We've been able to fetch a single image from each presentation we want to display...
<p>A <a href="https://msdn.microsoft.com/en-gb/library/cc189045(v=vs.95).aspx" rel="noreferrer">StaticResource</a> will be resolved and assigned to the property during the loading of the XAML which occurs before the application is actually run. It will only be assigned once and any changes to resource dictionary ignore...
<p>Important benefit of the dynamic resources</p> <p>if application startup takes extremely long time, you must use dynamic resources, because static resources are always loaded when the window or app is created, while dynamic resources are loaded when they’re first used.</p> <p>However, you won’t see any benefit un...
24,512
<p>Now that Silverlight 2.0 has been officially released I was wondering if anyone was using it for any line of business apps, for example POS, Vertical Market apps etc. If so how were your experiences compared to an old WinForms app or Web app?</p>
<p>I think Silverlight is going to be huge for business applications. This is some bullet points highlighting strengths of Silverlight as a LOB platform inside the browser. It's something i wrote to help a colleague out who was comparing ASP.NET vs. Silverlight, but hopefully it includes some hints.</p> <p><strong>Ext...
<p>Have a look at this <a href="http://www.silverlightshow.net/news/Welcome-Chris.aspx" rel="nofollow noreferrer">series of articles</a> by Chris Anderson - I know the fella and he's very into this at the moment. He is developing his own business platform on Silverlight.</p> <p>Edit: Have a look at this MSDN article t...
24,308
<p>I've got an upcoming project wherein I will need to connect our website (<code>PHP5/Apache 1.3/OpenBSD 4.1</code>) to our back-end system running on an iSeries with OS400 V5R3 so that I can access some tables stored there. I've done some checking around but am running into some roadblocks.</p> <p>From what I've see...
<p>Have you looked at connecting to the server using <a href="http://www.unixodbc.org/" rel="noreferrer">unixODBC</a>? If I remember correctly it has support for IBM DB2 and compiles on OpenBSD. Check out <a href="http://www.php.net/odbc" rel="noreferrer">http://www.php.net/odbc</a> for more information regarding the P...
<p>A web service is almost certainly the way to go. I'm sure you've already thought of this, but since you're doing PHP on both sides, you can shortcut things a little bit by using serialize() to build your response data instead of building a proper XML document. It's less flexible over the long run, but it will prob...
2,311
<p>I need to change an element's ID using jQuery. </p> <p>Apparently these don't work:</p> <pre><code>jQuery(this).prev("li").attr("id")="newid" jQuery(this).prev("li")="newid" </code></pre> <p>I found out that I can make it happen with the following code:</p> <pre><code>jQuery(this).prev("li")show(function() { ...
<p>Your syntax is incorrect, you should pass the value as the second parameter:</p> <pre><code>jQuery(this).prev("li").attr("id","newId"); </code></pre>
<p>Eran's answer is good, but I would append to that. You need to watch any interactivity that is not inline to the object (that is, if an onclick event calls a function, it still will), but if there is some javascript or jQuery event handling attached to that ID, it will be basically abandoned:</p> <pre><code>$("#my...
45,258
<p>I'm working on a large scale performance critical asp web application with a pretty much denormalized database (lots of data is duplicated across tables for performance reasons). The application is highly performance critical and large. There is almost no sense of any kind of n-tiered design. I can't touch the datab...
<p>There are tons of mapping tools out there that are intended to help with this task, but in practicality as far as maintainability goes, you're probably better off just doing it yourself (especially if it is unlikely that this database model will change).</p> <p>If I were in your situation, I'd create general classe...
<p>We faced the exact same issue a few weeks ago. We initially were code generating our Entities, Dal, and basic BLL. But the extensive code we would have had to write to load referenced entities, and collections would be extremeley complex without a centralized generic solution. </p> <p>We already had a great home-gr...
38,797
<p>I installed MySQL via <a href="http://en.wikipedia.org/wiki/MacPorts" rel="noreferrer">MacPorts</a>. What is the command I need to stop the server (I need to test how my application behave when MySQL is dead)?</p>
<p>There are different cases depending on whether you installed <a href="http://en.wikipedia.org/wiki/MySQL" rel="noreferrer">MySQL</a> with the official binary installer, using <a href="http://en.wikipedia.org/wiki/MacPorts" rel="noreferrer">MacPorts</a>, or using <a href="http://brew.sh/" rel="noreferrer">Homebrew</a...
<p>I installed mysql5 and mysql55 over macports. For me the mentioned files here are located at the following places:</p> <p>(mysql55-server) /opt/local/etc/LaunchDaemons/org.macports.mysql55-server/org.macports.mysql55-server.plist</p> <p>(mysql5) /opt/local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5....
12,624
<p>Greetings!</p> <p>I have an XML value that I'd like to use as a boolean value to toggle the visibility of a Panel. I have something like this:</p> <pre><code>&lt;asp:FormView id="MyFormView" runat="server" DataSourceID="MyXmlDataSource"&gt; &lt;ItemTemplate&gt; &lt;!-- some stuff --&gt; &lt;as...
<p>if the xpath returns a string, don't you want to use <a href="http://msdn.microsoft.com/en-us/library/system.boolean.parse.aspx" rel="nofollow noreferrer">Boolean.Parse</a>(XPath("Menu/Show"))</p>
<p>Try this:</p> <p>Not sure of the syntax of string equality in classic ASP, but you need to do a string compare, then return true or false.</p> <p>...Visible='&lt;%#XPath("Menu/Show")).ToString().equals("0") ? return true : false%>'...</p>
45,772
<p>I'm trying to run the Camel Example "camel-example-spring-jms" (also at <a href="http://activemq.apache.org/camel/tutorial-jmsremoting.html" rel="nofollow noreferrer">http://activemq.apache.org/camel/tutorial-jmsremoting.html</a>). However, when I try to start Camel using "org.apache.camel.spring.Main" class, I get ...
<p>So it works fine under maven - but not if you run it how? In your IDE or something?</p> <p>If you are using eclipse / intellij you can create an IDE project for the maven project using maven.</p> <pre><code>mvn eclipse:eclipse </code></pre> <p>or </p> <pre><code>mvn idea:idea </code></pre> <p>If you are writing...
<p>This particular exception is caused when the camel-jms library .jar is not on your classpath. As mentioned by James, ensure this library is correctly in your classpath when running.</p>
44,438
<p>If I safe an Array and reload it, is there a possibility to get the size if its unknown? Thanks</p>
<p>What do you mean by "unknown"? You can get the length of any java array with the length field.</p> <pre><code>int[] myArray = deserializeSomeArray(); int size = myArray.length; </code></pre>
<p>I think you need to supply some more information. How are you saving the array? Using an ObjectOutputStream?</p>
20,942
<p>This is my query:</p> <pre><code>$query = $this-&gt;db-&gt;query(' SELECT archives.id, archives.signature, type_of_source.description, media_type.description, origin.description FROM archives, type_of_source, media_type, origin WHERE archives...
<p>This actually has very little to do with CodeIgniter and a lot with how mysql_fetch_assoc provides the query results.</p> <p>The solution is that you should rename the columns inside the query using <code>&quot;AS&quot;</code>, e.g.</p> <pre><code>select type_of_source.description as type_of_source_description, orig...
<p>I recommend not to use it that way instead, you can rename output columns with <code>AS</code>.</p>
22,658
<p>I've read numerous posts about people having problems with <code>viewWillAppear</code> when you do not create your view hierarchy <em>just</em> right. My problem is I can't figure out what that means.</p> <p>If I create a <code>RootViewController</code> and call <code>addSubView</code> on that controller, I would e...
<p>If you use a navigation controller and set its delegate, then the view{Will,Did}{Appear,Disappear} methods are not invoked.</p> <p>You need to use the navigation controller delegate methods instead:</p> <pre><code>navigationController:willShowViewController:animated: navigationController:didShowViewController:anim...
<p>You should only have 1 UIViewController active at any time. Any subviews you want to manipulate should be exactly that - subVIEWS - i.e. UIView.</p> <p>I use a simlple technique for managing my view hierarchy and have yet to run into a problem since I started doing things this way. There are 2 key points:</p> <ul...
15,919
<p>I'm having trouble getting this code to show up correctly in WebKit browsers(chrome/safari). It looks fine in IE6, IE7, and FireFox. </p> <pre><code>&lt;table width="100%"&gt; &lt;tr&gt; &lt;td rowspan="2" style="vertical-align:middle;"&gt; &lt;a href="http://http://{$smarty.const.DOMAIN}/co...
<p>I have a few recommendations for you but I can't answer your question completely because WebKit seems to render your source fine when I try it.</p> <ol> <li>First, maybe you can change <code>width="100%"</code> to <code>style="width:100%;"</code> Perhaps combined with the other markup, it's putting the browser in q...
<p>I could help more with a live example to test on but you could try adding this to your <code>tr</code> tags.</p> <pre><code>&lt;tr style="height: 50%;"&gt; </code></pre> <p>Assuming you only need two rows this will bring them to equal height.</p>
49,586
<p>I am changing document template macros. The one thing I can't find out how to do is to customize error messages. For example an error message in a document is</p> <p>"Error! No table of figures entries found"</p> <p>I would like to change this to display something else. Is it possible to do this with Word VBA or V...
<blockquote> <p>Is it possible to put this in some kind of global error handler? – Craig</p> </blockquote> <p>It is possible. Here is a very rough example.</p> <p>In a standard module:</p> <pre><code>Sub HandleErr(ErrNo As Long) Select Case ErrNo Case vbObjectError + 1024 MsgBox "No table of figu...
<p>If you want to trap a specific error type in VBA, one method is to use On Error Resume Next then test for an error message on the line following the action to trap, e.g.:</p> <pre><code>On Error Resume Next ' try action If Err.Number &lt;&gt; 0 Then ' handle w/ custom message Err.Clear End If </code></pre> <p>...
27,162
<p>I have this strange issue with my web app. You see, I'm using jQuery with the Forms API and doing $('#MyForm').ajaxSubmit(api parms and callback function goes here).</p> <p>Randomly when I do this, however, and only on Firefox, the page load icon starts spinning, the page load progress bar runs in the status bar, a...
<h2>Why <code>rand</code> is a bad idea</h2> <p>Most of the answers you got here make use of the <code>rand</code> function and the modulus operator. That method <a href="http://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful" rel="noreferrer">may not generate numbers uniformly</a> (it depends on the ...
<p>I just found this on the Internet. This should work:</p> <pre><code>DWORD random = ((min) + rand()/(RAND_MAX + 1.0) * ((max) - (min) + 1)); </code></pre>
36,761
<p>I'm a newbie at networking. I understand the concept of multicast, but was wondering if it's reliable on the open/public internet?</p> <p>It seems like sort of an edge case that different backbones or ISPs might intentionally break to reduce router load or generally segment the network for practical high-use appli...
<p>IP multicast in the internet doesn't really work. From the <a href="http://en.wikipedia.org/wiki/Multicast" rel="noreferrer">Wikipedia article</a>: </p> <blockquote> <p>For both these reasons, and also reasons of economics, IP Multicast is not in general use in the commercial Internet.</p> </blockquote> <p...
<p>Typically multicast refers to UDP multicast, which is not reliable.</p>
31,888
<p>I am getting 'trailing whitespace' errors trying to commit some files in Git.</p> <p>I want to remove these trailing whitespace characters automatically right before I save Python files.</p> <p>Can you configure Vim to do this? If so, how?</p>
<p>I found the answer <a href="https://vim.fandom.com/wiki/Remove_unwanted_spaces#Automatically_removing_all_trailing_whitespace" rel="noreferrer">here</a>.</p> <p>Adding the following to my .vimrc file did the trick:</p> <pre class="lang-vim prettyprint-override"><code>autocmd BufWritePre *.py :%s/\s\+$//e </code></pr...
<p><code>autocmd BufWritePre * :%s/\s\+$//&lt;CR&gt;:let @/=''&lt;CR&gt;</code></p>
46,431
<p>I'm having trouble resizing a tableHeaderView. It simple doesn't work.</p> <p>1) Create a UITableView and UIView (100 x 320 px);</p> <p>2) Set the UIView as tableHeaderView of the UITableView;</p> <p>3) Build and Go. Everything is ok.</p> <p>Now, I want to resizing the tableHeaderView, so I add this code in view...
<p>FYI: I've gotten this to work by modifying the tableHeaderView and re-setting it. In this case, i'm adjusting the size of the tableHeaderView when the UIWebView subview has finished loading.</p> <pre><code>[webView sizeToFit]; CGRect newFrame = headerView.frame; newFrame.size.height = newFrame.size.height + webView...
<p>Did you try <code>[self.tableView reloadData]</code> after changing the height?</p>
44,349
<p>I could use some help writing a regular expression. In my Django application, users can hit the following URL:</p> <pre><code>http://www.example.com/A1/B2/C3 </code></pre> <p>I'd like to create a regular expression that allows accepts any of the following as a valid URL:</p> <pre><code>http://www.example.com/A1 ...
<p>Skip the <code>|</code>, use the <code>?</code> and <code>()</code></p> <p><code>http://www\.example\.com/A1(/B2(/C3)?)?</code></p> <p>And if you replace the A1-C3 with a pattern:</p> <p><code>http://www\.example\.com/[^/]*(/[^/]*(/[^/]*)?)?</code></p> <p>Explanation:</p> <ul> <li>it matches every string that s...
<pre><code>http://www\.example\.com/A1(/B2(/C3)?)? </code></pre>
22,686
<p>My company has a common code library which consists of many class libary projects along with supporting test projects. Each class library project outputs a single binary, e.g. Company.Common.Serialization.dll. Since we own the compiled, tested binaries as well as the source code, there's debate as to whether our con...
<p>It sounds to me as though you've covered all the major points. We've had a similar discussion at work recently and we're not quite decided yet.</p> <p>However, one thing we've looked into is to reference the binary files, to gain all the advantages you note, but have the binaries built by a common build system wher...
<p>I think that if the project is not part of the solution, you shouldn't include it there... but that's just my opinion</p> <p>I separate it by concept in short</p>
6,875
<p>When you have a derived class, is there an simpler way to refer to a variable from a method other than:</p> <pre><code>BaseClass::variable </code></pre> <p><strong>EDIT</strong> <br>As it so happens, I found a page that explained this issue using functions instead: <a href="http://www.parashift.com/c++-faq-lite/te...
<p>If the base class member variable is protected or public than you can just refer to it by name in any member function of the derived class. If it is private to the base class the compiler will not let the derived class access it at all. Example:</p> <pre><code> class Base { protected: int a; private: int b; ...
<p>Related: <a href="https://stackoverflow.com/questions/180601/using-super-in-c">Using “super” in C++</a></p>
29,809
<p>I've been trying desperately to get my application (15 C# dlls and 1 C++/CLI dll with C++ Runtime DLL dependencies) to deploy with ClickOnce. I got it to work by <a href="http://msdn.microsoft.com/en-us/library/ms235291(VS.80).aspx" rel="nofollow noreferrer">just copying the Release folder</a>, but ClickOnce refuses...
<p>I'm stupid: I just found this:</p> <p>On Publish tab of Properties page of my startup project: click Prerequisites... button > check Visual C++ Runtime Libraries, radio button setting: Download prerequisites from the component vendor's web site.</p> <p>It seems to work the way one might expect!</p>
<p>There should be a msi from microsoft that deploys those for you. I used....</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms235299(VS.80).aspx" rel="nofollow noreferrer">instructions</a></p> <p>and download vcredist_x86.exe<a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=32BC1BEE-A3F9-4...
26,303
<p>I'm a total newbie, but I was writing a little program that worked on strings in C# and I noticed that if I did a few things differently, the code executed significantly faster.</p> <p>So it had me wondering, how do you go about clocking your code's execution speed? Are there any (free)utilities? Do you go about it...
<p>What you are describing is known as performance profiling. There are many programs you can get to do this such as <a href="http://www.jetbrains.com/profiler/" rel="noreferrer">Jetbrains profiler</a> or <a href="http://www.red-gate.com/products/ants_profiler/index.htm" rel="noreferrer">Ants profiler</a>, although mos...
<p>I do the following things: 1) I use ticks (e.g. in VB.Net Now.ticks) for measuring the current time. I subtract the starting ticks from the finished ticks value and divide by TimeSpan.TicksPerSecond to get how many seconds it took. 2) I avoid UI operations (like console.writeline). 3) I run the code over a substant...
14,346
<p>Can I write to the end of a 5GB file in Java? This question came up in my office and no one is sure what the answer is.</p>
<p>This should be possible fairly easily using a <a href="http://java.sun.com/javase/6/docs/api/java/io/RandomAccessFile.html" rel="noreferrer">RandomAccessFile</a>. Something like the following should work:</p> <pre><code>String filename; RandomAccessFile myFile = new RandomAccessFile(filename, "rw"); // Set write...
<p>5GB? I wonder if the OS is a bigger problem, but that's doubtful.</p> <p>In theory, you can just open the file in append mode.</p> <pre><code>OutputStream in = new java.io.FileOutputStream(fileName, true); </code></pre> <p>and write till the filesystem fills up.</p> <p>See <a href="https://stackoverflow.com/ques...
43,976
<p>"C Interfaces and Implementations" shows some interesting usage patterns for data structures, but I am sure there are others out there.</p> <p><a href="https://rads.stackoverflow.com/amzn/click/com/0201498413" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/Interfaces-Implementations-Tech...
<p>Look at the Goddard Space Flight Center (NASA) C coding standard (at this <a href="http://software.gsfc.nasa.gov/assetsbytype.cfm?TypeAsset=Standard" rel="nofollow noreferrer">URL</a>). It has some good and interesting guidelines.</p> <p>One specific guideline, which I've adopted for my own code, is that headers s...
<p><a href="http://www.hwaci.com/sw/mkhdr/" rel="nofollow noreferrer">Makeheaders</a> is an interesting approach: use a tool to generate the headers. Makeheaders is used in D. R. Hipp's <a href="http://www.cvstrac.org/" rel="nofollow noreferrer">cvstrac</a> and <a href="http://www.fossil-scm.org/index.html/doc/tip/www/...
31,980
<p>Im looking to build a thread manager for an application.</p> <p>I have already started threading and it works entirely fine but I would like to be able to programatically kill them or get information on them.</p> <p>Does anyone have ideas?</p>
<p>Just one quick word of warning: don't use <code>Thread.Abort</code> unless you're really shutting down the whole application (or you're calling it from the thread you're aborting, in which case you know what the thread's doing at the time). If you really want to be able to "kill" threads, I'd advise a fairly "soft" ...
<p>Killing threads harshly: not a good idea. You should almost always communicate with a thread (even a simple volatile bit-flag would do), and let the thread commit suicide. Killing it is very risky, and can leave locks on objects etc.</p> <p>For the more general case - have you heard of <a href="http://blogs.msdn.co...
29,523