Skip to content

Instantly share code, notes, and snippets.

@leeky
leeky / gist:6580469
Created September 16, 2013 13:07
Raphael Arcs
paper.customAttributes.arc = function (centerX, centerY, startAngle, endAngle, innerR, outerR) {
var radians = Math.PI / 180,
largeArc = +(endAngle - startAngle > 180);
// calculate the start and end points for both inner and outer edges of the arc segment
// the -90s are about starting the angle measurement from the top get rid of these if this doesn't suit your needs
outerX1 = centerX + outerR * Math.cos((startAngle-90) * radians),
outerY1 = centerY + outerR * Math.sin((startAngle-90) * radians),
outerX2 = centerX + outerR * Math.cos((endAngle-90) * radians),
outerY2 = centerY + outerR * Math.sin((endAngle-90) * radians),
innerX1 = centerX + innerR * Math.cos((endAngle-90) * radians),
@leeky
leeky / pre-commit
Created April 26, 2013 14:14 — forked from Simbul/pre-commit
#!/usr/bin/env ruby
# This pre-commit hook will prevent any commit to forbidden branches
# (by default, "staging" and "production").
# Put this file in your local repo, in the .git/hooks folder
# and make sure it is executable.
# The name of the file *must* be "pre-commit" for Git to pick it up.
FORBIDDEN_BRANCHES = ["staging", "production"]
@leeky
leeky / gist:3601003
Created September 2, 2012 16:13
Automounting in OSX
1) Bring up Directory Utility (/Applications/Utilities/Directory Utility)
2) Click “Show Advanced Settings”.
3) Click “Mounts”
4) Click the lock to make the changes
5) Click “+” to add an entry
6) Add you entry, expand the mount parameters box and enter net in the options. If you have other options to add, add them as well, comma-separated.
7) At this point, you can either wait for some time for the autofs to detect the change and reload the maps or run the automount -cv command to load the changes.
@leeky
leeky / gist:3155900
Created July 21, 2012 14:07
Set up postgis template in PostgreSQL
# Creating the template spatial database.
$ createdb -E UTF8 template_postgis
$ createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
# Allows non-superusers the ability to create from this template
$ psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
# Loading the PostGIS SQL routines
$ psql -d template_postgis -f /usr/local/share/postgis/postgis.sql
$ psql -d template_postgis -f /usr/local/share/postgis/spatial_ref_sys.sql
@leeky
leeky / chef_solo_bootstrap.sh
Created May 23, 2012 13:54 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo - 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 ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@leeky
leeky / gist:1212750
Created September 12, 2011 23:23 — forked from kevinprince/gist:1212725
badges in ruby
# Requires the following gems: prawn, barby and rqrcode
require "prawn"
require "prawn/measurement_extensions"
require "barby"
require "barby/barcode/code_128"
require "barby/outputter/prawn_outputter"
barcode = Barby::Code128.new('12345','A')
badge = Prawn::Document.new(:page_size => "A5", :page_layout => :landscape, :margin => 0) do |pdf|
@leeky
leeky / clearing.css
Created January 19, 2011 15:05
Self Clearing Floats
.group:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
overflow: hidden;
}
* html .group {
1) Make sure .ssh directory exists on remote server
2) Generate SSH key using ssh-keygen -t rsa
3) Copy public key onto remote server and append to ~/.ssh/authorised_keys2
4) Test password-less SSH onto remote server, might need to edit ~/.ssh/config
Host shortname
HostName ipaddr
Port blah (if port not 22)
User blah (if user not the same as local user)
@leeky
leeky / RVM - Snow Leopard
Created April 18, 2010 23:40
RVM with Snow Leopard
# From: http://afreshcup.com/home/2009/9/2/migrating-to-snow-leopard-for-rails-development-a-definitive.html
sudo gem install rvm
rvm-install
rvm install 1.8.6 -C --enable-shared,--with-readline-dir=/usr/local
rvm install 1.8.7 -C --enable-shared,--with-readline-dir=/usr/local
rvm install 1.9.1 -C --enable-shared,--with-readline-dir=/usr/local
rvm install 1.9.2 -C --enable-shared,--with-readline-dir=/usr/local
rvm 1.8.7 --default
#!/usr/bin/env ruby
def output_config
puts <<-END
graph_category App
graph_title passenger status
graph_vlabel count
sessions.label sessions
max.label max processes