Skip to content

Instantly share code, notes, and snippets.

@padde
padde / pow_localhost.sh
Created September 12, 2011 11:18
Pow: Serve ~/Sites to localhost
# public directory needed for static files!
cd ~/Sites
ln -s . public
# symlink as 'default' (magic name) into .pow
cd ~/.pow
ln -s ~/Sites default
# check if it works
open -a Safari http://localhost
@padde
padde / gist:1273601
Created October 9, 2011 12:09
Nginx init script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@padde
padde / setup-10-04.sh
Created October 9, 2011 15:22
Ubuntu 10.04 Server setup with Nginx, Passenger, Rails, PHP, Sqlite3, MySQL
#! /bin/bash
function info {
echo -e "\e[0;32m---------------------------------------------------------"
echo -e $1
echo -e "---------------------------------------------------------\e[0m"
}
info "Update system"
apt-get update
@padde
padde / gist:1273626
Created October 9, 2011 12:24
PHP FastCGI init script
#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000
PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
#PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
@padde
padde / svg_builder.rb
Created November 2, 2011 12:20
Make SVG with builder
# encoding: utf-8
require 'rubygems'
require 'builder'
svg_doctype = [
:DOCTYPE,
:svg,
:PUBLIC,
"-//W3C//DTD SVG 1.1//EN",
@padde
padde / .gitignore
Created November 3, 2011 11:00
Basic .gitignore
# generic
*~
*.lock
*.sw?
# OSX noise
.DS_Store
.localized
# WIN noise
@padde
padde / .gitignore
Created November 16, 2011 10:30
XCode Noise .gitignore
# xcode noise
build/*
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
*.mode1
*.mode2v3
*.mode1v3
xcuserdata
@padde
padde / git-svn.sh
Created November 16, 2011 11:19
Commit to SVN via Git
# in case there is no first commit
svn co $SVN_PATH
svn add .
svn commit
# now the git-svn part
git svn init $SVN_PATH
git svn fetch
# commit from git
@padde
padde / gist:1400077
Created November 28, 2011 11:32
Quick benchmarking in Ruby
def quick_benchmark(repetitions=100, &block)
require 'benchmark'
Benchmark.bmbm do |b|
b.report {repetitions.times &block}
end
nil
end
@padde
padde / gist:1400075
Created November 28, 2011 11:32
Show interesting methods of an object in Ruby
# please only interesting methods!
class Object
# return only the methods not present on basic objects
def interesting_methods
(self.methods - Object.new.methods).sort
end
end