Skip to content

Instantly share code, notes, and snippets.

View danielres's full-sized avatar

Daniel Reszka danielres

View GitHub Profile
@kamali
kamali / gist:550231
Created August 25, 2010 20:30 — forked from mislav/gist:17371
## based on the example at:
## http://gist.github.com/17371
##
## put me in lib/un_haml.rb (in the haml-based project)
##
## call me on the command line thus:
## $ script/runner UnHaml app/views/layouts/application.html.haml
## $ script/runner UnHaml */*/*/*.haml
##
class UnHaml < Haml::Engine
module Core
def self.included(mod)
url = ENV['CORE_URL'] ? URI.parse(ENV['CORE_URL']) : URI.parse('postgres://postgres@localhost/heroku')
mod.establish_connection(
:adapter => "postgresql",
:host => url.host,
:username => url.userinfo.split(':')[0],
:password => url.userinfo.split(':')[1],
:database => url.path[1..-1]
)
@danielres
danielres / ubuntu_server_config.sh
Created January 9, 2011 00:04
steps used to install a rails environment for development on my Ubuntu 10.10 server box
# based on:
# http://www.hackido.com/2010/12/install-ruby-on-rails-on-ubuntu.html
# http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/
# http://ascarter.net/2011/01/02/rails-development-on-ubuntu-10.10.html
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install build-essential
sudo apt-get install git-core
@danielres
danielres / DRY database.yml
Created January 9, 2011 23:32
random personal notes and reminders related to my funny adventures with Rails
# inheritance in yml files:
development: &defaults
adapter: mysql
encoding: utf8
database: acme_development
username: root
test:
<<: *defaults
@danielres
danielres / notes.sh
Created March 11, 2011 13:53
random personal notes and reminders related to my funny adventures with Heroku
# $APP=$1
# S3_KEY=$2
# S3_SECRET=$3
# S3_BUCKET=$4
# GEMS=$5
gem install heroku --no-rdoc --no-ri
refinerycms $APP --heroku -g aws-s3,refinerycms-inquiries
# ,$5
cd $APP
@danielres
danielres / .bashrc_personal_base
Created March 11, 2011 19:39
bashrc personal settings
#!/bin/bash
## BASE #########
#BASH
alias ..="cd .."
alias j="jobs"
#GIT
alias gs="git status"
function ga { git add $* && gs; }
@ryanmarshall
ryanmarshall / gist:989900
Created May 24, 2011 22:29
Quick Ruby Signed Request Parser for Facebook
module Facebook
#
# Facebook request tools
#
class Request
class << self
def parse_signed_request(signed_request, secret, max_age=3600)
encoded_sig, encoded_envelope = signed_request.split('.', 2)
envelope = JSON.parse(base64_url_decode(encoded_envelope))
algorithm = envelope['algorithm']
@oriolgual
oriolgual / missing_translations.rb
Created July 6, 2011 11:01
No more missing translations in Rails thanks to Cucumber!
# features/support/missing_translations.rb
missing_translations = []
After do |scenario|
temp = all('.translation_missing')
if temp.any?
missing_translations << temp.to_a
raise "Missing Translation"
end
@st33n
st33n / account_example_without_context.rb
Created October 26, 2011 06:46
DCI example in Ruby, without ContextAccessor
#!/usr/bin/env ruby
# Lean Architecture example in Ruby - without ContextAccessor
# In this example, the context passes the needed roles into each method it
# invokes, and so the roles have no reference back to the context.
# Model class with no external dependenices. Includes a simple find method
# to create and store instances given an id - for illustration purposes only.
class Account
attr_reader :account_id, :balance
@mattbrictson
mattbrictson / .bashrc
Last active October 26, 2015 07:28
"r" shortcut in bash for "rails" and "rake"
# Shortcut for `bundle exec rails` and `bundle exec rake`.
# If bin/rails and bin/rake are available, use them instead as they are much
# faster to execute than `bundle exec`.
function r() {
if [[ "g|generate|c|console|s|server|db|dbconsole|r|runner|new" =~ $1 ]]; then
if [ -x bin/rails ]; then
bin/rails "$@"
elif [ -x script/rails ]; then
script/rails "$@"
else