Skip to content

Instantly share code, notes, and snippets.

View unders's full-sized avatar

Anders Törnqvist unders

  • Functionbox
  • Göteborg, Sweden
View GitHub Profile
@unders
unders / ruby-self-and-default-definee.rb
Created September 14, 2011 07:21
self is the self which you know. It is the default receiver of method invocation. There is always a self.
class Object
def singleton_class
class << self
self
end
end
end
# X.singleton_class
# - > X
@unders
unders / tmux.conf
Created December 11, 2010 11:53 — forked from bryanl/tmux.conf
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
@unders
unders / Presenter.rb
Created November 26, 2010 15:05
Presenter that works with Rails
#app/presenters/article_presenter
module ArticlePresenter
def fancy_name
end
end
#app/presenters/comment_presenter
module CommentPresenter
def fancy_name
end
@unders
unders / god.rb
Created October 18, 2010 14:53 — forked from defunkt/god.rb
rails_root = "/data/github/current"
20.times do |num|
God.watch do |w|
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "rake -f #{rails_root}/Rakefile production jobs:work"
w.uid = 'git'
@unders
unders / default.rb
Created October 18, 2010 14:49 — forked from ezmobius/default.rb
#
# Cookbook Name:: delayed_job
# Recipe:: default
#
if ['solo', 'app', 'app_master'].include?(node[:instance_role])
# be sure to replace "app_name" with the name of your application.
run_for_app("maloca") do |app_name, data|
development: &development
adapter: mysql
database: tinet_dev
username: root
host: 127.0.0.1
encoding: utf8
test: &test
<<: *development
database: tinet_test_<%= ENV['TEST_ENV_NUMBER'] %>
module DateTimeHelper
def format_date_range(date_range)
first = date_range.first
last = date_range.last
if same_day?(first, last)
"#{first.to_s(:month_day)}, #{first.year}"
elsif same_month?(first, last)
"#{first.to_s(:month_day)}-#{last.day}, #{last.year}"
else
"#{first.to_s(:month_day)}-#{last.to_s(:month_day)}, #{last.year}"
You are here:
<%= trail.to_html(response) %>
#!/bin/bash
# Unattended REE/Passenger installation
# Source: http://weblog.brightlight-ict.nl/2008/12/unattended-passenger-ruby-enterprise-installation-on-ubuntu-8/
# 15/03/09 Updated to use latest r.e.e. and passenger 2.1 and rewrote bits thanks to the comments left on my blog. Thanks guys
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to run this!"
exit 2
fi
@unders
unders / gist:77196
Created March 10, 2009 23:06 — forked from chad/gist:76951
# How to find out where a method comes from.
# Learned this from Dave Thomas while teaching Advanced Ruby Studio
# Makes the case for separating method definitions into
# modules, especially when enhancing built-in classes.
module Perpetrator
def crime
end
end
class Fixnum