Skip to content

Instantly share code, notes, and snippets.

View rguggemos's full-sized avatar

Russen Guggemos rguggemos

View GitHub Profile
@rguggemos
rguggemos / create_fake_test_DB
Created February 1, 2012 18:43
create a fake test database, that can test user creation
1. edit your database.yml, like so:
test:
adapter: postgresql
database: test4
host: dev.berkleemusic.com (or 'localhost', if you're in the VM)
username: rails
2. RAILS_ENV=test bundle exec rake db:setup
@rguggemos
rguggemos / .bashrc
Created January 31, 2012 20:04
bashrc for coloring?
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
@rguggemos
rguggemos / .bash_profile
Created January 31, 2012 20:02
bash_profile for OSX
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
@rguggemos
rguggemos / monitrc
Created July 1, 2011 17:13
redis and resque example
#RESQUE
#the resque_queue_start.sh contains this script:
# cd /web/bmn/; nohup bundle exec rake environment resque:work RAILS_ENV=staging QUEUE=* VERBOSE=1 PIDFILE=/web/bmn/log/resque_queue.pid 2>&1
check process resque_queue with pidfile /var/run/resque_queue.pid
start program = "/bin/su - root -c '/etc/redis/resque_queue_start.sh'"
stop program = "/bin/sh -c 'cd /web/bmn-dev/ && kill -s QUIT `cat /var/run/resque_queue.pid` && rm -f /var/run/resque_queue.pid; exit 0;'"
depends on redis
class SoundcloudAccount < ActiveRecord::Base
belongs_to :user
validates_presence_of :user, :on => :create, :message => "can't be blank"
validates_uniqueness_of :sc_user_id, :message => "must be unique"
def get_tracks
if self.sc_user_id.present?
client = self.get_client
@rguggemos
rguggemos / Kaminari ajax pager
Created March 18, 2011 17:33
Kaminari ajax pager
If you switch to kaminari,
http://railscasts.com/episodes/254-pagination-with-kaminari
...the lines added to application.js become redundant when you implement the pager like in this demo project:
https://github.com/amatsuda/kaminari_example/tree/ajax
in index.html: