61 cards

Vagrant, Virtualbox, 32bit systems and more than one cpu

If you spin up a 32bit guest system within vagrant using the virtualbox provider, setting the number of cpus is not enough. Meaning that the following won't do:

config.vm.provider "virtualbox" do |vb|
  vb.cpus = 2

You'll have to enable ioapic additionally.

config.vm.provider "virtualbox" do |vb|
  vb.customize ["modifyvm", :id, "--ioapic", "on"]
  vb.cpus = 2

Check outdated dependencies via Maven

If you're on a java project then you'll very likely use maven.

Outdated dependencies can simply be shown via

mvn versions:display-dependency-updates

Apache Wicket testing links in listview

Testing links in wicket is usually done like this tester.clickLink("wicketContainerId:linkId").

However if you have non-unique identifiers for example if your links are generated by a listview component then you need another approach. Fortunately this is easy. You can increment a counter (starting at 0) as a placeholders for the generated listview items. Which means you can test the links within the listview like this:


Setting gtk2 and gtk3 theme via config file

If you're not using gnome or xfce but have some gtk apps installed then you could always set your theme preferences via ~/.gtkrc-2.0 like this:

# ~/.gtkrc-2.0

gtk-can-change-accels = 1

gtk-icon-theme-name = "Faenza-Dark"
gtk-theme-name = "Zukitwo"

style "user-font"
        font_name="Terminus 12"
widget_class "*" style "user-font"
gtk-font-name = "Terminus 12"

But with gtk 3.0 this changed. You know have to edit the file ~/.config/gtk-3.0/settings.ini which will look like this:…

Git - quickly switch to last branch

Like the cd - command git also has a shortcut to checkout the last branch. git checkout - switches to the last checked out branch.

% git checkout -
Switched to branch 'foo'
% git checkout -
Switched to branch 'bar'

Howto to get into the android bootloader?

At least on my Nexus 4 (made by LG) I have to press the following keys: Power + Volume Down

Within the bootloader you can switch entries with the volume keys and select one with the power key.

This can be helpful if your android doesn't start anymore.

Enable powerline fonts with rxvt-unicode and vim-airline

I recently switched to airline as powerline replacement for vim.

To enable support for powerline-fonts the following steps were needed:

  1. Download font from powerline-fonts repository repository and copy it to ~/.fonts/
  2. Update local font cache by running fc-cache -vf ~/.fonts
  3. Update ~/.Xdefaults to use the font for example: URxvt*font: xft:Terminess Powerline:size=12
  4. Update local X setting…

Sylpheed and Opera

If you are using opera and sylpheed you might want to fire up sylpheed by clicking on a mailto link in the browser.

For best results the following parameter configuration is recommended:

--compose [mailto:%t][?subject=%s][&cc=%c][&bcc=%b][&body=%m]

Log to file using log4j when running with tomcat

In case you have an application running under tomcat and want to write your logs to a seperate file using log4j you can use some variables that tomcat is setting up.

Therefore you can use a path like ${catalina.home}/logs/... in your log4j.properties:

log4j.rootLogger=INFO, FileLogger

RSpec mocha warning with rails

Since some time you probably noticed ugly deprecation warning made by mocha if using rspec and rails.
Usually they look like this:

*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
*** Mocha deprecation warning: Test::Unit or MiniTest must be loaded *before* Mocha.
*** Mocha deprecation warning: If you're integrating with a test library other than Test::Unit or MiniTest, you should use `require 'mocha/api'` instead of `require 'mocha'`.

There are several workarounds for this but there is also a…

Rotating rails application log files

To prevent the log files of a rails application to grow without limit you should setup log rotation. There are several ways to do this. Here is a simple solution using logrotate.

Create a config file (usually something like /etc/logrotate.d/my-app):

/full/path/to/my_rails_app/log/*.log {
   rotate 52

This will rotate logs on a weekly basis and keep them for a year. Notice that the copytruncate option is essential to prevent your rails app f…

Mirror svn repositories with git and svn2git

If you want to mirror a svn repository via git there is a nice little gem called svn2git available that provides easy setup. Updating your repository is done via svn2git --rebase.

However what do you do if you clone your git repo onto another machine?

The svn metadata is not stored with the repository!

You have to set it up via svn2git once more.

  1. Re-create the repository with svn2git svn://my.domain/repository or whatever you need (see svn2git docs).
  2. Add the remote for your…

FreeBSD portmaster disable portaudit check

Sometimes you have to rebuild ports due to a library update. But if there are vulnerabilities known for that ports then make will bail out with an error message and refuse to build the port. Instead it gives you the advice to update or deinstall the port which is good advice but sometimes just not possible.

If you want to force the build of that port you can use the flag DISABLE_VULNERABILITIES=yes on make or if you use portmaster to manage your ports you can pass it through the -m flag, like this:

# portmaster -m DISABLE_VUL…

RSpec formatter to see failed tests faster.

When running rspec you usually have to wait for all tests to be finnished before you can see the failed tests.

The gem fuubar provides a formatter for rspec that displays the failures right when they appear. Just add it to your Gemfile and be sure to have the following options in your .rspec:

--format Fuubar

If you want rspec to bail out on the first failed test you can add the option --fail-fast to you .rspec as well.

Lighttpd, newrelic php and per directory settings.

If you are using lighttpd to host several php applications via virtual hosts and are using the newrelic php monitoring service then you'll have noticed that setting the php application name per virtual host does not seem possible at first.

I was able to workaround the problem by using the pecl htscanner package. It scans for .htaccess files in your applications directory and imports their settings into you php application.

  1. install the htscanner extension (usually somet…

Useable terminal font for windows

Besides the consolas font which is a splendid developer font I do like the terminus font for console and terminals.

If I'm stuck on a windows box I usually ssh via putty into linux or bsd boxes. Since the terminus font project does provide an installer for windows you can easily download, install and use it in your terminal session.

Rails session secret should not be in a public repository.

You can move the rails session secret to an environment variable by modifying config/initializers/secret_token.rb like this:

MyApp::Application.config.secret_token = ENV['RAILS_SESSION_SECRET']

Given that you have the pwgen utility installed you can start your rails server in your development environment this way:

% RAILS_SESSION_SECRET=`pwgen -cns 128` rails server

Get GitHub API oauth token with curl.

If you're running a non web app on the github api you can simply get the auth token for it (if you have configured in your account under applications of course) by running the following curl command.

% curl -i -u "username:password" \
  https://api.github.com/authorizations \
  -d '{"client_id":"APP_CLIENT_ID", "client_secret":"APP_CLIENT_SECRET"}'

Beware that you'll have to escape some shell sensitive special characters that may be in you password.

This website uses cookies to improve usability and analyze traffic.
Accept or learn more