Jan 14, 2014

Passing a class as default value for a virtus attribute

I might haven’t read the documentation properly or I am just to stupid to google properly, but it took me quite some time to figure out how to pass a class as a default value to a virtus attribute.

attribute :custom_klass, nil, default: ->_,_ { Your::CustomClass }

If you are not using a lambda, the class will get passed, but will be coerced to a Class object and wont respond to kind_of? or similar calls as expect. I tried to write a custom attribute definition with a coercer which just returns the value, but that failed as well. The value was already passed as a Class object.

Perhaps anyone else has a different solution.

Jan 9, 2014

40 Maps That Will Help You Make Sense of the World - A Sheep No More

Oct 28, 2013

Recover from lost commits

Good that I remembered this git talk back from one of the adcloud dev talks. I accidentally deleted the wrong commit during a git rebase. Luckily git does not immediately remove commits, but waits till the next clean up. You can find the commit with git reflog or git log -g and recover it with git branch your-branch-name HEAD@{n}. The HEAD@{n} is listed in the git log output.

Jul 11, 2013

Mercator Map Projection Puzzle

If you ever wondered why you are so bad at guessing country sizes? Have a look at the effect of the most common method of map projection. It will blow away your mind!

Jul 10, 2013

Beautiful and simple desktops

If you are still looking for some beautiful and simple wallpapers, checkout the page. Especially if you are a fan of the flat ui style.

Jul 4, 2013

Forward Port 80 to Port 3000

Why haven’t I thought about this… instead of starting your local applications as root to enable them to run on port 80, you can simply add a port forward to your iptables and you are fine.

Jul 1, 2013
Mar 12, 2013

Fix openssl issues with ruby 2.0.0

Just in case you want to install ruby 2.0.0 and have problems with openssl failing to install. Try the following bits of code. They finally fixed my issues:

$ rvm remove 2.0.0 # get rid of unsuccessful installation
$ rvm get head --autolibs=3 # get the latest RVM and build required libs
$ rvm requirements # just in case, install all other required stuff
$ rvm install ruby-2.0.0
$ rvm --default use ruby-2.0.0

(Source: apple.stackexchange.com)

Sep 18, 2012

Simple error classes in ruby

I just stumbled on this little gem to create your own flat error classes. Instead of defining your class in the most common ruby way of 

class MyCustomError < StandardError; end

You can also write

MyCustomError = Class.new(StandardError)

No ; required. So much nicer

(Source: blog.steveklabnik.com)

Sep 11, 2012
« To the past Page 1 of 9