Auto tmux ssh hostname window title that actually works

Working a lot with tmux? Lost in window list?

This very simple ssh wrapper that will automatically set your current tmux window title to the hostname that you’ve sshed on.

ssh() {
  tmux rename-window "$*"
  command ssh "$@"
  echo "Counting to 60"
  sleep 60 && exit
  tmux rename-window "bash (exited ssh)"


Add it to your ~/.zshrc or ~/.bashrc or any other environment file that is executed automatically and it will wrap your “ssh” command to a function that intercepts hostname that you ssh and will set you current tmux window name so it looks like this:

tmux windows

* all those positions are hostnames except for window 0


Ubuntu 12.04’s ghostscript v. 9 is 10-20 times slower than v. 8

Recently I’ve migrated huge rails app to Amazon Opsworks which support Amazon Linux and Ubuntu. My customers started to whine about the time that it takes to process their pdfs. I did some research and it came out that ghostscript version 9.05 that is the only available version on apt-get.

I was using this PDF for benchmarks .

This is benchmark for ghostscript 8.71 installed on Debian Squeeze. It takes 0.165s to process the file.

root@app2:/tmp# time gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor -dFirstPage=1 -dLastPage=1 "-sOutputFile=/tmp/magick-gY9GM5s6-%08d" -dNumRenderingThreads=8  -f ABC_Birgitte.pdf

real    0m0.165s
user    0m0.144s
sys     0m0.020s

Below we see it’s opponent – ghostscript 9.05 installed on Ubuntu 12.04: 10.3 s

root@chili-pepper:/home/ubuntu# time gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor -dFirstPage=1 -dLastPage=1 "-sOutputFile=/tmp/magick-gY9GM5s6-%08d" -dNumRenderingThreads=8 -dNOGC -dBandBufferSpace=500000000 -dBufferSpace=1000000000  -f ABC_Birgitte.pdf

real	0m10.334s
user	0m10.249s
sys	0m0.088s

Last but not least – ghostscript 9.05 installed on Ubuntu 12.04 from sources. 50% faster than identical version patched by Ubuntu developers: 5.3s

root@chili-pepper:/home/ubuntu# time gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor -dFirstPage=1 -dLastPage=1 "-sOutputFile=/tmp/magick-gY9GM5s6-%08d" -dNumRenderingThreads=8 -dNOGC -dBandBufferSpace=500000000 -dBufferSpace=1000000000  -f ABC_Birgitte.pdf

real	0m5.324s
user	0m5.141s
sys	0m0.088s

And the winner is “gs-910-linux_x86_64” version 9.07 which is a ghostscript vanilla binary downloaded from the site 1.2s (which is still almost 10 times slower than in ghostscript 8.71 though)

root@chili-pepper:/home/ubuntu# time gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor -dFirstPage=1 -dLastPage=1 "-sOutputFile=/tmp/magick-gY9GM5s6-%08d" -dNumRenderingThreads=8 -dNOGC -dBandBufferSpace=500000000 -dBufferSpace=1000000000  -f ABC_Birgitte.pdf

real	0m1.234s
user	0m1.121s
sys	0m0.248s

Conclusion: Ubuntu 12.04 ghostscript in version 9.05 has very very very poor performance.

macvim + janus + fish shell + brew + macosx lion = my environment

So my current setup for code development is created with following steps:

  1. Install Xcode from Appstore
  2. Install brew
  3. Install macvim using brew:
     brew install macvim 

    or use the installator from official website at google code.

  4. Install janus  
    curl -Lo- | bash 
  5. Now let’s install fish 
     brew install fish 

    or do it via their installator

So now you’ve got this pretty “everything inside” editor with cool, easy-to-learn and easy-to-use shell with man autosuggestions :

and this pretty shell:

So in the latest version there is an error:

"~/Documents/Development/Vagrant/chef/postgresql/attributes/default.rb" 365L, 17847C
Error detected while processing function <SNR>126_query_path:
line   17:
E484: Can't open file /var/folders/43/plwczvd96h761mp_vnm6xbth0000gn/T/vHQMBxp/0
Error detected while processing /Users/wojtek/.vim/janus/vim/langs/ruby/ftplugin/ruby.vim:
line  105:
E171: Missing :endif


 wojtek@Wojciechs-MacBook-Pro ~/D/D/V/bottlebooths_chef> cat ~/.vimrc.after
set shell=/bin/sh

This will make your vim know how to enter temporary catalogues :)

Talk about Ripple at SmartDevCon 2013

During last SmartDevCon 2013 that took place between 12 and 14 September in Katowice (Poland), I presented some materials  about ripple monetary system in the context of origin of money, capitalism and how ripple will change our future making money more personal and connected with real value as it used to be in the past.

Credits also go to Adam Filipowski (@panadash) for being a co-presenter here :)

(Simple) Amazon Opsworks Hipchat room notifications

I’m uberhappy to announce release of my next Amazon Opsworks Chef cookbook for sending deployment notifications to specified rooms.

Sourcecode and deployment-ready chef cookbook is here :

You will just have to modify your Opsworks stack settings, adding two additional attributes to deploy[:application] which are : hipchat_api_key and hipchat_room_id so it looks like this:

{ "deploy": {
        "my_fancy_app": {
            "hipchat_token" : "69d2627efe8f564c1cc0b6341e3291",
            "hipchat_room_id": "206231",
            "hipchat_run_on" : "rails-app1",
            "database": {
                "database": "my_fancy_app_production",
                "adapter": "postgresql",
                "host": "db1",
                "reconnect": true,
                "username": "my_fancy_app_production",
                "password": "rigfjnremwds"
            "symlink_before_migrate": {
                "config/database.yml": "config/database.yml",
                "config/s3.yml": "config/s3.yml",
                "config/sendgrid.yml": "config/sendgrid.yml",
                "config/application.yml": "config/application.yml",
                "config/sunspot.yml": "config/sunspot.yml"

Amazon Opsworks haproxy with multiple backends released

I’m happy to announce my own chef cookbook which may be used as an override (or replacement) for stock Amazon Opsworks haproxy cookbook. Typical rails stack on Opsworks with one server, say “rails-app1″ and multiple applications, say “schooplelogin”, “schooplehost”, “fundraiserapp”, “uniformapp” will be treated as one backend like following :




opsworks_haproxy will generate separate backend for every app like that:



So now you may monitor every backend separately. Also when you default vhost returns 500, other applications won’t be marked as “DOWN”