Skip to content

Instantly share code, notes, and snippets.

View pzol's full-sized avatar

Piotr Zolnierek pzol

View GitHub Profile
@pzol
pzol / ubuntu_rvm.sh
Created December 5, 2010 08:33
rvm installation under ubuntu
#!/bin/bash -l
install_path="$HOME/install"
### Verify if the executing user is the root
function is_root {
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "The installation process requires to be run as root. Consider using sudo."
false
fi
@pzol
pzol / tinypm.sh
Created December 5, 2010 22:09
Installation script for tinypm on Ubuntu 10.04 and 10.10
#! /bin/sh
TINYPMVERSION=2.2.3
# from /etc/init.d/tomcat6
NAME=tomcat6
# Directory where the Tomcat 6 binary distribution resides
CATALINA_HOME=/usr/share/$NAME
# Directory for per-instance configuration files and webapps
CATALINA_BASE=/var/lib/$NAME
@pzol
pzol / install_ruby192_freebsd.sh
Created December 18, 2010 23:24
How to install rvm 1.9.2 under FreeBSD - this is work in progress and not complete. You have to su or sudo -i to run this
# this does not run as a complete script :(
pkg_add -r bash curl sudo
pkg_add -r git vim # can you live without it?
pkg_add -r libxml2 libxslt # for nokogiri later
pw usermod pzol -G wheel
bash # start bash and run the rest inside it
curl -# -L http://bit.ly/rvm-install-system-wide > rvm-install-system-wide
bash -l < rvm-install-system-wide
@pzol
pzol / json.rb
Created August 5, 2011 19:10
ActiveSupport broken on UTF-8 strings
# encoding: UTF-8
# parsing with EOF throws illegal characters!?
json = <<EOF
{
"date_a": "2011-07-22T09:54:44Z",
"city": "wroc\u0142aw", # after this the next date is not parsed anymore!
"date_b": "2011-07-22T09:54:44Z"
}
EOF
@pzol
pzol / README.md
Created January 13, 2012 18:11
capybara poltergeist test

This was a test with Poltergeist I did the other day

#!ruby
def polter
   noop

end

@pzol
pzol / rvm.sh
Created January 28, 2012 10:59
rvm reinstall from system wide to local user
sudo bash -l -c 'rvm implode && rm -rf /etc/rvmrc /usr/local/bin/rvm* /usr/local/rvm'
rm ~/.rvmrc
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
rvm reload
# check if it is loaded correctly, this should return rvm is a function
type rvm | head -n 1
@pzol
pzol / beautiful_acceptance_spec.rb
Created March 25, 2012 16:27
Beautiful Acceptance Tests
feature 'Drinking Beer' do
scenario 'Drink a favorite beer' do
user = TestUser.new.extend(BeerDrinker)
user.pickup_favorite_beer "Belfast"
user.drinks_chosen_beer!
end
scenario "Getting wasted" do
user = TestUser.new.extend(BeerDrinker)
@pzol
pzol / maybe.rb
Created March 28, 2012 13:06
Maybe in ruby
def Maybe(obj)
return Maybe.new(Nothing.new) if obj.nil?
return Maybe.new(obj)
end
class Nothing
def method_missing(*args, &block)
self
end
@pzol
pzol / monadic.rb
Created May 30, 2012 17:56
Reliable presenter code with monadic
class MonadicHotelBookingPresenter
def initialize(booking)
@booking = Maybe(booking)
end
def hotel_name
hotel_details['name'].fetch.to_s
end
def hotel_category
@pzol
pzol / README.md
Created June 5, 2012 07:23
RVM + Puma + Ubuntu

Running Puma on Nginx

I use the latest Puma v1.4.0 from rubygems.

Make sure you have nginx installed with these options:

>/opt/nginx/sbin/nginx -V
nginx version: nginx/1.0.15

built by gcc 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)