• 100 ways to skin an interview question

    February 24, 2010

    In a recent interview, I was asked the following question: Write a program to determine the 10th Fibonacci number. Without further specification, this problem is worthless. Depending on the scope and nature of the program, the solution to this problem will vary wildly. For example, will this function get called in a tight inner loop? [...]

  • Copying a file in Java

    February 17, 2010

    Code snippet. Why isn’t this part of the Java API? Just use commons. <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</groupId> <version>1.4</version> </dependency> FileUtils gives us this: public static void copyFile(File srcFile, File destFile) throws IOException

  • Ruby and named regex matched groups.

    February 17, 2010

    Back from China, I’ve resume my normal programming schedule. I’m working through Pragmatic Bookshelf’s Programming Ruby, and there’s a lot more to ruby than I initially gave credit. For example, consider the following: str = ‘an’ * 3000 + ‘garbage’ + ‘an’*3000 r = /(?<pattern>.*) #The first part (?:.*?) #Garbage \k<pattern>/x #The first part, repeated. [...]

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org