Adding travis hook to new github project via the commandline

I got tired of clicking through the github menus, so after some toying around with the octopi github client (which does not work as expected…), I wrote this small script using pure rest-client.

Creates a new travis hook based on the travis info in your .gitconfig
and also triggers the initial test-run.

add to ~/.gitconfig

[travis]
  user = xxx
  token = yyy

download & run the Script
wget https://raw.github.com/grosser/dotfiles/master/bin/github-add-travis

./github-add-travis github-password project-name

Switching form Public Domain to MIT

All my new projects will be released under MIT / those I work on will be switched, which will still means the same as before: Do wtf you want with this code, no need for any naming/license copying.

After reading some articles I realized that public domain does not always work since some countries do not allow it and its also unclear what happens when the code causes problems <-> lawsuit.

Ill also try to add a s.license = ‘MIT’ to all gemspecs, to make license management easier.

A fresh start with Ubuntu Oneiric Ocelot 11.10

A fresh install for my laptop, with some Desktop tools and all the rails/ruby stuff I need.

  1. Choose a short name for your computer, it will later show in the prompt. Only enter your firstname/alias, it will always show in the toolbar.
  2. Enable canonical partners in “Software Sources” > Other Software
  3. Install RVM
    sudo apt-get install curl libcurl4-openssl-dev zlib1g-dev libssl-dev libreadline6-dev libncursesw5-dev libxml2 libxml2-dev libxslt1-dev libsqlite3-dev -y
    install rvm following instructions in the link...
    
  4. Rubymine to /opt/rubymine Command key: Choose "meta is mapped to left win" in advanced keyboard layout options Executable: /opt/rubymine/bin/rubymine.sh and setup mine as executable then
    alias m="mine . > /dev/null 2>&1 &"
    

    Inotify:

    # /etc/sysctl.conf 
    fs.inotify.max_user_watches = 524288
    

    and:
    sudo sysctl -p

    Sun-java: It is no longer in ubuntu repos.

    sudo add-apt-repository ppa:ferramroberto/java
    sudo apt-get update
    sudo apt-get install sun-java6-jre
    export RUBYMINE_JDK="/usr/lib/jvm/java-6-sun/jre"
    
  5. Map unity menu from super to Super+z, so you can use it with shortcuts (see below) and with rubymine commands
    sudo apt-get install compizconfig-settings-manager -y
    open compiz application and rebind unity laucher @ "ubuntu unity plugin", dont mess with anything else, I managed to make ubuntu no longer boot into a GUI with just a few clicks
  6. Shortcuts
    Super+D = desktop
    Super+E = open home
    Super+Up = maximize
    Super+Down = minimize
    Super+Q = quit application (Alt+F4)

  7. Chrome sudo apt-get install chromium-browser -y
  8. Git sudo apt-get install git-core
  9. Ruco commandline editor gem install ruco
  10. copy important dotfiles + firefox history/forms/... database from .mozilla
  11. dotfiles
  12. Multi-clipboard sudo apt-get install clipit
    (set history shortcut: Ctrl+Alt+V)
  13. Skype + add skype to startup
    (video fix in dotfiles --> add add /home/xxxx/dotfiles/bin/video-skype to "Startup Spplications" )

  14. Mysql:
    sudo apt-get install mysql-server mysql-client libmysql-ruby libmysqlclient-dev -y
    I`d recommend no root password
  15. Redis sudo apt-get install redis-server -y
  16. Memcached sudo apt-get install memcached
  17. ImageMagic sudo apt-get install imagemagick libmagick9-dev -y
  18. Arial/Verdana etc fonts: sudo apt-get install msttcorefonts
  19. VirtualBox
  20. Nginx + Passenger
  21. Restrcited codes sudo apt-get install ubuntu-restricted-extras -y
  22. Terminal
    Set Ctrl+Shift+L for clear+reset in terminal, so the history gets removed on keypress
    Set Ctrl+t for new tab
  23. Postgres
    sudo apt-get install postgresql libpq-dev
    gem install pg
    sudo su postgres
    createuser

    use no username / no password in database.yml

  24. Reverse scrolling
    If you often work on macs this can reduce your confusion.
    sudo add-apt-repository ppa:zedtux/naturalscrolling
    sudo apt-get update
    sudo apt-get install naturalscrolling -y

Ruby Money vs nil — aka undefined method `round’ for nil:NilClass

Problem
When using composed_of with Money you get this nice error when trying to get the money object while the cents column is nil.
Additionally Money.new(nil) does not work, neither do strings like Money.new(params[:cents]).

Solution
Overwrite the initializer to also accept nil and strings

# config/initializers/money.rb
require 'money'
class Money
  def initialize_with_default_currency(*args)
    args[0] = args[0].to_i if args[0].is_a?(String) or args[0].blank?
    args[1] ||= Money.default_currency
    initialize_without_default_currency(*args)
  end
  alias_method_chain :initialize, :default_currency
end