Skip to content

Instantly share code, notes, and snippets.

@statique
statique / install-ruby.sh
Created March 1, 2013 15:56
Install Ruby 2.0.0-p0 on Ubuntu 12.04 LTS
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -xvzf ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0/
./configure --prefix=/usr/local
make
make install
@statique
statique / install-ruby.sh
Created November 21, 2012 20:37 — forked from bartimaeus/install-ruby.sh
Install Ruby 1.9.3-p327 on Ubuntu 12.04 LTS
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar -xvzf ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327/
./configure --prefix=/usr/local
make
make install
@statique
statique / serialized_conversion.sql
Created November 2, 2012 20:42
PostgreSQL Convert Rails serialized YAML to JSON query
-- replace table_name with the name of your database table, e.g. users
-- replace data with the serialized field in the table, e.g. nicknames
-- output generates serialized data that decrypts to a Ruby array.
-- data with quotes, hyphens, or spaces will have issues with this query.
-- preview the YAML to JSON to confirm the conversion is working.
SELECT data, REPLACE(REPLACE(REPLACE(REPLACE(REGEXP_REPLACE(REPLACE(REPLACE(REPLACE(data,
' ', ''),
'...', ''),
'---', '["'),
@statique
statique / installation.sh
Created September 25, 2012 19:18
Setup Ubuntu 12.04 Web Server for Apache Passenger Rails RBEnv Postgres Memcache
# rbenv inspired by https://gist.github.com/1441139
# make sure running as root user
apt-get -y update
apt-get install linux-headers-2.6.32-5-amd64
apt-get -y upgrade
apt-get -y install curl git-core python-software-properties build-essential git-core curl libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev libcurl4-openssl-dev libxslt-dev libxml2-dev
# add-apt-repository
curl -o /usr/sbin/add-apt-repository http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txtchmod o+x /usr/sbin/add-apt-repository
@statique
statique / setup.sh
Created September 12, 2012 12:59
Setup Ubuntu 12.04 Web Server for NGINX Rails RBEnv Postgres Memcache
apt-get update
apt-get upgrade
apt-get -y install curl git-core python-software-properties
# nginx
add-apt-repository ppa:nginx/stable
apt-get -y update
apt-get -y install nginx
service nginx start
@statique
statique / nori_parser.rb
Created September 5, 2012 04:14
Demonstrates Nori's improper conversion of attribute-less elements
require 'awesome_print'
require 'nori'
Nori.parser = :nokogiri
xml = <<EOS
<?xml version="1.0" encoding="UTF-8"?>
<categories>
<category id="1234">
<styleId>123</styleId>