Archive for the 'programming' Category

So, I’m writing this constructor here: public Square(double x, double y, double size, double gap) {   … } Then I think, really, these should be BigDecimals, because I’m modeling a rectangular area on a grid, which could be of any precision and being maths stuff has to be precise, so I change it to: [...]


The new (well, not that new now) Windows search is way annoying, so I thought may be I could use Powershell for searching. This is how to do it (best do it on one line): foreach ($file in get-Childitem . -include *svn* -force -recurse)  { $file.fullname } The -force is to make it include the [...]


I had this funny little Scala actor related bug today. Imagine you want to process a few things in parallel. So you go: val processor = self jobs.foreach { job =>   actor {     processor ! (job.id, job.run)   } } // Merge results for (i <- 1 to jobs.size) {   self.receiveWithin(1000) {     case (jobId:Int, [...]


How often have you done something like this? -

public Result calculate() {
long start = System.currentTimeMillis();
Result myResult = doSomethingLongAndComplex();
log.debug(“Crunching took ” + (System.currentTimeMillis() – start) + “ms.”);
return myResult;
}

It’s kind of ugly when you do it a few times and it does clutter the code. The need for defining an explicit myResult var is even more annoying. So, today, I added…


Logging in Java can be messy. Especially the dreaded isDebugEnabled. Not so in Scala.