Java

  • Reading time: 1 min
  • Published 9 years ago

In Java, you can forget about doing it in the cleanest or the best way, because that is impossible. Whatever you do, however hard you try, the code will come out mediocre, verbose, redundant, and bloated, and the only thing you can do is relax and keep turning the crank until the necessary amount of code has come out of the spout. — Why I like Java

When reinstalling helps

  • Reading time: 1 min
  • Published 9 years ago

Today I learned about brew reinstall. This command allows to reinstall the currently installed version of a package. Now, why would that be useful? Because sometimes things go wrong. In my case, the installation of the latest PHP 5.6 release went wrong somewhere. Since I am generally bad at reading log messages, I did not notice that until I actually needed it working.

At first, it threw tons of errors at me of which I thought they originated from the code I was trying to execute - wrong. Then I realized that I might not have updated all the extensions I needed. Also wrong. Then I fooled around a bit and stumbled across homebrews reinstall command. It took a few cups of coffee for

brew reinstall php56

to finish but that's okay. It magically worked again.

Literally only minutes later was it when I discovered that my imagemagick installation was not compiled with webp support. Having learned about reinstall I could solve that problem without a stack overflow marathon.

brew reinstall imagemagick --with-webp

Another cup of coffee.

Chrome cleanup

  • Reading time: 1 min
  • Published 10 years ago

Google Chrome's automatic updating is very much awesome. But it has one big disadvantage for people like me who don't like unused junk on their hard disks. And old versions of programs belong to unused junk. Fortunately, there is an easy way to remove all old versions of Chrome (works for the default and the beta/dev channels, people using the canary channel simply have to swap out the application name):

Using the Finder

Navigate to Applications and select "Show Package Contents" on Google Chrome. You should be presented with something along the lines of the below picture.

Navigate to the Contents/Versions directory. In there, you can delete all directories except the one with the highest number - that's the version you're currently on.

Using the Terminal

On a command prompt, enter

[[ $(ls /Applications/Google\ Chrome.app/Contents/Versions \
| wc -l) -gt 1 ]] && \
rm -rf $(ls /Applications/Google\ Chrome.app/Contents/Versions \
| sort | sed \'$ 0\')

If you're unsure, which version your Chrome is currently running on, simply open a new tab and navigate to

chrome://version

Code listings

  • Reading time: 1 min
  • Published 10 years ago

This may be common knowledge to almost everyone but I only recently discovered the nl tool from GNU coreutils. Now, as long as the code listings to be done are to be published online - woah, that was some weird language - there's plenty of options to get them to have line numberings. GitHub's Gists do that. Almost all the syntax highlighting plugins for all the publishing platforms do that. So well. But there are situations where there is no such thing. At least not as conveniently available. Let's say you're writing a paper in TeX and need to embed a piece of code including line numberings. There is probably some kind of weird tex sorcery around that would do that for you. But there's also nl available via any* unix-y command line. Give that  a stream of text, get a stream with line endings back. Quick. Easy. Awesome.

Someone Great

  • Reading time: 1 min
  • Published 12 years ago
Thumbnail for linked media

Watch this video