input
stringlengths
51
42.3k
output
stringlengths
18
55k
How do I iterate through a string in Python? <p>As an example, lets say I wanted to list the frequency of each letter of the alphabet in a string. What would be the easiest way to do it?</p> <p>This is an example of what I'm thinking of... the question is how to make allTheLetters equal to said letters without somethi...
<p>The question you've asked (how to iterate through the alphabet) is not the same question as the problem you're trying to solve (how to count the frequency of letters in a string).</p> <p>You can use string.lowercase, as other posters have suggested:</p> <pre><code>import string allTheLetters = string.lowercase </c...
Application_Start works fine on workstation, is not called when deployed <p>I have an application that works great on my development workstation but fails when the application is deployed to the live environment. It seems that Application_Start is not being called in the live environment.</p>
<p>I was able to fix it by removing the PrecompiledApp.config file that was in the root directory of the web site on our test server. I'm guessing that file was a holdover from when the project was a Web Site project. I recently converted it over to a Web App project. So if you are building a Web App project, make s...
jQuery resize not working at FireFox, Chrome and Safari <pre><code>$("#dvMyDIV").bind("resize", function(){ alert("Resized"); }); </code></pre> <p>or</p> <pre><code>$("#dvMyDIV").resize(function(){ alert("Resized"); }); </code></pre> <p>The questions</p> <ol> <li>Why is this not working at FireFox, Chrome a...
<p>I believe the JavaScript resize event only applies to frames or windows, not to DIVs.</p> <p>e.g. see <a href="http://devguru.com/technologies/javascript/10929.asp">this page</a>:</p> <blockquote> <p>The onResize even handler is use to execute specified code whenever a user or script resizes a window or frame. T...
Class methods as event handlers in JavaScript? <p>Is there a best-practice or common way in JavaScript to have class members as event handlers?</p> <p>Consider the following simple example:</p> <pre><code>&lt;head&gt; &lt;script language="javascript" type="text/javascript"&gt; ClickCounter = function(but...
<pre><code>ClickCounter = function(buttonId) { this._clickCount = 0; var that = this; document.getElementById(buttonId).onclick = function(){ that.buttonClicked() }; } ClickCounter.prototype = { buttonClicked: function() { this._clickCount++; alert('the button was clicked ' + this._clic...
Apache MOD_REWRITE Domain Level Cookie <p>I need to deal with Affiliate Tracking on our website.</p> <p>In our .htaccess we have:</p> <pre><code>RewriteCond %{QUERY_STRING} affiliate=(.*) RewriteRule ^(.*)$ $1? [NC,R,L,co=AFFID:%1:%{HTTP:Host}:7200:/] </code></pre> <p>Which creates a COOKIE called AFFID with the va...
<p>Why don't you just hardcode it?</p> <pre><code>RewriteRule ^(.*)$ $1? [NC,R,L,co=AFFID:%1:.domain.com:7200:/] </code></pre> <p>If you can't do that, the you'd have to match the domain, like this (untested):</p> <pre><code>RewriteCond %{QUERY_STRING} affiliate=(.*) #This would work only for xxx.dom.com or dom.com...
How to ignore whitespace while reading a file to produce an XML DOM <p>I'm trying to read a file to produce a DOM Document, but the file has whitespace and newlines and I'm trying to ignore them, but I couldn't:</p> <pre><code>DocumentBuilderFactory docfactory=DocumentBuilderFactory.newInstance(); docfactory.setIgnori...
<p>‘IgnoringElementContentWhitespace’ is not about removing <em>all</em> pure-whitespace text nodes, only whitespace nodes whose parents are described in the schema as having ELEMENT content — that is to say, they only contain other elements and never text.</p> <p>If you don't have a schema (DTD or XSD) in u...
How to refresh Internet Explorer using SendMessage? <p>does anybody know how to refresh the Internet Explorer (like by pressingthe F5 key) but using some "backdoor" like PostMessage or SendMessage? The internet Explorer Window is not active so I can't use the keyboard.</p> <p>Thanks</p> <p>(Language doesnt matter)</p...
<p>I think I understand your need a little better now.</p> <p>Create a new webpage on your machine with the following:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="refresh" content="5"/&gt; &lt;/head&gt; &lt;body&gt; &lt;iframe src="http://google.com" height="100%" width="100%" frameborder="0...
Delphi Multi-Threading Message Loop <p>My application has several threads: 1) Main Thread 2) 2 Sub-Main Threads (each with Message Loop, as shown below), used by TFQM 3) n Worker Threads (simple loop, containing Sleep())</p> <p>My problem is, when I close my application, the Worker Threads manage to exit properly, but...
<p>If I may point to few problems in your code ...</p> <p>1) You're not checking output of AllocateHwnd. Yes, most probably it will never fail, but still ...</p> <p>2) AllocateHwnd belogs OUT of try..finally! If it fails, DeallocateHwnd should not be called.</p> <p>3) AllocateHwnd is not threadsafe. If you call it f...
need PropertyGrid with drill-down, similar to QuickWatch <p>I am trying to display object data members in a generic way. I started by using PropertyGrid, which satisfies my needs as far as simple properties are concerned. However, it doesn't let the user drill-down into data members. It allows browsing into collecti...
<p>You can drill down into properties in the PropertyGrid of course. This is a vast subject, but maybe your properties simply need to have the ExpandableObjectConverter attached to them? Or if you are going more into details, the attached TypeConverter needs to override the GetPropertiesSupported and GetProperties meth...
Timeouts WCF Services <p>How do the timeouts work in WCF? I know for example that you can configure <em>sendTimeout</em> and <em>receiveTimeout</em> for a clients binding. But how do they work?</p> <p>MSDN describes <em>sendTimeout</em> as:</p> <blockquote> <p>A TimeSpan value that specifies the interval of time pr...
<p>Client side:</p> <ul> <li>SendTimeout is used to initialize the OperationTimeout, which governs the whole interaction for sending a message (including receiving a reply message in a request-reply case). This timeout also applies when sending reply messages from a CallbackContract method.</li> <li>OpenTimeout and C...
gridview dynamic image change in imagebutton <p>I have a gridview containing some data from db, and after a check I want to see a small cross/tick image in each row, due to the result of the check.How can I change the image url dynamically? </p>
<p>You could either use inline statement like <br/> <code>&lt;%#Eval("check").ToString() == "1" ? "images/checked.gif" : "images/unchceked.gif")%&gt;</code></p> <p>or use a function to get the result as follows:</p> <pre><code>&lt;%# getImageUrl(Eval("value")) %&gt; Public Function getImageUrl(ByVal value As Integer)...
Class design for serialization - ideas or patterns? <p>Let me begin with an illustrative example (assume the implementation is in a statically typed language such as Java or C#).</p> <p>Assume that you are building a content management system (CMS) or something similar. The data is hierarchically organised into <code>...
<p>I don't know what kind of API you are trying to build, but your suggestion #1 sounds like it is close to what is recommended for REST style services and APIs. Basically, a <code>Folder</code> object would contain a list of URLs to its children.</p>
New web app project does not recognize the <asp: tag space <p>Visual Studio 2008 w/Sp1</p> <p>To reproduce my problem I simply create a new .Net 2.0 web application and add a page with the following markup:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebAppli...
<p>Try "<strong>B</strong>utton" (capital B):</p> <pre><code>&lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:Button id="button1" runat="server" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; </code></pre>
Mysterious assets used in swf, not found anywhere in fla? <p>near the top of the code i see things like, </p> <p>btn_dropdown._visible = false; mcMenuBkg._visible = false;</p> <p>but I can't find these assets anywhere in the library or in any code, how does this make any sense?</p> <p>The movie clips in the library ...
<p>In theory, any clip you see at runtime could be dynamically created, by making an empty MC and drawing in whatever contents you like with the drawing API. However, if you see clips in the library that are similar to what's showing up at runtime, then it's very unlikely that that's happening.</p> <p>Your first step ...
SelectedValue is invalid - doesn't exist in list - C#/ASP.NET <p>Exception is: 'Country' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value</p> <pre><code>UserService.DsUserAttributes dsCountry = us_service.GetUserAttributeDropDown(systemId, "Country"); Country....
<p>Try binding the data on postback. It sounds like when the event handler is accessing the DropDownList, it hasn't been repopulated with the values you are initially binding to the DropDownList.</p> <p>Also, remember to bind early enough so that it is bound before the event handler starts its processing. OnInit or ...
PHP syntax highlighting <p>I'm searching for a <strong>PHP syntax highlighting engine</strong> that can be customized (i.e. I can provide my <strong>own tokenizers</strong> for new languages) and that can handle several languages <em>simultaneously</em> (i.e. on the same output page). This engine has to work well toget...
<p>Since no existing tool satisfied my needs, I wrote my own. Lo and behold:</p> <h2><a href="https://github.com/klmr/hyperlight">Hyperlight</a></h2> <p>Usage is extremely easy: just use</p> <pre><code> &lt;?php hyperlight($code, 'php'); ?&gt; </code></pre> <p>to highlight code. Writing new language definitions is ...
Any good "contact us" recipes for Cherrypy? <p>I'm looking to implement a "Contact Us" form with Cherrypy and was wondering: Is there a good recipe (or a BSD licensed set of code) that I could use instead of reinventing the wheel?</p> <p>Ideally, this would be Cherrpy 3.1 compatible.</p>
<p>Well, I had to look into a solution. This works (ugly, and w/o Javascript validation) -- using the smtplib lib. Also, note that I stole Jeff's captcha for this example. Anyone using this will need to change it. </p> <p><strong>EDIT:</strong> I added validation.</p> <pre><code>#!/usr/local/bin/python2.4 import...
How to add a dynamic weather ticker to the webpage <p>All Weather Tickers I found are static and if the user wants to select a zip code it links you to a different page.</p> <p>Do you know any weather ticker that just gets the new info in the same page?</p>
<p><a href="http://demos.openrico.org/weather_demo" rel="nofollow">RICO</a> has an AJAX weather widget that seems to be along the lines of what you want.</p>
Can initialization list in constructors be used in template classes? <p>I find that most books concerning C++ templates don't tell anything about whether it's possible or not to use initialization list in constructor of a template class.</p> <p>For example, I have code like this:</p> <pre><code>template &lt;class T&g...
<p>Yes. Did the compiler tell you otherwise?</p>
Does foreach always create a copy on a none reference in PHP? <p>I'm wondering if PHP has this optimization built in. Normally when you call foreach without using a reference it copies the passed array and operates on it. What happens if the reference count to that array is only 1?</p> <p>Say for example if getData ...
<p>I can't say for certain, but PHP normally uses "copy on write", so everything is a reference until you try to write to it, at which time a copy is made and you write to the copy.</p>
Window Handle and window dimension <p>The MFC application that i created is dialog based. Just one dialog thats all. How do I get the window handle to this window, while the application is performing the InitDialog. I need to find out its dimension as well. GetForegroundWindow not necessarily gives you the handle to th...
<p>Check the m_hWnd member of your dialog object. GetClientRect() should work to give you the size of client (interior) of the dialog. GetWindowRect() will give you the total size including window borders, but the position will be off.</p>
How would you write a non-recursive algorithm to calculate factorials? <p>How would you write a non-recursive algorithm to compute <code>n!</code>?</p>
<p>Since an Int32 is going to overflow on anything bigger than 12! anyway, just do:</p> <pre><code>public int factorial(int n) { int[] fact = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600}; return fact[n]; } </code></pre>
Can I have url_for use a prefix option in Ruby on Rails? <p>In a project I am working on, Apache is set up to only forward requests that come in as /prefix/* to mongrel. How can I tell ruby on rails to generate all URLs with that prefix? </p> <p>I have the routes set up for forward to the correct controller action by ...
<p>The <code>RAILS_RELATIVE_URL_ROOT</code> environment variable should do the trick, though I haven't tried it myself.</p>
Installing a rails plugin from a Git repository <p>I've been trying to install <a href="http://thoughtbot.com/projects/shoulda" rel="nofollow">Shoulda</a></p> <pre><code>script/plugin install git://github.com/thoughtbot/shoulda.git </code></pre> <p>but all I get is:</p> <pre><code>removing: C:/Documents and Settings...
<p>Do you have git installed? If you don't, it will just not work. Rails assumes git is installed and can be found in your PATH.</p> <p>You can get Git for Windows <a href="http://code.google.com/p/msysgit/downloads/list" rel="nofollow">here</a>.</p>
How do I find where my .Net app is leaking Windows handles? <p>I've got a WinForms .Net app that runs over a lot of XPS documents (thousands) and during this run the number of handles (according sysinternals process monitor and task manager) increases by between 3-10 for each document. I heavily suspect that these are ...
<p>Possibly stupid, but have you checked that you're disposing everything that's disposable?</p>
Has anyone used or written an Ant task to compile (Rhino) JavaScript to Java bytecode? <p>I'd like to use the <a href="https://developer.mozilla.org/en/Rhino_JavaScript_Compiler" rel="nofollow">Rhino JavaScript</a> compiler to compile some JavaScript to .class bytecode files for use in a project. It seems like this sho...
<p>I'm using <a href="http://requirejs.org/">RequireJS</a> in my project, which includes a script that traces out dependencies between modules, and combines them into a single JavaScript file. Optionally, it can also minify the combined js file with the Google Closure compiler. Once it's in this form, where all depende...
Overriding CreateObject Function in VBScript <p>Need help to figure out how to overide the default CreateObject() function in VBScript with my own.</p> <p>Basically the same exact thing as this example in VB6:</p> <p><a href="http://www.darinhiggins.com/2007/08/22/TheVB6CreateObjectFunction.aspx" rel="nofollow">http:...
<p>This quick test seems to work...</p> <pre><code>Function CreateObject(className, serverName) '---- override the CreateObject ' function in order to register what ' object is being created in any error message ' that's generated Dim source, descr, errNum WScript.echo "In custom CreateO...
Sharepoint: Web Part vs. ASP.NET User Control <p>When creating web parts for Sharepoint, is it better to create an actual web part, or is using and ASP.NET User Control (.ascx) just as good?</p> <p>I already know how to create the user controls that I need, so it seems like the extra effort of creating a web part is j...
<p>I am a big fan of user controls except for the simplest web parts. I create a webpart that instantiates and loads the user control. There are other tools out there that you can use to expose your user control, like smartpart, but I would suggest you wrap it up yourself, as it is a good learning experience. Once y...
How to join another MySQL table when using Master/Detail Sample Form in Netbeans? <p>I am trying to implement an application by using MySQL/JAVA and I found this tool in netbeans to easily create a new form for an existing table. (edit, insert, delete etc.) Is there an easy way to modify the code to join another table ...
<p>I do not think you will find something like that in NetBeans. However, if your DB design is simple enough (i.e. title example is real), you can try to use updatable view (<a href="http://dev.mysql.com/doc/refman/5.0/en/create-view.html" rel="nofollow">more info</a>) and use it as a table. </p> <p>In complicated cas...
How do you compress objects stored in session / cache? <p>Scott Hanselman recently posted a <a href="http://www.hanselman.com/blog/TheWeeklySourceCode35ZipCompressingASPNETSessionAndCacheState.aspx" rel="nofollow">blog article</a> describing how to compress strings stored in the session / cache. This looks fairly prom...
<p>Firstly I'd look at why you need to compress the data in your session / cache. Compression should be an act of last resort, better programming should be the first. </p> <p>Are you running out of memory, and if so, which objects are consuming the most? This should point you in the direction for code improvement to r...
What does a type followed by _t (underscore-t) represent? <p>This seems like a simple question, but I can't find it with the Stack Overflow search or Google. What does a type followed by a <code>_t</code> mean? Such as</p> <pre><code>int_t anInt; </code></pre> <p>I see it a lot in C code meant to deal closely with ha...
<p>As Douglas Mayle noted, it basically denotes a type name. Consequently, you would be ill-advised to end variable or function names with '<code>_t</code>' since it could cause some confusion. As well as <code>size_t</code>, the C89 standard defines <code>wchar_t</code>, <code>off_t</code>, <code>ptrdiff_t</code>, ...
.NET compact framework and ActiveSync <p>Is there a way that my .NET CF app running on a Windows CE device can know when the device is docked/synced with the PC?</p>
<p>I believe this will help <a href="http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.status.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.status.aspx</a></p>
Force windows to refresh a disk FAT <p>I have a separate partition on my disk formatted with FAT32. When I hibernate windows, I want to be able to load another OS, create/modify files that are on that partition, then bring Windows out of hibernation and be able to see the changes that I've made.</p> <p>I know what you...
<p>So I finally got a solution to my problem. In my mind, I associated Mount Point with Mount. These are NOT the same thing. Removing all of the volume mount points does not make the volume unmounted. It's still mounted but not in the sense that you have a path you can access in explorer.</p> <p><a href="http://msdn.m...
SharePoint - ASP.Net Controls Integration <p>I have basically two separate sites, a SharePoint collaboration site, and an ASP.Net application site. The only linkage between the two are the hyperlinks going back and forth, and the user validation on the behalf of the SharePoint site. The user will enter and be authentic...
<p>You can use the ASP.NET Membership Provider on a SharePoint site. That is probably you're best option if you're not able to go with Windows Authentication.</p> <p>There's a good article by Andrew Connell on how to set up the Membership Provider for SharePoint. It is MOSS-described but the practices can be ported to...
How do you Manage Infragistics WebGrid Data from JavaScript/Ajax code? <p>I am working on a project that I need to use the Infragistics WebGrid control for some lists of data. I am loading the data on the client-side using JavaScript for display on a Map, and then I need to display that same data within multiple WebGri...
<p>The Infragistics webgrids expose a very complex client side object model that you will be able to use to populate your data client side.</p> <p>The first thing you will want to do is get a look at the full CSOM for the webgrid control, you can find the current doc version at: http://help.infragistics.com/NetAdvanta...
C++ Parent class calling a child virtual function <p>I want a pure virtual parent class to call a child implementation of a function like so:</p> <pre><code>class parent { public: void Read() { //read stuff } virtual void Process() = 0; parent() { Read(); Process(); } } class chi...
<p>Title of the following article says it all: <a href="http://www.artima.com/cppsource/nevercall.html">Never Call Virtual Functions during Construction or Destruction</a>.</p>
Image Slider with Silverlight <p>I have a requirement of creating an Image slider using Silverlight. I need to display 5 images at first. There will be two buttons previous and next. When I'll click the next button another new 5 images will be shown in place of previously diplayed images. Would it be possible for anyon...
<p>Check this out. <a href="http://www.silverlightshow.net/items/Image-slider-control-in-Silverlight-1.1.aspx" rel="nofollow">Image slider control in Silverlight 2</a></p> <p>Slide.Show 2 - Another cool sample from <a href="http://www.vertigo.com/slideshow.aspx" rel="nofollow">Vertigo</a>. Source available at <a href=...
Extra backslashes being added in PHP <p>My <sub>crappy</sub> web host did some upgrades the other day and some settings have gone awry, because looking at our company's wiki (MediaWiki), every quote is being escaped with a backslashes. It's not even just data which is being posted (ie: the articles) which are affected,...
<p>You may want to confirm that the data in your DB hasn't been corrupted. If you were addslash()ing your data when, unbeknownst to you, magic_quotes had been turned on, then you'd be double-slashifying data going into your DB.</p>
looking at client controls on the server <p>I'm just starting out with the whole ajax thing and I need some help. I have a form where the users will have the ability to add multiple e-mail addresses to a record. When the user clicks add a new e-mail address, I am going to perform an ajax call that will insert the ema...
<p>Why couldn't you use hidden fields anyway? As long as they are inside the <code>form</code> element it does not matter where they are, does it?</p> <p>Say, for example, that your emails fields have <code>name</code> attribute set like "email_1", "email_2", etc. You could set <code>name</code> for your hidden fields...
x86 question about bit comparisons <p>Im having a problem with a final part of my assignment. We get in a stream of bits, etc etc, in the stream is an integer with the number of 1's in the text portion. I get that integer and its 24 which is correct, now i loop through the text data i get and i try to count all the 1's...
<p>'shr bh,1' should probably be 'shr dh,1', no?</p>
Applications using Decimal versus double . . <p>I wanted to see if folks were using decimal for financial applications instead of double. I have seen lots of folks using double all over the place with unintended consequences . .</p> <p>Do you see others making this mistake . . .</p>
<p>We did unfortunately and we regret it. We had to change all doubles to decimals. Decimals are good for financial applications. You can look at this article <a href="http://www.codeproject.com/KB/recipes/MoneyTypeForCLR.aspx" rel="nofollow">A Money type for the CLR</a>:</p> <blockquote> <p>A convenient, high-perf...
How to configure security when calling WCF Service from .Net 2.0 Client <p>I have a WCF service up and running and am able to communicate between the service and a .Net 2.0 Client using basicHttpBinding. </p> <p>I now need to lock down the WCF service so that it can only be called by authenticated clients.</p> <p>I ...
<p>You can configure a WCF endpoint to use <strong>2-way SSL authentication</strong>. That means that you can require clients to present an X.509 certificate that confirms their identity whenever they make a request to the service.<br /><br/> On the server side of things, you can use one of the built-in validation sche...
How to backup project folders to local desktop if path more than 255 characters? <p>For e.g. if i am storing some files on a network server which is under many hierarchical folders.</p> <p>Then i want to do backup. But i always encounter issue because the file path is more than 255?</p> <p>How can i resolve this issu...
<p>Preface: I'm assuming the OS of the machine you want to copy the files to is some flavor of Windows.</p> <p>The first part of Mark Bessey's is somewhat correct, however even on modern versions of windows with modern filesystems (NTFS for example) you can still run into problems.</p> <p>I suspect the limitation you...
removing password for multiple PDF files <p>so I have a huge collection of PDF files that I need to extract text from. The files are encrypted, but I know the password for them. I'm looking for a way to automate the process of extracting the text.<br><br> I can manually open the file in Acrobat professional, remove sec...
<p>Take a look at pdftk. It's console-based and handles password-secured PDF files.</p>
Eclipse: Hide paths in the "Open resource" dialog <p>Is there any way to define what the "Open Resource" dialog in Eclipse should show?</p> <p>If you work with svn you don't want the *.svn files to show up. (I know there is a fix out for this one but does there exist a more general one?)</p>
<p>At the top-right corner of the "Open Resource" there is a small blue arrow. Click it and "Select Working Set". Create a new working set as required to include what you need</p>
What is the impact of virtualisation on cryptographically strong random number generators? <p>/dev/random and /dev/urandom use environmental noise to generate randomness. </p> <p>With a virtualised server there can be multiple instances of an Operating System on one hardware configuration. These operating systems will...
<p>I couldn't find any references quickly, but it would seem to me that the entropy is derived from the kernel data structures for the devices, not the actual devices themselves. Since these would be independent regardless of virtualization, I suspect the answer is not much.</p> <p>[EDIT] After peeking at the kernel ...
Cannot import SQLite with Python 2.6 <p>I'm running Python 2.6 on Unix and when I run the interactive prompt (<a href="http://en.wikipedia.org/wiki/SQLite">SQLite</a> is supposed to be preinstalled) I get:</p> <pre><code>[root@idev htdocs]# python Python 2.6 (r26:66714, Oct 23 2008, 16:25:34) [GCC 3.2.2 20030222 (Red ...
<p>The error: </p> <pre><code>ImportError: No module named _sqlite3 </code></pre> <p>means that <a href="http://en.wikipedia.org/wiki/SQLite">SQLite</a> 3 does not find the associated shared library. On Mac OS X it's _sqlite3.so and it should be the same on other Unix systems. </p> <p>To resolve the error you have t...
How much a tester should know about internal details of code? <p>How useful, if at all, is for the testers on a product team to know about the internal code details of a product. This does not mean they need to know every line of code but a good idea of how the code is structured, what is the object model, how the vari...
<p>That entirely depends upon the type of testing being done.</p> <p>For functional system testing, the testers can and probably should be oblivious to the details of the implementation -- if they know the details they may inadvertently account for that in their test strategy and not properly test the product.</p> <p...
Need to Impersonate user forAccessing Network resource, Asp.Net Account <p>I need to access a network resource on which only a given Domain Account has access. I am using the LogonUser call, but get a "User does not have required priviliege" exception, as the web application is running with the asp.net account and it d...
<p>Just calling LogonUser is not enough. You need to impersonate that user. You can impersonate for just the access to the network resource.</p> <p>Sample code can be found on <a href="http://msdn.microsoft.com/en-us/library/chf6fbt4.aspx">MSDN</a>.</p>
What technique would be the least effort to internationalise (at least multi-language) existing Delphi Applications? <p>I have developed about 300 Applications which I would like to provide with multi-language capabilities independent from the Operating System. I have written a just-in-time translator, but that is too ...
<p>We are using <a href="http://www.sicomponents.com/tsilang1.html" rel="nofollow">TsiLang</a> and are very happy with it.</p> <p>One of the best points is that you can pretranslate the project with a dictionary (which you filled from existing translations).</p>
Which Graphical Subsystem for Touchscreen Kiosk Development <p>I'm starting a hobby project in which I would like to have a graphical, touchscreen interface for interacting with a kiosk-like device running on top of Windows XP Embedded. For development of a rich UI experience, I was considering using WPF. However, a ...
<p>It seems that WPF works fine on embedded. See <a href="http://blogs.msdn.com/mikehall/archive/2006/07/10/661539.aspx" rel="nofollow">here</a> the second comment. </p> <p>I think that your choice should be dependent on the type of kyosk you want to build. Some kyosks are just an open browser page. And then you have ...
Domain redirection to the same page and Google <p>We developed a website for a client and he has purchased the .com, .net, .info versions of the domain.</p> <p>Is there any way to redirect all to the same page without being considered by Google as duplicated content and therefore penalized in the ranking position?</p>...
<p>Just use the <a href="http://en.wikipedia.org/wiki/HTTP_301" rel="nofollow">permanent redirect</a>.</p>
Beta testing a new product <p>As a Micro ISV I am coming to the stage in the development of a new desktop software application where beta testing it with an external group of users would be great.</p> <p><em>I would prefer private invite only beta testing as opposed to public free for all beta testing.</em></p> <p><s...
<p>Usually, invite-only beta testing pretty much restricts you to existing or potential customers. If you have customers of this product (you don't because you say it's "new") or of other products from your company, invite them to test your product. They won't all say yes.</p> <p>If you don't have customers, or you ...
Colorize logs in eclipse console <p>Is there a way to colorize parts of logs in the eclipse console. I know I could send to error and standard streams and color them differently but I'm more looking someting in the lines of ANSI escape codes (or anyother, HTML ?) where I could embed the colors in the string to have it...
<p>have a try with this Eclipse Plugin: <a href="http://marketplace.eclipse.org/content/grep-console">Grep Console</a></p> <p><strong>[UPDATE]</strong>: As pointed out by commenters: When installing Grep Console in the currently last version of Eclipse, you need to uncheck 'Group items by category' in the Install dial...
Tetris Piece Rotation Algorithm <p>What are the best algorithms (and explanations) for representing and rotating the pieces of a tetris game? I always find the piece rotation and representation schemes confusing.</p> <p>Most tetris games seem to use a naive "remake the array of blocks" at each rotation:</p> <p><a hr...
<p>There is a limited amount of shapes, so I would use a fixed table and no calculation. That saves time.</p> <p>But there are rotation algorithms. </p> <p>Chose a centerpoint and rotate pi/2. </p> <p>If a block of a piece starts at (1,2) it moves clockwise to (2,-1) and (-1,-2) and (-1, 2). Apply this for each bloc...
How can I create a copy of an Oracle table without copying the data? <p>I know the statement:</p> <pre><code>create table xyz_new as select * from xyz; </code></pre> <p>Which copies the structure and the data, but what if I just want the structure?</p>
<p>Just use a where clause that won't select any rows:</p> <pre><code>create table xyz_new as select * from xyz where 1=0; </code></pre>
Visual Studio solution that just points to a folder and shows all sub-folders and files in the solution explorer? <p>Is there a way to create a blank solution, or some type of file-based project solution within Visual Studio so that I can point to a root folder, and have all of the sub-folders and files in that root, s...
<p>You can also create the blank solution and then click the second-from-the-right icon at the top of the solution explorer (it looks like three files with one "cut out"). Once you click that button to show the files in the solution directory that are not in a project, you can select all the files (with shift-click) a...
How to pass parameter to servlet <p>How do I pass a parameter from a page's useBean in JSP to a servlet in Java? I have some data in a form that gets passed no problem with a submit button, but no way to send anything else. Please help? Here is my code:</p> <pre><code>&lt;input name = "deleteGameButton" type = "submit...
<p>You kind of mess things here.</p> <p>onclick() is Javascript and executed on client side. It has no (direct) way to update session-scoped bean. That bean is left on server-side, and was used when the HTML page was <strong>generated</strong>. To pass parameters back to servlet you need to use good old form fields, a...
Getting a sqlexception on successful insert, VB.NET <p>I'm trying to do a very simple INSERT using VB.NET. For some reason I'm getting a SqlException on every insert though. The data is inserted, but still get the following: </p> <p>Violation of PRIMARY KEY constraint 'PK_User'. Cannot insert duplicate key in object...
<p>As a side note, I STRONGLY recommend changing to parameterized queries to prevent the risk of SQL injection that your current code is not protected from.</p> <p>For the error issue, I would check to see that your code isn't being called twice in the VB version.</p>
Flash Logging API <p>Can anyone recommend a good (AS3) logging API for Flash/AIR/Flex? I need something to capture and record mouse and keyboard events in addition to coded events. Preferably something well documented/supported. Thanks in advance.</p>
<p>I've been using <a href="http://code.google.com/p/flash-thunderbolt/" rel="nofollow">Thunderbolt</a>. It allows you to see your log results in Firebug.</p>
Can anyone explain servlet mapping? <p>I'm trying to write a web application using SpringMVC. Normally I'd just map some made-up file extension to Spring's front controller and live happily, but this time I'm going for REST-like URLs, with no file-name extensions.</p> <p>Mapping everything under my context path to t...
<p>I think I may know what is going on.</p> <p>In your working web.xml you have set your servlet to be the default servlet (/ by itself is the default servlet called if there are no other matches), it will answer any request that doesn't match another mapping.</p> <p>In Failed 1 your /* mapping does appear to be a va...
How does Telnet server communicate to the client? <p>I want to write a C# application where it connects to a telnet server and communicates to the server. I was wondering how a telnet server sends information to the client. I have looked (skimmed) over the <a href="http://www.faqs.org/rfcs/rfc854.html" rel="nofollow">T...
<p>Moving the cursor and changing the color isn't done by the telnet protocol.</p> <p>Your telnet client is emulating a <a href="http://en.wikipedia.org/wiki/Computer_terminal" rel="nofollow">terminal</a>, most probably a VT-100 variant. To move the cursor and change the color, the server sends escape sequences especi...
BindingFlags for Type.GetMethods excluding property accesors <p>Suppose I've got the following program:</p> <pre><code>namespace ReflectionTest { public class Example { private string field; public void MethodOne() { } public void MethodTwo() { } public string Property ...
<p>From the top of my head:</p> <pre><code>mi.IsSpecialName &amp;&amp;( mi.Name.StartsWith("set_") || mi.Name.StartsWith("get_")) </code></pre> <p>should get you all set. SpecialName is more than property accessors (event add/remove methods count here as well), that's why you have to check the names as well.</p> <p>...
Skip Lists -- ever used them? <p>I'm wondering whether anyone here has ever used a <a href="http://en.wikipedia.org/wiki/Skip_list">skip list</a>. It looks to have roughly the same advantages as a balanced binary tree, but is simpler to implement. If you have, did you write your own, or use a pre-written library (and i...
<p>My understanding is that they're not so much a useful alternative to <em>binary trees</em> (e.g. red-black trees) as they are to <em>B-trees</em> for database use, so that you can keep the # of levels down to a feasible minimum and deal w/ base-K logs rather than base-2 logs for performance characteristics. The algo...
One DB per developer or not? <p>In a corporate development environment writing mostly administrative software, should every developer use their own database instance, or should they use a central database instance during development? What are the advantages and disadvantages of each approach? What about other environme...
<p>If you all share the same database, you might have some issues if someone make a structure change to the database and that the code is not "Synchronized" with it.</p> <p>I highly recommend one DB per developer for the only reason that you don't want to do "write" test to see someone else override you right after. A...
Solving the shared-server security problem for Python <p>So my group is trying to set up a shared-server environment for various and sundry web services. I think we've settled on setting <code>disable_functions</code> and <code>disable_classes</code> site wide in <code>php.ini</code> and <code>php_admin_value</code> t...
<p>Well, there is a system called <a href="http://pypi.python.org/pypi/virtualenv" rel="nofollow">virtualenv</a> which allows you to run Python in a sort of safe environment, and configure/load/shutdown these environments on the fly. I don't know much about it, but you should take a serious look into it; here is the de...
Can I use Class.newInstance() with constructor arguments? <p>I would like to use <code>Class.newInstance()</code> but the class I am instantiating does not have a nullary constructor. Therefore I need to be able to pass in constructor arguments. Is there a way to do this?</p>
<pre><code>Class.getDeclaredConstructor(String.class).newInstance("HERESMYARG"); </code></pre>
Which method name fits in best with Objective-C/Cocoa conventions? <p>Here's a quicky question. Which method name makes the most sense for an Objective-C Cocoa application?</p> <pre><code>-(void) doSomethingWithAnimation:(BOOL)animated </code></pre> <p>or:</p> <pre><code>-(void) doSomething:(BOOL)animated </code></p...
<p>I think the Cocoa convention would give your examples the following semmantics (ignoring the BOOL type for the argument, obviously):</p> <pre><code>-(void) doSomethingWithAnimation:(BOOL)animated </code></pre> <p>would actually expect an Animation as the parameter (i.e. something that represents the animation.</p>...
Weird case sensitivity bug in Class.getResource? <p>I was loading an image resource with the following code and it works fine from my dev environment (netbeans) but threw an exception as soon as it ran from the desktop.</p> <pre><code>new ImageIcon(Images.class.getResource("images/highlighter24.gif")); </code></pre> ...
<p>Let me guess: in NetBeans it was loading it from the file system (which is case-insensitive) whereas when running it from the desktop it was in a jar file (which is case-sensitive).</p> <p>I've seen this kind of thing before, where a web app worked fine on Windows but failed on Unix because we'd got the case wrong ...
Sending emails with the error log through CruiseControl <p>How do you configure cruiseControl to send out emails that contains the error log whenever a build fails? I've gotten it to send out emails to users when the build fails, but it does not include the actual error that caused the build to fail. I know that if I...
<p>You can check if \cruisecontrol.net\server\xsl\compile.xsl is the same as \cruisecontrol.net\webdashboard\xsl\compile.xsl.</p> <p>Compile.xsl is the default file used to print the error messages from your error log. The one in \webdashboard\ is used for the web dashboard (as the name implies) and the one under \ser...
What's the UITableView index magnifying glass character? <p>In Apple's iPhone apps (like Contacts), they have a nice magnifying glass icon at the top of the table view index. Since the table view index API is character-based, I assume that this magnifying glass is a Unicode character. So far I've resorted to placing a ...
<p>Returning <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006943-CH3-SW49"><code>UITableViewIndexSearch</code></a> as section index title (same as @"{search}") also works.</p>
General Business Object Practices (and exception errors - redux) <p>Recently, <a href="http://stackoverflow.com/questions/204814/is-there-any-valid-reason-to-ever-ignore-a-caught-exception">I made a post about the developers I'm working with not using try catch blocks properly</a>, and unfortuantely using try... catch ...
<p>Have you considered using an ORM like NHibernate? There's no point in re-inventing the wheel.</p> <p>To me this is a code smell:</p> <pre><code>BLLCustomer cust = ((BLLCustomer)new BLLCustomer()).FillByID(34); </code></pre> <p>Too many brackets!</p> <p>I've found that using the active record pattern in a langua...
What are the benefits of maintaining a "clean" list of using directives in C#? <p>I know VS2008 has the remove and sort function for cleaning up using directives, as does Resharper. Apart from your code being "clean" and removing the problem of referencing namespaces which might not exist in the future, what are the be...
<p>If you always only have the using directives that you need, and always have them appropriately sorted, then when you come to diff two versions of the code, you'll never see irrelevant changes.</p> <p>Furthermore, if you have a neat set of using directives then anyone looking at the code to start with can get a <em>...
Are there better clients for viewing System Monitor logs? <p>Does anyone know of a better GUI client for displaying Windows <a href="http://support.microsoft.com/kb/248345" rel="nofollow">System Monitor</a> log files? (System Monitor is sometimes called <a href="http://support.microsoft.com/?kbid=330138" rel="nofollow"...
<p>See <a href="http://stackoverflow.com/questions/37425/what-is-the-best-way-to-interpret-perfmon-analysis-into-application-specific-ob#158314">this</a> question.</p> <p>The PAL tool does a nice job of creating an HTML report with charts and graphs. By creating your own Threshold file you can control what goes into t...
What is the scope of a function in Javascript/ECMAScript? <p>Today I had a discussion with a colleague about nested functions in Javascript:</p> <pre><code>function a() { function b() { alert('boo') } var c = 'Bound to local call object.' d = 'Bound to global object.' } </code></pre> <p>In this exam...
<p>This is static scoping. Statements within a function are scoped within that function. </p> <p>Javascript has a quirky behavior, however, which is that without the <strong>var</strong> keyword, you've implied a <strong>global variable</strong>. That's what you're seeing in your test. Your "d" variable is availab...
C# How do I sort the columns in a datagrid into alphabetical order? <p>How do I sort the columns in a winforms datagrid control into alphabetical order?</p> <p>Thanks</p>
<p>Have you tried binding the DataGrid to a DataTable object (instead of a view) and turning setting the "AllowSorting" property to true on the DataGrid? I believe the grid will then automatically sort the table source for you.</p> <p>If not, you can always catch the event when a column header is clicked and rebuild a...
How to effectively implement sessions in GAE? <p>I was wondering about implementing my own sessions (more for an exercise than anything else) for a GAE app I'm working ... at first I was thinking of using the datastore to store the session data. However, every time something needs to be added to the session 'bucket', i...
<p><strong>UPDATE - 21 Mar 2011</strong> </p> <p>At the time of this answer <strong>app-engine-patch is discontinued</strong> and <strong>gaeutilities</strong> <a href="https://github.com/dound/gae-sessions/wiki/comparison-with-alternative-libraries">offer worst features</a> than <strong>gae-sessions</strong>.</p> <u...
Good FAQ For Recompiling apps with GCC for AmigaOS? <p>There are a couple of open source apps I am trying to recompile to work under amigaOS. Can someone point me to a good step-by-step guide explaining what changes (from a rule-of-thumb standpoint) I need to make to the source before it'll compile?</p>
<p>Here's a good place to <a href="http://www.monkeyhouse.eclipse.co.uk/amiga/dev.htm" rel="nofollow">start</a>. <a href="http://amiga.sourceforge.net/amigadevhelp/" rel="nofollow">This</a> also looks like an excellent resource.</p> <p>What kind of software are you looking to port, exactly?</p>
How do you detect low memory situations within the java virtual machine? <p>I've been getting some OutOfMemory errors lately in my application. Is it possible to detect ahead of time when the virtual machine is running low on memory? In other words to preemptively deal with OutOfMemory errors before they actually occur...
<p>Java (as of Java 5) now has a standard JMX bean that can be used to receive low memory notification. See <code>java.lang.management.MemoryMXBean</code>.</p>
Can the overall implementation of a component be divided in two objects? <p>I've seen with Microsoft COM and XPCOM, at least from what I've read and gathered so far, that the implementations of interfaces in a component have to essentially be in the single class that derives all the virtual interfaces. Is this correct?...
<p>This should be possible, although probably not supported by the standard high-level wrappers. Most of the wrappers (ATL, MFC, etc.) only support mapping a COM object to a single class. However, QueryInterface is allowed to return a different pointer and calls COM object code, so the first COM object could load a dif...
Is there a concise catalog of variable naming-conventions? <p>There are many different styles of variable names that I've come across over the years.</p> <p>The current wikipedia entry on naming conventions is fairly light... </p> <p>I'd love to see a concise catalog of variable naming-conventions, identifying it by...
<p>The best naming convention set that I've seen is in the book "<a href="http://rads.stackoverflow.com/amzn/click/0735619670" rel="nofollow">Code Complete</a>" Steve McConnell has a great section in there about naming conventions and lots of examples. His examples run through a number of "best practices" for different...
Is it possible to change SQL user-defined data type? <p>I have a bunch of tables using user-defined data type for PK column. Is it possible to change this type Using SQL Server 2005?</p>
<p>I would suggest that it is always possible to refactor poor or outmoded database designs, it simply depends on how much work you are willing to go to in order to do so.</p> <p>If you are looking to replace the user-defined data with a surrogate key then you should be able to simply alter the existing table to conta...
System.Windows.Forms.WebBrowser.Refresh showing previous page <p>My WinForms application has a tab with a <code>System.Windows.Forms.WebBrowser</code> control. There are several controls that set the WebBrowser's <code>.Url</code> property, and when the form repaints it calls the WebBrowser's <code>.Refresh(WebBrowserR...
<p>Unless you're doing something very special, it doesn't make sense to force the WB to repaint itself. Since it is its own control and has its own Handle, it is quite capable of repainting itself whenever it deems necessary. Since you are forcing it to repaint at a moment that's completely out of sync with its Ready...
F# int64 to int <p>How can I convert an <code>Int64</code> to an <code>Int32</code> type in F# without using the <code>Microsoft.FSharp.Compatibility.Int32.of_int64</code>?</p> <p>I'm doing this because interactive doesn't seem to work when I try:</p> <pre><code>open Microsoft.FSharp.Compatibility </code></pre> <p>W...
<p>F# 1.9.6 has a type conversion function so you can do this: </p> <pre><code>let num = 1000 let num64 = int64(num) </code></pre>
How do I make a function happen 50% of the time in vb6 <p>Making a small app, and I want a function to execute 50% of the time. So if I were to dbl click the exe half the time the function would execute, and the other half it wouldn't. I can't seem to find anyway to easily do this, the one solution I tried seemed to ...
<p>Generate a random decimal number between 0 and 1. If it is greater than 0.5 run, if it is less than or equal to 0.5 do not run. </p>
How to lookup django session for a particular user? <p>I am writing an application where I will be accessing the database from django and from a stand alone application. Both need to do session verification and the session should be the same for both of them. Django has a built in authentication/session verification, w...
<p>This answer is being posted five years after the original question, but this SO thread is one of the top Google results when searching for a solution to this problem (and it's still something that isn't supported out of the box with Django).</p> <p>I've got an alternate solution for the use case where you're only c...
VistaDB Connection Issue Programmatically using SQLConnection and ConnectionString <p>I'm getting an error connecting to a VistaDB using a connection string in the web.config file.</p> <p>It works fine using a SQLDataSource AFTER I specified the ProviderName. On another page I'm only connecting in code and </p> <p><e...
<p>You can't use a SqlConnection with a VistaDB connection string. That is the error you are getting from SQL Server - it can't find that server.</p> <p>Use a VistaDBConnection instead.</p>
What's a Turing machine? <p>What is a Turing machine and why do people keep mentioning it? My IBM PC is all I need to do my computation! Why does anyone care about these machines?</p>
<p>The reason that Turing Machines are a big deal has to do with the study of classical Computing Science or Theory of Computation type stuff. It's basically about analyzing the general properties of a computer, such as what theoretical abilities and limitations a computer has, as well as what we mean when we talk abo...
PHP Script Version Checking/Notification <p>How can I check the version of my script against an online file to see if it's the latest version?</p> <p><em>For clarification, I'm talking about a script I wrote, not the version of PHP. I'd like to incorporate a way for the end user to tell when I've updated the script.</...
<p>To specify the second (more simple) solution <a href="http://stackoverflow.com/questions/236070/php-version-checking#236098">phjr</a> proposed:</p> <p>Have a file <code>version.txt</code> on your own public server and include the following function into your deployed project/script:</p> <pre><code>define('REMOTE_V...
Is there a Windows Forms native way to flash a form's title bar? <p>Is there a correct way in Windows Forms to flash a titlebar without having to drop to P/Invoking FlashWindow?</p> <p>I'm using .NET 2.0 for compatibility and size reasons, so maybe I just missed the method because it's in newer versions of the .NET fr...
<p>No, I dont think so. PInvoking the <code>FlashWindowEx</code> method is the only way I think. </p>
Can garbage collection coexist with explicit memory management? <p>For example, say one was to include a 'delete' keyword in C# 4. Would it be possible to guarantee that you'd never have wild pointers, but still be able to rely on the garbage collecter, due to the reference-based system?</p> <p>The only way I could se...
<p>You can - kind of: make your object disposable, and then dispose it yourself.</p> <p>A manual delete is unlikely to improve memory performance in a managed environment. It might help with unmanaged ressources, what dispose is all about. </p> <p>I'd rather have implementing and consuming Disposable objects made eas...
Any Smalltalk on .NET? <p>Are there any usable implementations of Smalltalk for the .NET runtime?</p>
<p>There's a project to build Smalltalk on top of the DLR. Unsurprisingly, it's called <a href="http://www.codeplex.com/IronSmalltalk">IronSmaltalk</a>.</p>
Using the typical get set properties in C#... with parameters <p>I'd like to do the same in C#. Is there anyway of using properties in C# with parameters in the same way I've done with the parameter 'Key' in this VB.NET example?</p> <blockquote> <pre><code>Private Shared m_Dictionary As IDictionary(Of String, Object) ...
<blockquote> <p>Is there anyway of using properties in C# with parameters</p> </blockquote> <p>No. You only can provide the <em>default</em> property in C# with an argument, to model indexed access (as in a dictionary):</p> <pre><code>public T this[string key] { get { return m_Dictionary[key]; } set { m_Dic...
Printing Scrolled Divs <p>I have a web page that displays a long line graph inside a div with overflow-x: scroll. This works well as a web page allowing the use to scroll back and forward through the graph.</p> <p>However, when printing the page the scroll position is reset to zero. Is there a way to overcome this?</p...
<p>I think you're going to have to specify an alternate CSS for printing where you somehow need to remove the overflow:</p> <pre><code>&lt;link rel="stylesheet" type="text/css” href="sheet.css" media="print" /&gt; </code></pre> <p>However, maybe there is an approach with JavaScript or even Flash? If I understand co...
How do I get a zipped file's content using the rubyzip library? <p>I'm trying to extract an uploaded zip file and store its contents in the database, one entry per file. The rubyzip library has nearly no useful documentation.</p> <p>There is an assets table that has key :string (file name) and data :binary (file cont...
<p>Found an even more simple way: </p> <pre><code>asset.data = entry.get_input_stream.read </code></pre>
Embedding Opera in Cocoa <p>So, I'm writing a Cocoa application that needs to be able to display web content using Opera's rendering engine. This is for a feature, not because I'm an Opera fanboi (I'm not). All I've been able to find on the subject is this <a href="http://www.opera.com/pressreleases/en/2003/09/30/" rel...
<p>Adobe has gone to Opera and licensed their software for some (exorbitant?) amount of money. What that probably means is Adobe has access to the library and SDK documentation so they can embed it in their applications. Opera doesn't give its engine away for free as in beer or freedom. It appears there are several B2B...
Is there hard evidence of the ROI of unit testing? <p>Unit testing sounds great to me, but I'm not sure I should spend any time really learning it unless I can convince others that is has significant value. I have to convince the other programmers and, more importantly, the bean-counters in management, that all the ex...
<p>Yes. This is a <a href="http://collaboration.csc.ncsu.edu/laurie/Papers/TDDpaperv8.pdf">link</a> to a study by Boby George and Laurie Williams at NCST and a <a href="http://research.microsoft.com/en-us/groups/ese/nagappan_tdd.pdf">another</a> by Nagappan et al. I'm sure there are more. Dr. Williams <a href="http:...
What methods get called when you resize a JFrame? <p>I'm using a JFrame in which the CENTER portion of the BorderLayout is occupied by a JScrollPane that wraps around a JPanel. What I'm finding is that when I initiate the action that actually causes the JPanel to be displayed, the display doesn't change. But when I r...
<p>Its been a little bit since I've done swing, but from memory, calling validate() on the panel should do the trick. This will cause it and its children to have their layout calculated which is when the scrollbars decision is made. If that doesn't work, try calling validate on the frame's content pane. This is a li...
abstract methods in skeletal implementations of interfaces <p>I was re-reading Effective Java (2nd edition) item 18, <a href="http://my.safaribooksonline.com/9780137150021/ch04lev1sec6" rel="nofollow">prefer interfaces to abstract classes</a>. In that item Josh Bloch provides an example of a skeletal implementation of...
<ol> <li>I would say it helps emphasize what the concrete class is intended to deal with, instead of just leaving it up to the compiler to tell you (or you having to compare both to see what is missing). Kind of self-documenting code. But it certainly isn't necessary, it is more of a style thing, as far as I can see.</...
Tickmark algorithm for a graph axis <p>I'm looking for an algorithm that places tick marks on an axis, given a range to display, a width to display it in, and a function to measure a string width for a tick mark.</p> <p>For example, given that I need to display between 1e-6 and 5e-6 and a width to display in pixels, t...
<p>Check Paul Heckbert's article "Nice Numbers for Graph Labels" on Graphics Gems.</p> <p><a href="http://books.google.com/books?id=fvA7zLEFWZgC&amp;pg=PA61&amp;lpg=PA61#v=onepage&amp;q&amp;f=false">Google book preview</a></p>