instruction
stringlengths
0
30k
In practice, it *usually* decides to do a garbage collection. The answer varies depending on lots of factors, like which JVM you're running on, which mode it's in, and which garbage collection algorithm it's using. I wouldn't depend on it in your code. If the JVM is about to throw an OutOfMemoryError, calling Sy...
If you can guarantee the presence of ImageMagick, you can use their `mogrify -flop` command. It preserves transparency.
I assume by "rotate image" you mean "change the image in use" and not "rotational transformation about an axis" -- a simple way is to have a hash table that maps day modulo X to an image name. $imgs = array("kitten.jpg", "puppy.gif","Bob_Dole.png"); $day_index = 365 * date("Y") + date("Z") .....
[JOGL][1] My reasons can be quoted off the previously linked site: > JOGL provides full access to the APIs in the OpenGL 2.0 specification as well as nearly all vendor extensions, and integrates with the AWT and Swing widget sets. Also if you want to have some fun learning and poking around, [Processing][2] is...
http://www.dreamincode.net/forums/showtopic24692.htm
You can basically parse the page returned by doing a WebRequest of http://whatismyipaddress.com http://www.dreamincode.net/forums/showtopic24692.htm
For using the HttpClient commons class, you want to look into the <tt>org.apache.commons.httpclient.util.URIUtil</tt> class, specifically the <tt>encode()</tt> method. Use it to URI-encode the URL before trying to fetch it.
There are actually three index-based access methods that Oracle can use when a predicate is placed on a non-leading column of an index. i) Index skip-scan: http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/optimops.htm#PFGRF10105 ii) Fast full index scan: http://download.oracle.com/docs/cd/B19306_01/...
This is a good trick for returning the last record in a table: SELECT TOP 1 * FROM TableName ORDER BY Time DESC Check out [this site](http://www.quackit.com/sql/tutorial/sql_top.cfm) for more info.
could you not do: select account,value,max(time) from table group by account,value
could you not do: select account,last(value),max(time) from table group by account I tested this (granted for a very small, almost trivial record set) and it produced proper results.
could you not do: select account,last(value),max(time) from table group by account I tested this (granted for a very small, almost trivial record set) and it produced proper results. Edit: that also doesn't work after some more testing. I did a fair bit of access programming in a past life an...
I like to use [SAP Memory Analyzer][1], which is based in Eclipse. It works very well, also for large heap dumps! [1]: http://www.eclipse.org/mat/
The reason most sites use it is probably SEO (Search Engine Optimization). Yahoo used to give a reasonable weighting to the presence of the search keyword in the URL itself, and it also helped in the Google result as well. More recently the search engines have lowered the weighting given to keywords in the URL, like...
In this link http://kerneltrap.org/node/553/2131 there's a discussion with Linus Torvalds and a "new guy" about the using of GOTOs in linux code. Some very good points there and Linus dressed in that usual arrogance :) Some passages: > Linus: "No, you've been brainwashed by > CS people who thought that Niklaus ...
Jack M.: Agreed, it is not a problem on Windows. If I create an environment variable Foo I can reference it in Perl as $ENV{FOO} or $ENV{fOO} or $ENV{foo}. The problem is: I create it as Foo and dump the entire %ENV to a file and then read in the file from *NX to recreate the Environment hash and use the same script...
If we assume that the start and end ranges will follow the same alternating pattern, and limit the range of digits to `0-9` and `A-Z`, we can think of each group of digits as a component in a multi-dimensonal coordinate. For example, `1A` would correspond to the two-dimensional coordinate `(1,A)` (which is what Excel u...
If we assume that the start and end ranges will follow the same alternating pattern, and limit the range of digits to `0-9` and `A-Z`, we can think of each group of digits as a component in a multi-dimensonal coordinate. For example, `1A` would correspond to the two-dimensional coordinate `(1,A)` (which is what Excel u...
Linq makes testing much easier. Linq queries work just as well on Lists as on the Linq-to-sql stuff. You can swap out Linq to SQL for list objects and test that way.
@Vinko For your generic approach, I'm not sure why you chose to limit the length of the TLD in your regex? It's not very future-proof, and I'm unsure what benefit it's providing? It's actually not even "now-proof" actually because there's at least one 6-character TLD out there (.museum) which won't be matched. ...
@Vinko For your generic approach, I'm not sure why you chose to limit the length of the TLD in your regex? It's not very future-proof, and I'm unsure what benefit it's providing? It's actually not even "now-proof" actually because there's at least one 6-character TLD out there (.museum) which won't be matched. ...
@Vinko For your generic approach, I'm not sure why you chose to limit the length of the TLD in your regex? It's not very future-proof, and I'm unsure what benefit it's providing? It's actually not even "now-proof" because there's at least one 6-character TLD out there (.museum) which won't be matched. It seems ...
What's the best way to authenticate over WCF?
|.net|asp.net|wcf|authentication|membership|
What's the best way to implement authentication over WCF? I'd prefer to not use WS-* as it needs to be transport independant. Should I "roll my own"? Is there any guidance for doing that (articles/blog posts)? Or is there some way to *(and should I)* use the built in ASP.NET Membership and Profile providers on...
@jongalloway - var doesn't necessarily make your code more unreadable. var myvariable = DateTime.Now DateTime myvariable = DateTime.Now; The first is just as readable as the second, and requires less work var myvariable = ResultFromMethod(); here, you have a point, var could make the code less ...
You might want to look at [TDD on Three Index Cards][1] and [Three Index Cards to Easily Remember the Essence of Test-Driven Development][2]: Card #1. Uncle Bob’s Three Laws - Write no production code except to pass a failing test. - Write only enough of a test to demonstrate a failure. - Write only enough p...
@Mark Struzinski I actually discovered that it was a problem with the installer, when installing the "Full Version". I discovered, since the product was downloaded, instead of delivered on CD/DVD, that the installer was looking for information in a path that was not correct. There was a MS Knowledge Base articl...
> I know I'm doing something silly (I'm a php newbie) but I can't seem to find what it is... that is how you are going to learn a lot ;) enjoy it ...
Where to start with CruiseControl.NET
|continuous-integration|cruisecontrol.net|
I'm setting up my team's source control + build/integration process from scratch. We were using VSS and a tool we created in-house to perform the build process. We decided to move on to a more modern environment. I have the SVN running, and I would like to set a continuous integration process with CruiseControl.NET. I...
[NetBeans][1] has some really solid Ruby support. [1]: http://netbeans.org
This sounds like a good use-case for multi-threading... I'd think you could pretty easily setup one thread to be reading data while the other(s) process it. That may be a way to dramatically increase the perceived performance. Just a thought.
If you have a fixed width container, then you are losing some of the effectiveness of a percentage width child span. For your case of 33% you could add a class to the first and every 4th child span to set the correct width as necessary. <div> <span class="first-in-row">/<span><span></span><span></span><s...
You might try a table with a fixed table layout. It should calculate the column widths without concerning itself with the cell contents. table.ClassName { table-layout: fixed }
Set the secure flag on cookies for SSL applications. Otherwise there is always a highjacking attack that is *much* easier to conduct than breaking the crypto. This is the essence of CVE-2002-1152.
As a general advice, I would recommend not stealing the focus from the address bar. ([Jeff already talked about that.][1]) Web page can take some time to load, which means that your focus change can occur some long time after the user typed the pae URL. Then he could have changed his mind and be back to url typing w...
`getElementsByTag()` returns a NodeList instead of an Array. You can convert a NodeList to an Array but note that the array will be another object, so reversing it will not affect the DOM nodes position. var listNodes = document.getElementById("myDivHolderId").getElementsByTagName("img"); var arrayNodes = A...
`getElementsByTag()` returns a NodeList instead of an Array. You can convert a NodeList to an Array but note that the array will be another object, so reversing it will not affect the DOM nodes position. var listNodes = document.getElementById("myDivHolderId").getElementsByTagName("img"); var arrayNodes = A...
Nest a GridView within Repeater
|c#|asp.net|data-binding|gridview|repeater|
Are there disadvantages to nesting a GridView within a Repeater and then binding each repeated GridView during the Repeater's `ItemDataBound` event? What are some alternative solutions? A simple scenario would be repeating a list of US states and displaying a table of cities and city populations for each state.
Nesting a GridView within Repeater
I have a scenario wherein, for example, I need to repeat a list of US states and display a table of cities and city populations after the name of each state. The design requirement dictates that every outer repetition must be the name of a state followed by a table of cities, and that requirement cannot be changed at t...
|asp.net|data-binding|gridview|repeater|
|c#|asp.net|data-binding|gridview|repeater|
|asp.net|data-binding|gridview|repeater|
1. Win-E to open an explorer reference 2. Win-R from the Run box 3. Ctrl-Escape to open the start menu And, of course, Alt-F4 to close things
You can use the java.lang.instrumentation package:<br /> [http://java.sun.com/j2se/1.5.0/docs/api/java/lang/instrument/Instrumentation.html][1] Compile and put this class in a JAR: import java.lang.instrument.Instrumentation; public class ObjectSizeFetcher { private static Instrumentation...
* Alt-F4 to close a program. * WindowsKey + L to lock my workstation * Ctr-Shift-Ins to copy text from a textbox * Alt-PrintScreen to capture a shot of just a window * WindowsKey + R to open the "Run" dialog (XP Pro only- does something else on XP Home)
Win-L to lock the computer.
Windows-Pause/Break to bring up computer info and to access environment variables under the advanced tab. Windows-R to go straight to the run box (though I barely use this anymore since I started with [Launchy][1]) of course Alt-Tab but also Alt-Shift-Tab for going backwards. Oh, and personally, I hate Ctrl+F4 f...
have you tried the decimal values, like setting width to 33.33%? As specified in the CSS syntax, the width property (http://www.w3.org/TR/CSS21/visudet.html#the-width-property) can be given as &lt;percentage&gt; (http://www.w3.org/TR/CSS21/syndata.html#value-def-percentage), which is stated to be a &lt;number&gt;. ...
Are unit-test names important?
|unit-testing|
If unit-test names can become outdated over time and if you consider that the test itself is the most important thing, then is it important to choose wise test names? ie [Test] public void ShouldValidateUserNameIsLessThan100Characters() {} verse [Test] public void UserNameTestValidation1...
i wouldn't put conditions that test needs to meet in the name, because conditions may change in time. in your example, i'd recommend naming like UserNameLengthValidate() or UserNameLengthTest() or something similar to explain what the test does, but not presuming the testing/validation parameters.
The name of any method should make it clear what it does. IMO, your first suggestion is a bit long and the second one isn't informative enough. Also it's probably a bad idea to put "100" in the name, as that's very likely to change. What about: public void validateUserNameLength() If the test changes, the ...
I think if one can not find a good concise name for a test method it's a sign that design of this test is incorrect. Also good method name helps you to find out what happened in less time.
subselect vs outer join
|sql-server|database|performance|
Consider the following 2 queries: select tblA.a,tblA.b,tblA.c,tblA.d from tblA where tblA.a not in (select tblB.a from tblB) select tblA.a,tblA.b,tblA.c,tblA.d from tblA left outer join tblB on tblA.a = tblB.a where tblB.a is null Which will perform better? My assumption is that in general the j...
|sql-server|database|performance|sql|
|sql|sql-server|database|performance|
Consider the following 2 queries: select tblA.a,tblA.b,tblA.c,tblA.d from tblA where tblA.a not in (select tblB.a from tblB) select tblA.a,tblA.b,tblA.c,tblA.d from tblA left outer join tblB on tblA.a = tblB.a where tblB.a is null Which will perform better? My assumption is that in general the j...
Try using the [GoDaddy SQL backup/restore tool][1] to get a local copy of the database. At that point, use the [SQL Server DTS tool][2] to import the data. It's an easy to use, drag-and-drop graphical interface. [1]: http://blog.godaddyhosting.com/2007/07/20/presentingdrum-roll-please-the-ms-sql-backuprestore-fe...
Shouldn't this: imagecolortransparent($img, imagecolorallocate($img, 0, 0, 0)); imagealphablending($img, false); imagesavealpha($img, true); ...be this: imagecolortransparent($temp, imagecolorallocate($img, 0, 0, 0)); imagealphablending($temp, false); imagesavealpha($temp, true); ...
GTGE ([www.goldenstudios.or.id][1]) is an excellent 2D Java Game Library, with tutorials and an extensive API. It has gone open-source in its latest version, and the source can be downloaded, browsed, etc. at [gtge.googlecode.com][2]. [1]: http://www.goldenstudios.or.id [2]: http://gtge.googlecode.com
Download Debugging tools for Windows: [http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx][1] Debugging Tools for Windows has has a script (ADPLUS) that allows you to create dumps when a process CRASHES: [http://support.microsoft.com/kb/286350][2] The command should be something like (if you are usin...
Download Debugging tools for Windows: [http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx][1] Debugging Tools for Windows has has a script (ADPLUS) that allows you to create dumps when a process CRASHES: [http://support.microsoft.com/kb/286350][2] The command should be something like (if you are usin...
This is a standard CSV-style parse. A lot of people try to do this with regular expressions. You can get to about 90% with regexes, but you really need a real CSV parser to do it properly. I found a [fast, excellent C# CSV parser on CodeProject][1] a few months ago that I highly recommend! [1]: http://www.codepr...
I don't have personal experience, so favor the advice of someone that does over mine. I know two coworkers that have used this factory and both had the same take-way: 1. It hurt to set up and learn 2. It was worth it in the end So if you have up-front time to spare, I'd go for it.
# Here's one in pseudocode (a.k.a. Python) in one pass :-P def parsecsv(instr): i = 0 j = 0 outstrs = [] # i is fixed until a match occurs, then it advances # up to j. j inches forward each time through: while i < len(instr): ...
@jj33: You might want to test if the property is not on the prototype chain... var element_count = 0; for(var e in myArray) if(myArray.hasOwnProperty(e)) element_count++;
If Safari and Firefox support is good enough for you, there is a CSS solution: UL { column-count:3; -moz-column-count:3; -webkit-column-count:3; column-gap:2em; -moz-column-gap:2em; -webkit-column-gap:2em; } I'm not sure about Opera.
@[Tom][1] Partial classes are provided so that you can separate tool auto-generated code from any customisations you may need to make after the code gen has done its bit. This means your code stays intact after you re-run the codegen and doesn't get overwritten. This is a good thing. [1]: http://stackoverflo...
- Win-D to minimize all applications - Ctrl-Shift-Esc to open Task Manager
If you were using JGraph, you should give a try to [JGraphT](http://jgrapht.sourceforge.net/) which is designed for algorithms. One of its features is visualization using the JGraph library. It's still developed, but pretty stable. I analyzed the complexity of JGrapT algorithms some time ago. Some of them aren't the qu...
I don't have favorites among keyboard shortcuts -- they are all utility entities to me... Except for Win-L, which means another coffee break!
CSS: Textbox to Fill Parent Container
|css|
I'm trying to let an `<input type="text">` (henceforth referred to as “textbox”) fill a parent container by settings its `width` to `100%`. This works until I give the textbox a padding. This is then added to the content width and the input field overflows. Notice that in Firefox this only happens when rendering the co...
I'm trying to let an `<input type="text">` (henceforth referred to as “textbox”) fill a parent container by settings its `width` to `100%`. This works until I give the textbox a padding. This is then added to the content width and the input field overflows. Notice that in Firefox this only happens when rendering the co...
The number one mistake you can make is creating a globally accessible class called with a generic name, like Constants. This simply gets littered with garbage and you lose all ability to figure out what portion of your system uses these constants. Instead, constants should go into the class which "owns" them. Do you...
int line = textbox.GetLineFromCharIndex(textbox.SelectionStart); int column = textbox.SelectionStart - textbox.GetFirstCharIndexFromLine(line);
just add the name property to the base class and pass it ito the base class's constructor and have the constuctor from the derived class pass in it's command name
Perl has excellent utilities for doing testing. The most commonly used module is probably Test::More, which provides all the infrastructure you're likely to need for writing regression tests. The prove utility provides an easy interface for running test suites and summarizing the results. The Test::Differences module (...
*+2* for "Practical Common Lisp". It is a mixture of a Common Lisp Cookbook and a quality Teach Yourself Lisp book. There's also "Successful Common Lisp" ([http://www.psg.com/~dlamkins/sl/cover.html][1] and [http://www.psg.com/~dlamkins/sl/contents.html][2]) which seemed to fill a few gaps / extend things in "Pract...
You have no control over GC in java -- the VM decides. I've never run across a case where System.gc() is _needed_. Since a System.gc() call simply SUGGESTS that the VM do a garbage collection and it also does a FULL garbage collection (old and new generations in a multi-generational heap), then it can actually cause ...
The name needs to matter within reason. I don't want an email from the build saying that test 389fb2b5-28ad3 failed, but just knowing that it was a UserName test as opposed to something else would help ensure the write person gets to do the diagnosis.
The name needs to matter within reason. I don't want an email from the build saying that test 389fb2b5-28ad3 failed, but just knowing that it was a UserName test as opposed to something else would help ensure the right person gets to do the diagnosis.
Migrating to a GUI witout losing business logic written in COBOL
|user-interface|cobol|busines-logic|code-migration|
We maintain a system that has over a million lines of COBOL code. Does someone have suggestions about how to migrate to a GUI (probably Windows based) without losing all the business logic we have written in COBOL? And yes, some of the business logic is buried inside of the current user interface.
Migrating to a GUI without losing business logic written in COBOL
We maintain a system that has over a million lines of COBOL code. Does someone have suggestions about how to migrate to a GUI (probably Windows based) without losing all the business logic we have written in COBOL? And yes, some of the business logic is buried inside the current user interface.
|user-interface|cobol|business-logic|code-migration|
I think ReSharper is great. I've been using it for 3 years now and I just love it more and more.
We already had this [discussion](http://stackoverflow.com/questions/24451/goto-usage) and I stand by [my point](http://stackoverflow.com/questions/24451/goto-usage#24475). Furthermore, I'm fed up with people describing higher-level language structures as “`goto` in disguise” because they clearly haven't got the poin...