input
stringlengths
51
42.3k
output
stringlengths
18
55k
Regular expression to match URLs in Java <p>I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java <code>String</code> flavor and pasted it into Java code, it does not work. The f...
<p>Try the following regex string instead. Your test was probably done in a case-sensitive manner. I have added the lowercase alphas as well as a proper string beginning placeholder.</p> <pre><code>String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&amp;@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&amp;@#/%=~_|]"; </code></pre> <p>This...
Database Design Issues with relationships <p>I'm working on an upgrade for an existing database that was designed without any of the code to implement the design being considered. Now I've hit a brick wall in terms of implementing the database design in code. I'm certain whether its a problem with the design of the dat...
<p>What you're looking for is <a href="http://www.dbazine.com/ofinterest/oi-articles/celko1" rel="nofollow">relational division</a> Not implemented directly in SQL, but it can be done. Search google for other examples.</p>
Printing to a pdf printer programatically <p>I am trying to print an existing file to PDF programmatically in Visual Basic 2008.</p> <p>Our current relevant assets are: Visual Studio 2008 Professional Adobe Acrobat Professional 8.0</p> <p>I thought about getting a sdk like ITextSharp, but it seem like overkill for wh...
<p>This is how I do it in VBScript. Might not be very useful for you but might get you started. You need to have a PDF maker (adobe acrobat) as a printer named "Adobe PDF".</p> <pre><code>'PDF_WILDCARD = "*.pdf" 'PrnName = "Adobe PDF" Sub PrintToPDF(ReportName As String, TempPath As String, _ OutputName...
Is there a maximum number of characters that can be written using a StreamWriter? <p>Is there a maximum number of characters that can be written to a file using a StreamWriter? Or is there a maximum number of characters that <code>WriteLine()</code> can output? I am trying to write some data to a file but all of the da...
<p>Are you calling StreamWriter.Close() or Flush()?</p>
AJAX and the Browser Back Button <p>I run a browser based game at www.darknovagames.com. Recently, I've been working on reformatting the site with CSS, trying to get all of its pages to verify according to the HTML standard.</p> <p>I've been toying with this idea of having the navigation menu on the left AJAX the page...
<p>Use ajax for portions of the page that needs to update, not the entire thing. For that you should use templates.</p> <p>When you want to still preserve the back button for your various state changes on the page, combine them with # achors to alter the url (without forcing the browser to issue another GET).</p> <p...
ASP.NET project size <p>Are there any known issues around how many "pages" are in an ASP.NET project?</p> <p>Does the size of the DLL created by the project matter at all?</p> <p>My existing project is about 150 pages and the DLL is only around 3MB but it has increased from about 50 pages and 0.5 MB recently</p>
<p><a href="http://www.hanselman.com/blog/WhatsTheUpperLimitOnTheNumberOfProjectsWithinVS2005.aspx" rel="nofollow">Scott Hanselman</a> got on the subject two years ago.</p> <p>The absolute limit is your system memory. The bigger the project the more memory it will use.</p> <p>Surely you can stay in a [50-200] project...
Generic GDI+ Error <p>I have a Form being launched from another form on a different thread. Most of the time it works perfectly, but I get the below error from time to time. Can anyone help?</p> <pre><code>at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap..ctor(Int3...
<p>The user has to be able to see multiple open accounts simultaneously, right? So you need multiple instances of a form?</p> <p>Unless I'm misreading something, I don't think you need threads for this scenario, and I think you are just introducing yourself to a world of hurt (like these exceptions) as a result.</p> ...
HTML/Javascript app that runs on the filesystem, security issue <p>I'm putting together a little tool that some business people can run on their local filesystems, since we don't want to setup a host for it.</p> <p>Basically, its just HTML + Javascript (using jQuery) to pull some reports using REST from a 3rd party.</...
<p>In a similar situation, my solution was to use Mark Of The Web, which is a special HTML comment that IE recognizes. It places the page in a different security zone.</p> <p>Reference: <a href="http://msdn.microsoft.com/en-us/library/ms537628(VS.85).aspx" rel="nofollow">MSDN</a></p>
Best Source Control Solution for Oracle/ASP.NET Environment? <p>I am trying to plan a way for 5 developers to use Visual Studio 2005/2008 to collaboratively develop an ASP.NET web app on a development web server against an Oracle 8i(soon to be 10g) Database.</p> <p>The developers are either on the local network or com...
<p>I have used <a href="http://subversion.tigris.org/" rel="nofollow">Subversion</a> and <a href="http://tortoisesvn.tigris.org/" rel="nofollow">TortoiseSVN</a> and was very pleased.</p>
Should QA test from a strictly black-box perspective? <p>Assuming that unit tests are handled by development, is there any reason for QA to have knowledge of the details of how a product works? By which I mean, do they need to know what's going on in the background and should they test segments of a product without us...
<p>It depends on the approach and the kind of software you are writing. There are different kinds of QA. If the software should be fault-tolerant, QA should simulate faults. Also, knowing how a product works can help QA think of potentially problematic cases and test them more thoroughly.</p> <p>On the other hand, kno...
Ping Failure Without IPv6 <p>Our user interface is communicating with another application on a different machine, often connecting using domain names. </p> <p>On our network, when IPv6 is installed, DNS name resolution works great, all machines can be pinged and contacted fine.</p> <p>When IPv6 is uninstalled, pingin...
<p>You've got multiple things going on here</p> <ol> <li>DNS Name resolution</li> <li>Windows Name resolution</li> <li>IP-IP ICMP communication</li> </ol> <p>You've written your question as if there's a problem with #3, but everything you describe points to the problem actually being with #1. If you take resolution ...
Sql 2005 Express edition slow connections <p>I'm running SqlServer 2005 express edition on my laptop for development purposes. It seems that when I open a connection to the database, the setup time is REALLY slow. It can take up to 10 seconds to get a connection. I usually have multiple connections open at the same tim...
<p>I figured it out. The problem was I had multiple databases with AutoClose set to true. I shut it off in all my databases and the problem went away.</p> <p>see <a href="http://www.sqlservercentral.com/articles/Administering/autoclosefordatabases/891/" rel="nofollow">this article</a> for more info.</p>
Why is it that UTF-8 encoding is used when interacting with a UNIX/Linux environment? <p>I know it is customary, but why? Are there real technical reasons why any other way would be a really bad idea or is it just based on the history of encoding and backwards compatibility? In addition, what are the dangers of not usi...
<p>Partly because the file systems expect NUL ('\0') bytes to terminate file names, so UTF-16 would not work well. You'd have to modify a lot of code to make that change.</p>
Programmatically launching standalone Adobe flashplayer on Linux/X11 <p>The standalone flashplayer takes no arguments other than a .swf file when you launch it from the command line. I need the player to go full screen, no window borders and such. This can be accomplished by hitting ctrl+f once the program has started....
<p>You can use a dedicated application which sends the keystroke to the window manager, which should then pass it to flash, if the window starts as being the active window on the screen. This is quite error prone, though, due to delays between starting flash and when the window will show up.</p> <p>For example, your s...
To Nest or Not to Nest? <p><strong>Premise:</strong> Usually during preparation of a new Ruby on Rails App, I draw out models and relations regarding user navigations. Usually I hit a place where I need to ask myself, whether or not I should go beyond the usual "rule of thumb" of nesting no more 1 level deep. Sometimes...
<p>I tend to follow Jamis Buck's <a href="http://weblog.jamisbuck.org/2007/2/5/nesting-resources" rel="nofollow">advice</a> and never nest more than one level deep.</p> <p>Edit: If you are going to nest more than 1 level I would check out the new <a href="http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rail...
How can I see my applications threads while debugging in Visual Studio? <p>I would like to see the threads currently active in my application while debugging it.</p> <p>How can I do this using Visual Studio?</p>
<p>Yes, go to Debug->Windows->Threads</p>
How to create and resolve relative paths? <p>My app open file in subdirectory of directory where it is executed, subdirectory is called <code>sample</code> and it contains files:</p> <ul> <li><code>example.raf</code> (example extension, non significant)</li> <li><code>background.gif</code></li> </ul> <p><code>example...
<p>Next code from my project ZipSolution (http://zipsolution.codeplex.com/) shows how to resolve and create relative pathes in .net</p> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.IO; namespace ZipSolution { internal static class RelativePathDiscovery { /...
CLOS like object model for PHP <p>I have returned to php development from <a href="http://www.iinteractive.com/moose/" rel="nofollow">Moose</a> and I really miss CLOS like object model for php. Is there some kind of syntaxtic sugar which would allow me to write <strong>less code</strong> in php when dealing with object...
<p>There are no mixins in php yet but there is an RFC for traits which will work roughly the same. <a href="http://wiki.php.net/rfc/traits" rel="nofollow">http://wiki.php.net/rfc/traits</a></p> <p>Using overloading for __call can allow you to dispatch methods to other classes and have it look like a mixin.</p>
If I grab a paramenter out of the query string, is it URL decoded? <p>In .NET if I do something like:</p> <pre><code>string temp = Request.QueryString["myKey"]; </code></pre> <p>is the value in temp already URL decoded?</p>
<p>Yes, it is.</p>
Referencing build artifacts from an svn:external build in .Net project <p>This is a continuation question from a previous question <a href="http://stackoverflow.com/questions/142237/integrating-external-sources-in-a-build.">I have asked</a></p> <p>I now have a /externals directory in the root of my project tree. Insid...
<p>I'd say build them once and check the build artifacts in /public/ext/some_dependency/ref (obviously, the naming of that folder is up to you :-)) and reference them from there.</p> <p>My main reason is that you seldom need to build external dependencies every time you do a build of your product. In general external ...
Installing .NET 3.5 on a server with .NET 2.0 applications <p>I would like to upgrade my web projects on an IIS 5 server from .NET 2.0 to .NET 3.5. These web applications live on a server with other web applications that will not be upgraded to .NET 3.5. The server administrator is reluctant to install .NET 3.5 becau...
<p>If you have .NET 2 SP1 you shouldn't have a problem.</p> <p>To be exact .NET 3 &amp; 3.5 are built on top of .NET 2.0 SP 1, we had a problem deploying 3.5 onto a server which only had .NET 2 (not SP1) and it caused the apps on there to break. The reason is your core framework assemblies in .NET 2 are upgraded and h...
SubSonic SubSonic.SqlQuery & Dates <p>Does SubSonic.SqlQuery have a between/and for date ranges? If not, what would be the best way to get a range.</p>
<p>Try something like this:</p> <pre><code>SqlQuery query = new SqlQuery().From("Table") .WhereExpression("Column") .IsBetweenAnd("1/1/2008", "12/31/2008"); DataSet dataSet = query.ExecuteDataSet(); // Or whatever output you need </code></pre>
In Ruby on Rails, how do I format a date with the "th" suffix, as in, "Sun Oct 5th"? <p>I want to display dates in the format: short day of week, short month, day of month without leading zero but including "th", "st", "nd", or "rd" suffix.</p> <p>For example, the day this question was asked would display "Thu Oct 2nd...
<p>Use the ordinalize method from 'active_support'.</p> <pre><code>&gt;&gt; time = Time.new =&gt; Fri Oct 03 01:24:48 +0100 2008 &gt;&gt; time.strftime("%a %b #{time.day.ordinalize}") =&gt; "Fri Oct 3rd" </code></pre> <p>Note, if you are using IRB with Ruby 2.0, you must first run:</p> <pre><code>require 'active_sup...
How to add a Tooltip to a "td" with jquery? <p>I need to add a tooltip/alt to a "td" element inside of my tables with jquery.</p> <p>Can someone help me out?</p> <p>I tried:</p> <pre><code>var tTip ="Hello world"; $(this).attr("onmouseover", tip(tTip)); </code></pre> <p>where I have verified that I am using the "td...
<pre><code>$(this).mouseover(function() { tip(tTip); }); </code></pre> <p>a better way might be to put <code>title</code> attributes in your HTML. That way, if someone has javascript turned off, they'll still get a tool tip (albeit not as pretty/flexible as you can do with jQuery).</p> <pre><code>&lt;table id="my...
Why is my Perl regex using so much memory? <p>I'm running a regular expression against a large scalar. Though this match isn't capturing anything, my process grows by 30M after this match:</p> <pre><code># A if (${$c} =~ m/\G&lt;&lt;\s*/cgs) { #B ... } </code></pre> <p><code>$c</code> is a reference to a pre...
<p>Just a quick sanity check, are you mentioning $&amp;, $` or $' (sometimes called $MATCH, $PREMATCH and $POSTMATCH) anywhere in your code? If so, Perl will copy your entire string for <em>every</em> regular expression match, just in case you want to inspect those variables.</p> <p>"In your code" in this case means ...
Can J# code run on JVM <p>If I create a J# Application is there any way I can execute it on JVM as well</p>
<p>No, J# programs are designed to run on the .NET platform. See the <a href="http://msdn.microsoft.com/en-nz/vjsharp/bb188604.aspx" rel="nofollow">J# FAQ</a>.</p>
How to debug RESTful services? <p>I'm looking for an easy way to debug RESTful services. For example, most webapps can be debugged using your average web browser. Unfortunately that same browser won't allow me to test HTTP PUT, DELETE, and to a certain degree even HTTP POST.</p> <p>I am not looking to automate tests. ...
<p>Use an existing 'REST client' tool that makes it easy to inspect the requests and responses, like <a href="https://github.com/wiztools/rest-client">RESTClient</a>.</p>
What's the nicest way to do observer/observable in objective-c (iphone version) <p>I'm used to coding Java Swing UIs, and in those if you have some properties that change, and you want your UI to update, you would implement the observer/observable pattern. In Java you do this normally by having your class maintain a li...
<p>There are two built-in ways of doing observation in Cocoa: Key-Value Observing and notifications. In neither system do you need to maintain or notify a collection of observers yourself; the framework will handle that for you.</p> <p>Key-Value Observing (KVO) lets you observe a property of an object — including ...
What is the best way for me to implement record locking? <p>I have a question about locking. This doesn't have to be only about record locking, but anyway.</p> <p>Let's say I'm writing a web accessible CMS. I am struggling with some ideas.</p> <p>I could, on the moment when a user opens an article for editing, flag t...
<p>My vote is for <a href="http://www.15seconds.com/issue/030604.htm" rel="nofollow">optimistic locking</a> wherever possible. </p> <p>In one place, where I have implemented actual locks, I had an admin page to remove locks. There was also a service running on the server to unlock any locks which did not have a corres...
Site-Mining tools <p>Many of the questions asked here are relevant to research I'm doing. These questions and answers are widely dispersed and not always easy to find, doing manual browsing, and sometimes an insightful answer or comment occurs in unrelated topics as well.</p> <p>I want to automate finding these releva...
<p>Another option would be using <a href="http://pipes.yahoo.com/pipes/" rel="nofollow">Yahoo! Pipes</a>. (<a href="http://www.jumpcut.com/fullscreen?id=F4396574585311DC87A2000423CF0184&amp;type=clip" rel="nofollow">demo</a>)</p> <p>You can build such system visually online using a combination of feed urls, filters, e...
How can I get data from a stored procedure into a temp table? <p>Am working on sybase ASE 15. Looking for something like this</p> <pre><code>Select * into #tmp exec my_stp; </code></pre> <p>my_stp returns 10 data rows with two columns in each row.</p>
<p>In ASE 15 I believe you can use functions, but they're not going to help with multirow datasets.</p> <p>If your stored proc is returning data with a "select col1,col2 from somewhere" then there's no way of grabbing that data, it just flows back to the client.</p> <p>What you can do is insert the data directly into...
How can I scale the content of an iframe? <p>How can I scale the content of an iframe (in my example it is an HTML page, and is not a popup) in a page of my web site?</p> <p>For example, I want to display the content that appears in the iframe at 80% of the original size.</p>
<p><a href="http://stackoverflow.com/questions/166160/how-can-i-scale-the-content-of-iframe/2224816#2224816">Kip's solution</a> should work on Opera and Safari if you change the CSS to:</p> <pre><code>&lt;style&gt; #wrap { width: 600px; height: 390px; padding: 0; overflow: hidden; } #frame { width: 800px; heig...
How to convert a DB2 date-time string into an Excel Date <p>I'll regularly get an extract from a DB/2 database with dates and timestaps formatted like this:</p> <pre><code>2002-01-15-00.00.00.000000 2008-01-05-12.36.05.190000 9999-12-31-24.00.00.000000 </code></pre> <p>Is there an easier way to convert this into the ...
<p>It's not clear if you talk about formula functions or VBA functions.</p> <h2>Formula functions</h2> <p>Don't use the DateValue function, which expects a string; use the Date function, which expects numeric Year, Month, Day:</p> <pre><code>=DATE(INT(LEFT(A1,4)),INT(MID(A1,6,2)),INT(MID(A1,9,2))) </code></pre> <p>...
Restore Eclipse subversion project connection <p>I have a project in subversion, which I'm developing using Eclipse. I did the original checkout from the svn repository from inside Eclipse. All was well for some weeks then for some unknown reason, Eclipse (specifically: subclipse in Ganymede) no longer recognizes my pr...
<p>If you are using sublipse as your SVN provider I recommend doing the following</p> <p>Team -> Share project is usually enough to connect the metadata.</p> <p>(that is, assuming that the .svn files are still there which they seem to be if you can work on the command line).</p> <p>Hope this helps as to why this wou...
Oracle instant client with OraOLE DB provider? <p>Is it possible to use oracle instant client for application that use oraoledb driver for connecting to oracle 9i DB.</p>
<p>I don't believe so. The <a href="http://www.oracle.com/technology/tech/oci/instantclient/ic-faq.html#A3661" rel="nofollow">Instant Client FAQ</a> states</p> <blockquote> <p>What can Instant Client be used for? Instant Client can be used to run your OCI, OCCI, Pro*C, JDBC, and ODBC applications without installi...
Parameterized Sql queries <p>This is a nut I'm cracking these days</p> <p>Application I'm working on has some advanced processing towards SQL. One of the operations selects various metadata on the objects in the current context from different tables, based on the item names in the collection. For this, a range of "sel...
<p>One potential workaround is to use the ability to query XML and simply send all the data for your 'in' as an xml column and then join on that. </p> <p>The same approach could be used to populate your temp table, but then again, why not just use it directly.</p> <p>Here's a short sample that should illustrate:</p> ...
Write a password protected Zip file in Java <p>I need to zip and password-protect a file. Is there a good (free) library for this?</p> <p>This needs to be opened by a third party, so the password protection needs to work with standard tools.</p>
<p>You can try <a href="http://www.lingala.net/zip4j/">Zip4j</a>, a pure java library to handle zip file. It supports encryption/ decryption of PKWare and AES encryption methods.</p> <p>Key features:</p> <ul> <li>Create, Add, Extract, Update, Remove files from a Zip file</li> <li>Read/Write password protected Zip fil...
Writing a generic class to handle built-in types <p>Not too practical maybe, but still interesting.</p> <p>Having some abstract question on matrix multiplication I have quickly implemented a matrix for ints, then tested my assumptions.</p> <p>And here I noticed that just int matrix is not good, if I occasionally want...
<p>For this you need generic maths. Luckily <a href="http://www.yoda.arachsys.com/csharp/genericoperators.html" rel="nofollow">I have done this</a>. Usage would be similar to this "complex" (i.e. x+iy) <a href="http://csharpindepth.com/ViewNote.aspx?NoteID=50" rel="nofollow">example</a>. The Operator class is now part ...
What deployment directories do you use for Rails applications (deploying to a debian box)? <p>I wonder what's the best deployment directory for Rails apps? Some developers use directories such as <code>/u/apps/#{appname}</code>. Are there <strong>any</strong> advantages when using <code>/u/apps/#{appname}</code> instea...
<p>As other people have said, it really doesn't matter where you keep your applications - the thing that does matter is that you're consistent about it, so that whichever server you're on, its just a case of going to the usual location.</p> <p>I think the only reason people use /u/apps/#{appname} is that it's Capistra...
Does NetworkStream.DataAvailable see buffered data? <p>Does NetworkStream.DataAvialable know whether the sender's send buffer is empty? Or does it simply indicate whether the receiver's read buffer has data? My assumption is the latter...</p> <p>Specifically, for some socket work involving an ongoing conversation, I c...
<p>One side of a connection is not going to know whether the other side's send buffer is empty.</p> <p><code>DataAvailable</code> only indicates whether there is incoming data to be read. You could use that prior to <code>Read()</code>, but it alone doesn't give you the information you want. It doesn't tell you the be...
What to put in the IF block and what to put in the ELSE block? <p>This is a minor style question, but every bit of readability you add to your code counts.</p> <p>So if you've got:</p> <pre><code>if (condition) then { // do stuff } else { // do other stuff } </code></pre> <p>How do you decide if it's better li...
<p>I prefer to put the most common path first, and I am a strong believer in nesting reduction so I will break, continue, or return instead of elsing whenever possible. I generally prefer to test against positive conditions, or invert [and name] negative conditions as a positive.</p> <pre><code>if (condition) ret...
java date format incompatible with xquery xs:date format, how to fix? <p>In java, when using SimpleDateFormat with the pattern:</p> <pre><code>yyyy-MM-dd'T'HH:mm:ss.SSSZ </code></pre> <p>the date is outputted as:</p> <pre><code>"2002-02-01T18:18:42.703-0700" </code></pre> <p>In xquery, when using the xs:dateTime fu...
<p>OK, the linked to forum post DID help, thank you. I did however find a simpler solution, which I include below:</p> <p>1) Use Apache commons.lang java library<br> 2) Use the following java code: </p> <pre class="lang-java prettyprint-override"><code>//NOTE: ZZ on end is not compatible with jdk, but allows for f...
How to repeat a string a variable number of times in C++? <p>I want to insert 'n' spaces (or any string) at the beginning of a string in C++. Is there any direct way to do this using either std::strings or char* strings?</p> <p>E.g. in Python you could simply do</p> <pre><code>&gt;&gt;&gt; "." * 5 + "lolcat" '.....lo...
<pre><code>std::string foo = std::string(5, '.') + "lolcat"; </code></pre> <p>Check out <a href="http://www.cppreference.com/wiki/string/string_constructors">std::string's constructors</a>.</p>
Should I have a dedicated primary key field? <p>I'm designing a small SQL database to be used by a web application.</p> <p>Let's say a particular table has a Name field for which no two rows will be allowed to have the same value. However, users will be able to change the Name field at any time.</p> <p>The primary k...
<p>I would use a generated PK myself, just for the reasons you mentioned. Also, indexing and comparing by integer is faster than comparing by strings. You can put a unique index on the name field too without making it a primary key.</p>
Removing a subset of a dict from within a list <p>This is really only easy to explain with an example, so to remove the intersection of a list from within a dict I usually do something like this:</p> <pre><code>a = {1:'', 2:'', 3:'', 4:''} exclusion = [3, 4, 5] # have to build up a new list or the iteration breaks to...
<p>Consider <a href="http://docs.python.org/library/stdtypes.html#dict.pop" rel="nofollow">dict.pop</a>:</p> <pre><code>for key in exclusion: a.pop(key, None) </code></pre> <p>The <code>None</code> keeps pop from raising an exception when <code>key</code> isn't a key.</p>
RSpec Stories and Specs: When to use what? <p>So I want to start using RSpec stories, but I am not sure where writing controller, model and view specs fit in. </p> <p>For example, you have the story "Logging in" with "User provides wrong password" scenario, don't you end up testing the same stuff than controller/model...
<p>If you are starting with stories now (as opposed to having a lot of legacy stories) you may want to look at <a href="http://github.com/aslakhellesoy/cucumber/wikis/migration-from-rspec-stories">Cucumber</a> which is the long term replacement for the RSpec story runner.</p> <p>The easiest way of splitting between sp...
Class data responsibilities <p>I have a 'Purchase Order' class. It contains information about a single purchase order. I have a DAO class for database methods.</p> <p>Where should the responsibility reside for the methods that will load and update the purchase order?</p> <p>Should the PurchaseOrder class have '.updat...
<p>The Purchase Order should be ignorant of the details of its persistence. This is the point of having some sort of data access layer, it handles the management of the object and the object itself can concentrate on just being a purchase order.</p> <p>This also makes the system easier to test, as you can create mock ...
Eclipse for IntelliJ Idea Users <p>I have a coworker who is looking to switch from InteilliJ Idea to Eclipse, and is concerned about not knowing the Eclipse set of commands. </p> <p>I was wondering - would anyone have a link to keyboard mappings that can set Eclipse commands to at least sort of match Idea? </p> <p>Ha...
<p>Get the plugin from <a href="http://www.jroller.com/santhosh/entry/intellij_idea_key_scheme_for">here</a>. It seems easier to install than the one in Bartosz' answer, plus no 404s...</p> <p>For the lazy: <a href="http://jroller.com/santhosh/resource/IdeaKeyScheme_1.0.0.jar">direct link to plugin</a></p> <p>Drop th...
Does anyone know some cool PL/SQL plugin for IntelliJ Idea? <p>I've evaluated some plugins from official IntelliJ repository, but none of them seems to provide more then basic syntax highlighting. Even highlighting is limited. For example, Database Navigator doesn't highlight IF. It would be great to have proper highli...
<p>Have you tried <a href="http://java.sstiller.de/sql/index.html" rel="nofollow" title="KiwiSoft - SQL Query Plugin">SQL Query Plugin</a>? It comes with a great host of features, including multiple query windows, direct editing of tables, and of course, proper highlighting for PL/SQL syntax and a browser of the intern...
Is there a way to prevent the VB6 compiler from shuffling the contents of files? <p>For reasons unknown, the VB6 compiler often likes to reorder the contents of .vbp files and the control descriptor block at the top of .frm files (The code that describes the properties of controls on the form. Code that you don't see ...
<p>I don't think there's much you can do about this. I've noticed the same problem: the IDE likes to rearrange things for seemingly no apparent reason. Some things I've noticed:</p> <ul> <li><p>When you use the SSTab control, VB likes to rearrange properties for tabs, especially the TabEnabled property.</p></li> <li><...
Any problems with SVN merge on a multi column ( tab delimited ) text file? <p>I have a multi-column text file ( tab delimited ) that I use for localized text in my project. </p> <p>I picked this format since it can easily be edited by anyone in most text editors (and excel too). </p> <p>My makefile processes it into ...
<p>It is line by line.</p> <ol> <li>The person who tries to commit later will get 'out of date' error, and when they try to update it, they will get a conflict in changed lines.</li> <li>Same with the merge. The one who merges later will have to sort out conflicts manually.</li> </ol>
Possible Memory leak in Number of Loaded classes in Java Application <p>I recently began profiling an osgi java application that I am writing using VisualVM. One thing I have noticed is that when the application starts sending data to a client (over JMS), the number of loaded classes starts increasing at a steady rate...
<blockquote> <p>Are you dynamically creating new classes on the fly somehow?</p> </blockquote> <p>Thanks for your help. I figured out what the problem is. In one of my classes, I was using Jaxb to create an XML string. In doing this, JAXB ueses reflection to create a new class.</p> <pre><code>JAXBContext context...
Hiding a function <p>I have a class holding complex scientific computations. It is set up to only allow a user to create a properly instantiated case. To properly test the code, however, requires setting internal state variables directly, since the reference documents supply this data in their test cases. Done impro...
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx" rel="nofollow">InternalsVisibleToAttribute</a> to mark internal members as visible to your test assembly. It seems to shine when used in this context, though its not quite "friend".</p> <o...
How can I embed one file into another with Ant? <p>I am developing a small web app project (ColdFusion) and I am trying to keep my project split into multiple files during development, but deploy just one file on completion.</p> <p>I have references to external files, for instance:</p> <pre><code>&lt;script type="tex...
<p>Does this do what you want?</p> <pre><code>&lt;property name="filename" value="jquery-1.2.6.pack.js" /&gt; &lt;loadfile property="contents" srcfile="${filename}" /&gt; &lt;replace dir="."&gt; &lt;include name="index.cfm"/&gt; &lt;replacetoken&gt;&lt;![CDATA[&lt;script type="text/javascript...
JPA and inheritance <p>I have a some JPA entities that inherit from one another and uses discriminator to determine what class to be created (untested as of yet).</p> <pre><code>@Entity(name="switches") @DiscriminatorColumn(name="type") @DiscriminatorValue(value="500") public class DmsSwitch extends Switch implements ...
<p>As the previous commentors I agree that the class model should be different. I think something like the following would suffice:</p> <pre><code>@Entity(name="switches") @DiscriminatorColumn(name="type") @DiscriminatorValue(value="400") public class Switch implements ISwitch { // Implementation details } @Entity(...
How can I do bi-directional communication with a custom USB device? <p>I'm planning to build a USB device that has buttons that some software needs to respond to, and indicators that the software needs to control. I'm new to USB, so I'm looking for any pointers that will get me started.</p>
<p>When I did some USB development a while ago, I found the information at <a href="http://www.lvr.com/usb.htm" rel="nofollow">USB Central</a> extremely valuable.</p> <p>For low bandwidth requirements, you can use something like the <a href="http://www.ftdichip.com/Products/FT232R.htm" rel="nofollow">FT232R</a> which ...
Other than for LINQ queries, how do you use anonymous types in C#? <p>I've been trying to get up to speed on some of the newer features in C# and one of them that I haven't had occasion to use is anonymous types.</p> <p>I understand the usage as it pertains to LINQ queries and I looked at <a href="http://stackoverflow...
<p>With a bit of reflection, you can turn an anonymous type into a Dictionary&lt;string, object&gt;; Roy Osherove blogs his technique for this here: <a href="http://weblogs.asp.net/rosherove/archive/2008/03/11/turn-anonymous-types-into-idictionary-of-values.aspx" rel="nofollow">http://weblogs.asp.net/rosherove/archive/...
Do .net applications run on Linux? <p>Do .net applications run on linux? </p> <p>Are there any free/paid interop libraries available ?</p>
<p><a href="http://www.mono-project.com/" rel="nofollow">Mono</a> is a .NET-compatible platform, including compiler and runtime. The <a href="http://www.mono-project.com/Moma" rel="nofollow">Mono Migration Analyzer</a> helps figure out compatibility issues.</p>
Is it possible to connect PHP to SQL Server Compact Edition? <p>Is it possible to connect PHP to a SQL Server Compact Edition database? What would be the best driver?</p> <hr> <p>I need it for a desktop application where SQL Server Express is too heavy.</p>
<p>Short Answer : <strong>No.</strong></p> <p>Long Answer : To my knowledge, unlike PostgreSQL / MySQL / MS-SQL, there is no native driver to connect PHP to SQL Server Compact Edition.</p> <p>If you want to connect to it, your best bet is to use PHP ODBC connections to talk to a ODBC Driver connected to the SQL Compa...
How do I show an embedded excel file in a WebPage? <p>I want to allow an Excel report to be viewed embedded in a WebPage... is there a way?</p> <ul> <li><p>I don't want to use an ActiveX, or OWC (Office Web Components), I just want to open an existing file from the internet explorer application.</p></li> <li><p>I don'...
<p>This has to do with the local person's browser set up and not really anything you can do on your end. If they click a link with the .xls(x) extension, the browser determines if it wants to open it itself or in a new window.</p> <p>Here is a microsoft page on how to change these settings: <a href="http://support.mic...
How do you add a link that will add an event to your iPhone calendar from safari? <p>This seems like it should be simple but after a couple hours of googling I have not figured it out. I know I can add iCal links using ICS files, but this does not work on the iPhone.</p> <p>BTW, when I say iPhone I would like it to w...
<p>You can get iPhone to download the .ics file (using Safari on a mobile web page) by using the webcal protocol:</p> <p>webcal://website.mobi/mymeeting.ics</p>
Where are some good resources for learning the new features of Perl 5.10? <p>I didn't realize until recently that Perl 5.10 had significant new features and I was wondering if anyone could give me some good resources for learning about those. I searched for them on Google and all I found was some slides and a quick ov...
<p>The <a href="http://search.cpan.org/dist/perl-5.10.0/pod/perl5100delta.pod">perldelta</a> manpage has all the nitty-gritty details. There's a brief (but informative) slide presentation, <a href="http://www.slideshare.net/rjbs/perl-510-for-people-who-arent-totally-insane/">Perl 5.10 for people who aren't totally insa...
Display a tooltip over a button using Windows Forms <p>How can I display a tooltip over a button using <a href="http://en.wikipedia.org/wiki/Windows_Forms">Windows Forms</a>?</p>
<p>The ToolTip is actually a WinForms control that handles displaying tool tips for multiple elements on a single form.</p> <p>Say your button is called MyButton.</p> <ol> <li>Add a ToolTip control (under Common Controls in the Windows Forms toolbox) to your form. </li> <li>Give it a name - say MyToolTip </li> <li>Se...
Best Practices for Performing Sequential Operations <p>What is the best way to perform a couple of tasks together and if one task fails then the next tasks should not be completed? I know if it were the database operations then I should have used Transactions but I am talking about different types of operations like th...
<p>Rollbacks are tough - AFAIK, there's really only 2 ways to go about it. Either a <a href="http://en.wikipedia.org/wiki/Two-phase-commit_protocol" rel="nofollow">2 phase commit protocol</a>, or <a href="http://en.wikipedia.org/wiki/Compensating_transaction" rel="nofollow">compensating transactions</a>. You really hav...
Can you get a Windows (AD) username in PHP? <p>I have a PHP web application on an intranet that can extract the IP and host name of the current user on that page, but I was wondering if there is a way to get/extract their Active Directory/Windows username as well. Is this possible?</p>
<p>Check the <code>AUTH_USER</code> request variable. This will be empty if your web app allows anonymous access, but if your server's using basic or Windows integrated authentication, it will contain the username of the authenticated user.</p> <p>In an Active Directory domain, if your clients are running Internet Exp...
Questions when moving from MbUnit to MsTest <p>Our team is looking to switch from using mbunit to mstest, but there appears to be some disconnect between the two.</p> <p>Does anyone know how to simulate the CombinatorialTest and Factory attributes from mbunit when using mstest?</p> <p>I think that is our only stumbli...
<p>As far as I'm aware, you basically need to write a test method that generates all of the combinations (or calls the factory and iterates through the items) that calls your original test (now no longer a test method) a bunch of times.</p> <p>Unfortunately, these do not show up as individual tests in results - they s...
Pseudocode Programming Process vs. Test Driven Development <p>For those who haven't read Code Complete 2, the Pseudocode Programming Process is basically a way to design a routine by describing it in plain English first, then gradually revise it to more detailed pseudocode, and finally to code. The main benefit of this...
<p>My team mixes both approaches and it's an awesome way to develop (at least for us). We need unit tests because we have a large and complex software system. But the Pseudocode Programming Process is hands-down the best approach to software design I've come across. To make them work together:</p> <ul> <li>We start by...
Python - How do I write a decorator that restores the cwd? <p>How do I write a decorator that restores the current working directory to what it was before the decorated function was called? In other words, if I use the decorator on a function that does an os.chdir(), the cwd will not be changed after the function is c...
<p>The answer for a decorator has been given; it works at the function definition stage as requested.</p> <p>With Python 2.5+, you also have an option to do that at the function <em>call</em> stage using a context manager:</p> <pre><code>from __future__ import with_statement # needed for 2.5 ≤ Python &lt; 2.6 impor...
Is there a way to change something in Tool->Options via a macro? <p>I'd like to be able to toggle easily between two values for "maximum number of parallel project builds" in Visual Studio 2008 (in Tools->Options->Projects and Solutions->Build and Run). (When I'm planning on doing concurrent work I'd like to reduce it ...
<p>It appears to be impossible, according to the MSDN page for <em><a href="http://msdn.microsoft.com/en-us/library/ms165642.aspx" rel="nofollow">Determining Names of Property Items in Tools Options Pages </a></em></p> <p>If it <em>was</em> possible, it would have been something like this:</p> <pre><code>Dim p = DTE....
What's the right way to display emoticons? <p>In your own application that is.</p> <p>[edit]</p> <p><strong>Alright, so I agree completely -- more than you know -- without equivocation that graphical emoticons are an abomination. But! That doesn't help me when the project owners tell me that we must support graphical...
<ol> <li>Create a new font. <em>This is left as an exercise for the reader</em></li> <li>Transcode your strings into the character set of your new font. </li> <li>Draw:</li> <li>Make repeated calls operating environment function to calculate Text Metrics - to locate the position of your emoticons. <li>Draw the ...
Set server or workstation GC <p>How can I configure an application, or even an entire machine, to use either the server or workstation flavor of the CLR's garbage collection? </p>
<p>Have a look <a href="http://blogs.msdn.com/maoni/archive/2004/09/25/234273.aspx" rel="nofollow">here</a>. </p> <p>I recommend giving the entire series of blog posts a good read - very informative.</p>
what is the best way to do keep alive socket checking in .NET? <p>I am looking for a way to do a keep alive check in .NET. The scenario is for both UDP and TCP.</p> <p>Currently in TCP what I do is that one side connects and when there is no data to send it sends a keep alive every X seconds.</p> <p>I want the other ...
<p>If you literally mean "KeepAlive", try the following.</p> <pre><code> public static void SetTcpKeepAlive(Socket socket, uint keepaliveTime, uint keepaliveInterval) { /* the native structure struct tcp_keepalive { ULONG onoff; ULONG keepalivetime; ULONG keepaliveinterval; }; */ // marshal the equiv...
Initializing C# auto-properties <p>I'm used to writing classes like this:</p> <pre><code>public class foo { private string mBar = "bar"; public string Bar { get { return mBar; } set { mBar = value; } } //... other methods, no constructor ... } </code></pre> <p>Converting Bar to an auto-property seems ...
<p>Update - the answer below was written before C# 6 came along. In C# 6 you can write:</p> <pre><code>public class Foo { public string Bar { get; set; } = "bar"; } </code></pre> <p>You can <em>also</em> write read-only automatically-implemented properties, which are only writable in the constructor (but can also...
Merging Rails databases <p>I have two databases with the same structure. The tables have an integer as a primary key as used in Rails.</p> <p>If I have a patients table, I will have one patient using primary key 123 in one database and another patient using the same primary key in the other database.</p> <p>What woul...
<p>Set both your databases up with entries in config/database.yml, then generate a new migration.</p> <p>Use ActiveRecord::Base.establish_connection to switch between the two databases in the migration like this:</p> <pre><code>def self.up ActiveRecord::Base.establish_connection :development patients = Patient.fi...
Simple way to programmatically get all stored procedures <p>Is there a way to get stored procedures from a SQL Server 2005 Express database using C#? I would like to export all of this data in the same manner that you can script it our using SQL Server Management Studio, without having to install the GUI.</p> <p>I've ...
<p>You can use SMO for that. First of all, add references to these assemblies to your project:</p> <ul> <li>Microsoft.SqlServer.ConnectionInfo</li> <li>Microsoft.SqlServer.Smo</li> <li>Microsoft.SqlServer.SmoEnum</li> </ul> <p>They are located in the GAC (browse to C:\WINDOWS\assembly folder). </p> <p>Use the follo...
Open source cad drawing (dwg) library in C# <p>Anyone knows of an open source DWG (autocad drawing) library in C#?</p>
<p>The major hurdle with the DWG format is that the binary format changes every 3 years - and it is due to change again in March 2009. It is encrypted and the specifications for it are not made public. It is a massively complicated library with many dark alleys unknown to even AutoDesk (they acquired it years ago).</p>...
Generic Java Framework to Manage Bidirectional Associations and Inverse Updates <p>I've been looking for a generic way to deal with bidirectional associations and a way to handle the inverse updates in manual written Java code.</p> <p>For those who don't know what I'm talking about, here is an example. Below it are my...
<p>google collections (from google's internal code) -- <a href="http://code.google.com/p/google-collections/">http://code.google.com/p/google-collections/</a> is Java Generics compatible(not only compatible, uses generics very well)</p> <p>Class BiMap -- <a href="http://google-collections.googlecode.com/svn/trunk/java...
Aren't Information Expert / Tell Don't Ask at odds with Single Responsibility Principle? <p>It is probably just me, which is why I'm asking the question. Information Expert, Tell Don't Ask, and SRP are often mentioned together as best practices. But I think they are at odds. Here is what I'm talking about:</p> <p>Code...
<p>I don't think that they are so much at odds as they are emphasizing different things that will cause you pain. One is about structuring code to make it clear where particular responsibilities are and reducing coupling, the other is about reducing the reasons to modify a class.</p> <p>We all have to make decisions e...
Does the iPhone timeout if a function takes too long to execute? <p>I have a function in which I get en external resource from the web using cocoa's Url object. And it works fine on the simulator, but occasionally fails on the device itself (it's a google query so the resource obviously does exist). Which leads me to ...
<p>The iPhone OS will terminate your app if it seems it has become unresponsive - basically if your main thread blocks for a few seconds. This is also important when exiting - if you save on exit you have a very small window to complete the save which is compounded by the fact the OS may be doing other things. If you t...
Warning when using mysql_fetch_assoc in PHP <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/795746/warning-mysql-fetch-array-supplied-argument-is-not-a-valid-mysql-result">Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result</a> </p> </blo...
<p>It generally means that you've got an error in your SQL.</p> <pre><code>$sql = "SELECT * FROM myTable"; // table name only do not add tb $result = mysql_query($sql); var_dump($result); // bool(false) </code></pre> <p>Obviously, <code>false</code> is not a MySQL resource, hence you get that error.</p> <p><stron...
How can I detect a held down mouse button over a PictureBox? <p>I need to fire an event when the mouse is above a PictureBox with the mouse button already clicked and held down.</p> <p>Problems: </p> <p>The MouseDown and MouseEnter event handlers do not work together very well.</p> <p>For instance once a mouse butto...
<p>When the mouse is pressed down most controls will then <em>Control.Capture</em> the mouse input. This means that all <em>MouseMove</em> events are sent to the original control that captured rather than the control the mouse happens to be over. This continues until the mouse loses capture which typically happens on t...
strcat() new line, duplicate string <p>I'm writing a function that gets the path environment variable of a system, splits up each path, then concats on some other extra characters onto the end of each path.</p> <p>Everything works fine until I use the <code>strcat()</code> function (see code below).</p> <pre><code>ch...
<p>strtok() does not give you a new string.<br> It mutilates the input string by inserting the char '\0' where the split character was.</p> <p>So your use of strcat(token[j],"/") will put the '/' character where the '\0' was.<br> Also the last token will start appending 'which' past the end of your allocated memory in...
Java EE -- is it just fluff or the real stuff? <p>I'm familiar with the LAMP stack and over the years have successfully deployed a handful of web sties based on it. I've used everything from Apache + modPerl, to PHP, to Ruby and Rails. With good use of caching my Rails site can sustain a pretty good load, but I'm not t...
<p>The key differentiator that Java EE offers over the LAMP stack can be boiled down to a single word. Transactions.</p> <p>Most smaller systems simply rely on the transaction system supplied by the database, and for many applications that is (obviously) quite satisfactory.</p> <p>But each Java EE server includes a d...
2D animation in Python <p>I'm writing a simulator in Python, and am curious about options and opinions regarding basic 2D animations. By animation, I'm referring to rendering on the fly, not displaying prerendered images.</p> <p>I'm currently using matplotlib (Wxagg backend), and it's possible that I'll be able to con...
<p>I am a fan of <a href="http://pyglet.org" rel="nofollow">pyglet</a> which is a completely self contained library for doing graphical work under win32, linux, and OS X. </p> <p>It has very low overhead, and you can see this for yourself from the tutorial on the website. It <em>should</em> play well with wxpython, or...
What are the differences between using the New keyword and calling CreateObject in Excel VBA? <p>What criteria should I use to decide whether I write VBA code like this:</p> <pre><code>Set xmlDocument = New MSXML2.DOMDocument </code></pre> <p>or like this:</p> <pre><code>Set xmlDocument = CreateObject("MSXML2.DOMDoc...
<p>As long as the variable is not typed as object</p> <pre><code>Dim xmlDocument as MSXML2.DOMDocument Set xmlDocument = CreateObject("MSXML2.DOMDocument") </code></pre> <p>is the same as</p> <pre><code>Dim xmlDocument as MSXML2.DOMDocument Set xmlDocument = New MSXML2.DOMDocument </code></pre> <p>both use early bi...
Benefits of using a Case statement over an If statement in a stored procedure? <p>Hi are there any pros / cons relating to the speed that a stored procedure executes when using an IF statement or choosing to use a CASE statement instead?</p>
<p>I try not to use <code>IF</code>s if I can avoid it, because they are non transactional, i.e. you have generally no guarantee that the condition of the <code>IF</code> will still be valid inside the <code>BEGIN... END</code> block of the <code>IF</code>.</p> <p>I assume that you mean using <code>CASE</code> stateme...
How do I add the interactive user to a directory in a localized Windows using WiX? <p>How do I add the Swedish interactive user, </p> <pre><code>NT INSTANS\INTERAKTIV </code></pre> <p>or the English interactive user, </p> <pre><code>NT AUTHORITY\INTERACTIVE </code></pre> <p>or any other localised user group with ...
<p>With recent releases of Wix, you can retrieve the localized names of often-used built-in user and group names via a property. For example, <code>WIX_ACCOUNT_NETWORKSERVICE</code> contains the localized name of the Network Service account. Unfortunately, as of 3.0.4513 <code>NT AUTHORITY\INTERACTIVE</code> is not amo...
Looping over elements in jQuery <p>I want to loop over the elements of an HTML form, and store the values of the &lt;input&gt; fields in an object. The following code doesn't work, though:</p> <pre><code>function config() { $("#frmMain").children().map(function() { var child = $("this"); if (child....
<p>don't think you need quotations on this:</p> <pre><code>var child = $("this"); </code></pre> <p>try:</p> <pre><code>var child = $(this); </code></pre>
Why do thread functions need to be declared as '__cdecl'? <p>Sample code that shows how to create threads using MFC declares the thread function as both static and <code>__cdecl</code>. Why is the latter required? Boost threads don't bother with this convention, so is it just an anachronism?</p> <p>For example (MFC)...
<p>__cdecl tells the compiler to use the C calling convention (as opposed to the stdcall, fastcall or whatever other calling convention your compiler supports). I believe, VC++ uses stdcall by default.</p> <p>The calling convention affects things such as how arguments are pushed onto the stack (or registers, in the ca...
HowTo: Parse the UninstallString reg entry <p>In <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\</code> is the list of installed programs in my machine (at least most of them). There, there's a String Value called UninstallString which has what you need to run in order to uninstall the pro...
<p>Have a look at <a href="http://msdn.microsoft.com/en-us/library/ms954376.aspx" rel="nofollow">this link from MSDN explaining install/unistall procedures</a>, specifically item #6 "Support Add/Remove Programs Properly".</p> <p>As an excerpt from the table there:</p> <pre> Key Name | Key Type | ...
Stored procedure not being executed within another stored procedure <p>I have found that SP2 doesn't execute from within SP1 when SP1 is executed.</p> <p>Below is the structure of SP1:</p> <pre><code>ALTER PROCEDURE SP1 AS BEGIN Declare c1 cursor.... open c1 fetch next from c1 ... while @@fetch_status = 0 Begin ....
<p>What happens if you run the Stored Procedure code as a single query? If you put a <code>PRINT</code> statement before and after the exec, do you see both outputs?</p> <ul> <li>If you do, then the stored procedure must have been executed. Probably it's not doing what you would like.</li> <li>If you don't see any pri...
Language features to implement relational algebra <p>I've been trying to encode a relational algebra in Scala (which to my knowlege has one of the most advanced type systems) and just don't seem to find a way to get where I want.</p> <p>As I'm not that experienced with the academic field of programming language design...
<p>What your asking for is to be able to structurally define a type as the <em>difference</em> of two other types (the original relation and the projection definition). I honestly can't think of any language which would allow you to do that. Types can be structurally cumulative (<code>A with B</code>) since <code>A w...
UNIX socket implementation for Java? <p>I realize that since UNIX sockets are platform-specific, there has to be some non-Java code involved. Specifically, we're interested in using JDBC to connect to a MySQL instance which only has UNIX domain sockets enabled. </p> <p>It doesn't look like this is supported, but fro...
<p>Checkout the JUDS library. It is a Java Unix Domain Socket library...</p> <p><a href="https://github.com/mcfunley/juds">https://github.com/mcfunley/juds</a></p>
Rich Text in Windows Forms application <p>I would like to update a Windows Forms application to provide the following features:</p> <ul> <li>spell checking</li> <li>limited formatting of text: bold, italics, bulleted lists</li> </ul> <p>Ideally the formatted text could be accessed in a plain text way for reporting th...
<p>You can add / create a drop-in spell checker for the Window Forms RichTextBox.</p> <p>A ready to go <a href="http://www.c-sharpcorner.com/UploadFile/scottlysle/SpellCheckCC05152007084528AM/SpellCheckCC.aspx" rel="nofollow">richtextbox</a> custom control with spell checking. An app for <a href="http://www.codeproje...
Can I put a caching server in front of my web site? <p>I have a web site using apache httpd as the server and mysql as the backend. It publishes a "thought for the day" that has gotten so popular that the server is crashing due to the number of requests. Since the same page is been requested (the thought only changes o...
<p>For slow changing pages, a cache will definitely reduce CPU usage; but in your extreme case, where the page changes once a day, and it's perfectly predictable, it would be far easier to use a simple and fast static file server (<a href="http://www.lighttpd.net/" rel="nofollow">lighthttp</a>, <a href="http://nginx.ne...
Best way to use sessions with MVC and OO PHP <p>I've been working with sessions, MVC design and object oriented PHP. Where should I save or retrieve data from a session? I would like to retrieve it from within methods so I don't have to pass the data to the methods. Whats the best practice?</p>
<p>I typically put this inside the controller. It just makes sense.. The controller decides what happens and why not let it decide if people are allowed to do the requested actions. Typically you have multiple controllers in a MVC system. Eg. BaseController (abstract - common), NonSessionController extends BaseContro...
Embedding HWND into external process using SetParent <p>I'm trying to embed a window from my process into the window of an external process using the <strong>SetParent</strong> function and have encountered a few problems that I'm hoping someone can help me out with. First off, here is an outline of what I am currently...
<p>Well, I finally found the answer to my question.</p> <p>To fix the issue with the main app losing focus you need to use the <strong>AttachThreadInput</strong> function to attach the embedded window thread to the main app thread.</p> <p>Also, one can use the <strong>TranslateAccelerator</strong> function in respons...
Parsing T-SQL to Parameterize a Query <p>The application I am currently working on generates a lot of SQL inline queries. All generated SQL is then handed off to a database execution class. I want to write a parsing service for the data execution class that will take a query like this:</p> <pre><code>SELECT field1, fi...
<p>Don't do this. This is way too much work. Plus, there are loads of security risks with this approach.</p> <p>Look into Command objects and parameterized queries, at the minimum.</p> <p><a href="http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson06.aspx" rel="nofollow">Here is a small tutorial.</a></p>
How can I avoid duplicate content in ASP.NET MVC due to case-insensitive URLs and defaults? <blockquote> <p><strong>Edit</strong>: Now I need to solve this problem for real, I did a little more investigation and came up with a number of things to reduce duplicate content. I posted detailed code samples on my ...
<p>I was working on this as well. I will obviously defer to ScottGu on this. I humbly offer my solution to this problem as well though.</p> <p>Add the following code to <strong>global.asax</strong>:</p> <pre><code>protected void Application_BeginRequest(Object sender, EventArgs e) { // If upper case letters are...
Find out what is the new data from an RSS feed, compared with entries already in the database. Then put new entries in db. How? <p>Let's say I have a database, and an RSS feed. I have to find out what is the new data from an RSS feed, that isn't already in the database. How would you go about approaching this problem?<...
<p>How about generating a hashcode or some unique identifier to each RSS item, then storing it in the database? Then you just generate the hashcode for each item in the new RSS, and check it against the database.</p>