input
stringlengths
51
42.3k
output
stringlengths
18
55k
jQuery: selecting checked checkbox <p>Suppose I have the following HTML:</p> <pre><code>&lt;form id="myform"&gt; &lt;input type='checkbox' name='foo[]'/&gt; Check 1&lt;br/&gt; &lt;input type='checkbox' name='foo[]' checked='true'/&gt; Check 2&lt;br/&gt; &lt;input type='checkbox' name='foo[]'/&gt; Check 3&lt;br/&...
<p>The name of the field isn't <code>foo</code>, it is <code>foo[]</code>. You could use the <a href="http://docs.jquery.com/Selectors/attributeStartsWith#attributevalue">attributeStartsWith</a> selector:</p> <pre><code>$("input[name^='foo']:checked:enabled",'#myform'); </code></pre> <p>Ideally, you'd be able to do t...
Populate 2 or more tables in ASP MVC <p>I'm looking for a way to populate more than 1 table in MVC, because the method only allows me to return One ModelView or I don't know how to return more. Do I have to build the table in the controller and store into a ViewData and display the viewData in the page?</p> <p>Edit: S...
<p>ViewData is a dictionary; you can store multiple items in there, simply via:</p> <pre><code>ViewData["foo"] -= ... ViewData["bar"] -= ... </code></pre> <p>You can then get these (separately) in the view. The other approach is to declare a type that <em>encapsulates</em> both properties, and use an instance of that...
MSSQL - Presenting data when column names dynamic <p>I am presenting to a final authority evaluation scores for employees. Each row is an employee’s data and since the categories to be evaluated can change from period to period the column names cannot be hardcoded in the Stored Procedures. I have already devised t...
<p>don't store data in the schema</p> <p>create tables like this:</p> <pre><code>Assignment AssignmentID int not null primary key identity(1,1) AssignmentName varchar(50) not null AssignmentDate datetime not null etc.. Score ScoreID int not null primary key identity(1,1) EmployeeID int not null Assignmen...
Quick way to insert interface methods to a class in Visual Studio 2005 <p>I know that in Eclipse, if your class implements an interface or extends an abstract class, there is a quick way to add the method definitions to your class. Can this be done with VS2005? How?</p>
<p>This is language specific but </p> <p>For C#: Right click on the interface, navigate to Implement Inteface and choose the explicit or implict option. The same menu is available for abstract classes (slightly different name)</p> <p>There is also a smart tag that will show up on a C# interface / abstract base with ...
Photo application <p>I'm developing an application just for fun that consists of capturing images from a webcam.</p> <p>What I would like to know is how can I apply some filters to the image that I capture? Ideally I would like to develop something like Apple iPhoto; something that defaces the image.</p> <p>The progr...
<p>if you wnat to implement the filter algorithms, first of all you have to find all operations involved in the algorithm (also a simple low-pass can involve a bit of work) and then you need to access every single pixels of the image (you can do this using Image or Bitmap classes, using the Set/GetPixel method.</p>
Java Transactions API and .NET System.Transactions <p>I'm analyzing the different behaviors between the JTA (Java Transactions API) and the .NET counterpart System.Transactions: the approach is quite different between the two of them. In fact, Java's version of Transactions seems more a specification, leaving to develo...
<p>rollback() sends an actual rollback command to the underlying resources. setRollbackOnly() puts a marker on the current transaction which is read when it's time to decide whether to commit or rollback. Once setRollbackOnly() has been called the only possible outcome is rollback but the rollback call is not actually ...
How do I add syntactic sugar in my Javascript library? <p>Right now the library can translate this operation </p> <pre><code>Select * from List where name = k% order by desc </code></pre> <p>to</p> <pre><code>List.filter(function(x) { return x.first_char() == 'k' }).sort().reverse()); </code></pre> <p>Whats the bes...
<p>For lists you can use <a href="http://json.org" rel="nofollow">JSON</a> notation:</p> <pre><code>["1", "2", "3"] </code></pre>
How to display simple HTML in a Silverlight textblock? <p>I've got a source of data that has HTML tags in it (B, I, A) and need to display this in a Silverlight ListBox. </p> <p>Searching around it seems to be an issue but most of the posts are old and have to do with Silverlight 1 it seems.</p> <p>What is currently ...
<p>There's no native support in Silverlight 2.0. However, someone has gone and created a <code>HtmlTextBlock</code> control which should be suitable for your purposes. Check out the author's <a href="http://blogs.msdn.com/delay/archive/2008/03/17/continuing-support-for-simple-html-display-in-silverlight-htmltextblock-s...
Passing multiple Eval() to a JavaScript function from ASPX <p>I am trying to pass multiple <code>Eval()</code> arguments to a JavaScript function from an <code>.aspx</code> file, but I keep getting compiler errors. I am new to JavaScript and have never really used <code>Eval()</code> before. Where am I going wrong?</...
<p><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.onclick.aspx" rel="nofollow">OnClick</a> is a property on the control which expects a reference to an event handler method. Putting JavaScript in the OnClick property will not work.</p> <p>If you want to execute arbitrary JavaScri...
benchmarking django apps <p>I'm interested in testing the performance of my django apps as I go, what is the best way to get line by line performance data?</p> <p><strong>note</strong>: Googling this returns lots of people benchmarking django itself. I'm not looking for a benchmarks of django, I'm trying to test the p...
<p>There's two layers to this. We have most of #1 in place for our testing. We're about to start on #2.</p> <ol> <li><p>Django in isolation. The ordinary Django unit tests works well here. Create some tests that cycle through a few (less than 6) "typical" use cases. Get this, post that, etc. Collect timing data....
How do I catch the click event of a button who has a TDBGrid as its parent? <p>I have a small button I want to add to the top left corner of a Delphi TDBGrid component (in the header/title cells). I am able to place the button easily, but now the click event is not handled. I'm guessing the event is being caught by the...
<p>Wow, this is a toughie. TDBGrid doesn't have a generic "OnClick" event handler, and the position of your button makes it difficult to fake it. The only thing I can think of is to create your own component. This isn't as difficult as it might sound at first. Descend from TDBGrid and override the MouseUp method. ...
Is this LINQable? <p>I have a string which denotes a filter path (eg. "Plant Filters\Equipment\Equipment List") The leaf node is of type Filter and rest are FilterFolders. </p> <p>I need to:</p> <ol> <li>Go thru each node (not leaf) and get it's -> Folders</li> <li>Check the next entry in the path and see if it match...
<p>This is a recursive structure and cannot be handled with the LINQ standard query operators. Here you can find an <a href="http://www.pluralsight.com/community/blogs/jeffsch/archive/2006/08/18/33631.aspx" rel="nofollow">implementation of the Y-combinator</a> that allows to write recursive lambda expression. I am not ...
passing a jquery object into a function <p>How would you do something like this:</p> <pre><code>somemethod($("#buttonelement")); function(ele) { ele.click(function(event) { alert("hi"); }); } </code></pre> <p>in other words how do you pass in an element as a jquery object and register the click event.</p>
<p>Just like that...?</p> <pre><code>function someMethod(ele) { ele.click(function(event) { alert("hi"); }); } someMethod($("#buttonelement")); </code></pre> <p>The jQuery object is just like any other object in Javascript and can be passed to functions as normal.</p>
AspNetSqlMembershipProvider and PasswordRecovery Control <p>My scenario is I have a asp.net 2.0 application web application which had the AspNetSqlMembershipProvider properties as:</p> <blockquote> <p>enablePasswordRetrieval="false" and passwordFormat="Hashed"</p> </blockquote> <p>But now the need has risen to stor...
<p>I don't think you'll have any luck trying to use two methods for storing passwords in the database.</p> <p>My advice is to change the passwords on the accounts that have hashed passwords so they get stored as plain text and move on from there.</p> <p>Alternatively, if you <em>must</em> store some hashed and some c...
Why do I get a 404 error when I try to access my rails site using https? <p>My server is currently hosting a php site. This site uses ssl for certain pages already. Now I am transitioning over to rails, and all my new rails apps go into a subfolder. Passenger is setup and and my app works great. One problem, If i try t...
<p>Apache for the SSL (port 443) site is probably not set up for Passenger in the same way as for the "normal" (port 80) site.</p>
scaleable cloud computing services <p>I'm looking for a cloud computing service with the following requirements:</p> <ul> <li>no need to manage servers</li> <li>instant availability</li> <li>automatic scaling</li> <li>ability to run tasks for at least a couple of minutes</li> </ul> <p>Google App Engine seems to meet ...
<p>I believe Amazon's EC2 fits your requirements.</p> <p><a href="http://aws.amazon.com/ec2/" rel="nofollow">Amazon EC2</a></p>
How do you remove an advertised shortcut programmatically? <p>So I botched an msi installer and deployed it after only testing installation, not uninstall (bad I know, added running of an exe after install, but forgot to specify that it should only occur on install not uninstall). </p> <p>I found the <a href="http://...
<p>As far as the shortcut is concerned, it's just a normal file that can be deleted. </p> <p>However I'll caution you about using MSIZAP - it is really a <em>last resort</em> and leaves a lot of information behind, shared DLL counts, registry entries, files, etc. Once removing the Windows Installer information you the...
Updating display order of multiple MySQL rows in one or very few queries <p>I have a table with say 20 rows each with a number for display order (1-20).</p> <pre><code>SELECT * FROM `mytable` ORDER BY `display_order` DESC; </code></pre> <p>From an admin area you can drag the rows around or type a new number manually ...
<p>You should first ensure that the column has no UNIQUE index, otherwise mysql will tell you that the constraint is broken during the query. After that you can do things like:</p> <pre><code>-- Move #10 down (i.e. swap #10 and #11) UPDATE mytable SET display_order = CASE display_order WHEN 10 THEN 11 WHEN 1...
Best way to obfuscate an e-mail address on a website? <p>I've spent the past few days working on updating my personal website. The URL of my personal website is (my first name).(my last name).com, as my last name is rather unusual, and I was lucky enough to pick up the domain name. My e-mail address is (my first name)@...
<p>I encode the characters as HTML entities (<a href="http://www.wbwip.com/wbw/emailencoder.html">something like this</a>). It doesn't require JS to be enabled and seems to have stopped most of the spam. I suppose a smart bot might still harvest it, but I haven't had any problems.</p>
Optimizing Telerik ASP.NET AJAX Controls <p>Any good sources(links) about optimizing Telerik Web controls? I imagine that there are features that are turned on by default. These features require resources (javascript, css, images) to be downloaded on request. It would be nice to know what these feature are and to turn ...
<p>Does this help?</p> <p><a href="http://www.telerik.com/help/aspnet-ajax/optimizing_output_and_page_load_time_by_using_radscriptmanager_and_radstylesheetmanager.html" rel="nofollow">Optimizing output, page load time and the overall performance of RadControls for ASP.NET AJAX</a></p> <p><a href="http://www.telerikwa...
BindAsEventListener equivalent in jQuery? <p>I am trying to bind a click event to some element using jQuery. Using prototype I know I can do this using <code>BindAsEventListener()</code>.</p> <p>Example: </p> <pre><code>var myObject = { init: function(txtOneId, txtTwoId, lblResultId, ancAddId) { this.txtOneId =...
<p>I assume that you are still using prototype, and have added the jQuery no conflict so that <strong>$()</strong> is a prototype method and <strong>$j()</strong> is a jQuery method.</p> <p><strong>Quick Answer</strong></p> <p>You only need to make a change on your init method.</p> <pre><code> init: function(txtO...
Does the Sun JVM slow down when more memory is allocated via -Xmx? <p>Does the Sun JVM slow down when more memory is available and used via -Xmx? (Assumption: The machine has enough physical memory so that virtual memory swapping is not a problem.)</p> <p>I ask because my production servers are to receive a memory up...
<p>By adding more memory, it will take longer for the heap to fill up. Consequently, it will reduce the frequency of garbage collections. However, depending on how mortal your objects are, you may find that how long it takes to do any single GC increases.</p> <p>The primary factor for how long a GC takes is how many...
Where to go to browse for open source projects to work on? <p>I've decided to have a look around for open source projects that need a hand and lend a bit of time to one or two. One question though, is there a site(s) that lists current open source projects that are looking for developers and is there anywhere I could f...
<p>The three major ones:</p> <p><a href="http://sourceforge.net/" rel="nofollow"><strong>SourceForge</strong></a></p> <p><a href="http://www.codeplex.com" rel="nofollow"><strong>CodePlex</strong></a></p> <p><a href="http://code.google.com" rel="nofollow"><strong>Google Code</strong></a></p>
Django: How to use stored model instances as form choices? <p>I have a model which is essentially just a string (django.db.models.CharField). There will only be several instances of this model stored. How could I use those values as choices in a form?</p> <p>To illustrate, the model could be <code>BlogTopic</code>. I'...
<pre><code>topics = forms.ModelMultipleChoiceField(queryset=BlogTopic.objects.all()) </code></pre>
Keep a http connection alive in C#? <p>How do i keep a connection alive in C#? I'm not doing it right. Am i suppose to create an HttpWebRequest obj and use it to go to any URLs i need? i dont see a way to visit a url other then the HttpWebRequest.Create static method.</p> <p>How do i create a connection, keep it alive...
<p>Have you tried the <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.keepalive.aspx">HttpWebRequest.KeepAlive</a> property? It sets the appropriate Keep-Alive HTTP header and does persist the connections. (Of course this must also be supported and enabled by the remote web server).</p> <p>T...
Partial list unpack in Python <p>In Python, the assignment operator can unpack list or tuple into variables, like this:</p> <pre><code>l = (1, 2) a, b = l # Here goes auto unpack </code></pre> <p>But I need to specify exactly the same amount of names to the left as an items count in the list to the right. But sometim...
<p>This may be of no use to you unless you're using Python 3. However, for completeness, it's worth noting that the <a href="http://www.python.org/dev/peps/pep-3132/" rel="nofollow">extended tuple unpacking</a> introduced there allows you to do things like:</p> <pre><code>&gt;&gt;&gt; a, *b = "length=25".split("=") &g...
force breaking a string in a fixed width Gridview cell <p>I have a Gridview control on an ASP.Net page with fixed width cells. The data coming from the database occasionally comes over as a contiguous string of characters. When there are dashes in the string, it will break so as not to upset the width of the layout. If...
<p>If you handle the <a href="http://msdn.microsoft.com/en-us/library/aa479342.aspx" rel="nofollow">RowDataBound event</a> you'll be able to break the string "manually". Otherwise it'll only break based on "HTML rules".</p>
How to detect a hung thread? <p>Is it possible to detect a hung thread? This thread is not part of any thread pool, its just a system thread. Since thread is hung, it may not process any events.</p> <p>Thanks,</p>
<p>In theory, it is <a href="http://en.wikipedia.org/wiki/Halting%5FProblem" rel="nofollow">impossible</a>. If you are on Windows and suspect that the thread might be deadlocked, I guess you could use GetThreadContext a few times and check if it is always the same, but I don't know how reliable it will be.</p>
<cite> as part of semantic markup <p>One of the sites I develop has lots of information linked between each other; we have companies, we have products for those companies. The company page links to the page listing the products for that company, and vice versa.</p> <p>From the <a href="http://www.w3.org/TR/html401/st...
<p>If you're just linking to other pages then semantically you should just use <code>&lt;a href=...&gt;</code>. If you're quoting a small piece of information, like the information from the HTML spec in your question, and providing a link to the original source, you might use <code>&lt;cite&gt;</code>. Think of it as...
How to generate examples of a gettext plural forms expression? In Python? <p>Given a gettext Plural-Forms line, general a few example values for each <code>n</code>. I'd like this feature for the web interface for my site's translators, so that they know which plural form to put where. For example, given:</p> <p><code...
<p>Given that it's late, I'll bite.</p> <p>The following solution is hacky, and relies on converting your plural form to python code that can be evaluated (basically converting the x ? y : z statements to the python x and y or z equivalent, and changing &amp;&amp;/|| to and/or)</p> <p>I'm not sure if your plural form...
Default values in a C Struct <p>I have a data structure like this:</p> <pre> struct foo { int id; int route; int backup_route; int current_route; } </pre> <p>and a function called update() that is used to request changes in it. </p> <pre> update(42, dont_care, dont_care, new...
<p>While macros and/or functions (as already suggested) will work (and might have other positive effects (i.e. debug hooks)) they are more complex than needed; the simplest and possibly most elegant solution is to just define a constant that you use for variable initialisation:</p> <pre><code>const struct foo FOO_DONT...
Refactoring method that binds controls to LINQ <p>I have a function that binds LINQ results to the controls on my form. The below code works but I just can't get over the feeling I should be slapped for the copy/paste aspect. Can someone help me with what i need to do to deodorize this?</p> <p>Thank You!</p> <pre><...
<p>I don't know if this really solves anything but try:</p> <pre><code>public static class MyExtentsions { public IQueryable&lt;string&gt; GetItemDescriptions(this Table&lt;CN_MaintItem&gt; table, int cat) { return from x in table where x.CategoryID == cat select x.ItemDes...
Delimiter in one string <p>Here is an example of a file that i use to create a mysql db. The delimiter is "," but in the description for a single column exist ",".</p> <pre><code>Header: City State Zip Description Los Angeles, California , 98005, "welcome to california, were are living the dream","Please stay, a while...
<p>No need to reinvent any wheels, PHP already has what you need in <a href="http://www.php.net/manual/en/function.fgetcsv.php" rel="nofollow">fgetcsv</a></p>
jgoodies bindings + indirect changes <p>I'm having a brain cramp trying to understand the appropriate way to use JGoodies bindings in my application.</p> <p>I have a class Article which is a bean that has read-only properties. <code>Article</code> is a "plain" bean, and doesn't manage property listeners, since the pro...
<p>I figured it out.</p> <p>I do something like this:</p> <pre><code> // on setup: BeanAdapter&lt;Article&gt; adapter = new BeanAdapter&lt;Article&gt;((Article)null, false); // the "false" in the constructor means don't try to observe property // changes within the Article, but we still can observe changes /...
Is there a way to find out what's referencing my object in .NET? <p>Basically, I have an object that I think should be garbage-collected but it's not. I am pretty certain all references to it are gone from what I can see in the code but for some reason, it is not getting destroyed.</p> <p>Is there some way to find out...
<p>Yes, you can use WinDbg + SOS to trace your managed heap. <a href="http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx" rel="nofollow">This link</a> should get you started.</p> <p>Note - you don't have to use VADump (steps 1 to 3) to get a dump file, the Visual Studio debugger has this feature built in for ...
How to write my own wrapper in C#? <p>In my other question, I've been trying to find someone who knows where to find free open source OCR library for C#. However, it seems there is only C++ library and obviously, C++ is not C#.</p> <p>One of the responds suggested to write my own wrapper in C#. I have pretty much no i...
<p>You can get a good start here:</p> <p><a href="http://www.csharphelp.com/2006/01/call-unmanaged-code-part-1-simple-dllimport/" rel="nofollow">Call Unmanaged Code. Part 1 - Simple DLLImport</a></p>
Using TwitPic API from ObjectiveC/iPhone <p>There's a similar question on here about this which I've read and I've tried to follow the advice given there... and I think I'm 95% complete but the remaining 5%... well you know ;-)</p> <p>So I'm trying to call the twitPic API to upload an image and I've got the image cont...
<p>You need to use the setData method to copy the image data into the post, like this:</p> <pre><code>[request setData:twitPicImage forKey:@"media"]; </code></pre> <p>You're making a synchronous call, which is going to stall your app while you upload all that image data - you might want to switch to using an NSOperat...
Close MS Office C# Console <p>I'm writing an automated test to determine whether or not rtf files are successfully opened by MS Word. So far I looping through all the rtfs within a given directory and opening them. Later I will have to catch exceptions to generate a report (log the file name that crashed word).</p> <p...
<pre><code>WordApp.Quit() </code></pre> <p>will exit the application. </p> <p>However, the safest way is to get a handle to the process and kill the winword process. In C# the following code would do that:</p> <pre><code>foreach (Process p in Process.GetProcessesByName("winword")) { if (!p.HasExited) { ...
Actionscript 3.0: Scope <p>Tutorials usually don't deal with scope in Actionscript. Can you point me to some documentation and/or explain what should I know about it. I want to avoid problems arising from certain classes are not visible at certain places.</p>
<p>These should help.</p> <p>Function scope:</p> <p><a href="http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_21.html" rel="nofollow">http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_21.html</a></p> <p>Packaging and namespace:</p> <p><a href="http://livedo...
Unable to show only one drawer by jQuery at startup <p>I want only one drawer to be open at startup. At the moment, all drawers are open.</p> <p><strong>The <a href="http://jqueryfordesigners.com/slide-out-and-drawer-effect/" rel="nofollow">jQuery code</a></strong></p> <pre><code>$(document).ready(function () { ...
<p>You've got the right idea, just the wrong placement of your :first clause.</p> <pre><code>$('li.drawer:first ul').addClass('open'); </code></pre>
How to shell execute a file in C#? <p>I tried using the Process class as always but that didn't work. All I am doing is trying to run a Python file like someone double clicked it.</p> <p>Is it possible?</p> <p>EDIT:</p> <p>Sample code:</p> <pre><code>string pythonScript = @"C:\callme.py"; string workDir = System.I...
<p>Here's my code for executing a python script from C#, with a redirected standard input and output ( I pass info in via the standard input), copied from an example on the web somewhere. Python location is hard coded as you can see, can refactor.</p> <pre><code> private static string CallPython(string script, stri...
Silverlight Toolkit Treeview: Getting the parent of a selected item <p>I'm using the TreeView component from the Silverlight toolkit and I'm trying to get the parent of a selected node. The TreeView is bound to a series of objects, so directly working with a TreeViewItem appears to be out of the question. </p> <pre><c...
<p>As long as you've downloaded the latest Silverlight Toolkit then this is easy using the TreeViewExtensions that are included.</p> <ol> <li>Download the <a href="http://www.codeplex.com/Silverlight" rel="nofollow">Silverlight Toolkit</a> and install.</li> <li>Add a reference to System.Windows.Controls.Toolkit (from ...
Display slideshow of Private Photosets from Flickr <p>I have a number of photo sets that are marked as private on Flickr. I have a website and I would like to display all of them as Flash Sideshow.</p> <p>I am currently using Flickr.NET open source library and I have created a web application to retrieve the list of a...
<p>You can't do it using the standard Flickr embed: <a href="http://www.flickr.com/help/blogging/#2937" rel="nofollow">http://www.flickr.com/help/blogging/#2937</a></p> <p>All the embed parameters outlined here: <a href="http://paulstamatiou.com/2005/11/19/how-to-quickie-embedded-flickr-slideshows" rel="nofollow">http...
Structuremap 2.0 documentation <p>I'm just starting to learn DI/IOC methods and like what I see so far from Structuremap. The problem is that my current project is limited to .NET 2.0 so I cannot use the new version (2.5) of Structuremap. That being said, can someone point me towards some documentation for v2.0? Mos...
<p>Your best bet would be to download the Docs folder from the <code>Release_2.0</code> tag of StructureMap's subversion repository:</p> <p><a href="http://structuremap.svn.sourceforge.net/viewvc/structuremap/tags/Release%5F2.0/Docs/" rel="nofollow">http://structuremap.svn.sourceforge.net/viewvc/structuremap/tags/Rele...
MSChart and ASP.NET MVC Partial View <p>I'm currently trying to add an MSChart to a partial view in ASP.NET MVC RTM. I have reviewed the following blog <a href="http://code-inside.de/blog-in/2008/11/27/howto-use-the-new-aspnet-chart-controls-with-aspnet-mvc/" rel="nofollow">entry</a>, and I'm currently investigating O...
<p>I'm not exactly sure what the problem is, but the most common cause of that error is that you've used a statement inside a "&lt;%= %>" block rather than an expression. Since the code within a "&lt;%= %>" block is placed within a call to <code>System.IO.TextWriter.Write</code>, it must be an expression. Statements ...
jQuery Execution? <p>My jQuery script has a glitch animating a div position. The bug seems to occur when I click the link right as the page is loading.</p>
<blockquote> <p>The bug seems to occur when I click the link right as the page is loading</p> </blockquote> <p>This is because you are using the <code>ready</code> function and that executes as soon as the <strong>page has finished loading.</strong></p> <p>Thus, if you click on something whilst the page is still ...
is there statically typed language with nice lambda support for the JVM? <p>I'd quite like to write some Google App Engine apps, but I'm a c# developer by trade, and as such I like static typing and Linq (or at least extensions + lambdas + predicates, if not query syntax). Is there a language I can use on the JVM that ...
<p>Scala: <a href="http://www.scala-lang.org/" rel="nofollow">http://www.scala-lang.org/</a></p> <p>Actually, Groovy also has optional static typing, so I'll include it as well, but most static-type, uh, types seem to prefer Scala. Groovy can be found at: <a href="http://groovy.codehaus.org/" rel="nofollow">http://gr...
Javascript document.all and document.getSelection - Firefox alternative <p>The script below will replace selected word in a textarea. But it only works on IE. Any idea how to make it work on Firefox? (The problem seems to lie in (document.all)? document.selection.createRange() : document.getSelection();)</p> <pre><cod...
<p>The document.all bit is being used as a test to see if it's IE or not. The way it's written document.getSelection() is what would be used in Firefox and document.selection.createRange() in IE</p> <p>See <a href="http://www.hscripts.com/tutorials/javascript/ternary.php" rel="nofollow">http://www.hscripts.com/tutoria...
I'm looking for an application/text editor that <p>can best help me systematically modify the "replace" field of a regex search as it encounters each match.</p> <p>For example, I have an xml file that needs the phrase "id = $number" inserted at regular points in the text, and basically, $number++ each time the regex m...
<p>emacs (version 22 and later) can do what you're looking for. See <a href="http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-22.html" rel="nofollow">Steve Yegge's blog</a> for a really interesting read about it. I think this should work:</p> <pre> M-x replace-regexp Replace regexp: <i>insert pattern re...
Is there an alternative way to free dynamically allocated memory in C - not using the free() function? <p>I am studying for a test, and I was wondering if any of these are equivalent to free(ptr):</p> <pre><code> malloc(NULL); calloc(ptr); realloc(NULL, ptr); calloc(ptr, 0); realloc(ptr, 0); </code></pre> ...
<p>Actually, the last of those is equivalent to a call to <code>free()</code>. Read the specification of <code>realloc()</code> very carefully, and you will find it can allocate data anew, or change the size of an allocation (which, especially if the new size is larger than the old, might move the data around), and it...
RA layer request failed while git-svn fetch <p>I use git svn to sync with the subversion repos:</p> <pre><code>$ mkdir prj &amp;&amp; cd prj $ git svn init http://url/to/repos/branches/experimental $ git svn fetch </code></pre> <p>and got the error message:</p> <pre><code>RA layer request failed: OPTIONS of 'http://...
<p>I had the same issue when accessing a SVN repo <strong>through a proxy</strong>.</p> <p>The solution for me was to edit <code>~/.subversion/servers</code> and add the needed proxy to the <code>[globals]</code> section. Uncomment the relevant lines (<code>http-proxy-host</code>, <code>http-proxy-port</code>, optiona...
shadow mapping multitexture <p>There is this tutorial about shadow mapping: <a href="http://www.paulsprojects.net/tutorials/smt/smt.html" rel="nofollow">http://www.paulsprojects.net/tutorials/smt/smt.html</a></p> <p>Ok, but I did not realize how to make a scene with multitexture.</p> <p>If in the third pass of shadow...
<p>Just to clarify, you have a pre-existing multi-textured scene you want to shadowmap?</p> <p>If so, activating all your texture units should work (<strong>if</strong> you have enough, I think the OpenGL 1.4/1.5 spec only calls for a minimum of two; check GL_MAX_TEXTURE_UNITS_ARB via glGetIntegerv()). If you don't h...
tabbed html application <p>I am writing a complex tab based web application where each tab is unrelated to each other in the sense that there is no interaction. So for ease of development i want I want each tab to be a separate html page viewable on its own and at later stage I can assemble them via tabs or may be menu...
<ol> <li><p>Yes, all major desktop browsers support iframes. So do many mobile browsers, including IEMobile, Opera Mobile, and Safari on the iPhone. The only major browser I know of that <i>doesn't</i> support iframes is the BlackBerry Browser.</p></li> <li><p>The object tag is supported by most browsers, but the imple...
How do I set or clear the first 3 bits using bitwise operations? <p>Lets say I have a number like <code>0x448</code>. In binary this is <code>0100 0100 1000</code>.</p> <p>How do I set the bits 1, 2 and 3 to either all 0's or all 1's using bit-wise operations? When I say the first three, I'm counting the rightmost bi...
<p>You have the bit setting correct: <code>OR</code> with the mask of the bits you want to set.</p> <p>Bit clearing bits is very similar: <code>AND</code> with the ones-complement of the bits you want cleared. </p> <p>Example: Word of <code>0x0448</code>.</p> <p>Settings bits 1, 2 and 3 would be <code>Word OR 0x000e...
How can I print a single JPanel's contents? <p>I have a <code>JPanel</code> with two labels with pictures. I need to print these content of the <code>JPanel</code>. Please help me out. How can I print only this <code>JPanel</code>'s contents, as I also have different components on my <code>JFrame</code> but I just need...
<p>Here is the sample to print any Swing component.</p> <pre><code>public void printComponenet(){ PrinterJob pj = PrinterJob.getPrinterJob(); pj.setJobName(" Print Component "); pj.setPrintable (new Printable() { public int print(Graphics pg, PageFormat pf, int pageNum){ if (pageNum &gt; 0){ ...
Does the order of headers in an HTTP response ever matter? <p>Is it ever meaningful whether the order of headers is</p> <pre><code>A: 1 B: 2 </code></pre> <p>vs</p> <pre><code>B:2 A:1 </code></pre> <p>I'm trying to figure out if I can use a dictionary to store a list of headers or if it needs to be some kind of lis...
<p>No, it does not matter for headers with different names. See <a href="http://tools.ietf.org/html/rfc2616">RFC 2616</a>, section 4.2:</p> <blockquote> <p>The order in which header fields with differing field names are received is not significant. However, it is "good practice" to send general-header fie...
Java XML APIs <p>I've dealt with a few XML APIs in Java, but I don't have a good understanding of all the frameworks available in Java for dealing with XML for whatever purpose (e.g. JAXB, JAXP, Xerces, StAX, Castor, etc.). Can anyone highlight the most popular Java XML APIs and give a quick description of what they'r...
<ul> <li><p><a href="http://en.wikipedia.org/wiki/Java%5FAPI%5Ffor%5FXML%5FProcessing">JAXP</a> is a "pluggable API", a set of interfaces and abstract classes with a "reference implementation" by Sun, but it uses the factory approach to allow you to swap out to a different implementation (e.g. one that might be faster ...
Convert string value into html format in php <p>Any one know how to convert string value into html format in php? For Example:</p> <pre><code>$string = "Hello World!! How are you?" </code></pre> <p>If I echo $string, it will display like this:</p> <pre><code>Hello World!!How are you? </code></pre> <p>Ins...
<p>You’re looking for the <a href="http://docs.php.net/nl2br" rel="nofollow"><code>nl2br</code> function</a> that adds an HTML line break tag <code>&lt;br /&gt;</code> to every physical line break sequence (<code>\n</code>, <code>\r</code> or <code>\r\n</code>):</p> <pre><code>\n → &lt;br /&gt;\n \r → &l...
WatiN Compatibility with Windows <p>I am running tests successfully on Windows XP but not even got a single successful build while running through Windows 2003.</p> <p>Any one knows whether it is compatible or not as I read on some site that WatiN is fully tested on XP and not on other Windows editions.</p>
<p>I'd ordinarily post this as a comment on Sam's answer, but I'm trying to make a stack trace searchable, so here goes...</p> <pre><code>WatiN.Core.Exceptions.IENotFoundException : Could not find an IE window matching constraint: Timeout while waiting to attach to newly created instance of IE.. Search expired after '...
how to write java program get pid <p>how to write java program get pid?</p>
<p><a href="http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html" rel="nofollow">How a Java Application Can Discover its Process ID (PID)</a></p> <p>Not very straightforward, but apparently there is no "official" way.</p>
Bypass all cacheing on jQuery.autocomplete(1.02) <p>I am using <strong>jQuery.autocomplete(1.02)</strong> on my search box and I want <strong>exact</strong> string and substring matching. I don't care (yet!) about the database load, I'm happy for it to fire off a query every keystroke and bypass the caching entirely - ...
<p>I wonder why <strong>cacheLength</strong> doesn't work, but had trouble with autocomplete too. IMHO, there are errors in it. However, in the <a href="http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url%5For%5Fdataoptions" rel="nofollow">list of options</a>, there is a <strong>matchSubset</strong> you could ...
Eclipse class designer and design<--> java source bindings <p>I'm tutoring a subject on rapid prototyping at university for 2nd/3rd year students.</p> <p>Can anyone recommend a (free) way to design class hierarchies in a GUI design surface within Eclipse? </p> <p>The UML design surfaces in Eclipse Modelling Tools are...
<p><a href="http://www.bluej.org/about/what.html" rel="nofollow">BlueJ</a> is a GUI Java IDE that allows students to go from UML diagrams to code. It's free and recently open source.</p> <p>It also supports extensions similar to popular Eclipse extensions: PMD, checkstyle, etc.</p> <p>It's specifically designed for ...
Most common docblock for Delphi and/or FreePascal code <p>I'm quite familiar with PHP dockblocks since it's been my job for the last 15+ years.</p> <pre><code>/** * Description * * @tag bla bla * @tag more bla bla */ </code></pre> <p>What I'm trying to understand is if there is a standard like that for Delp...
<h1>Delphi documentation tools</h1> <p>Using the XMLDoc tool for API documentation and HelpInsight with Delphi 2005 &nbsp;&nbsp;<a href="http://edn.embarcadero.com/article/32770" rel="nofollow">http://edn.embarcadero.com/article/32770</a></p> <p>XML Documentation in Delphi 2006 &nbsp;&nbsp;<a href="http://tondrej.blo...
How can I change annotations/Hibernate validation rules at runtime? <p>If have a Java class with some fields I want to validate using Hibernate Validator. Now I want my users to be able to configure at runtime which validations take place.</p> <p>For example:</p> <pre><code>public class MyPojo { ... @NotEmpt...
<p>You can't do it normally.</p> <p>Here's what I've done to get more dynamic validations working via Hibernate Validator.</p> <ol> <li>Extend the <code>ClassValidator</code> class.</li> <li>Override the <code>getInvalidVaues(Object myObj)</code> method. First, call <code>super.getInvalidValues(myObj)</code>, then a...
How much code in a rails view is ok? <p>I know that it is best to keep code out of the presentation layer. But, I am wondering how much is considered "acceptable". For example I populate an html select box with this line of code. </p> <pre><code>CodesecureProject.find(:all,:order =&gt; 'name').collect {|project| [pr...
<p>I'm not going to say I'd never do it (I'd be lying) but the code example given would make me nervous. I think I'd be more inclined to deliver the data to the select box from my controller. A helper method is another option if I notice I'm doing something more than once. I'm more likely to see the duplication in the ...
How to install program shortcuts for all users? <p>I'm creating an installer msi file using the Windows Installer XML toolkit. When installing the created msi file, a shortcut placed under the ProgramMenuFolder folder results in a shortcut for the Administrator user only. How do I let the installer create a shortcut un...
<p>In the <a href="http://wix.sourceforge.net/manual-wix3/wix%5Fxsd%5Fpackage.htm">Package element</a>, add an InstallScope attribute like this:</p> <pre><code>InstallScope='perMachine' </code></pre>
NHibernate requires events to be virtual? <p>I'm attempting to map an entity hierarchy using NHibernate almost all of which have events. When attempting to build a session factory however, I get error messages similar to the following:</p> <blockquote> <p>Core.Domain.Entities.Delivery: method remove_Scheduled shou...
<p>Public members must be declared virtual if you use lazy loading because NHibernate will create proxy objects for your entities at runtime. So do not use lazy loading or just declare the event as virtual - that is not so common, but it is possible.</p> <p>NHibernate creates proxy classes for all lazy loaded entities...
Checking if a particular device driver is loaded <p>I'm trying to work out if I can check if a particular video card device driver is loaded in Windows Server 2003 using C++. Can anyone give me pointers on how I might achieve this?</p> <p>Thanks</p>
<p>Use <strong>EnumDeviceDrivers</strong> - there's an example <a href="http://msdn.microsoft.com/en-us/library/ms682619%28VS.85%29.aspx" rel="nofollow">here</a>.</p>
Are source-code comments good practice or problematic? <p>I talk about source-code-comments, that explains what happens on the next lines of code, not Javadoc/Doxygen-comments (that comment on the interface).</p> <p>Comments can make your intention for the code clearer, but on the other hand they could be redundant or...
<p>Add comments where you need them to explain to another <strong>why</strong> you did something, the code itself should show clearly enough <strong>what</strong> you did. When Adding comments detailing what the code is doing is when you run the risk of redundant or outdated comments confusing readers of your code.</p>...
MySQL and SQLite differences in SQL <p>I'm writing java application that is using both <strong>SQLite</strong> and <strong>MySQL</strong> using <strong>JDBC.</strong></p> <p>Are there any differences in <strong>SQL</strong> for those databases? Can I use same queries for both <strong>SQLite</strong> and <strong>MySQL<...
<p>If you stick to <a href="http://en.wikipedia.org/wiki/SQL-92">ANSI SQL92</a>, you'll should be fine. </p> <p>There are some SQL92 features missing from both MySQL and SQLite (e.g. FULL OUTER JOIN). MySQL has both RIGHT JOIN, and LEFT JOIN, SQLite only the LEFT JOIN. SQLite doesn't support FOREIGN KEY constraints,...
Best way to get the next id number without "identity" <p>I have to insert some records in a table in a legacy database and, since it's used by other ancient systems, changing the table is not a solution.</p> <p>The problem is that the target table has a int primary key but no identity specification. So I have to find ...
<p>Create another table:</p> <pre><code>t_identity (id INT NOT NULL PRIMARY KEY CHECK (id = 1), value INT NOT NULL) </code></pre> <p>with a single row, lock this row, and increment <code>value</code> by one each time you need an <code>IDENTITY</code>.</p> <p>To lock, increment, and return the new value in a single s...
Howto access data held in widget options when inside a widget event handler <p>I have data held in the options variable, but in an event (OnChange) of a select list this refers to the DOMElement and therefore this.options refers to the list of objects.</p> <p>everywhere else I can have </p> <pre><code>var o = this....
<p>Use the <a href="http://api.jqueryui.com/jQuery.widget/#method-_on" rel="nofollow"><code>this._on()</code> method</a> to bind the handler. This method is provided by the jQuery UI widget factory and will make sure that within the handler function, <code>this</code> always refers to the widget instance.</p> <pre cla...
How can i get List items to stay together using CSS? <p>The skeleton of the HTML is this</p> <pre><code>&lt;div class="TwoCol"&gt; &lt;img src="imgurl"/&gt; &lt;h1&gt;A headline&lt;/h1&gt; &lt;p&gt;Some exciting text&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Item A&lt;/li&gt; &lt;li&gt;Item B&lt;/li&gt; &lt;li&gt;Item C&lt;/li&g...
<p>You could set the <code>&lt;ul&gt;</code> to </p> <pre><code>display: inline-block; </code></pre> <p>You might also want to <code>clear: left;</code> your images, since it's possible that they could start stacking up next to each other depending on the other content.</p>
Suggestions For String and DateTime utility functions' Library using Extension Methods <p>I'm writing a library of Extension Methods for String and DateTime utility functions in C#. Can you please help me out by suggesting the useful utlity functions for String and DateTime you may want to be part of it ? With your sug...
<pre><code>public static bool IsNullOrEmpty(this string value){ return string.IsNullOrEmpty(value); } public static string Reverse(this string value) { if (!string.IsNullOrEmpty(value)) { char[] chars = value.ToCharArray(); Array.Reverse(chars); value = new string(chars); } retur...
How to XML configure Spring bean for constructor injection when bean has varargs constructor <p>Is there a way to write a Spring bean in XML so that it uses constructor injection when that constructor has a varargs parameter type? IE, is there a way to specify an array the way you can specify a list? </p> <p>For insta...
<p>since <code>args</code> is an array of <code>String</code> you can use <code>&lt;list&gt;</code>:</p> <pre><code> &lt;bean name="myBean" class="MyClass"&gt; &lt;constructor-arg&gt; &lt;list&gt; &lt;value&gt;111&lt;/value&gt; &lt;value&gt;222&lt;/value&gt; &lt;value&gt...
PostgreSQL concatenation <p>I got this function to concat fields in my pgSQL-server:</p> <pre> BEGIN IF acc IS NULL OR acc = '' THEN RETURN instr; ELSE RETURN acc || ';' || instr; END IF; END; </pre> <p>It works great, but now I want this function to distinct equal entries. How can I do this...
<pre><code>CREATE TYPE tp_concat AS (data TEXT[], delimiter TEXT); CREATE OR REPLACE FUNCTION group_concat_iterate(_state tp_concat, _value TEXT, delimiter TEXT, is_distinct boolean) RETURNS tp_concat AS $BODY$ SELECT CASE WHEN $1 IS NULL THEN ARRAY[$2] WHEN $4 AND $1.data @&gt; ARRAY[$2] THEN $1.d...
SQL CLR Stored Procedure and Web Service <p>I am current working on a task in which I am needing to call a method in a web service from a CLR stored procedure.</p> <p>A bit of background:</p> <p>Basically, I have a task that requires ALOT of crunching. If done strictly in SQL, it takes somewhere around 30-45 mins to...
<p>I am just figuring this out, but this is what I got:</p> <p>You need to set the permission_set when you create the assembly in SQL to UNSAFE.</p> <pre><code>CREATE ASSEMBLY [&lt;assemblyname&gt;] FROM '&lt;path&gt;/&lt;assemblyname&gt;.dll' WITH PERMISSION_SET = UNSAFE GO </code></pre> <p>If you are using a VS SQ...
Accessing sqlite3 database <p>I have created database and table through sqlite3 using terminal on macbook, then deploy it with my iPhone application. Its working fine in simulator inserting &amp; retrieving the values from table.</p> <p>But when i install it on real iPhone it is not working, why? I think it can not ge...
<p>Are you leaving the database in the base app path?<br /> Because if you are, the actual hardware won't allow you to write to files in that directory, just read. To write to the database, you will first have to copy it to an accessible directory.</p> <p>I'm doing something similar to this (where filename is an NSStr...
Which validation framework to choose: Spring Validation or Validation Application Block (Enterprise LIbrary 4.0)? <p>I am trying to choose one of the validation frameworks for a major application, and while both options seem enticing, I was wondering whether there are any specific pros and cons I should be aware of bef...
<p>Validation with attributes is not best solution in my view. Firstly you have to reference infrastructure in domain model. Secondly you don't have any chance to add validation to compiled classes. Lastly you can't validate complex logic with attributes and you have to make Validate method to entity and that just seem...
How to find out size of ASP.NET session, when there are non-serializable objects in it? <p>I have a feeling that I'm putting rather much data in my ASP.NET session, but I've no idea how much and if I should be concerned. I found a <a href="http://stackoverflow.com/questions/198082/how-to-find-out-size-of-session-in-asp...
<p>For testing, you could put together a stub Custom Session provider, implementing the SessionStateStoreProviderBase abstract class. I would write backing fields that stash everything in WebCache (so that you have session data managed), and eventually generate a statistic using the Marshal.SizeOf() method when the Se...
How do I make textures transparent in OpenGL? <p>I've tried to research this on Google but there doesn't appear to me to be any coherent simple answers. Is this because it's not simple, or because I'm not using the correct keywords?</p> <p>Nevertheless, this is the progress I've made so far.</p> <ol> <li>Created 8 ve...
<p>So the other answer which was here but was deleted mentioned this - Generally, for alpha blending to work correctly you need to sort the objects from far to near in the coordinate system of the camera.<br /> This is why your polygons are blended with the background. You can confirm that this is indeed the problem by...
Temporary table resource limit <p>i have two applications (server and client), that uses TQuery connected with TClientDataSet through TDCOMConnection, and in some cases clientdataset opens about 300000 records and than application throws exception "Temporary table resource limit".</p> <p>Is there any workaround how to...
<p>The error might be from the TQuery rather than the TClientDataSet. When using a TQuery it creates a temporary table and it might be this limit that you are hitting. However in saying this, loading 3,000,000 records into a TClientDataSet is a bad idea also as it will try to load every record into memory - which ma...
Multiple Footer Rows in a JSF dataTable <p>I am wanting to know if there is any way to have multiple footer rows in a h:dataTable (or t:datatable) I want to do somthing like this (which does not compile) </p> <pre><code>&lt;h:dataTable ... var="row"&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt; Header ...
<p>The solution I ended up using was a custom renderer associated with t:datatable (the tomahawk extension to datatable) </p> <pre><code>public class HtmlMultiHeadTableRenderer extends HtmlTableRenderer </code></pre> <p>I only had to override one method </p> <pre><code>protected void renderFacet(FacesContext facesCo...
problem with containers: *** glibc detected *** free(): invalid pointer: 0x41e0ce94 *** <p>I have a C++ program on Linux that crashes after some time with the message:</p> <pre><code>*** glibc detected *** free(): invalid pointer: 0x41e0ce94 *** </code></pre> <p>Inside the program I make extensive use of containers. ...
<p>Consider using a std::string to hold the string value instead of a raw char pointer. Then you won't have to worry about managing the string data in your assignment, copy, and destruction methods. Most likely your problem lies there.</p> <p>Edit: There's no issue with the newer class you posted, and no problem wit...
Initializing a Generic.List in C# <p>In C#, I can initialize a list using the following syntax.</p> <pre><code>List&lt;int&gt; intList= new List&lt;int&gt;() { 1, 2, 3 }; </code></pre> <p>I would like to know how that <code>{}</code> syntax works, and if it has a name. There is a constructor that takes an <code>IEnum...
<p>This is called a <em>collection initializer</em>. It's calling the parameterless constructor, and then calling Add:</p> <pre><code>List&lt;int&gt; tmp = new List&lt;int&gt;(); tmp.Add(1); tmp.Add(2); tmp.Add(3); List&lt;int&gt; intList = tmp; </code></pre> <p>The requirements for the type are:</p> <ul> <li>It imp...
Suggest class names for an Event Booking system <p>I'm writing an Event Booking system in C#, which is vexing me greatly because "event" and "delegate" are reserved words. "Delegate" I've changed to "Attendee", but I can't think of an alternative name for the Event class (and instances thereof). The best I've come up w...
<p>If you really want to use a C# reserved word, you can prefix it with '@'.</p> <p>E.g.</p> <pre><code>public class @class { ... } </code></pre> <p>Use with caution...</p>
Is it possible to get the favorites list from the browser? <p>Is it possible to read a user's favorites list using asp.net?</p>
<p>This would violate the visitors privacy. You would need a browser component that they installed locally to do such a thing.</p>
SSIS - lookup surrogate key for parent <p>I have a table in my source DB that is self referencing</p> <p>|BusinessID|...|ParentID|</p> <p>This table is modeled in the DW as |SurrogateID|BusinessID|ParentID|</p> <p>First question is, should the ParentID in the DW reference the surrogate id or the business id. My idea...
<p>One trick I've used in this situation is to load the rows without the ParentID. I then used another data flow to create an update script based on the source data and the loaded data, then used a SQL task to run the created update script. It won't win prizes for elegance, but it does work.</p>
Techniques for storing/retrieving historical data in Rails <p>I'm looking for some ideas about saving a snapshot of some (different) records at the time of an event, for example user getting a document from my application, so that this document can be regenerated later. What strategies do you reccomend? Should I use th...
<p>There are several plugins for this. </p> <pre><code>Acts_audited </code></pre> <p>acts as audited creates a single table for all of the auditable objects and requires no changes to your existing tables. You get on entry per change with the changes stored as a hash in a memo field, the type of change (CRUD). It ...
PHP Query Fail <pre><code>&lt;?php if(isset($_POST['upload']) &amp;&amp; $_FILES['userfile']['size'] &gt; 0) { $dbhost = 'localhost'; $dbuser = 'zuk1_boo'; $dbpass = 'lols'; $dbname = 'zuk1_boo'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $name = $_POST['name']; $iq = $_POS...
<pre><code>mysql_query($query) or die('q fail'); </code></pre> <p>Replace this with</p> <pre><code>mysql_query($query) or die(mysql_error()); </code></pre> <p>And tell us what you get.</p>
Downsides to immutable objects in Java? <p>The advantages of immutable objects in Java seem clear:</p> <ul> <li>consistent state</li> <li>automatic thread safety</li> <li>simplicity</li> </ul> <p>You can favour immutability by using private final fields and constructor injection.</p> <p>But, what are the downsides t...
<blockquote> <p>But, what are the downsides to favouring immutable objects in Java? incompatibility with ORM or web presentation tools?</p> </blockquote> <p>Reflection based frameworks are complicated by immutable objects since they <strong>requires</strong> constructor injection: </p> <ul> <li>there are no d...
JQuery animate <p>I have some JQuery code in the click event handler for a checkbox that updates the value of a span control on the page, then animates the background color of the span tag to yellow and then fade back to white in about a second to draw attention to the user that the value of the span has changed. The ...
<p>Simply call stop() on the object before animating it:</p> <pre><code> $('#button').click( function() { $('#animatedSpan').stop().animate( { } ); }); </code></pre>
Compare text of two methods <p>Is there a tool that can do a diff of two methods? I'm working on some legacy code that has several 100-200 line methods that contain a lot of duplication and I would like to abstract the duplication out. Being able to diff the two methods would be a huge help. In case it matters, I'm wor...
<p>I use <a href="http://winmerge.org/" rel="nofollow">WinMerge</a> in conjunction with <a href="http://visualstudiogallery.msdn.microsoft.com/a7519ab0-6029-49f3-9243-a74d1718a5bb" rel="nofollow">ClipboardDiff</a>. You can then do the comparison between clipboard contents and highlighted contents, with no need to save...
Socket programmimg in C, need sample codes and tutorials <p>I want to do socket programming in C. Where client and server are exchanging messages. I have the sample codes with me, but i wanted some elaborate links and tutorials for socket programming C, so that i can write effective and error free code. I will be worki...
<p>I think the standard response to this question is:</p> <p><a href="http://beej.us/guide/bgnet/" rel="nofollow">http://beej.us/guide/bgnet/</a></p>
Security risks of an un-encrypted connection across an international WAN? <p>The organisation for which I work has an international WAN that connects several of its regional LANs. One of my team members is working on a service that receives un-encrypted messages directly from a FIX gateway in Tokyo to an app server in ...
<p>You should protect traffic even on a LAN. Haven't you heard of Heartland Payment Systems and the breach of their system that processes credit cards for hundreds of thousands of merchants? Thieves were sniffing unprotected traffic on Heartland's internal network.</p> <p>Do this right is cheap and easy, so the value ...
Visual Studio code formatter <p>I'm using Visual Studio 2008 for doing work in C# and JavaScript (AJAXy stuff).</p> <p>Here's my issue -- I love Eclipse and especially the code formatted (Ctrl-Shift-F). Visual Studio's Ctrl-k, Ctrl-d, really sucks in comparison, especially for javascript.</p> <p>Is there a way to get...
<p>Go into Tools | Options | Text Editor and edit the language specific settings to you're liking. Ctrl-K, Ctrl-D honors these settings, so you can make the code formatter working the way you want. There are a ton of options you can change (bracket positioning, spacing, indenting, etc.).</p>
Anything like DPAPI available for .NET Compact Framework or Windows Mobile? <p>I need a way to protect a private key on a mobile device.</p> <p>I know in "Writing Secure Code" chapter "Protecting Secret Data" says "Windows CE" cannot be used in secure environments. But the book is many years old now, 2003.</p> <p>Is ...
<p>The DPAPI is embodied in a set of Win32 functions, <a href="http://msdn.microsoft.com/en-us/library/aa922939.aspx" rel="nofollow">CryptProtectData</a> and <a href="http://msdn.microsoft.com/en-us/library/aa925037.aspx" rel="nofollow">CryptUnprotectData</a>. These functions are available on Windows CE and Windows Mo...
Trouble porting OpenGL code to iPhone's OpenGL ES <p>Here, is the sample code which I am using. This code is in OpenGL. I want to port it to OpenGL ES. <code>glArrayElement()</code> is not supported in OpenGL ES. Instead, it was recommended to use <code>glDrawElements()</code>, <code>glDrawArrays()</code>. I am not abl...
<p>everything from glLockArrays down you can get rid of. just replace all that with glDrawArrays and youre done.</p>
Javascript to handle manipulating url anchor for bookmarking <p>I'd like to use the anchor part of the url (after the #) so that my page can have ajax/dhtml but still be able to have bookmarks work properly. I'm wondering is someone can help me get started on writing some javascript code for this. I'm using jQuery, but...
<p>Have a look at the <strong>jQuery history plugin</strong>: <a href="http://www.mikage.to/jquery/jquery_history.html" rel="nofollow">http://www.mikage.to/jquery/jquery_history.html</a></p>
Is there anything as good as TOAD for Postgres (Windows)? <p>I'm just looking for a management tool like TOAD for Postgres. Anyone used a good one?</p> <p>Edit - I work mostly within the data itself and the database already has a mature model/design. I use the edit windows the most (well, in TOAD for Oracle anyway.)...
<p>Doesn't TOAD exist for several plattforms?</p> <p>I'm using pgAdmin III which fills my needs so far.</p> <p><a href="http://www.pgadmin.org/">http://www.pgadmin.org/</a></p>