instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Does anyone know of a good way to display hierarchical data with columns?</p> <p>It has to be virtualizing, as it must be able to handle several million records. </p> <p>It should also be multi-select, most treeview controls are not. </p> <p>Winforms preferred, but will ElementHost WPF if necessary.</p>
<p>I'm not quite clear what you mean about hierarchical data with columns, can you clarify? One possibility is the new WPF DataGrid. Depending on the functionality you're looking for it <em>may</em> be what you're looking for.</p> <p>The bits for datagrid are available on codeplex: <a href="http://www.codeplex.com/wpf...
<p>Take a look at the Infragistics UltraWinGrid, here's a video that demos some features: <a href="http://www.infragistics.com/howto/wingrid.aspx" rel="nofollow noreferrer">http://www.infragistics.com/howto/wingrid.aspx</a></p>
9,246
<p>I have been googling for a good time on how to move a file with c# using the TFS API. The idea is to have a folder on which the developers drop database upgrade scripts and the build process get's to the folder creates a build script and moves all the files on the folder to a new folder with the database build versi...
<p>Its pretty simple :).</p> <pre><code>Microsoft.TeamFoundation.VersionControl.Client.Workspace workspace = GetMyTfsWorkspace(); workspace.PendRename( oldPath, newPath ); </code></pre> <p>Then you need CheckIn it of course. Use a "workspace.GetPendingChanges()" and "workspace.CheckIn()" methods to do it.</p>
<p>Here's a quick and dirty code sample that should get you most of the way there. </p> <pre><code>using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; public void MoveFile( string tfsServer, string oldPath, string newPath ) { TeamFoundationServer server = TeamFoundation...
17,937
<p>I have an offline paper based form. I need to convert it into a software that people can use on their computers to fill and submit information. Since the form (it is a tax return) requires considerable time in filling, it is not convenient to have it online. I would much rather have a simple exe which gathers inform...
<p>There are many Windows programs that can take paper forms and convert them to electronic forms people can fill out, including Acrobat, Form Pilot, and OmniForm.</p> <p><a href="http://www.nuance.com/omniform/" rel="nofollow noreferrer">OmniForm</a> may be good for you, as it allows things like calculated fields, an...
<p>True, you get an exe during compile of a Windows.Forms application, only check the bin folder of the project.</p> <p>You can check the output in Project/Properties/Application/Output type in Visual Studio.</p> <p>This is a little bit offtopic: you cound create to a native image, with <a href="http://msdn.microsoft...
38,687
<p>When does java let go of a connections to a URL? I don't see a close() method on either URL or URLConnection so does it free up the connection as soon as the request finishes? I'm mainly asking to see if I need to do any clean up in an exception handler.</p> <pre><code>try { URL url = new URL("http://foo.bar"); ...
<p>It depends on the specific protocol specified in the protocol. Some maintain persistent connections, other close their connections when your call close in the input or outputstream given by the connection. But other than remembering to closing the streams you opened from the URLConnection, there is nothing else you ...
<p>I had to download several hunders of files at a time and meet the problem.</p> <p>You may check your app's open descriptors with the following command:</p> <pre><code>adb shell ps </code></pre> <p>Find your application PID in the list and use another command:</p> <pre><code>adb shell run-as YOUR_PACKAGE_NAME ls -l ...
34,367
<p>Very basic question: how do I write a <code>short</code> literal in C++?</p> <p>I know the following:</p> <ul> <li><code>2</code> is an <code>int</code></li> <li><code>2U</code> is an <code>unsigned int</code></li> <li><code>2L</code> is a <code>long</code></li> <li><code>2LL</code> is a <code>long long</code></li...
<pre><code>((short)2) </code></pre> <p>Yeah, it's not strictly a short literal, more of a casted-int, but the behaviour is the same and I think there isn't a direct way of doing it.</p> <blockquote> <p>That's what I've been doing because I couldn't find anything about it. I would guess that the compiler would be sm...
<p>As far as I know, you don't, there's no such suffix. Most compilers will warn if an integer literal is too large to fit in whatever variable you're trying to store it in, though.</p>
25,570
<p>I have several user drawn controls on a form, unfortunately when the form is shown the user drawn controls are showing the previous forms background rather than the current forms background. </p> <p>The OnPaint event is very simple, and the OnBackgroundPaint event is empty... </p> <p>Like this:</p> <pre><code> ...
<p>Ruby performs shell expansion when %x is used with a single argument (like you are doing).</p> <p>Here's my guess as to what is going on:</p> <p>Ruby scans the command to determine if there are any special characters that would result in the need to perform shell expansion, if so it calls the shell to do that. In...
<p>I went through this situation by developing an asynchronous processor work that has a series of subprocesses(fork), and it happened when the master was in the foreground and received a SIGINT.</p> <p>I run: puts "the result is %(monster-delayed-job)"</p> <p>and the output was only: "the result is "</p> <ul> <li>Y...
26,335
<p>I quite like the drag and drop pluggable programming blocks in scratch ( <a href="http://scratch.mit.edu/" rel="nofollow noreferrer">http://scratch.mit.edu/</a> )</p> <p>I'd like to be able to get users to create their own mini scripts using the same kind of technique...</p> <p>just wondering if anyone knows of ...
<p>Maybe <a href="http://msdn.microsoft.com/en-us/netframework/aa663328.aspx" rel="nofollow noreferrer">Windows Workflow Foundation</a> is something for you. You can <a href="http://msdn.microsoft.com/nl-be/library/cc835242(en-us).aspx" rel="nofollow noreferrer">host the designer</a> in your own application. So end-use...
<p>It's not .NET, but have you looked at Alice? (<a href="http://www.alice.org/" rel="nofollow noreferrer">http://www.alice.org/</a>)</p>
9,441
<p>I am using .Net framework 2.0 / jQuery to make an Ajax call to a 2.0 web service. No matter what I set the contentType to in the ajax call, the service always returns XML. I want it to return Json!</p> <p>Here is the call:</p> <pre><code> $(document).ready(function() { $.ajax({ type: "POS...
<p>It's no problem to <a href="http://encosia.com/2010/03/08/asmx-scriptservice-mistakes-installation-and-configuration/" rel="noreferrer">return JSON from ASMX services in ASP.NET 2.0</a>. You just need the ASP.NET AJAX Extensions installed.</p> <p>Do be sure to add the [ScriptService] decoration to your web service....
<p>I may not be 100% correct on this but I'm sure .net webservices are XML/SOAP based.</p> <p>You would need to override the default behavior of the webservice. I'm not entirely sure that this would even be possible.</p> <p>I know this won't be the most useful answer, but may get you headed in the right direction.</p...
36,775
<p>I have this code</p> <pre><code> protected void btnUpdateAddress_Click(object sender, EventArgs e) { sdsAddressComparison.Update(); } </code></pre> <p>that I'm using to update an oracle database. When I run the update sql code in SQL Navigator I have to type "Commit" or hit the commit button.<...
<p>Normally, No you do not need the commit.</p> <p>However you can write the code to use a transaction, and at the completion of the transaction you can call commit.</p> <p><strong>E.G. (Regular):</strong></p> <pre><code>try {         // Open connection         dbConn.Open();         //DB Update Code Here     }     ...
<p>Just for clarification....I'm not talking about SQL Server transactions ....I'm talking about Oracle updates which usually require a commit command when I use either SQL navigator or SQL Plus</p> <p>The reason i'm posting this is because I can update this data in SQL Navigator but it doesn't update when I use ASP.N...
43,469
<p>I have used fork() in C to start another process. How do I start a new thread?</p>
<p>Since you mentioned fork() I assume you're on a Unix-like system, in which case <a href="http://en.wikipedia.org/wiki/POSIX_Threads" rel="noreferrer">POSIX threads</a> (usually referred to as pthreads) are what you want to use.</p> <p>Specifically, pthread_create() is the function you need to create a new thread. I...
<p>Check out the <a href="https://computing.llnl.gov/tutorials/pthreads/" rel="nofollow noreferrer">pthread</a> (POSIX thread) library.</p>
8,091
<p>this is a bit of a philosophical question. I am adding a small feature to my software which I assume will be used by most users but only maybe 10% of the times they use the software. In other words, the software has been fine without it for 3 months, but 4 or 5 users have asked for it, and I agree that it should be ...
<p>Make sure people know, that you know, that there are problems. That there are bugs. And give them an easy way to proide feedback.</p> <p>What about having a "closed beta" with the "4 or 5 users" who suggested the feature in the first place?</p>
<p>If it doesn't break anything else, why not ship it? It sounds like you have a good relationship with your customers, so those who want the feature will be happy to get it even if it's not all the way there, and those who don't want it won't care. Plus you'll get lots of feedback to improve it in the next release!</...
11,394
<p>How to detect the Internet connection is offline in JavaScript?</p>
<p>You can determine that the connection is lost by making <strong>failed XHR requests</strong>.</p> <p>The standard approach is to <strong>retry the request</strong> a few times. If it doesn't go through, <strong>alert the user</strong> to check the connection, and <strong>fail gracefully</strong>.</p> <p><strong>S...
<p>Here is a snippet of a helper utility I have. This is namespaced javascript:</p> <pre><code>network: function() { var state = navigator.onLine ? "online" : "offline"; return state; } </code></pre> <p>You should use this with method detection else fire off an 'alternative' way of doing this. The time is fas...
22,974
<p>I am sure there is a simple answer to this one.</p> <p>I have a docx file that I get an error when trying to download(document cannot be found).... .doc is fine .txt is also fine. I am sure this is just an iis setting, the permissions on the server are all the same for all files. </p>
<p>Yes, it's just an IIS setting: by default, <a href="http://support.microsoft.com/kb/326965" rel="noreferrer">it will only serve files for which the extension matches a defined MIME type</a>.</p> <p>To allow .docx files to be downloaded, follow the steps from the KB article linked above:</p> <ol> <li>Open the IIS M...
<p>When there is no mime type associated with an extension in IIS (6.0 and up), it will give you 404. See <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/deeac9ef-cf55-4acd-86ce-b46022ff5479.mspx" rel="nofollow noreferrer">Requests for static files return 404 error (IIS 6.0)</a>. (<s...
21,623
<p>I'm not sure if the term's actually "Array Addition". </p> <p>I'm trying to understand what does the following line do:</p> <pre><code>int var[2 + 1] = {2, 1}; </code></pre> <p>How is that different from <code>int var[3]</code>?</p> <p>I've been using Java for several years, so I'd appreciate if explained using ...
<p>It's not different. C++ allows expressions (even non-constant expressions) in the subscripts of array declarations (with some limitations; anything other than the initial subscript on a multi-dimensional array must be constant).</p> <pre>int var[]; // illegal int var[] = {2,1}; // automatically sized to 2 int va...
<blockquote> <p>How is that different from <code>int var[3]</code>?</p> </blockquote> <p>In no way that I can see.</p>
19,275
<p>I know this question had been asked more than a few times, but so far I haven't been able to find a good solution for it.</p> <p>I've got a panel with other control on it.<br> I want to draw a line on it and on top of all the controls in the panel</p> <p>I came across 3 types of solutions (non of them worked the w...
<p>Turns out this is a whole lot easier than I thought. Thanks for not accepting any of my other answers. Here is the two-step process for creating a <strong>Fline</strong> (<strong>f</strong>loating <strong>line</strong> - sorry, it's late):</p> <p><a href="https://i.stack.imgur.com/MG0Lw.jpg" rel="nofollow norefer...
<p>I think the best way is to inherit the control of which you want to draw a line on. Override the OnPaint method, call base.Paint() from within, after that draw the line using the same graphic instance. At the same time, you can also have a parameter which specific at which point the line should be draw, so that you ...
35,832
<p>In our organization, we have the following problem. We want to have our web tree revision-controlled, but many of us want to be able to alter (and check in) any file of that tree. We would also like there to be only a single check-out for all this because the tree is rather huge. For parts of that tree, we are curre...
<p>Are the developers not on their own machines? Is the tree so huge that it must be checked-out onto a shared network drive on a server, since it doesn't fit on individual developers' workstations? I think this question needs some numbers to clarify the problems and reasoning behind it further.</p>
<p>I'd suggest that you use one special account for the web tree which all developers have access to, and check out the web tree as that user.</p>
37,751
<p>I am using an XmlDocument to parse and manipulate an XHTML string, converting some nodes to non-HTML nodes.</p> <p>What is the best way to get a list of all nodes with a given class name? Can it be done with XPath?</p>
<p>With a given class? If it is just the one class, then you should be able to do something like .SelectNodes("//*[@class='foo']"). If it isn't xhtml, then the <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow noreferrer">HTML Agility Pack</a> is worth looking at.</p> <p>At the client, jQuery would be a ...
<p>Yes, it's easy with XPath:</p> <pre><code>//*[@class='foo'] </code></pre>
32,292
<p>I have a small program that is installed in a custom folder in the program files, but when I tried to read or write to files that are needed to operate, the program raises an Access Denied Exeption. How can I elevte the program, with the user's permission of course.</p>
<p>I guess you're running under Vista? In Vista I don't think you're allowed to read/write to files under Program Files, you should put your data files in Documents and Settings instead.</p>
<p>You can do everything you need using the <strong>ClickOnce APIs</strong>. If you have multiple parts (e.g., more than one EXE) then you need to include them in your package.</p> <p>The only scenario not supported (by ClickOnce) as far as I know are authenticating proxies.</p>
38,161
<p>I need to index a whole lot of webpages, what good webcrawler utilities are there? I'm preferably after something that .NET can talk to, but that's not a showstopper.</p> <p>What I really need is something that I can give a site url to &amp; it will follow every link and store the content for indexing.</p>
<p>HTTrack -- <a href="http://www.httrack.com/" rel="noreferrer">http://www.httrack.com/</a> -- is a very good Website copier. Works pretty good. Have been using it for a long time.</p> <p>Nutch is a web crawler(crawler is the type of program you're looking for) -- <a href="http://lucene.apache.org/nutch/" rel="norefe...
<p>I haven't used this yet, but <a href="http://www.vsj.co.uk/dotnet/display.asp?id=407" rel="nofollow noreferrer">this</a> looks interesting. The author wrote it from scratch and posted how he did. The code for it is available for download as well.</p>
21,294
<p>Ok, so I'm an idiot. </p> <p>So I was working on a regex that took way to long to craft. After perfecting it, I upgraded my work machine with a blazing fast hard drive and realized that I never saved the regex anywhere and simply used RegexBuddy's autosave to store it. Dumb dumb dumb. </p> <p>I sent a copy of ...
<p>On my XP box, it was in the registry here:</p> <pre><code>HKEY_CURRENT_USER\Software\JGsoft\RegexBuddy3\History </code></pre> <p>There were two REG_BINARY keys called <strong>Action0</strong> and <strong>Action1</strong> that had hex data containing my two regexes from the history.</p> <p><img src="https://i.stac...
<p>It depends on the OS, of cause, but on Windows I would guess the application data directory. I can't remember the path on xp but on vista it's something like this:</p> <p>C:\Users\ <em>user name</em> \AppData\</p> <p>And then it would probably be here:</p> <p>C:\Users\ <em>user name</em> \AppData\roaming</p>
7,885
<p>How can I determine all of the assemblies that my .NET desktop application has loaded? I'd like to put them in the about box so I can query customers over the phone to determine what version of XYZ they have on their PC.</p> <p>It would be nice to see both managed and unmanaged assemblies. I realize the list will...
<pre><code>using System; using System.Reflection; using System.Windows.Forms; public class MyAppDomain { public static void Main(string[] args) { AppDomain ad = AppDomain.CurrentDomain; Assembly[] loadedAssemblies = ad.GetAssemblies(); Console.WriteLine("Here are the assemblies loaded in this appdomai...
<p>Looks like <code>AppDomain.CurrentDomain.GetAssemblies();</code> will do the trick :)</p>
4,134
<p>I'm using TopLink as my ORM and MySQL as the DB.</p> <p>I traded my auto-increment primary keys for GUIDs for one of my tables (alright, not quite: I'm actually using a random 64 bit integer, but that's good enough for my needs).</p> <p>Anyway, now queries, which don't even use the key, are taking much longer.</p>...
<p>If your table is indexed by the fields your are querying by. content of the key shouldn't have any noticeable performance impact. They maybe something else there .</p>
<blockquote> <p>i have a field that represents the creationDate. how can i force my table to be index accordingly?</p> </blockquote> <pre><code>create index Table_creationDate on Table(creationDate); </code></pre>
44,985
<p>I want to be able to access custom URLs with apache httpclient. Something like this:</p> <pre><code>HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("media:///squishy.jpg"); int statusCode = client.executeMethod(method); </code></pre> <p>Can I somehow register a custom URL handler? Or should...
<p>I don't think there's a way to do this in commons httpclient. It doesn't make a whole lot of sense either, after all it is a HTTP client and "media:///squishy.jpg" is not HTTP, so all the code to implement the HTTP protocol probably couldn't be used anyways.</p> <pre><code>URL.setURLStreamHandlerFactory(...) </code...
<p>I don't think there's a way to do this in commons httpclient. It doesn't make a whole lot of sense either, after all it is a HTTP client and "media:///squishy.jpg" is not HTTP, so all the code to implement the HTTP protocol probably couldn't be used anyways.</p> <pre><code>URL.setURLStreamHandlerFactory(...) </code...
17,875
<p>When I disable ViewState for the page. It does not allow any other control to use ViewState .. even if I set EnableViewState="true" for that particular control ..</p> <p>is it possible to enable ViewState for a control when ViewState is disabled for the page itself?</p> <p>if not how can disable viewstate for cont...
<p>If you set turn page's ViewState off, then there is no way for you to enable ViewState for specific components. This is because ViewState is serialzed recursively, so when if the Page is not allowing ViewState, it will not serialize the ViewState for any of it's child controls.</p> <p>In answer to your question, if...
<p>You could also inherit from a BasePage. On the BasePage disable ViewState.</p> <pre><code>/// &lt;summary&gt; /// All pages inherit this page /// &lt;/summary&gt; public class BasePage : System.Web.UI.Page { protected override void OnLoad(EventArgs e) { base.OnLoad(e); } public bool ViewState...
22,597
<p>For standard ABS and PLA filament, most distributors recommend storing the filament in an airtight bag. Does not doing this actually make print quality worse? I have left mine in the open for a year and have had no noticeable problems.</p>
<p>It makes a difference where I live, and I'm not in a particularly humid climate (California). When printing with wet filament, you'll sometimes hear it popping and see steam coming out of the extruder (it's usually only this extreme with nylon). With most other filaments, when they're wet, the extruded filament wi...
<p>I haven't had any other issues storing it in the open, but keeping it in an airtight environment (especially if you live in a humid environment) keeps it moisture free, which can effect print quality. Manufacturers recommend this to help keep filament dry.</p>
107
<p>I'm trying to select a specific HTML element in a document, for firefox i just use:</p> <pre><code>xpathobj = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); </code></pre> <p>which works fine. However when I try the IE equivilent:</p> <pre><code>xmlDoc=new Activ...
<p>Take a look at <a href="http://dev.abiss.gr/sarissa/" rel="nofollow noreferrer">http://dev.abiss.gr/sarissa/</a> project. They have migrated most of XML-related APIs to IE. Otherwise it is indeed also easy to implement. The problems you would need to solve would be: serialization of HTML into valid XML, syncing resu...
<p>Are you sure X-Path is implemented in your version of Internet Explorer? As in: what version are you using?</p>
21,454
<p>I've decided to make a big push towards MVC for all new sites I make. I have a question about whether or not you can have any processing on the model level.</p> <p>The case that brought up this question is a video site. I have a Video class (model) and one of the things I need to do when a user views the video I ...
<p>Ruby on Rails has the motto <a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model" rel="nofollow noreferrer">skinny controller, fat model</a>. This doesn't apply to just Rails and should be practiced with any mvc framework.</p>
<p>Keep in mind, there are many variations on MVC and no real "right way" to do things. Ultimately, how you design your classes comes down to personal preference. However, since you asked for design advice, here are my two cents:</p> <p><strong>Business logic belongs in the controller. Keep it out of the model and vie...
42,715
<p>Is there a way to programmatically change the screen resolution or enable/disable multiple monitors in Windows XP? For example to change from 1024x768 with one monitor to 1280x1024 on two monitors? I would be most interested in a win32 function to do this but anything that can be tied to a windows shortcut would s...
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/dd162609.aspx" rel="noreferrer">EnumDisplayDevices</a> to figure out what displays you have available and <a href="http://msdn.microsoft.com/en-us/library/dd162611.aspx" rel="noreferrer">EnumDisplaySettings</a> to get a list of available resolutions for yo...
<p>You can easily script this with <a href="http://www.autohotkey.com" rel="nofollow">http://www.autohotkey.com</a></p> <p>Here's a script for swapping between one monitor and two monitors with Windows+1 and Windows+2</p> <pre><code>#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releas...
26,475
<p>Does anybody know what's going on here:</p> <p>I run hibernate 3.2.6 against a PostgreSQL 8.3 (installed via fink) database on my Mac OS X. The setup works fine when I use Java 6 and the JDBC 4 driver (postgresql-8.3-603.jdbc4). However, I need this stuff to work with Java 5 and (hence) JDBC 3 (postgresql-8.3-603.j...
<p>I don't see you specifying the driver class in your Hibernate configuration. Try adding the following:</p> <pre><code>&lt;hibernate-configuration&gt; &lt;session-factory&gt; . . &lt;property name="connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt; . &lt;/sessi...
<p>did you notice that the connection url is incomplete</p> <pre><code>&lt;property name="connection.url"&gt;jdbc:postgresql:test&lt;/property&gt; </code></pre> <p>as opposed to </p> <pre><code>&lt;property name="connection.url"&gt;jdbc:postgresql://localhost/test&lt;/property&gt; </code></pre>
34,413
<p>Inspired by this <a href="https://stackoverflow.com/questions/283561/extracting-leaf-paths-from-n-ary-tree-in-f">question</a> and <a href="https://stackoverflow.com/questions/283561/extracting-leaf-paths-from-n-ary-tree-in-f#283638">answer</a>, how do I create a generic permutations algorithm in F#? Google doesn't ...
<p>you can also write something like this:</p> <pre><code>let rec permutations list taken = seq { if Set.count taken = List.length list then yield [] else for l in list do if not (Set.contains l taken) then for perm in permutations list (Set.add l taken) do yield l::per...
<p>If you need permutations with repetitions, this is the "by the book" approach using List.indexed instead of element comparison to filter out elements while constructing a permutation.</p> <pre><code>let permutations s = let rec perm perms carry rem = match rem with | [] -&gt; carry::perms ...
36,399
<p>I need to store the user's password in my iphone app. </p> <p>When posting an app to the app store, I have to tell Apple if there's encryption in the app for export purposes.</p> <p>I don't want my app to be restricted to US only, but I also don't want to store or send passwords over the net in clear text.</p> <p...
<p>Looks like the supplied crypt() function can be used for passwords:</p> <blockquote> <p>This library (FreeSec 1.0) was developed outside the United States of America as an unencumbered replacement for the U.S.only libcrypt encryption library. Programs linked against the crypt() interface may be exported from the...
<p>First, if the user name and password are encrypted and decrypted on the phone, then the decryption key is obviously also on the phone and pretty much worthless. I wouldn't worry about storing user names and passwords encrypted on the phone.</p> <p>For secure communication, you should use SSL which is probably in a ...
23,045
<p>Real strange.</p> <p>I cannot find a tool that enables one to display a SVN repository in graphical form.<br /> I would like the ability to see changes in revision / time , branch / time graphs.</p> <p>Does anyone know of one. <strong>Ideally it would be platform neutral or even better web based</strong>.</p> <p>Sol...
<p><a href="http://www.atlassian.com/software/fisheye/" rel="noreferrer">Fisheye</a>, from Atlassian, looks at an SVN repository and can show you a few graphs. Also provides a handy web interface for blame, diff, etc.</p> <p>for example, some sample images at <a href="http://fisheye2.atlassian.com/chart/~charttype=Pie...
<p>You could also try <a href="http://mpy-svn-stats.berlios.de/" rel="nofollow noreferrer">MPY SVN STATS</a>. <a href="http://mpy-svn-stats.berlios.de/zope-stats/" rel="nofollow noreferrer">Here</a> is an example graph for Zope.</p>
3,407
<p>Where can documentation be found for the features of GDB, and the debugging process, specific to debugging of Cell Linux programs mixing PPU and SPU code?</p>
<p>Documents at the IBM developerWorks site for Cell can be found here: <a href="http://www.ibm.com/developerworks/power/cell/documents.html?S_TACT=105AGX16&amp;S_CMP=LP" rel="nofollow noreferrer">Cell @developerWorks</a></p> <p>You sound like you'd want the <a href="http://www.ibm.com/chips/techlib/techlib.nsf/techdo...
<p>One comprehensive overview seems to be here <a href="http://www.redbooks.ibm.com/redpieces/abstracts/sg247575.html?Open" rel="nofollow noreferrer">http://www.redbooks.ibm.com/redpieces/abstracts/sg247575.html?Open</a></p>
19,530
<p><code>celsius = (5.0/9.0) * (fahr-32.0);</code></p> <p>Is it just a development choice that the C developers decided upon or is there a reason to this? I believe a float is smaller than a double, so it might be to prevent overflows caused by not knowing what decimal format to use. Is that the reason, or am I overlo...
<pre><code>celsius = (5.0/9.0) * (fahr-32.0); </code></pre> <p>In this expression, <code>5.0</code>, <code>9.0</code>, and <code>32.0</code> are <code>double</code>s. That's the default type for a floating-point constant - if you wanted them to be <code>float</code>s, then you would use the <code>F</code> suffix:</p> ...
<p>Floating point constants should have the available highest precision. The result can be assigned to a float without undue trouble.</p>
5,912
<p>I've writen an Excel-based, database reporting tool. Currentely, all the VBA code is associated with a single XLS file. The user generates the report by clicking a button on the toolbar. Unfortunately, unless the user has saved the file under another file name, all the reported data gets wiped-out.</p> <p>When I ha...
<p>You can modify the user's personal.xls file, stored in the excel startup directory (varies between Office versions). If you have lots of users though, that can be fiddly.</p> <p>An alternative way to get over your problem is to store the macro in a template (.xlt) file. Then when the users opens it they can't save ...
<p>Have you looked into ClickOnce deploying the Excel file?</p>
4,929
<p>Does anyone know how bash handles sending data through pipes?</p> <pre><code>cat file.txt | tail -20 </code></pre> <p>Does this command print all the contents of file.txt into a buffer, which is then read by tail? Or does this command, say, print the contents of file.txt line by line, and then pause at each line f...
<p>I decided to write a slightly more detailed explanation.</p> <p>The "magic" here lies in the operating system. Both programs do start up at roughly the same time, and run at the same time (the operating system assigns them slices of time on the processor to run) as every other simultaneously running process on your...
<p>cat will just print the data to standard out, which happens to be redirected to the standard in of tail. This can be seen in the man page of bash.</p> <p>In other words, there is no pausing going on, tail is just reading from standard in and cat is just writing to standard out.</p>
3,960
<p>When using copy-on-write semantics to share memory among processes, how can you test if a memory page is writable or if it is marked as read-only? Can this be done by calling a specific assembler code, or reading a certain spot in memory, or through the OS's API?</p>
<p>On Linux you can examine /proc/<em>pid</em>/maps:</p> <pre><code>$ cat /proc/self/maps 002b3000-002cc000 r-xp 00000000 68:01 143009 /lib/ld-2.5.so 002cc000-002cd000 r-xp 00018000 68:01 143009 /lib/ld-2.5.so 002cd000-002ce000 rwxp 00019000 68:01 143009 /lib/ld-2.5.so 002d0000-00407000 r-xp 00000000 68:01 1430...
<p>If you're using Win32, there are the calls IsBadReadPtr and IsBadWritePtr. However, their use is discouraged:</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb871031.aspx" rel="nofollow noreferrer">"The general consensus is that the IsBad family of functions (IsBadReadPtr, IsBadWritePtr, and so forth) is ...
31,995
<p>From <a href="http://en.wikipedia.org/wiki/Generic_programming" rel="noreferrer">Wikipedia</a>: </p> <blockquote> <p>Generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types pr...
<p>C# and VB have generics to take advantage of generics support in the underlying CLR (or is the other way around?). They allow you to write code ina statically-typed language that can apply to more than one kind of type without rewriting the code for each type you use them for (the runtime will do that for you) or o...
<p>The common example is collections. e.g. a set of type T, as an Add(T) method and a T get() method. Same code, different type safe collections.</p> <p>C++, D, Ada and others have templates, a superset of generics that do it a little different bug get the same end result (and then some).</p> <p>IIRC Java has generic...
12,490
<p>I have a 2D image randomly and sparsely scattered with pixels.<br> given a point on the image, I need to find the distance to the closest pixel that is not in the background color (black).<br> What is the fastest way to do this? </p> <p>The only method I could come up with is building a kd-tree for the pixels. but...
<p>As Pyro says, search the perimeter of a square that you keep moving out one pixel at a time from your original point (i.e. increasing the width and height by two pixels at a time). When you hit a non-black pixel, you calculate the distance (this is your first expensive calculation) and then continue searching outwa...
<p>I would do a simple lookup table - for every pixel, precalculate distance to the closest non-black pixel and store the value in the same offset as the corresponding pixel. Of course, this way you will need more memory.</p>
39,569
<p>I'm trying to run some commands in paralel, in background, using bash. Here's what I'm trying to do:</p> <pre><code>forloop { //this part is actually written in perl //call command sequence print `touch .file1.lock; cp bigfile1 /destination; rm .file1.lock;`; } </code></pre> <p>The part between backticks (``...
<p>I haven't tested this but how about</p> <pre><code>print `(touch .file1.lock; cp bigfile1 /destination; rm .file1.lock;) &amp;`; </code></pre> <p>The parentheses mean execute in a subshell but that shouldn't hurt.</p>
<p>Just in case that someone is still interested, you can do it without calling a subshell like this:</p> <pre><code>print `touch .file1.lock &amp;&amp; cp bigfile1 /destination &amp;&amp; rm .file1.lock &amp;`; </code></pre>
19,494
<p>Is there a limit to the length of a GET request?</p>
<p>Not in the <a href="http://www.faqs.org/rfcs/rfc2068.html" rel="noreferrer">RFC</a>, no, but there are practical limits.</p> <p><em>The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbo...
<p>setFixedLengthStreamingMode(int) with contentLength parameters could set the fixed length of a HTTP request body.</p>
33,390
<p>When running performance tests file system cache hit or miss can significantly influence test results. Therefore generally before running such tests used files are evicted from system cache. How to do that on Linux?</p> <p><strong>Clarification:</strong> If possible, the solution should not require root privileges....
<p>As a superuser you can do the following:</p> <p>To free pagecache:</p> <ul> <li>echo 1 > /proc/sys/vm/drop_caches</li> </ul> <p>To free dentries and inodes:</p> <ul> <li>echo 2 > /proc/sys/vm/drop_caches</li> </ul> <p>To free pagecache, dentries and inodes:</p> <ul> <li>echo 3 > /proc/sys/vm/drop_caches</li> <...
<p>If you can put the test data in a separate filesystem then mounting the filesystem afresh for the test will give you empty caches.</p> <p>If you list the test fileystem in /etc/fstab with the "user" option then you can mount it for the test without being superuser</p>
19,577
<p>Let say I run this command:</p> <pre><code>makecert testcert.cer </code></pre> <p>Is a private key created? If so, where is it automatically stored in the system even though I did not tell makecert to install this certificate in any certificate store?</p>
<p>It looks like the private key is stored in the file itself. From the documentation at <a href="http://msdn.microsoft.com/en-us/library/bfsktky3(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bfsktky3(VS.80).aspx</a> it states...</p> <p>Caution<br> You should use a certificate store ...
<p>The private key is not created because I HasPrivateKey of X509Certificate2 is set to false when I load the certificate in .NET.</p>
28,785
<p>I am having a very hard time finding a standard pattern / best practice that deals with rendering child controls inside a composite based on a property value.</p> <p>Here is a basic scenario. I have a Composite Control that has two child controls, a textbox and a dropdown. Lets say there is a property that toggles ...
<p>You use ViewState to store property value so that it persists between postbacks but you have to do it <a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/truly-understanding-viewstate.aspx" rel="nofollow noreferrer" title="TRULY Understanding ViewState">correctly</a>.</p> <pre><code>public virtual boo...
<p>I would think something like:</p> <pre><code>public bool ShowDropDown { get{ return (bool)ViewState["ShowDropDown"]; } set{ ViewState["ShowDropDown"]; } } private void Page_Load(object sender, EventArgs e) { DropDaownControl.Visible = ShowDropDown; TextBoxControl.Visible = !ShowDropDown; } /* so...
20,418
<p>I need an OpenSource API in Java, which can encode *.wav and *.au formats to MP3 and vice-versa. </p> <p>I have evaluated Java Sound API and <a href="http://openinnowhere.sourceforge.net/lameonj" rel="noreferrer">LameOnJ</a>, but they do not meet my requirements and are not stable, respectively. Please suggest one ...
<p>There may not be an adequate answer for you, yet, as the MP3 format requires the authors of decoder/encoders to obtain a license from the Fraunhofer Institute. </p> <p>I think the the LAME library is distributed from a country that does not respect these IP issues, but it took a considerably amount of legal hackery...
<p>The <a href="https://github.com/a-schild/jave2" rel="nofollow noreferrer">Jave2 project</a> is Java library that wraps FFMPEG and provides most of its functionality<sup>*</sup> through a rather useful Java API.</p> <p>Pros:</p> <ul> <li>Useful Java API that is powerful and rather simple.</li> <li>FFMPEG binary is ...
40,884
<p>For an iPhone app that submits images to a server I need somehow to tie all the images from a particular phone together. With every submit I'd like to send some unique phone id. Looked at <pre> [[UIDevice mainDevice] uniqueIdentifier]<br> and [[NSUserDefaults standardDefaults] stringForKey:@"SBFormattedPhoneNu...
<p>What errors are you getting? <code>[[UIDevice currentDevice] uniqueIdentifier]</code> (<i>edited to fix API, thanks Martin!</i>) is the officially recommended way of doing this.</p>
<p>Haven't done iphone work, but how about taking a hash of something unique to the phone ... oh, say the phone number?</p> <p><a href="https://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-iphone-os">Getting iphone number</a></p>
28,168
<p>I'd like to hide a div when user click anywhere on the page outside of that div. How can I do that using raw javascript or jQuery?</p>
<p>Attach a click event to the document to hide the div:</p> <pre><code>$(document).click(function(e) { $('#somediv').hide(); }); </code></pre> <p>Attach a click event to the div to stop clicks on it from propagating to the document:</p> <pre><code>$('#somediv').click(function(e) { e.stopPropagation(); }); </c...
<p>It sure sounds like you want a modal dialog. This jQuery plugin <a href="http://code.google.com/p/simplemodal/" rel="nofollow noreferrer">http://code.google.com/p/simplemodal/</a> looks like it has potential.</p>
41,572
<p>I have a windows service that uses log4net. We noticed that the service in question was running painfully slow so we attached a debugger to it and stepped through. It appears that each time it tries to write an entry to the log via log4net that it takes anywhere from 10 to 30 seconds before the next line of code can...
<p>Jeff mentioned a performance problem with Log4Net in <a href="https://blog.stackoverflow.com/2008/09/podcast-20/">Podcast 20</a>. It's possible that you are seeing a similar issue.</p>
<p>I have log4net with adonet appender and have not seen any decremental performance of my windows service. what appender are you using?</p>
35,293
<p>I want to print a flowerpots, for advanced watering system.</p> <p>Plants are going to be eaten.</p> <p>What is the most suitable material, when we consider the fact, that we do not want to just make forms and do clay flowerpots(which may seem most healthier), but having them directly printed.</p> <p>What are the...
<p>If you break up a large piece into multiple smaller pieces and properly glue them together, you basically add stiffeners (as a result of printing walls). This could lead to a more stiff model; this might have been confused by calling large prints more brittle opposed to constructed models.</p> <p>If printing is con...
<p>I'd recommend getting the object to fit together by design, rather than glue - though I tend (if the item is never to be disassembled) use Zap-a-gap - that stuff sticks like crazy though you must not squeeze the parts together but let it naturally sit.</p>
1,353
<p>I have a ListBox that when in focus, and when I have an item selected returns a valid SelectedIndex. If I have a valid SelectedIndex and I click on a TextBox on the same Forum, the SelectedIndex now becomes -1. However I want it to keep its SelectedIndex from changing. How would I go about doing this?</p>
<p>ListBox will keep it's SelectedIndex regardless of focus. <Br></p> <p>I tested it on a blank project with one ListBox, one TextBox and one Label used to display the ListBox's SelectedIndex. Under both the ListBox's SelectedIndexChanged and the TextBox's TextChanged events I updated the Label with the ListBox's Sel...
<p>I haven't verified this in my apps but if the SelectedIndex property changes when the LB loses focus you probably have to handle that case yourself by caching the last selected index and resetting it when the control regains focus. You can do this in the containing form or you can do it in a class derived from ListB...
22,310
<p>So odd situation that I ran into today with OrderBy:</p> <pre><code>Func&lt;SomeClass, int&gt; orderByNumber = currentClass =&gt; currentClass.SomeNumber; </code></pre> <p>Then:</p> <pre><code>someCollection.OrderBy(orderByNumber); </code></pre> <p>This is fine, but I was going to create a method instead ...
<p>Finally! I (partially) solved it:</p> <p>It looks like the CDockablePane parent window indeed caused this problem...</p> <p>First I removed all the tooltip-specific code from the CTreeCtrl-derived class. Everything is done in the parent pane window.</p> <p>Then I edited the parent window's <code>OnCreate()</code>...
<p>Try to specifically handle all tooltip ids:</p> <pre><code>ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, &amp;CMyTreeCtrl::OnNeedTipText) </code></pre> <p>If that doesn't work, you may have to manually call RelayEvent() from PreTranslateMessage().</p>
33,908
<p>In the past I wrote most of my unit tests using C# even when the actual software development was in another .NET language (VB.NET, C++.NET etc.) but I could use VB to get the same results. I guess the only reason I use C# is because most of the examples in the internet are written in C#.</p> <p>I you use unit tests...
<p>You should use what ever language is comfortable for your dev team.</p> <p>I don't see what you would write your unit tests in a language other than the language that the rest of the project is written in as it would have the possibility to cause confusion, or require devs know two different languages to work on th...
<p>I write all my .Net application/business code in C#, so it is quite natural to write the unit tests in C# as well. I think that writing the test code in another language introduces an unnecessary separation between the test code and the application code.</p>
42,682
<p>For example I have a value of 103.33 I want to put 100 to one variable and 33 to another variable. How can I do this? </p> <p>Thanks.</p>
<p>Create two formula fields, eg wholepart and decimalpart.</p> <p>The formula for wholepart is trunc({yourfieldnamehere}) and the formula for decimalpart is {yourfieldnamehere} - trunc({yourfieldnamehere})</p> <p>The value you get in decimalpart is going to be the decimal fraction; if you know it's always going to b...
<p>You can also use the 'Remainder' function to find the number after the decimal point. For example, REMAINDER ({FIELD NAME},1) should give you 0.33</p>
48,939
<p>I have the following class which uses BinaryReader internally and implements IDisposable.</p> <pre> class DisposableClass : IDisposable { private BinaryReader reader; public DisposableClass(Stream stream) { reader = new BinaryReader(stream); } protected virtu...
<p>It won't work because the <code>Dispose</code> method on <code>BinaryReader</code> has been explicitly implemented.</p> <p>Instead of being implicitly implemented, as in:</p> <pre><code>public void Dispose() { } </code></pre> <p>...it has been explicitly implemented, as in:</p> <pre><code>void IDisposable.Dispos...
<p>Actually they have chosen to use Close() instead of Dispose() Dispose has been explicitly implemented. Which is why you can't see it.</p> <p>However Close does the same thing as dispose and this is the method they want you to use. Reflector gives the following disassembly for the Close method</p> <pre><code>public...
27,520
<p>I am developing an OpenGL application and I am seeing some strange things happen. The machine I am testing with is equipped with an NVidia Quadro FX 4600 and it is running RHEL WS 4.3 x86_64 (kernel 2.6.9-34.ELsmp).</p> <p>I've stepped through the application with a debugger and I've noticed that it is hanging on O...
<p>It appears that this is an issue with less-than-perfect NVidia drivers for Linux. Upgrading to a newer kernel appears to help. If I am forced to use this dated kernel, there are some things that I've tried that seem to help.</p> <p>Defining the <code>__GL_YIELD</code> environment variable to <code>&quot;NOTHING&qu...
<p>You may be able to dig deeper by using a system profiler like <a href="http://www.daimi.au.dk/~sandmann/sysprof/" rel="nofollow noreferrer">Sysprof</a> or <a href="http://oprofile.sourceforge.net/news/" rel="nofollow noreferrer">OProfile</a>. Do other OpenGL applications using these calls exhibit similar behavior?</...
48,813
<p>I just started writing tests for a lot of code. There's a bunch of classes with dependencies to the file system, that is they read CSV files, read/write configuration files and so on.</p> <p>Currently the test files are stored in the test directory of the project (it's a Maven2 project) but for several reasons this...
<p>First one should try to <strong>keep the unit tests away from the filesystem</strong> - see this <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=126923" rel="noreferrer">Set of Unit Testing Rules</a>. If possible have your code working with Streams that will be buffers (i.e. in memory) for the unit tests,...
<p>Usually, file system tests aren't very critical: The file system is well understood, easy to set up and to keep stable. Also, accesses are usually pretty fast, so there is no reason per se to shun it or to mock the tests.</p> <p>I suggest that you find out why the directory doesn't exist and make sure that it does....
49,423
<p>I'm writing a global error handling "module" for one of my applications.</p> <p>One of the features I want to have is to be able to easily wrap a function with a <code>try{} catch{}</code> block, so that all calls to that function will automatically have the error handling code that'll call my global logging method...
<p>Personally instead of polluting builtin objects I would go with a decorator technique:</p> <pre><code>var makeSafe = function(fn){ return function(){ try{ return fn.apply(this, arguments); }catch(ex){ ErrorHandler.Exception(ex); } }; }; </code></pre> <p>You can use it like that:</p> <p...
<p>As far as polluting the namespaces, I'm actually going to pollute them some more... Since everything that happens in JS is initiated by an event of some kind, I'm planning to call my magical wrapper function from within the Prototype Event.observe() method, so I don't need to call it everywhere.</p> <p>I do see th...
42,316
<p>I've seen <a href="https://stackoverflow.com/questions/55622/best-tools-for-working-with-docbook-xml-documents">Best tools for working with DocBook XML documents</a>, but my question is slightly different. Which is the currently recommended formatting toolchain - as opposed to editing tool - for XML DocBook?</p> <...
<p>I've been doing some manual writing with DocBook, under cygwin, to produce One Page HTML, Many Pages HTML, CHM and PDF.</p> <p>I installed the following:</p> <ol> <li>The <a href="http://www.docbook.org" rel="nofollow noreferrer">docbook</a> stylesheets (xsl) repository.</li> <li>xmllint, to test if the xml is cor...
<p>I prefer using Windows for most of my content creation (Notepad++ editor). Publican in Linux is a good tool chain to create a good documentation structure and process outputs. I use Dropbox (there are other document sharing services as well, which should work well on both platforms) on my Windows machine as well as ...
14,932
<p>Is it possible to migrate a VB.NET Winform solution to a 3.5 WPF solution. If so, any suggestions how to do it?</p> <p>Thanks in advance! JFV</p>
<p>Microsoft is doing everything for us so that we have to throw away everything we've written 2 years ago. According to Josh Smith, </p> <blockquote> <p>Is there a way to convert Winforms application to a WPF application?</p> </blockquote> <p>No. Those two UI platforms are very different and there is no app which...
<p>There is now a project that does exactly what you ask for. See <a href="http://wf2wpf.codeplex.com/" rel="nofollow noreferrer">Windows Forms to Windows Presentation Foundation Converter</a>. Also, see the <a href="http://video.msn.com/video.aspx?vid=2c995b74-cba6-4307-8bc8-82c9d959235a" rel="nofollow noreferrer">v...
40,383
<p>If <code>UNION ALL</code> is an <em>addition</em> in T-SQL. What is the equivalent of subtraction?</p> <p>For example, if I have a table <code>PEOPLE</code> and a table <code>EMPLOYEES</code>. And I know if I remove <code>EMPLOYEES</code> records from <code>PEOPLE</code> I will be left with my companies <code>CONTR...
<p>Instead of using UNION, use EXCEPT, ( or INTERSECT to get only records in both ) as described in </p> <p><a href="http://msdn.microsoft.com/en-us/library/ms188055.aspx" rel="nofollow noreferrer">msdn EXCEPT Link for Sql2k8</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/ms188055(SQL.90).aspx" rel="nof...
<p>I found it is a lot easier to use a tool like SQLMerger to do this for you. The results are displayed in a nicer way and you can go on with whatever you need to do with the data thereafter easily.</p> <p>www.auisoft.com/SQLMerger &lt;= the tool that makes it easy to compare data</p> <p>example on comparing two tab...
48,641
<p>How to call a javascript file (.js) via Excel VBA?</p> <hr> <p>So as i am opposed to the same kind of problem i'll try to submit you guys my case.</p> <p>I am trying to automate datas extraction from valeo's catalogue using excel vba macro.</p> <p>I have a list of références attached to valeo's automotive produc...
<p>All the previously suggested approaches sound hacky to me. </p> <p>For a more reliable solution, embed the Javascript in a COM component via <a href="http://msdn.microsoft.com/en-us/library/07zhfkh8(VS.85).aspx" rel="nofollow noreferrer">Windows Script Components</a>, and call the Javascript-based COM component as ...
<p>I don't think that there is a direct way to run JavaScript code in VBA. </p> <p>What you could try to do is to embed the JavaScript code in an HTML form which you could open in a (hidden) browser control. Then fill the form controls via the DOM of the browser control and submit the form. The submit triggers the Jav...
44,322
<p>Has anyone ever done work to get Ruby to do continuations (like Seaside on Smalltalk)?</p>
<p>Yes, in most cases. MRI (1.8) have supported them as far as my memory reaches, Ruby 1.9 (YARV) <a href="http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&amp;revision=12380" rel="noreferrer">does it, too</a>, so does Rubinius. JRuby and IronRuby don't have continuations, and it's quite unlikely they will get them...
<p>neverblock uses 1.9 fibers for a single threaded ruby web server</p>
18,023
<p>Is it possible to retrieve items from a Python dictionary in the order that they were inserted?</p>
<p>The standard Python <code>dict</code> does this by default if you're using CPython 3.6+ (or Python 3.7+ for any other implementation of Python).</p> <p>On older versions of Python you can use <a href="https://docs.python.org/library/collections.html#ordereddict-objects" rel="noreferrer"><code>collections.OrderedDic...
<p>if you don't need the dict functionality, and only need to return tuples in the order you've inserted them, wouldn't a queue work better?</p>
8,589
<p>I'm working on a C#.Net application which has a somewhat annoying bug in it. The main window has a number of tabs, each of which has a grid on it. When switching from one tab to another, or selecting a different row in a grid, it does some background processing, and during this the menu flickers as it's redrawn (Fil...
<p>There are calls on classes derived from <code>Control</code> for this purpose. They are <code>SuspendLayout</code> and <code>PerformLayout</code>. As they are on <code>Control</code> and <code>Form</code> is derived from <code>Control</code>, your <code>Form</code> has them too.</p> <p>These calls suffice for most ...
<p>The behavior you're describing is not normal for a .NET winforms application. The fact that you're using WndProc and sending messages in your example suggests that there is a lot of other unusual stuff going on with this form (I'm guessing there's more than one thread involved). Another possibility that is common ...
45,687
<p>In the following, I'd like to alter the CSS such that the <code>right-sibling</code> is <em>truly</em> centered in the <code>container</code> div. (Edit: without using absolute positioning). </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type='text/css'&gt; #container { width: 500px; ...
<p>A trick I just used to get this to work is to have padding on the left of the container and we can encourage the left-sibling to sit inside this space by giving it an equal but negative margin.</p> <p>To complete the picture we also put padding on the right of the container of an equal size to the width of the left...
<p>You can change the <code>float: left;</code> on <code>#left-sibling</code> to <code>position: absolute;</code>. This will take it out of the normal flow, so it won't affect right-sibling any more.</p> <p>Of course, this could have other side-effects with your design.</p>
44,643
<p>I've been programming a long time, and the programs I see, when they run out of memory, attempt to clean up and exit, i.e. fail gracefully. I can't remember the last time I saw one actually attempt to recover and continue operating normally.</p> <p>So much processing relies on being able to successfully allocate me...
<p>It really depends on what you're building.</p> <p>It's not entirely unreasonable for a webserver to fail one request/response pair but then keep on going for further requests. You'd have to be sure that the single failure didn't have detrimental effects on the global state, however - that would be the tricky bit. G...
<p>I have this:</p> <pre><code>void *smalloc(size_t size) { void *mem = null; for(;;) { mem = malloc(size); if(mem == NULL) { sleep(1); } else break; } return mem; } </code></pre> <p>Which has saved a system a few times already. Just because you're out of memory now, doesn't mean some othe...
43,266
<p>Does anyone know of any tools capable of defining a declarative mapping from T-Box structures from one ontology to another, which when executed can effect translation of A-Box instance data from one ontology's form to another's? </p> <p>I have recently written such a tool to meet my needs, but I was wondering if I...
<p>Your issue is your <code>#define</code>. You did <code>#define Card</code>, so now everywhere <code>Card</code> is seen as a token, it will be replaced.</p> <p>Usually a <code>#define Token</code> with no additional token, as in <code>#define Token Replace</code> will use the value <code>1</code>.</p> <p>Remove th...
<p>Remove the <strong>#define Card</strong>.</p>
13,162
<p>In vb.net / winforms, how can a hashtable be bound to a drop down list or any other datasource-driven control?</p>
<p>Is this winforms, wpf, or asp.net? [update: ahh... winforms ;-p]</p> <p>winforms wants data to be <code>IList</code> (or, indirectly, via <code>IListSource</code>) - so I'm guessing (from the comment) that you are using winforms. None of the inbuilt dictionary-like collections implement <code>IList</code>, but to b...
<pre><code>myCtrl.DataSource = myHashtable myCtrl.DataBind() </code></pre> <p>Example source of bindable control:</p> <pre><code>&lt;itemtemplate&gt; &lt;%# DataBinder.Eval(Container.DataItem, "Key", "&lt;td&gt;{0}&lt;/td&gt;") %&gt; &lt;%# DataBinder.Eval(Container.DataItem, "Value", "&lt;td&gt;${0:f2}&lt;/t...
38,283
<p>I used to use the implicit call of toString when wanting some debug info about an object, because in case of the object is null it does not throw an Exception.</p> <p>For instance: </p> <pre><code>System.out.println("obj: "+obj); </code></pre> <p>instead of:</p> <pre><code>System.out.println("obj: "+obj.toStrin...
<p>There's little difference. Use the one that's shorter and works more often.</p> <p>If you actually want to get the string value of an object for other reasons, and want it to be null friendly, do this:</p> <pre><code>String s = String.valueOf(obj); </code></pre> <p><strong>Edit</strong>: The question was extende...
<p>It is quite easy to write a generic reference type.</p> <pre><code>class ref { static public class Reference&lt;T&gt; { private T value; public Reference(T value) { set(value); } public Reference() { set(null); } public void set (T value) { this.value = value; } public T get () { return this...
42,582
<p>I am calling a .txt file from a jquery ajax call. It has some special characters like <code>±</code>. This <code>±</code> is a delimiter for a set of array; data I want to split out and push into a JavaScript array.</p> <p>It is not treated as <code>±</code> symbol when interpreted like this.</p> <p>How do I get t...
<p>Why don't you encode your text file using <a href="http://www.json.org/" rel="nofollow noreferrer">JSON</a> ? Much more easier, as it already is javascript. </p> <p>Use JQuery's <a href="http://docs.jquery.com/Ajax/jQuery.getJSON" rel="nofollow noreferrer">getJSON()</a> method, and the file contents will directly ...
<p>Why don't you encode your text file using <a href="http://www.json.org/" rel="nofollow noreferrer">JSON</a> ? Much more easier, as it already is javascript. </p> <p>Use JQuery's <a href="http://docs.jquery.com/Ajax/jQuery.getJSON" rel="nofollow noreferrer">getJSON()</a> method, and the file contents will directly ...
42,133
<p>If you're familiar with the phrase "build one to throw away", well, we seem to have done that; we’re reaching the limits of version 1 of our online app. It's time to clean things up by:</p> <ul> <li>Re-organizing code and UI</li> <li>Unifying UI processes</li> <li>Adding more functionality</li> <li>Building for the...
<p>The answer, I'm afraid, is it depends. It depends on the kind of application and the kind of users you have. Without knowing what the system is and the scope of the changes in the version, it is difficult to offer an answer. </p> <p>That said, there are some rules of thumb.</p> <p>Firstly, avoid the big bang launc...
<p>It sounds like <strong>incremental re-architecture</strong> should be your agile buzz-phrase of choice.</p> <p>I've never done it on a web application, but I have been through some fairly radical client application changes that were done incrementally. If you invest a little bit of time up front to make sure that p...
8,475
<p>I am using a navigation controller, and I have the style set to :</p> <pre><code>navController.navigationBar.barStyle = UIBarStyleBlackTranslucent; </code></pre> <p>But when I run my program, the navigation controller looks like it is on top of a white background, not my background. When I push a controller, left ...
<p>I believe the UINavigationController assumes that your controller view frames don't include the area beneath the navigation bar.</p> <p>UIBarStyleBlackTranslucent is more often used for UIToolbar, so Apple probably didn't make it easy to use it nicely with UINavigationBar. You'll probably need to abandon the UINavi...
<p>If you set your nav controller's navigationBar to transparent in your App delegate early enough (It worked for me before adding the nav controller to the window), it will automatically shift your view up underneath the navigation bar.</p> <p>Unfortunately it does not also shift your view underneath the status bar. ...
28,258
<p>I want to generate unique filenames per image so I'm using MD5 to make filenames.Since two of the same image could come from different locations, I'd like to actually base the hash on the image contents. What caveats does this present? </p> <p>(doing this with PHP5 for what it's worth)</p>
<p>It's a good approach. There is an extremely small possibility that two different images might hash to the same value, but in reality your data center has a greater probability of suffering a direct hit by an asteroid.</p> <p>One caveat is that you should be careful when deleting images. If you delete an image recor...
<p>If you have two identical images loaded from different places, say a stock photo, then you could end up over-writing the 'original'. However, that would mean you're only storing one copy, not two.</p> <p>With that being said, I don't see any big issues with doing it in the way you described.</p>
25,239
<p>So basically I'm building an app for my company and it NEEDS to be built using MS Access and it needs to be built on SQL Server.</p> <p>I've drawn up most of the plans but am having a hard time figuring out a way to handle the auditing system.</p> <p>Since it is being used internally only and you won't even be abl...
<p>Does this work for you?</p> <pre><code> select user_name(),suser_sname() </code></pre> <hr> <p>Doh! I forgot to escape my code.</p>
<p>How many users of the app will there be? Is there possibility of using windows integrated authentication for SQL authentication?</p> <p><strong>Updated</strong>: If you can give each user a SQL login (windows integrated) then you can pickup the logged on user using the SYSTEM_USER function. </p>
3,371
<p>I am playing around with ASP.NET MVC for the first time, so I apologize in advance if this sounds academic. </p> <p>I have created a simple content management system using ASP.NET MVC. The url to retrieve a list of content, in this case, announcements, looks like:</p> <pre><code>http://www.mydomain.com/announcem...
<p>I would update the field in the DetailsView to a TemplateField: </p> <pre><code>&lt;asp:TemplateField&gt; &lt;InsertItemTemplate&gt; &lt;asp:TextBox ID="txtField" runat="server" Text='&lt;%# Bind("GUID") %&gt;'/&gt; &lt;/InsertItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lblField" runat="s...
<p>I'm guessing you need to use one of detailsview events. Hook up to ItemCommand, ModeChanging or ModeChanged events and fill your value there.</p>
34,183
<p>I am having this problem with my printer. It doesn't print smooth circular objects. The objects are typically "ribbed" or ridged... never smooth. I am not sure how to fix this.</p> <p>I have tried fixing it in Meshmixer, I've tried <em>Sli3r</em> (I normally use <em>Cura</em> 2.7). I've tried turning down accelerat...
<p>Any deviation from smoothness is caused by irregularity in the material feed, the motion, or both. In this case, I would suggest both.</p> <p>The problem is that current 3D printer control firmware (If someone has a counter-example in the hobbiest space, please add it) prints in linear segments. This starts as @s...
<p>Did you try to use different infill? Denser or less dense?</p> <p>You can also try to reduce overlapping infil with outlines.</p> <p>Try to set 2 or 3 outer perimeters / outlines.</p>
688
<p>In my ideal world, what I'm looking for would exist as something along the lines of this:</p> <pre><code>public string UserDefinedField { get { return _userDefinedField; } internal set { _userDefinedField = value; } set { _userDefinedField = value; ChangedFields.Add(Fields.UserDefinedField); } }...
<pre><code>public string UserDefinedField { get { return _userDefinedField; } set { SetField(value); ChangedFields.Add(Fields.UserDefinedField); } } // Call this from internal methods and use the public property for other cases internal string SetField(string userValue) { _userDefinedField = userValue; } <...
<p>This isn't exactly what you're asking, but in a case like that, I would use an internal method to set the value directly.</p> <pre><code>... internal void SetUserDefinedField(string val) { _userDefinedField = val; } ... </code></pre>
26,200
<p>We have a Java codebase that is currently one Web-based Netbeans project. As our organization and codebase grows it seems obvious that we should partition the various independent pieces of our system into individual jars. So one Jar library for the data access layer, one for a general lib, one for a specialized know...
<p>I'd agree with SteveG above on using Maven2 to help you modularise your code base, but I'd use <a href="http://nexus.sonatype.org/" rel="nofollow noreferrer">Nexus</a> as the local repository for Maven instead of Archiva. The guys at Sonatype also have an excellent (free html/pdf) book on how to use Maven, Nexus, an...
<p>I would create <a href="http://ant.apache.org/" rel="nofollow noreferrer">ant</a> scripts to build the pieces and for deployment. Then you are not depending on your IDE for build/deployment. </p>
23,395
<p>How do i delete all the tables in the schema on Apache Derby DB using JDBC?</p>
<p>For actual code that does this, check <a href="http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java?view=markup" rel="nofollow noreferrer">CleanDatabaseTestSetup.java</a> in the Derby test suite section of the Derby distribution.</p>
<p>JDBC allows you to solve your task in a database agnostic way:</p> <ol> <li>Open the connection</li> <li>Grab the DatabaseMetaData</li> <li>Use it to list all tables in your database <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getTables(java.lang.String,%20java.lang.String,%20jav...
20,703
<p>I the following styles:</p> <pre><code>a.button { background-color: orange; margin: .2cm; padding: .2cm; color: black; font-family: sans-serif; text-decoration: none; font-weight: bold; border: solid #000000; } a.buttonMouseover { background-color: darkGoldenRod; margin: .2c...
<p>Depending on your target browsers, you could use the <code>hover</code> pseudo tag.</p> <pre><code>a.button { background-color: orange; margin: .2cm; padding: .2cm; color: black; font-family: sans-serif; text-decoration: none; font-weight: bold; border: solid #000000; } a.button:hov...
<p>You can use a library like <a href="http://jquery.com/" rel="nofollow noreferrer" title="jQuery">jQuery</a> to make things simpler.</p>
32,451
<p>I've run into this issue quite a few times and never liked the solution chosen. Let's say you have a list of States (just as a simple example) in the database. In your code-behind, you want to be able to reference a State by ID and have the list of them available via Intellisense. </p> <p>For example:</p> <pre>...
<p>Personally, I would store lookup data in a database, and simply try to avoid the type of hard coding that binds rules to things like individual states. Perhaps some key property <em>of</em> those states (like .ApplyDoubleTax or something). And non-logic code doesn't need to use intellisense - it typically just needs...
<p>This cries out for a custom MSBuild task. You really want an autogenerated enum or class in this case; if the IDs are sourced from a database and can/will change, and are not easily predicted. You could then put the task in your project and it would run before each build updating as necessary.</p> <p>Or start looki...
23,252
<p>I couldn't find a decent ThreadPool implementation for Ruby, so I wrote mine (based partly on code from here: <a href="http://web.archive.org/web/20081204101031/http://snippets.dzone.com:80/posts/show/3276" rel="nofollow noreferrer">http://web.archive.org/web/20081204101031/http://snippets.dzone.com:80/posts/show/32...
<p>Ok, so the main problem with the implementation is: how to make sure no signal is lost and avoid dead locks ?</p> <p>In my experience, this is REALLY hard to achieve with condition variables and mutex, but easy with semaphores. It so happens that ruby implement an object called Queue (or SizedQueue) that should sol...
<p>I'm slightly biased here, but I would suggest modelling this in some process language and model check it. Freely available tools are, for example, the mCRL2 toolset (using a ACP-based language), the Mobility Workbench (pi-calculus) and Spin (PROMELA).</p> <p>Otherwise I would suggest removing every bit of code that...
10,754
<p>Given a class like this:</p> <pre><code>class Foo { public: Foo(int); Foo(const Foo&amp;); Foo&amp; operator=(int); private: // ... }; </code></pre> <p>Are these two lines exactly equivalent, or is there a subtle difference between them?</p> <pre><code>Foo f(42); Foo f = 42; </code></pre> <hr...
<pre><code>Foo f = 42; </code></pre> <p>This statement will make a temporary object for the value '42'.</p> <pre><code>Foo f(42); </code></pre> <p>This statement will directly assign the value so one less function call.</p>
<pre><code>Foo f = 42; </code></pre> <p>This statement will make a temporary object for the value '42'.</p> <pre><code>Foo f(42); </code></pre> <p>This statement will directly assign the value so one less function call.</p>
48,714
<p>I would really like to annotate a method with a reference to a single property in a property file for injection.</p> <pre><code>@Resource("${my.service.url}") private String myServiceUrl; </code></pre> <p>Of course, this syntax does not work ;) Thats why I'm asking here.</p> <p>I am aware that I can inject the fu...
<p>There's a thread about this on the <a href="http://forum.springframework.org/showthread.php?t=50790" rel="nofollow noreferrer">Spring forum</a>. The short answer is that there's really no way to inject a single property using annotations. </p> <p>I've heard that the support for using annotations will be improved in...
<p>You could try injecting value of property "my.service.url" to a filed in your bean.</p> <p>Take a look at: <a href="http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-placeholderconfigurer" rel="nofollow noreferrer">http://static.springframework.org/spring/docs/2.5.x/reference/be...
26,754
<p>I am using SetCursor to set the system cursor to my own image. The code looks something like this:</p> <pre><code>// member on some class HCURSOR _cursor; // at init time _cursor = LoadCursorFromFile("somefilename.cur"); // in some function SetCursor(_cursor); </code></pre> <p>When I do this the cursor does chan...
<p>It seems that I have two options. The first is the one that Mark Ransom suggested here, which is to respond to the windows <code>WM_SETCURSOR</code> message and call SetCursor at that time based on where the mouse is. Normally windows will only send you <code>WM_SETCURSOR</code> when the cursor is over your window,...
<p>As @Heinz Traub said the problem comes from the cursor defined on the <code>RegisterClass</code> or <code>RegisterClassEx</code> call. You probably have code like:</p> <pre><code>BOOL CMyWnd::RegisterWindowClass() { WNDCLASS wndcls; // HINSTANCE hInst = AfxGetInstanceHandle(); HINSTANCE hInst = AfxGetRe...
20,415
<p><strong>Duplicate of <a href="https://stackoverflow.com/questions/371/how-do-you-make-sure-email-you-send-programmatically-is-not-automatically-marke">How do you make sure email you send programmatically is not automatically marked as spam?</a></strong></p> <p>Initially I planned to send emails from my website as h...
<p>In my experience, most anti-spam systems will score HTML's Hamminess slightly below plaintext, but there are much more important things to consider that affect deliverability:</p> <ul> <li>make sure you have a valid Reverse DNS configuration for your mail server, or you will be undeliverable to many domains.</li> <...
<p>I think to be safe, other than what Tim Howland recommended, you could always first send a plain text email welcoming the person and asking to put your domain in their email safe file. I see this happen a lot with big companies; I get a plain text email saying "Welcome, make sure email@bigcompany.com is in your saf...
34,618
<p>I am testing some weird-looking CSS code that I wrote (I'm using a mix of percentages and pixel values for width of DIVs, basically). While I'm not convinced that it's right, it works perfectly on all screen sizes on IE 5.5, IE 6.0 (<a href="http://tredosoft.com/Multiple_IE" rel="nofollow noreferrer">thanks to these...
<blockquote> <p>will it work on Mac and Linux?</p> </blockquote> <p>Not necessarily.</p> <p>Font rendering is the biggest issue with that sort of cross-platform. Some fonts that are available on Windows are not included in others by default and OSX has a very heavy font-rendering model (though Safari on Windows sho...
<p>in my experience FF3 on Mac and Win does not render <em>exactly</em> the same, but still close enough to not bother checking both.</p>
26,468
<p>I've had to move my page title into my node to accommodate a client need, but I'm unable to now get a title to display on a page view of my views list. The argument I have to display title on edit, admin and track pages is:</p> <pre><code>&lt;?php if ($title &amp;&amp; ((arg(2) == 'track') || (arg(2) == 'edit') || ...
<p>OK - I found my own solution that didn't require creating 20 plus page templates. For the above example, I added the condition of <code>!node-&gt;type</code> to my query, since view's don't provide a node-type, then went through the site ensuring that title's were disabled at the page view level where needed.</p> <...
<p>In case someone else is researching some similar questions, another way to provide an argument in the node.tpl file that would apply to when the node is displayed via a View (module) would be to use:</p> <p>if ($page == 0)</p> <p>Anything that follows would be ignored for a "regular" display of a single node. Thi...
49,030
<p>We have followed the approach below to get the data from multiple results using LINQ To SQL</p> <pre><code>CREATE PROCEDURE dbo.GetPostByID ( @PostID int ) AS SELECT * FROM Posts AS p WHERE p.PostID = @PostID SELECT c.* FROM Categories AS c JOIN PostCategories A...
<p><a href="http://weblogs.asp.net/scottgu/about.aspx" rel="noreferrer">Scott Guthrie</a> (the guy who runs the .Net dev teams at MS) covered how to do this on his blog some months ago much better than I ever could, <strong><a href="http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-us...
<p>Just curious, if a Post have have one or many Categories, is it possible to instead of using the for loop, to load the Post.PostCategories with the list of Categories (one to many), all in one shot, using a JOIN?</p> <pre><code>var rslt = from p in results.GetResult&lt;Post&gt;() join c in results.GetRes...
48,542
<p>I'm currently in the process of writing a wizard and want to make each page validate before moving onto the next page.</p> <p>I want to prevent the user from progressing by calling the Validate() method on every child control on the page and and stopping navigation if any of them fail.</p> <p>The problem is that t...
<p>If the pages happen to be ContainerControl instances, you can just call ValidateChildren. If not, this seems to work on an individual control:</p> <pre><code>private void ValidateControl(Control control) { Type type = control.GetType(); type.InvokeMember("PerformControlValidation", BindingFlags.Instance | Bindi...
<p>No need for reflection - what you want is <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.containercontrol.validatechildren.aspx" rel="nofollow noreferrer">ContainerControl.ValidateChildren()</a> (call it on your form/dialog)</p> <p>Note that <a href="http://msdn.microsoft.com/en-us/library/sy...
33,696
<p>Which <strong>standalone Windows GUI application</strong> do you recommend for use for accessing a Subversion repository?</p> <p>Edit: A lot of people are mentioning Tortoise, however I am looking for an application not a shell extension. Also people are questioning my reasoning behind not wanting to use a shell e...
<p><strong>Standalone Clients</strong></p> <p>For total stand alone <a href="http://www.syncrosvnclient.com/" rel="nofollow noreferrer">Synchro SVN</a> is a powerful and cross platform solution. It looks like the most native application on each of the platforms.</p> <p>The <a href="http://subversion.tigris.org/links...
<p>Memory and disk IO can be a problem with TSVNCache, which manages Tortoise's icon overlays. You can fix it by putting your checkouts in one or two directories and making the cache process only look at those directories, rather than your entire drive.</p> <p><a href="http://www.paraesthesia.com/archive/2007/09/26/o...
8,364
<p>Which is a better way to force GC on ThreadLocal instance?</p>
<p>Simple answer: you can't force the GC in java. Some may posts tricks but all in all you simply can't.</p> <p>Well, in fact you can. With exit!</p>
<p>The <a href="http://code.google.com/p/jlibs/wiki/GarbageCollection" rel="nofollow">jlibs library has a good utility class for garbage collection</a>. You can force garbage collection using a nifty little trick with <a href="http://download.oracle.com/javase/1,5.0/docs/api/java/lang/ref/WeakReference.html" rel="nofol...
40,552
<p>I have a project with 2 subfolders in the App_code folder, one for VB and one for F# (C# files are in the root). I can access the VB classes just fine (via the namespace) but not the F# code. Has anyone had a problem like this and if so how did you fix it?</p> <p>Addendum: F# code that is <em>not</em> in the App_Co...
<p>Note that by default, if you don't declare a namespace or module, top-level F# code ends up in a module with the same name as the filename. See the first part of</p> <p><a href="http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!444.entry" rel="nofollow noreferrer">http://lorgonblog.spaces.live.com/blog/c...
<p>Open up the actual generated assemblies via Reflector - see what the actual namespacing is.</p>
39,134
<p>The Separat<em>ion</em> of Layout and Content is the domain of CSS and HTML - so far well understood. Now about separat<em>ing</em>...</p> <p>I'm looking for hints and Best Practices to get started with the task of providing a "skin" or "theme" for a content management system. </p> <h2>Background:</h2> <p>We are ...
<p>If you're looking for practical examples of separating style and content, then I'd suggestion the <a href="http://www.csszengarden.com/" rel="nofollow noreferrer">CSS Zen Garden</a>. Trawling through the HTML and CSS is inspirational and enlightening and should help with what you're trying to do.</p> <p>My #1 tip w...
<p>Have look at <a href="http://csstidy.sourceforge.net/" rel="nofollow noreferrer">CSS Tidy</a>, we normally use this to clean up the CSS and reorganise for development and production. However, I personally prefer writing HTML/CSS by hand before using this. It is just a matter of individual preference I guess.</p>
23,196
<p>I really enjoyed <a href="http://www.codinghorror.com/blog/archives/001148.html" rel="noreferrer">Jeff's post</a> on <a href="http://ssdl-wiki.cs.technion.ac.il/wiki/index.php/Spartan_programming" rel="noreferrer">Spartan Programming</a>. I agree that code like that is a joy to read. Unfortunately, I'm not so sure i...
<p>In <strong>The Pragmatic Programmer</strong> Hunt and Thomas talk about a study they term the Law of Demeter and it focuses on the coupling of functions to modules other than there own. By allowing a function to never reach a 3rd level in it's coupling you significantly reduce the number of errors and increase the ...
<p>Maintainability, and with it, readability, is king. Luckily, shorter very often means more readable.</p> <p>Here are a few tips I enjoy using to slice and dice code:</p> <ul> <li><strong>Variable names</strong>: how would you describe this variable to someone else on your team? You would <em>not</em> say "the nu...
7,399
<p>See question above.</p>
<p>Yes, use IKVM.</p> <p><a href="http://www.ikvm.net/" rel="noreferrer">http://www.ikvm.net/</a></p> <p>And it's incredibly easy to use:</p> <pre><code>ikvmc myjar.jar </code></pre> <p>outputs myjar.dll</p>
<p>It is better to create a c++ loader which</p> <p>1)Hides the console</p> <p>2)runs your application</p>
32,876
<p>Is there a Regular Expression that can detect SQL in a string? Does anyone have a sample of something that they have used before to share?</p>
<p>Don't do it. You're practically guaranteed to fail. Use <code>PreparedStatement</code> (or its equivalent) instead.</p>
<p>I don't have a regex but my understanding is that the most important thing is to detect the single quote. All the injection attacks start from there. They probably have the -- in there too to comment out and other SQL that might be after the string.</p>
6,690
<p>Imagine to have two RESTful controllers (UsersController, OffersController) and a PagesController (used for static content such as index, about and so on) in your application.</p> <p>You have the following routes defined:</p> <pre><code>map.with_options :controller =&gt; 'pages' do |pages| pages.root :action =&g...
<p>One thing you could play with is yield and content_for, used with a few partials for the menus. For example you could put each section of the menu in a partial and then modify your layout to something like:</p> <pre><code>&lt;%= yield(:menu) %&gt; </code></pre> <p>You then can then specify in your views content_f...
<p>Typically, I would abstract out the menuing functionality so that I have a helper method for rendering the Admin menu. This way, it's possible to throw as much logic in the helper as you want without clouding up your view logic. </p> <p>So, your helper would look like (forgive the ruby/rails pseudo-code, it's bee...
15,354
<p>What's the most efficient algorithm to find the rectangle with the largest area which will fit in the empty space?</p> <p>Let's say the screen looks like this ('#' represents filled area):</p> <pre><code>.................... ..............###### ##.................. .................### .................### #####....
<p>@lassevk</p> <p>I found the referenced article, from DDJ: <a href="http://www.ddj.com/184410529" rel="noreferrer">The Maximal Rectangle Problem</a></p>
<p>Implementation of the stack-based algorithm in plain Javascript (with linear time complexity):</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function maxRectangle(mask) ...
2,887
<p>I have an application that reads a CSV file with piles of data rows. I give the user a summary of the number of rows based on types of data, but I want to make sure that I don't read in too many rows of data and cause <code>OutOfMemoryError</code>s. Each row translates into an object. Is there an easy way to find...
<p>You can use the <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html" rel="noreferrer"><code>java.lang.instrument</code> package</a>.</p> <p>Compile and put this class in a JAR:</p> <pre><code>import java.lang.instrument.Instrumentation; public class ObjectSizeFetcher { pr...
<p>I doubt you want to do it programmatically unless you just want to do it once and store it for future use. It's a costly thing to do. There's no sizeof() operator in Java, and even if there was, it would only count the cost of the references to other objects and the size of the primitives.</p> <p>One way you coul...
7,560