Archive Page 2

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 hidden files in the results. A bit shorter, but arguably less readable if you don’t know Powershell:

 get-Childitem . -include *svn* -force -recurse
    | foreach ($_) { $_.fullname }

I bet you can go even shorter, I don’t really know Powershell, though it loos very, very powerful. Naturally.

Anyway, now I can do what I originally intended and blast all the svn info from my project, like so:

 get-Childitem . -include *svn* -force -recurse
   | foreach ($_) { remove-item $_ -recurse -force }

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, result:JobResult) => mergeResult(result)
  }
}

All good. Then you realise that one or more of the jobs Continue reading ‘Make sure you get all your messages in your Scala code’


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 Continue reading ‘Scala makes things expressive – timing’


Logging in Java can be messy. Especially the dreaded isDebugEnabled. Look – a class that calculates something:

import org.slf4j.LoggerFactory;
class SomeCalculator implements Calculator {
  private final log = LoggerFactory.getLogger(getClass());
  public Result caclulate(Input input) {
    if (log.isDebugEnabled()) {
      log.debug("Input is " + input);
    }
    Result result = input.times(64).shift(LEFT);
    if (log.isDebugEnabled()) {
      log.debug("Result is " + result);
    }
    return result;
  }
}

We have a class which has one line that actually does something and loads of lines that Continue reading ‘Scala makes things tidy – logging’


Fresh start

16Jun09

Having spent months pondering how to migrate my old blog to here, I though to myself, is it of any value to anyone? In this day and age, does anyone really need to generate hibernate mappings from xdoclet, or sneakily introduce open source technology through the back door, because the “architecture committee” won’t have it. That’s all in the stone age. If you still consider generating Hibernate XML mappings with xdoclet, then I probably don’t want you on my blog anyway.

There are of course old technology blog entries that are of value, but I don’t think mine were amongst them.

That, and the irony of not scrapping a blog that contains at least two articles on attachment, convinced me I should just let go of it. I mean, the blog is still there, just that all the old urls are broken. Might upset a couple of search engines, but, really, who cares?

I guess the lesson this has taught me is that it’s stupid to build your own thing when much better ones are available out there, often for free. I only built my own blog, because I wanted to try Ruby on Rails. It was fun doing it, but then kept becoming more and more high-maintenance, until I just stopped posting. While watching the free blog suppliers add more and more cool features, which I just couldn’t have, because I’d built my own and had my main business to do as well.

So here we are – blank sheet and all that :)