Skip to content

Instantly share code, notes, and snippets.

Fredrik Bränström semikolon

Block or report user

Report or block semikolon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View harmony.rb
module Harmony
# Allows accessing config variables from harmony.yml like so:
# Harmony[:domain] => harmonyapp.com
def self.[](key)
unless @config
raw_config = File.read(RAILS_ROOT + "/config/harmony.yml")
@config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
end
@config[key]
end
View IPExternal.scpt
set theIP to do shell script "curl -sf http://checkip.dyndns.org/|cut -d ':' -f 2|cut -d '<' -f1|sed -e 's/ //g'"
tell application "LaunchBar"
display in large type theIP with title "External IP Address:"
end tell
return theIP
View database.yml
shared: &shared
# Use different adapters with JRuby vs. MRI
adapter: <%= defined?(JRuby) ? "jdbcmysql" : "mysql" %>
encoding: utf8
username: root
password:
host: localhost
socket: /opt/local/var/run/mysql5/mysqld.sock
<%
View install-passenger.sh
RE="ruby-enterprise-1.8.6-20081215"
PREFIX=/opt/$RE
VERSION=2.0.6
GEM_PATH="$PREFIX/lib/ruby/gems/1.8/gems/passenger-$VERSION"
DOMAIN=odpiralnicasi.com
APP_ROOT=/srv/oc
# install Apache2
apt-get install -qq apache2 apache2-prefork-dev
View gist:51649
# in config/routes.rb
map.connect '', :controller => 'domain_tests', :action => 'domain1', :conditions => {:hostname => "domain1"}
map.connect '', :controller => 'domain_tests', :action => 'domain2', :conditions => {:hostname => "domain2"}
# in config/environment.rb after the initialize section
module ActionController
module Routing
class RouteSet
def extract_request_environment(request)
{ :method => request.method, :hostname => request.domain.split('.').first }
View brew.pl
#!/usr/bin/env perl
#
# Copyright (c) 2009 Michelle Steigerwalt <msteigerwalt.com>
# All rights reserved.
#
# Upgraded to metric system by Fredrik Bränström <branstrom.name>
#
# Handy-dandy tea brewing timer. Uses Growl for messaging.
#
# Normal Mode:
View brew.pl
#!/usr/bin/env perl
#
# Copyright (c) 2009 Michelle Steigerwalt <msteigerwalt.com>
# All rights reserved.
#
# Handy-dandy tea brewing timer. Uses Growl for messaging.
#
# Normal Mode:
# > brew oolong
# Steeping for five minutes.
View project.rb
class Project < ActiveRecord::Base
def self.find(*args)
options = args.extract_options!
if not options.include? :order
options[:order] = 'finished_at desc'
end
args.push(options)
super
end
View gist:38159
fredrik@Benton ‣ svn co http://svn.ruby-lang.org/repos/ruby/tags/v1_8_6_111/ext/readline/ readline
A readline/depend
A readline/readline.c
A readline/README.ja
A readline/extconf.rb
A readline/.cvsignore
A readline/README
U readline
Checkade ut revision 20886.
fredrik@Benton ‣ readline ~/Code/RoR
View dump_fixtures.rake
namespace :spec do
namespace :db do
namespace :fixtures do
desc 'Create YAML spec fixtures from data in an existing database. Defaults to development database. Set RAILS_ENV to override. You can also set tables to dump with rake spec:db:fixtures:dump TABLES=posts,pages'
task :dump => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_info", "schema_migrations"]
ActiveRecord::Base.establish_connection(RAILS_ENV)
You can’t perform that action at this time.