input
stringlengths
51
42.3k
output
stringlengths
18
55k
Wildcard Subdomain Exceptions <p>I have a wildcard subdomain enabled and dynamically parse the URL by passing it as-is to my <code>index.php</code> (ex. <code>somecity.domain.com</code>). </p> <p>Now, I wish to create a few subdomains that are static where I can install different application and not co-mingle with my...
<p>Your .htaccess does nothing useful, as Apache is probably configured with DirectoryIndex index.php. Well, it does move domain.com/a to domain.com/index.php, but I doubt that is what you want.</p> <p>Your wildcard virtualhost works because you probably have ServerAlias *.domain.com in your configuration, or a singl...
ColdFusion: Is it safe to leave out the variables keyword in a CFC? <p>In a ColdFusion Component (CFC), is it necessary to use fully qualified names for variables-scoped variables?</p> <p>Am I going to get myself into trouble if I change this:</p> <pre><code>&lt;cfcomponent&gt; &lt;cfset variables.foo = "a privat...
<p>It won't matter to specify "variables" when you create the variable, because foo will be placed in the variables scope by default; but it will matter when you access the variable.</p> <pre><code>&lt;cfcomponent&gt; &lt;cfset foo = "a private instance variable"&gt; &lt;cffunction name="doSomething"&gt; ...
Most effective form of CAPTCHA? <p>Of all the forms of CAPTCHA available, which one is the "least crackable" while remaining fairly human readable?</p>
<blockquote> <p>I believe that CAPTCHA is dying. If someone really wants to break it, it will be broken. I read (somewhere, don't remember where) about a site that gave you free porn in exchange for answering CAPTCHAs to they can be rendered obsolete by bots. So, why bother?</p> </blockquote> <p>Anyone who really wa...
lock keyword in C# <p>I understand the main function of the lock key word from MSDN</p> <blockquote> <p>lock Statement (C# Reference)</p> <p>The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing...
<blockquote> <p>When should the lock be used?</p> </blockquote> <p>A lock should be used to protect shared resources in multithreaded code. Not for anything else.</p> <blockquote> <p>But is it necessary when the application does not spin off any other threads?</p> </blockquote> <p>Absolutely not. It's just a t...
How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC? <p>So I'm working on an exceedingly large codebase, and recently upgraded to gcc 4.3, which now triggers this warning:</p> <blockquote> <p>warning: deprecated conversion from string constant to ‘char*’</p> </blockquote...
<p>Any functions into which you pass string literals <code>"I am a string literal"</code> should use <code>char const *</code> as the type instead of <code>char*</code>.</p> <p>If you're going to fix something, fix it right.</p>
In a LotusScript Agent how do you get the name of the current server? <p>In a LotusScript Agent that is being run via WebQueryOpen, how do you get the name of the current server?</p>
<pre><code>Set s = New NotesSession Set db = s.CurrentDatabase If db.Server &lt;&gt; "" Then Set sName = New NotesName(db.Server) Else Set sName = New NotesName(s.Username) End If </code></pre>
Best way to transfer an xml to SQL Server? <p>I have been hearing the podcast blog for a while, I hope I dont break this. The question is this: I have to insert an xml to a database. This will be for already defined tables and fields. So what is the best way to accomplish this? So far I am leaning toward programatic. ...
<p>In an attempt to try and help, we may need some clarification. Maybe by restating the problem you can let us know if this is what you're asking:</p> <p><strong>How can one import existing xml into a SQL 2005 database, without relying on the built-in xml type?</strong></p> <p>A fairly straight forward solution that...
bug in linq Contains statement - is there a fix or workaround? <p>I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround.</p> <p>If the querysource you do the contains with has more than 10 item...
<p>The more I look at it, and after running more tests, I'm thinking the bug may be in the Sql Server Query Visualizer plugin for Visual Studio, not actually in Linq to SQL itself. So it is not nearly as bad a situation as I thought - the query will return the right results, but you can't trust what the Visualizer is s...
How do I create a spring bean for a Java double primitive? <p>I'd like to create a spring bean that holds the value of a double. Something like:</p> <pre><code>&lt;bean id="doubleValue" value="3.7"/&gt; </code></pre>
<p>Declare it like this</p> <pre><code>&lt;bean id="doubleValue" class="java.lang.Double"&gt; &lt;constructor-arg index="0" value="3.7"/&gt; &lt;/bean&gt; </code></pre> <p>And use like this</p> <pre><code>&lt;bean id="someOtherBean" ...&gt; &lt;property name="value" ref="doubleValue"/&gt; &lt;/bean&gt; </cod...
Are Stored Procedures more efficient, in general, than inline statements on modern RDBMS's? <p>Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them <strong>ALL THE TIME</strong>.</p> <p>I am pretty sure this is grounded in some historical context where this was...
<blockquote> <p><strong>NOTE</strong> that this is a general look at stored procedures not regulated to a specific DBMS. Some DBMS (and even, different versions of the same DBMS!) may operate contrary to this, so you'll want to double-check with your target DBMS before assuming all of this still holds.</p> ...
C++ inheritance and member function pointers <p>In C++, can member function pointers be used to point to derived (or even base) class members? </p> <p>EDIT: Perhaps an example will help. Suppose we have a hierarchy of three classes <code>X</code>, <code>Y</code>, <code>Z</code> in order of inheritance. <code>Y</code...
<p>C++03 std, <a href="http://www.open-std.org/jtc1/sc22/WG21/docs/wp/html/nov97-2/conv.html#conv.mem">§4.11 2 Pointer to member conversions</a>:</p> <blockquote> <p>An rvalue of type “pointer to member of B of type <i>cv</i> T,” where B is a class type, can be converted to an rvalue of type “pointer to membe...
How do you resize an IE browser window to 1024 x 768 <p>In Firefox you can enter the following into the awesome bar and hit enter:</p> <pre><code>javascript:self.resizeTo(1024,768); </code></pre> <p>How do you do the same thing in IE?</p>
<pre><code>javascript:resizeTo(1024,768); vbscript:resizeto(1024,768)</code></pre> <p>Will work in IE7, But consider using something like</p> <pre><code>javascript:moveTo(0,0);resizeTo(1024,768);</code></pre> <p>because IE7 doesn't allow the window to "resize" beyond the screen borders. If you work on a 1024,768 des...
Is there a child's PID? <p>I am currently in an operating systems class and my teacher spent half of the class period talking about PIDs. She mentioned, as many know, that processes know their parent's ID.</p> <p>My question is this:</p> <p>Does a process's PCB know its child's ID? If so, what is the way to go about ...
<p>As far as I know a process doesn't have an explicit list of its children's PIDs, but it can easily be built, since a process should know which child processes it spawns. For example the UNIX fork() call returns the child PID in the parent process and 0 in the child process, CreateProcess() on Windows returns (IIRC) ...
In C# (or any language) what is/are your favourite way of removing repetition? <p>I've just coded a 700 line class. Awful. I hang my head in shame. It's as opposite to DRY as a British summer.</p> <p>It's full of cut and paste with minor tweaks here and there. This makes it's a prime candidate for refactoring. Befo...
<p>I like to start refactoring when I need to, rather than the first opportunity that I get. You might say this is somewhat of an agile approach to refactoring. When do I feel I need to? Usually when I feel that the ugly parts of my codes are starting to spread. I think ugliness is okay as long as they are contained, b...
How to escape text for regular expression in Java <p>Does Java have a built-in way to escape arbitrary text so that it can be included in a regular expression? For example, if my users enter "$5", I'd like to match that exactly rather than a "5" after the end of input.</p>
<p>Since <a href="http://download.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#quote%28java.lang.String%29">Java 1.5, yes</a>:</p> <pre><code>Pattern.quote("$5"); </code></pre>
My first Lisp macro; is it leaky? <p>I've been working through <a href="http://gigamonkeys.com/book" rel="nofollow">Practical Common Lisp</a> and as an exercise decided to write a macro to determine if a number is a multiple of another number:</p> <p><code>(defmacro multp (value factor)<br /> `(= (rem ,value ,facto...
<p>Siebel gives an extensive rundown (for simple cases anyway) of possible sources of leaks, and there aren't any of those here. Both <code>value</code> and <code>factor</code> are evaluated only once and in order, and <code>rem</code> doesn't have any side effects.</p> <p>This is not good Lisp though, because there's...
Can I change the appearance of an html image during hover without a second image? <p>Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)?</p>
<p><a href="http://www.w3schools.com/css/css_image_transparency.asp" rel="nofollow">Here's some good information about image opacity and transparency with CSS</a>.</p> <p>So to make an image with opacity 50%, you'd do this:</p> <pre><code>&lt;img src="image.png" style="opacity: 0.5; filter: alpha(opacity=50)" /&gt; <...
Here are fifteen characters <p>I will never understand why the SE network insists that every worthless question has to exist forever.</p>
<p>It's more of a browse assist than a search assist. If you see a large or bold tag in a tag cloud that interests you it my lead to some knowledge discovery that wouldn't have otherwise been sought out with a deliberate search. When I am browsing del.ico.us or stackoverflow I appreciate the tags as they sometimes le...
What are the best strategies for using multiple AJAX libraries? <p>What experience can you share about using multiple AJAX libraries?</p> <p>There are useful features in Prototype, some in jQuery, the Yahoo library, etc. Is it possible to include all libraries and use what you want from each, do they generally all pla...
<p>You could use all those libraries, but I highly recommend against it. Downloading and executing that much JavaScript will most likely choke the browser and slow down your user's experience. It would be much better from a user's perspective and a developer's to pick one. Less context/architecture switching and less c...
loading Java classes from a signed applet <p>If I'm running a signed Java applet, can I load additional classes from remote sources (in the same domain, maybe even the same host) and run them?</p> <p>I'd like to do this without changing pages or even stopping the current applet. Of course, the total size of all classe...
<p>I think classes are lazy loaded in applets. being loaded on demand.</p> <p>Anyway, if the classes are outside of a jar you can simply use the applet classloader and load them by name. Ex:</p> <pre><code>ClassLoader loader = this.getClass().getClassLoader(); Class clazz = loader.loadClass("acme.AppletAddon"); </cod...
Why should the "PIMPL" idiom be used? <p>Backgrounder:</p> <p>The <a href="http://en.wikipedia.org/wiki/Opaque_pointer" rel="nofollow">PIMPL Idiom</a> (Pointer to IMPLementation) is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library the publ...
<p>I think most people refer to this as the Handle Body idiom. See James Coplien's book Advanced C++ Programming Styles and Idioms (<a href="http://rads.stackoverflow.com/amzn/click/0201548550">Amazon link</a>). It's also known as the <a href="http://en.wikipedia.org/wiki/Cheshire_Cat">Cheshire Cat</a> because of Lewis...
Best way to initiate a download? <p>On a PHP-based web site, I want to send users a download package after they have filled out a short form. The site-initiated download should be similar to sites like download.com, which say "your download will begin in a moment."</p> <p>A couple of <strong>possible approaches</stron...
<p>You can also do a meta refresh, which most browsers support. Download.com places one in a noscript tag.</p> <pre><code>&lt;meta http-equiv="refresh" content="5;url=/download.php?doc=123.zip"/&gt; </code></pre>
Getting started with Silverlight development <p>How does one start development in Silverlight?</p> <p>Does one need a new IDE? or Visual studio will support?</p>
<p>Yes there is tooling support for Visual Studio. It is still in Beta though.</p> <p><a href="http://silverlight.net/GetStarted/" rel="nofollow">Get Started Building Silverlight 2 Applications</a></p> <p>1) Install Visual Studio 2008 then Install Silverlight Tools Beta 2 for Visual Studio 2008 This add-on to Visual ...
ASP.NET - Is it possible to trigger a postback from server code? <p>Is it possible to to programmatically trigger a postback from server code in ASP.NET? I know that it is possible to do a Response.Redirect or Server.Transfer to redirect to a page, but is there a way to trigger a postback to the same page in server co...
<p>Asp.net Postbacks are initiated from the client (typically form submission). I am not sure what you are trying to achieve. Some of the server side <a href="http://www.15seconds.com/issue/020102.htm">page lifecyle</a> events are already executed and what you are trying to do is raise the previous event handlers again...
How do I write a python HTTP server to listen on multiple ports? <p>I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass of BaseHTTPServer.BaseHTTPRequestHandler. Is it possible to make this listen on more than one port?</p> <p>What I'm doing now:</p> <pre><code>class MyRequestHandler(...
<p>Sure; just start two different servers on two different ports in two different threads that each use the same handler. Here's a complete, working example that I just wrote and tested. If you run this code then you'll be able to get a Hello World webpage at both <a href="http://localhost:1111/">http://localhost:111...
How to determine the value of a controller variable during execution in Ruby on Rails? <p>What is the best way for me to determine a controller variable's value during execution?</p> <p>For example, is there a way I can insert a break in the code, and cause the value of the variable to be output to the screen (or the ...
<p>Yes. The easiest way is to raise the value as a string. Like so: <code>raise @foo.to_s</code></p> <p>Or, you can install the debugger (<code>gem install ruby-debug</code>), and then start the development server with the <code>--debugger</code> flag. Then, in your code, call the <code>debugger</code> instruction.</p...
Which jQuery plugin should be used to fix the IE6 PNG transparency issue? <p>Is there an IE6/PNG fix that is officially developed by the jQuery team?</p> <p>If not which of the available plugins should I use?</p>
<p>I'm using <a href="http://jquery.andreaseberhard.de/pngFix/" rel="nofollow">jquery.pngFix.js</a>. I don't know if it's officially sanctioned or not, I do know that it works. I chose it because it was the plugin included with FancyBox, no other reason. </p>
Installing Curl IDE/RTE on AMD processors <p>Trying to move my development environment to Linux. And new to Curl. Can't get it to install the IDE &amp; RTE packages on an AMD HP PC running Ubuntu x64. I tried to install the Debian package via the package installer and get "Error: Wrong architecture - i386". Tried using...
<p>It's been a while since I ran linux, but try looking for the x64 version. There are also x64 to x86 compatibility libraries available that should make 32 bit programs work for most situations. </p> <p>The <a href="http://ubuntuforums.org/" rel="nofollow">ubuntu forums</a> are a much better place for this question, ...
Find out how much memory is being used by an object in C#? <p>Does anyone know of a way to find out how much memory an instance of an object is taking?</p> <p>For example, if I have an instance of the following object:</p> <p>TestClass tc = new TestClass();</p> <p>Is there a way to find out how much memory the insta...
<p>If you are not trying to do it in code itself, which I'm assuming based on your ANTS reference, try taking a look at CLRProfiler (currently v2.0). It's free and if you don't mind the rather simplistic UI, it can provide valuable information. It will give you a in-depth overview of all kinds of stats. I used it a whi...
What is wrong with using inline functions? <p>While it would be very convenient to use inline functions at some situations,</p> <p>Are there any drawbacks with inline functions?</p> <p><strong>Conclusion</strong>:</p> <p>Apparently, There is nothing wrong with using inline functions.</p> <p>But it is worth noting t...
<p>It worth pointing out that the inline keyword is actually just a hint to the compiler. The compiler may ignore the inline and simply generate code for the function someplace.</p> <p>The main drawback to inline functions is that it can <strong>increase the size of your executable</strong> (depending on the number of...
Changing the font in Aquamacs? <p>I've recently had a need to do a bit of lisp editing and I found the nifty Ready Lisp package for OS X, which is great, except Aquamacs automatically uses a proportional font (which is idiotic, IMHO) and I want to change it to a monospace font. However, I'm not really much of an EMACS ...
<p>In Aquamacs 2.1, you can set the font through Options->Appearance->Font for Text Mode... That brings up the standard font chooser window, choose the font you like. Then, when you exit out of emacs (C-x C-c) you'll be prompted to save options, hit "y".</p>
What is the best implementation for DB Audit Trail? <p>A DB Audit Trail captures the User Last Modified, Modified Date, and Created Date.</p> <p>There are several possible implementations:</p> <ul> <li>SQL Server Triggers</li> <li>Add UserModified, ModifiedDate, CreatedDate columns to the database and include logic i...
<p>Depending on what you're doing, you might want to move the audit out of the data layer into the data access layer. It give you more control.</p> <p>I asked a similar question wrt NHibernate and SqlServer <a href="http://stackoverflow.com/questions/15917/data-auditing-in-nhibernate-and-sqlserver" rel="nofollow">her...
Is there a better Windows Console Window? <p>I find working on the command line in Windows frustrating, primarily because the console window is wretched to use compared to terminal applications on linux and OS X such as "rxvt", "xterm", or "Terminal". Major complaints:</p> <ol> <li><p>No standard copy/paste. You hav...
<p>Sorry for the self-promotion, I'm the author of another Console Emulator, not mentioned here.</p> <p><a href="http://www.fosshub.com/ConEmu.html">ConEmu</a> is opensource console emulator with tabs, which represents multiple consoles and simple GUI applications as one customizable GUI window.</p> <p>Initially, the...
Development directory Structure <p>I am wondering what directory structure are commonly used in development projects. I mean with the idea of facilitating builds, deploys release, and etc.</p> <p>I recently used a <a href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html"...
<p>After a couple years working with different structures I recently found a structure that hols most variations for me:</p> <pre><code>/project_name (everything goes here) /web (htdocs) /img /css /app (usually some framework or sensitive code) /lib (externa libs) ...
How to save the output of a console application <p>I need advice on how to have my C# console application display text to the user through the standard output while still being able access it later on. The actual feature I would like to implement is to dump the entire output buffer to a text file at the end of program ...
<p>The perfect solution for this is to use <a href="http://logging.apache.org/log4net/">log4net</a> with a console appender and a file appender. There are many other appenders available as well. It also allows you to turn the different appenders off and on at runtime. </p>
Mocking Static Blocks in Java <p>My motto for Java is "just because Java has static blocks, it doesn't mean that you should be using them." Jokes aside, there are a lot of tricks in Java that make testing a nightmare. Two of the most I hate are Anonymous Classes and Static Blocks. We have a lot of legacy code that make...
<p><a href="http://powermock.org">PowerMock</a> is another mock framework that extends EasyMock and Mockito. With PowerMock you can easily <a href="http://code.google.com/p/powermock/wiki/SuppressUnwantedBehavior">remove unwanted behavior</a> from a class, for example a static initializer. In your example you simply ad...
Web in a desktop application: Good web browser controls? <p>I've been utlising a "web browser control" in desktop based applications (in my case Windows Forms .NET) for a number of years. I mostly use it to create a familiar flow-based user interface that also allows a seamless transition to the internet where require...
<p>hmm..Interestingly </p> <ol> <li><a href="http://www.iol.ie/~locka/mozilla/control.htm" rel="nofollow">Mozilla</a> seems to provide ActiveX control</li> <li><a href="http://kmeleon.sourceforge.net/" rel="nofollow">K-Melon</a> is another Gecko based browser control</li> </ol>
Is there a good, free WYSIWYG editor for creating HTML using a Django template? <p>I'm interested to get a free, WYSIWYG HTML editor that is compatible with Django template. Any ideas?</p> <blockquote> <p>Thanks LainMH.</p> <p>But I afraid fckeditor is used in web app, for the purpose of editing HTML. What I ...
<p><a href="http://www.fckeditor.net/">http://www.fckeditor.net/</a> ?</p> <p>EDIT: Just found this: <a href="http://blog.newt.cz/blog/integration-fckeditor-django/">http://blog.newt.cz/blog/integration-fckeditor-django/</a></p>
DIV's vs. Tables or CSS vs. Being Stupid <p>I know that tables are for tabular data, but it's so tempting to use them for layout. I can handle DIV's to get a three column layout, but when you got 4 nested DIV's, it get tricky. </p> <p>Is there a tutorial/reference out there to persuade me to use DIV's for layout?</p> ...
<p>There's the <a href="http://developer.yahoo.com/yui/grids/">Yahoo Grid CSS</a> which can do all sorts of things. But remember: <strong>CSS IS NOT A RELIGION</strong>. If you save hours by using tables instead of css, do so. </p> <p>One of the corner cases I could never make my mind up about is forms. I'd love to do...
What are the pros and cons of the SVN plugins for Eclipse, Subclipse and Subversive? <p>SVN in Eclipse is spread into 2 camps. The SVN people have developed a plugin called <a href="http://subclipse.tigris.org/">Subclipse</a>. The Eclipse people have a plugin called <a href="http://www.eclipse.org/subversive/">Subversi...
<p>Both are very similar but Subversive is the "eclipse svn provider". I primarily use Subversive because of a few convenient features:</p> <p><strong>Grouping of history</strong></p> <p>When I'm browsing the history of a branch instead of just seeing a bunch of rows for every commit it can group commits by today, we...
What Makes a Good Unit Test? <p>I'm sure most of you are writing lots of automated tests and that you also have run into some common pitfalls when unit testing. </p> <p>My question is do you follow any rules of conduct for writing tests in order to avoid problems in the future? To be more specific: What are the <stron...
<p>Let me begin by plugging sources - <a href="http://pragprog.com/titles/utj/pragmatic-unit-testing-in-java-with-junit" rel="nofollow">Pragmatic Unit Testing in Java with JUnit</a> (There's a version with C#-Nunit too.. but I have this one.. its agnostic for the most part. Recommended.)</p> <p>Good Tests should be A ...
How can I access the backing variable of an auto-implemented property? <p>In the past we declared properties like this:</p> <pre><code>public class MyClass { private int _age; public int Age { get{ return _age; } set{ _age = value; } } } </code></pre> <p>Now we can do:</p> <pre>...
<p>The aim of the new automatic properties is to reduce the amount of boilerplate code you need to write when you just have a simple property that doesn't need any special logic in the get or the set. </p> <p>If you want to access the private member that these properties use, that's usually for a few reasons:</p> <ul...
What are the pros and cons of object databases? <p>There is a lot of information out there on object-relational mappers and how to best avoid impedance mismatch, all of which seem to be moot points if one were to use an object database. My question is why isn't this used more frequently? Is it because of performance ...
<p>I've been using <a href="http://www.db4o.com">db4o</a> which is an OODB and it solves most of the cons listed:</p> <ul> <li>Familiarity - Programmers know their language better then SQL (see Native queries)</li> <li>Performance - this one is highly subjective but you can take a look at <a href="http://polepos.sourc...
How to work around a very large 2d array in C++ <p>I need to create a 2D int array of size 800x800. But doing so creates a stack overflow (ha ha).</p> <p>I'm new to C++, so should I do something like a vector of vectors? And just encapsulate the 2d array into a class?</p> <p>Specifically, this array is my zbuffer i...
<p>You need about 2.5 megs, so just using the heap should be fine. You don't need a vector unless you need to resize it. See <a href="https://isocpp.org/wiki/faq/freestore-mgmt#multidim-arrays" rel="nofollow">C++ FAQ Lite</a> for an example of using a "2D" heap array.</p> <pre><code>int *array = new int[800*800]; </...
How to implement database engine independent paging? <p>Task: implement paging of database records suitable for different RDBMS. Method should work for mainstream engines - MSSQL2000+, Oracle, MySql, etc.</p> <p>Please don't post RDBMS specific solutions, I know how to implement this for most of the modern database en...
<p>There would have been a universal solution if SQL specifications had included paging as a standard. The requirement for any RDBMS language to be called an RDBMS language does not include paging support as well. </p> <p>Many database products support SQL with proprietary extensions to the standard language. Some of ...
Browser WYSIWYG best practices <p>I am using a rich text editor on a web page. .NET has feature that prevent one from posting HTML tags, so I added a JavaScript snippet to change the angle brackets to and alias pair of characters before the post. The alias is replaced on the server with the necessary angle bracket and...
<p>There's actually a way to turn that "feature" off. This will allow the user to post whichever characters they want, and there will be no need to convert characters to an alias using Javascript. See this article for <a href="http://mdid.org/mdidwiki/index.php?title=Disabling_Request_Validation" rel="nofollow">disabl...
Is there a way to asynchronously filter an IList? <p>Ok, so there has to be a way to do this... no? If not I'd love some ideas. </p> <p>I have two repeaters and an image inside an update panel along with some AJAX dropdowns with link buttons to the left. I want to update the data inside the update panel as fast as pos...
<p>As far as I know, it is not easy to get just Data and data-bind the repeater on the client side. But, you might want to <a href="http://dotnetslackers.com/articles/ajax/ASPNETRepeater.aspx" rel="nofollow">check this out</a>.</p>
Sum of items in a collection <p>Using LINQ to SQL, I have an Order class with a collection of OrderDetails. The Order Details has a property called LineTotal which gets Qnty x ItemPrice. </p> <p>I know how to do a new LINQ query of the database to find the order total, but as I already have the collection of OrderDet...
<p>You can do LINQ to Objects and the use LINQ to calculate the totals:</p> <pre><code>decimal sumLineTotal = (from od in orderdetailscollection select od.LineTotal).Sum(); </code></pre> <p>You can also use lambda-expressions to do this, which is a bit "cleaner".</p> <pre><code>decimal sumLineTotal = orderdetailscol...
ADO.NET Entity Framework tutorials <p>Does anyone know of any good tutorials on ADO.NET Entity Framework?</p> <p>There are a few useful links here at <a href="http://stackoverflow.com/questions/42826/where-to-start-with-entity-framework">Stack OverFlow</a>, and I've found one tutorial at <a href="http://dotnet-archite...
<p>Microsoft offers <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=355c80e9-fde0-4812-98b5-8a03f5874e96&amp;displaylang=en">.NET 3.5 Enhancements Training Kit</a> it contains documentation and sample code for ADO.NET EF</p>
How to save jpg image to database and then load it in Delphi using FIBplus and TImage? <p>How do I save a jpg image to database and then load it in Delphi using FIBplus and TImage?</p>
<pre><code>var S : TMemoryStream; begin S := TMemoryStream.Create; try TBlobField(AdoQuery1.FieldByName('ImageField')).SaveToStream(S); S.Position := 0; Image1.Picture.Graphic.LoadFromStream(S); finally S.Free; end; end; </code></pre> <p>if you are using JPEG images, add JPG unit to <strong>u...
Does pop_back() really invalidate *all* iterators on an std::vector? <pre><code>std::vector&lt;int&gt; ints; // ... fill ints with random values for(std::vector&lt;int&gt;::iterator it = ints.begin(); it != ints.end(); ) { if(*it &lt; 10) { *it = ints.back(); ints.pop_back(); continue;...
<p>Here is your answer, directly from The Holy Standard:</p> <blockquote> 23.2.4.2 A vector satisfies all of the requirements of a container and of a reversible container (given in two tables in 23.1) and of a sequence, including most of the optional sequence requirements (23.1.1). </blockquote> <blockquote> 23.1.1.1...
Regular expression that rejects all input? <p>Is is possible to construct a regular expression that rejects all input strings?</p>
<p>Probably this:</p> <pre><code>[^\w\W] </code></pre> <p>\w - word character (letter, digit, etc)<br /> \W - opposite of \w</p> <p>[^\w\W] - should always fail, because any character should belong to one of the character classes - \w or \W</p> <p>Another snippets:</p> <pre><code>$.^ </code></pre> <p>$ - assert p...
How can I get Axis 1.4 to not generate several prefixes for the same XML namespace? <p>I am receiving SOAP requests from a client that uses the Axis 1.4 libraries. The requests have the following form:</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmln...
<p>I have the same issue. For the moment, I've worked around it by writing a BasicHandler extension, and then walking the SOAPPart myself and moving the namespace reference up to a parent node. I don't <em>like</em> this solution, but it does seem to work.</p> <p>I really hope somebody comes along and tells us what ...
How to prevent IE6 from refetching already-fetched images added via DOM manipulation <p>If you add a image to your browser's DOM, IE6 will not check its cache to see if it already downloaded the image but will, instead, re-retrieve it from the server. I have not found any combination of HTTP response headers (of the e...
<p>Maybe <a href="http://www.mister-pixel.com/index.php?Content__state=is_that_simple" rel="nofollow">this</a> will work? (is the same behaviour like hovering on links with css background image)</p>
How do I move a file (or folder) from one folder to another in TortoiseSVN? <p>I would like to move a file or folder from one place to another within the same repository without having to use Repo Browser to do it, and without creating two independent add/delete operations. Using Repo Browser works fine except that yo...
<p>To move a file or set of files using <code>Tortoise SVN</code>, right-click-and-drag the target files to their destination and release the right mouse button. The popup menu will have a <code>SVN move versioned files here</code> option.</p> <p><strong>Note that the destination folder must have already been added to...
Saving Java Object Graphs as XML file <p>What's the simplest-to-use techonlogy available to save an arbitrary Java object graph as an XML file (and to be able to rehydrate the objects later)?</p>
<p>The easiest way here is to serialize the object graph. Java 1.4 has built in support for serialization as XML.</p> <p>A solution I have used successfully is XStream (<a href="http://x-stream.github.io/)-" rel="nofollow">http://x-stream.github.io/)-</a> it's a small library that will easily allow you to serialize an...
IIS crashes when serving an ASP.NET application under heavy load. How to troubleshoot it? <p>I am working on an ASP.NET web application, it seems to be working properly when I try to debug it in Visual Studio. However when I emulate heavy load, IIS crashes without any trace -- log entry in the system journal is very ge...
<p>Download Debugging tools for Windows: <a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" rel="nofollow">http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx</a></p> <p>Debugging Tools for Windows has has a script (ADPLUS) that allows you to create dumps when a process CRASHES: <a href=...
Exceptions not passed correctly thru RCF (using Boost.Serialization) <p>I use RCF with boost.serialization (why use RCF's copy when we already use the original?) It works OK, but when an exception is thrown in the server, it's not passed correctly to the client. Instead, I get an RCF::SerializationException quoting an ...
<p>Here's a patch given by Jarl at <a href="http://www.codeproject.com/KB/threads/Rcf_Ipc_For_Cpp.aspx?msg=2739150#xx2730536xx" rel="nofollow">CodeProject</a>:</p> <p>In RcfServer.cpp, before the line where RcfServer::handleSession() is defined (around line 792), insert the following code:</p> <pre><code>void seriali...
using asynchbeans instead of native jdk threads <p>are there any performance limitations using IBM's asynchbeans? my apps jvm core dumps are showing numerous occurences of orphaned threads. Im currently using native jdk unmanaged threads. Is it worth changing over to managed threads?</p>
<p>In my perspective asynchbeans are a workaround to create threads inside Websphere J2EE server. So far so good, websphere lets you create pool of "worker" threads, controlling this way the maximum number of threads, typical J2EE scalability concern. </p> <p>I had some problems using asynchbeans inside websphere on "...
How do I get an auto-scrolling text display on .NET forms - e.g. for credits <p>Need to show a credits screen where I want to acknowledge the many contributors to my application. </p> <p>Want it to be an automatically scrolling box, much like the credits roll at the end of the film.</p>
<p>A easy-to-use snippet would be to make a multiline textbox. With a timer you may insert line after line and scroll to the end after that:</p> <pre><code>textbox1.SelectionStart = textbox1.Text.Length; textbox1.ScrollToCaret(); textbox1.Refresh(); </code></pre> <p>Not the best method but it's simple and working. Th...
BufferedImage in IKVM <p>What is the best and/or easiest way to replace the missing BufferedImage functionality for a Java project I am converting to .NET with IKVM?</p> <p>I'm basically getting "cli.System.NotImplementedException: BufferedImage" exceptions when running the application, which otherwise runs fine.</p>
<p>The AWT code in IKVM is fairly easy to read and edit. I'd recommend you look for the methods that you are using that throw that exception, and then implement them. I've done this several times before with IKVM's AWT implementation and found it easy to do for background/server related functions. Its much less usab...
Surrogate vs. natural/business keys <p>Here we go again, the old argument still arises... </p> <p>Would we better have a business key as a primary key, or would we rather have a surrogate id (i.e. an SQL Server identity) with a unique constraint on the business key field? </p> <p>Please, provide examples or proof to ...
<p>Just a few reasons for maintaining surrogate keys:</p> <ol> <li><p><strong>Stability</strong>: Changing a key because of a business or natural need will negatively affect related tables. Surrogate keys rarely, if ever, need to be changed because there is nothing tied to the value.</p></li> <li><p><strong>Conventio...
Scrum Process Management - Tips, Pitfalls, Ideas <p>I've been doing scrum with a team for a while, but things seem messy for some reasons. I've been thinking on how they could be changed and have a couple of questions that I would like to raise here. </p> <p>First, what should be the role of testers, designers and no...
<p>In general testers and documenters (and other non-developes) are all equal members of a scrum team. The idea behind that is to minimize risk. </p> <p>Requiring a definition of done, which includes a potentially shipable product that's fully tested and documented, forces the project to come together at the end of e...
Add Custom TextboxCell to a DataGridView control that contains a button to open the FileDialog <p>I would like to add a DataGridViewTextBoxCell cell to a DataGridViewCell control, but as well as being able to type in the text cell as normal it must also contain a '...' button that once clicks brings up the OpenFileDial...
<p><a href="http://msdn.microsoft.com/en-au/library/7tas5c80.aspx" rel="nofollow">This</a> MSDN article explains how to add a custom control to a DataGridView</p> <p>You should be able to make a UserControl that has a textbox and button on it and embed that in the DataGridView.</p>
What's the best way to build a string of delimited items in Java? <p>While working in a Java app, I recently needed to assemble a comma-delimited list of values to pass to another web service without knowing how many elements there would be in advance. The best I could come up with off the top of my head was something ...
<h3>Pre Java 8:</h3> <p>Apache's commons lang is your friend here - it provides a join method very similar to the one you refer to in Ruby: </p> <p><a href="http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#join(java.lang.Iterable,%20char)"><code>StringUtils.join(java.lan...
Is there a way to build a Flash 9 SWF from an FLA file without using the Flash IDE? <p>Two reasons this would be useful, in case there's some other way to achieve these goals: 1) Building in the Flash IDE is really slow; I was hoping a third-party compiler would be faster. 2) It would be nice to be able to build projec...
<p>To answer the original question, there is no way to compile FLAs without using the Flash IDEs. </p> <p>The only partial solution to to use a command line script that automates opening Flash Authoring and compiling the FLA. You can find one such example here:</p> <p><a href="http://www.mikechambers.com/blog/2004/02...
How do you reliably get an IP address via DHCP? <p>I work with embedded Linux systems that sometimes want to get their IP address from a DHCP server. The DHCP Client client we use (<a href="http://www.phystech.com/download/dhcpcd.html" rel="nofollow" title="DHCPCD">dhcpcd</a>) has limited retry logic. If our device s...
<p>The reference dhclient from the ISC should run forever in the default configuration, and it should acquire a lease later if it doesn't get one at startup.</p> <p>I am using the out of the box dhcp client on FreeBSD, which is derived from OpenBSD's and based on the ISC's dhclient, and this is the out of the box beha...
Does Vista do stricter checking of Interface Ids in DCOM calls? (the Stub received bad Data)? <p>I hope everyone will pardon the length, and narrative fashion, of this question. I decided to describe the situation in some detail in my blog. I later saw Joel's invitation to this site, and I thought I'd paste it here t...
<p>When Microsoft got the security religion, DCOM (and the underlying RPC) got a lot of attention, and there definitely were changes made to close security holes that resulted in stricter marshaling. I'm suprised you see this in Vista but not in XP, but its possible that additional checks were added for Vista. Altern...
VS 2003 Reports "unable to get the project file from the web server" when opening a solution from VSS <p>When attempting to open a project from source control on a newly formatted pc, I receive an "unable to get the project file from the web server" after getting the sln file from VSS. If I attempt to open the sln file...
<p>This question is very old so you have probably solved the issue, but just in case: Does the project file use IIS? If so then it is probably trying to read the project file from IIS and the virtual directory does not exist on the newly formatted computer. Also, there should be more detail about the message in the Out...
Does Java impose any further restrictions on filenames other than the underlying operating system? <p>Does Java impose any extra restrictions of its own. Windows (upto Vista) does not allow names to include</p> <pre><code>\ / &lt; &gt; ? * : </code></pre> <p>I know HOW to validate names (a regular expression).</p> <...
<p>No, you can escape any character that Java doesn't allow in String literals but the filesystem allows.</p> <p>Also, if trying to port an Windows app to Mac or Unix it is best to use:</p> <pre><code>File.separator </code></pre> <p>To determine the correct file separator to use on each platform.</p>
Splitting a file and its lines under Linux/bash <p>I have a rather large file (150 million lines of 10 chars). I need to split it in 150 files of 2 million lines, with each output line being alternatively the first 5 characters or the last 5 characters of the source line. I could do this in Perl rather quickly, but I w...
<p>Homework? :-)</p> <p>I would think that a simple pipe with sed (to split each line into two) and split (to split things up into multiple files) would be enough.</p> <p>The man command is your friend.</p> <p><hr /></p> <p>Added after confirmation that it is not homework:</p> <p>How about</p> <pre><code>sed 's/...
Best Way to Animate Sprites in Flex <p>Is there a preferred way to handle animation when using Flex -- For instance, if I want to render a ball and bounce it around the screen?</p>
<p>If you're building a Flex application, you should use Flex's native Effect classes. They're probably already compiled into your app, since the core components use them, and you won't increase your SWF size with duplicate functionality like you would if you used another library. For simple animations, either mx.effec...
Struts 1.3: forward outside the application context? <p>Struts 1.3 application. Main website is NOT served by struts/Java. I need to forward the result of a struts action to a page in the website, that is outside of the struts context. Currently, I forward to a JSP in context and use a meta-refresh to forward to the...
<p>You can't "forward", in the strict sense. Just call sendRedirect() on the HttpServletResponse object in your Action class's execute() method. and, then 'return null'.</p> <p>alternately, either call setModule on the ActionForward object (that you are going to return) or set the path to an absolute URI</p>
Missing classes in WMI when non-admin <p>I'd like to be able to see <code>Win32_PhysicalMedia</code> information when logged in as a <em>Limited User</em> in Windows XP (no admin rights). It works ok when logged in as <em>Admin</em>, <code>WMIDiag</code> has just given a clean bill of health, and <code>Win32_DiskDrive<...
<p>WMI does not give limited users this information.</p> <p>If you can access Win32 functions from your language, you can call <a href="http://msdn.microsoft.com/en-us/library/aa364993(VS.85).aspx" rel="nofollow">GetVolumeInformation</a>.</p>
How to make Emacs terminal colors the same as Emacs GUI colors? <p>I program with Emacs on Ubuntu (Hardy Heron at the moment), and I like the default text coloration in the Emacs GUI. However, the default text coloration when Emacs is run in the terminal is different and garish.</p> <p>How do I make the colors in the ...
<p>You don't have to be stuck to your terminal's default 16 (or fewer) colours. Modern terminals will support 256 colours (which will get you pretty close to your GUI look).</p> <p>Unfortunately, getting your terminal to support 256 colours is the tricky part, and varies from term to term. <a href="http://www.xvx.ca/~...
Game Programming and Event Handlers <p>I haven't programmed games for about 10 years (My last experience was DJGPP + Allegro), but I thought I'd check out XNA over the weekend to see how it was shaping up.</p> <p>I am fairly impressed, however as I continue to piece together a game engine, I have a (probably) basic qu...
<p>If you were to think of an event as a subscriber list, in your code all you are doing is registering a subscriber. The number of instructions needed to achieve that is likely to be minimal at the CLR level.</p> <p>If you want your code to be generic or dynamic, then you're need to check if something is subscribed ...
Draining Standard Error in Java <p>When launching a process from Java, both stderr and stdout can block on output if I don't read from the pipes. Currently I have a thread that pro-actively reads from one and the main thread blocks on the other.</p> <p>Is there an easy way to join the two streams or otherwise cause t...
<p>Set the redirectErrorStream property on ProcessBuilder to send stderr output to stdout:</p> <pre><code>ProcessBuilder builder = new ProcessBuilder(command); builder.redirectErrorStream(true); </code></pre> <p>You should then create a thread to deal with the process stream, something like the following:</p> <pre><...
How does one record audio from a Javascript based webapp? <p>I'm trying to write a web-app that records WAV files (eg: from the user's microphone). I know Javascript alone can not do this, but I'm interested in the least proprietary method to augment my Javascript with. My targeted browsers are Firefox for PC and Mac (...
<p>This is an old thread, but the issue remains relevant. It should be noted that there is a way to record audio to the server in Flash without a proprietary back-end. Here's an example project to get you started:</p> <p><a href="https://code.google.com/p/wami-recorder/">https://code.google.com/p/wami-recorder/</a><...
Is there good .sol editor for Flash Player 9 Local Shared Objects? Can we build one? <p>There's plenty of them out there but none of them do what I would like them to do.</p> <p>Most of them crash when opening a file or simply corrupt the data. Many don't run at all. It seems to me that most were written 3-4 years ago...
<p>Use <a href="http://blog.coursevector.com/minerva">minerva</a>. I've tried it, it works with every .sol I open it with.</p>
How do I call MySQL stored procedures from Perl? <p>How do I call MySQL stored procedures from Perl? Stored procedure functionality is fairly new to MySQL and the MySQL modules for Perl don't seem to have caught up yet.</p>
<p>MySQL stored procedures that produce datasets need you to use Perl DBD::mysql 4.001 or later. (<a href="http://www.perlmonks.org/?node_id=609098" rel="nofollow">http://www.perlmonks.org/?node_id=609098</a>)</p> <p>Below is a test program that will work in the newer version:</p> <pre><code>mysql&gt; delimiter // my...
How to copy text from Emacs to another application on Linux <p>When I yank text in Emacs 22.1.1 (in its own window on X, in KDE, on Kubuntu), I can't paste it anywhere else.</p>
<p>Let's be careful with our definitions here</p> <ul> <li>An <em>Emacs copy</em> is the command <code>kill-ring-save</code> (usually bound to <kbd>M-w</kbd>).</li> <li>A <em>system copy</em> is what you typically get from pressing <kbd>C-c</kbd> (or choosing "Edit->Copy" in a application window).</li> <li>An <em>X co...
Using Apache mod_rewrite to remove sub-directories from URL <p>I'm managing an instance of Wordpress where the URLs are in the following format:</p> <pre> http://www.example.com/example-category/blog-post-permalink/ </pre> <p>The blog author did an inconsistent job of adding categories to posts, so while some of them...
<p>Something as simple as:</p> <pre><code>RewriteRule ^/[^/]+/([^/]+)/?$ /$2 [R] </code></pre> <p>Perhaps would do it? </p> <p>That simple redirects <code>/foo/bar/</code> to <code>/bar</code>.</p>
Is there any AIM API for PHP that would allow a user to set their status from a website? <p>Some users on a site I have been working on have requested the ability to allow the server to set their aim status when they are listening to a song though our flash music player. I looked at the AIM developer pages, but didn't ...
<p>You probably want the <a href="http://dev.aol.com/aim/web/serverapi_reference" rel="nofollow">Web AIM Server API</a>; it looks like you can set the AIM status through authenticated HTTP calls, among many other things. Should be language-independent; in PHP you could use the cURL library, for instance. I've never u...
How can I write an iPhone app entirely in JavaScript without making it just a web app? <p>I don't want to take the time to learn Obj-C. I've spent 7+ years doing web application programming. Shouldn't there be a way to use the WebView and just write the whole app in javascript, pulling the files right from the resource...
<p>I found the answer after searching around. Here's what I have done:</p> <ol> <li><p>Create a new project in XCode. I think I used the view-based app.</p></li> <li><p>Drag a WebView object onto your interface and resize.</p></li> <li><p>Inside of your WebViewController.m (or similarly named file, depending on the na...
Explode that doesn't return empty strings? <p>PHP's explode function returns an array of strings split on some provided substring. It will return empty strings like this:</p> <pre><code>var_dump(explode('/', '1/2//3/')); array(5) { [0]=&gt; string(1) "1" [1]=&gt; string(1) "2" [2]=&gt; string(0) "" [3]=&...
<p>Try <a href="http://php.net/preg_split">preg_split</a>.</p> <p><code>$exploded = preg_split('@/@', '1/2//3/', NULL, PREG_SPLIT_NO_EMPTY);</code></p>
Parsing exact dates in C# shouldn't force you to create an IFormatProvider <p>Someone please correct me if I'm wrong, but parsing a yyyy/MM/dd (or other specific formats) dates in C# <strong>should</strong> be as easy as </p> <pre><code>DateTime.ParseExact(theDate, "yyyy/MM/dd"); </code></pre> <p>but no, C# forces yo...
<p>The IFormatProvider argument can be null.</p>
Should HTML co-exist with code? <p>In a web application, is it acceptable to use HTML in your code (non-scripted languages, Java, .NET)?</p> <p>There are two major sub questions:</p> <ol> <li>Should you use code to print HTML, or otherwise directly create HTML that is displayed?</li> <li>Should you mix code within yo...
<p>Generally, it's better to keep presentation (HTML) separate from logic ("back-end" code). Your code is decoupled and easier to maintain this way.</p>
Why aren't my breakpoints working? <p>I have breakpoints set but Xcode appears to ignore them.</p>
<p>First of all, I agree 100% with the earlier folks that said turn <strong>OFF</strong> <code>Load Symbols Lazily</code>.</p> <p>I have two more things to add.</p> <p>(My first suggestion sounds obvious, but the first time someone suggested it to me, my reaction went along these lines: "come on, please, you really t...
how to implement shortcut key combination of CTRL or SHIFT + <letter> through javascript? <p>ASP.NET 2.0 web application, how to implement shortcut key combination of CTRL + , preferably through javascript, to make web application ergonomically better? How to capture multiple-key keyboard events through javascript?</p>...
<p>The short answer is that you use Javascript to capture a <strong>keydown</strong> event and use that event to fire off a function. Relevant articles:</p> <ul> <li><a href="http://www.openjs.com/scripts/events/keyboard_shortcuts/">http://www.openjs.com/scripts/events/keyboard_shortcuts/</a></li> <li><a href="http://...
Best way to convert text files between character sets? <p>What is the fastest, easiest tool or method to convert text files between character sets?</p> <p>Specifically, I need to convert from UTF-8 to ISO-8859-15 and vice versa.</p> <p>Everything goes: one-liners in your favorite scripting language, command-line tool...
<p><a href="http://linux.die.net/man/1/iconv">Stand-alone utility</a> approach</p> <pre><code>iconv -f UTF-8 -t ISO-8859-1 in.txt &gt; out.txt </code></pre> <pre> -f ENCODING the encoding of the input -t ENCODING the encoding of the output </pre>
Is GCJ (GNU Compiler for Java) a viable tool for publishing a webapp? <p>Is it really viable to use GCJ to publish server-side applications? Webapps? </p> <p>My boss is convinced that compiling our (<strong><em>my</em></strong>) webapp into a binary executable is a brilliant idea. (Then again, he likes nice, small ...
<p>I don't know about GCJ, but my company uses Excelsior JET with success. We haven't done it with a webapp (yet) but it should be able to handle anything that the Sun JRE can. In fact JET is a Sun-certified Java implementation.</p>
Is there a way to add global error handler in a visual basic 6.0 application? <p>VB 6.0 does not have any global handler.To catch runtime errors,we need to add a handler in each method where we feel an error can occur.But, still some places might be left out.So,we end up getting runtime errors.Adding error handler in a...
<p>No there is no way to add a global error handler in VB6. However, you do not need to add an error handler in every method. You only really need to add an error handler in every event handler. E.g. Every click event,load event, etc</p>
NHibernate, Sum Query <p>If i have a simple named query defined, the preforms a count function, on one column:</p> <pre><code> &lt;query name="Activity.GetAllMiles"&gt; &lt;![CDATA[ select sum(Distance) from Activity ]]&gt; &lt;/query&gt; </code></pre> <p>How do I get the result of a sum or any quer...
<p>As an indirect answer to your question, here is how I do it without a named query.</p> <pre><code> var session = GetSession(); var criteria = session.CreateCriteria(typeof(Order)) .Add(Restrictions.Eq("Product", product)) .SetProjection(Projections.CountDistinct("Price")); return (int) criteria.Uni...
Java Open Source Workflow Engines <p>What is the best open source java workflow framework (e.g. OSWorkflow, jBPM, XFlow etc.)?</p>
<p><a href="http://eprints.qut.edu.au/archive/00014320/" rel="nofollow">Here's an article</a> that compares kBPM, OpenWFE, and Enhydra Shark that looks like it has some good, thorough info.</p>
How to get name associated with open HANDLE <p>What's the easiest way to get the filename associated with an open HANDLE in Win32?</p>
<p>There is a correct (although undocumented) way to do this on Windows XP <strong>which also works with directories</strong> -- the same method <a href="http://msdn.microsoft.com/en-us/library/aa364962.aspx">GetFinalPathNameByHandle</a> uses on Windows Vista and later.</p> <p>Here are the eneded declarations. Some of...
How do you crash a JVM? <p>I was reading a book on programming skills wherein the author asks the interviewee, "How do you crash a JVM?" I thought that you could do so by writing an infinite for-loop that would eventually use up all the memory.</p> <p>Anybody has any idea?</p>
<p>I wouldn't call throwing an OutOfMemoryError or StackOverflowError a crash. These are just normal exceptions. To really crash a VM there are 3 ways:</p> <ol> <li>Use JNI and crash in the native code.</li> <li>If no security manager is installed you can use reflection to crash the VM. This is VM specific, but normal...
Convert a .doc or .pdf to an image and display a thumbnail in Ruby? <p>Convert a .doc or .pdf to an image and display a thumbnail in Ruby?<br> Does anyone know how to generate document thumbnails in Ruby (or C, python...)</p>
<p>A simple RMagick example to convert a PDF to a PNG would be:</p> <pre><code>require 'RMagick' pdf = Magick::ImageList.new("doc.pdf") thumb = pdf.scale(300, 300) thumb.write "doc.png" </code></pre> <p>To convert a MS Word document, it won't be as easy. Your best option may be to first convert it to a PDF before ge...
Apache Axis ConfigurationException <p>I am using Apache Axis to connect my Java app to a web server. I used wsdl2java to create the stubs for me, but when I try to use the stubs, I get the following exception:</p> <blockquote> <p>org.apache.axis.ConfigurationException: No service named <code>&lt;web service name&gt;...
<p>According to the <a href="http://wiki.apache.org/ws/FrontPage/Axis/DealingWithCommonExceptions">documentation</a> linked to by @arnonym, this exception is somewhat misleading. In the first attempt to find the service a ConfigurationException is thrown and caught. It is logged at DEBUG level by the ConfigurationExcep...
How to add method using metaclass <p>How do I add an instance method to a class using a metaclass (yes I do need to use a metaclass)? The following kind of works, but the func_name will still be "foo":</p> <pre><code>def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): ...
<p>Try dynamically extending the bases that way you can take advantage of the mro and the methods are actual methods:</p> <pre><code>class Parent(object): def bar(self): print "bar" class MetaFoo(type): def __new__(cls, name, bases, dict): return type(name, (Parent,) + bases, dict) class Foo(obj...
In Tomcat how can my servlet determine what connectors are configured? <p>In Tomcat 5.5 the server.xml can have many connectors, typically port only 8080, but for my application a user might configure their servlet.xml to also have other ports open (say 8081-8088). I would like for my servlet to figure out what socket...
<p>In Tomcat 6.0 it should be something like:</p> <pre><code>org.apache.catalina.ServerFactory.getServer().getServices </code></pre> <p>to get the services. After that you might use </p> <pre><code>Service.findConnectors </code></pre> <p>which returns a Connector which finally has the method</p> <pre><code>Connect...