Skip to content

Instantly share code, notes, and snippets.

View abachman's full-sized avatar
🙌
good times

Adam Bachman abachman

🙌
good times
View GitHub Profile
require 'rubygems'
require 'railroad/models_diagram'
require 'railroad/options_struct'
options = OptionsStruct.new
options.parse = ['--verbose']
mod = ModelsDiagram.new options
mod.generate
mod.graph.nodes.each do |node|
@abachman
abachman / gist:77142
Created March 10, 2009 21:16
Take a look at all the models in your project and find out how they're related.
require 'rubygems'
require 'railroad/models_diagram'
require 'railroad/options_struct'
options = OptionsStruct.new
options.parse = ['--verbose']
mod = ModelsDiagram.new options
mod.generate
mod.graph.nodes.each do |node|
@abachman
abachman / gist:78702
Created March 13, 2009 18:55
A bash script for listing directory trees (with color)
#!/usr/bin/env bash
#
# This script produces a complete tree structure for the directory
# in which it is running.
#
# FROM
# http://www.sun.com/bigadmin/scripts/submittedScripts/lstree.sh.txt
#
# Modifications by Adam Bachman
#
@abachman
abachman / gist:79949
Created March 16, 2009 16:19
multi-env rake command for rails projects
#!/bin/bash
#
# For example, you're deep in prototyping mode, and want to keep your test
# and development environments in sync. Don't keep typing:
# rake RAILS_ENV=test db:migrate && rake RAILS_ENV=development db:migrate
# instead:
# rakes -dt db:migrate
#
# don't repeat yourself.
# drop in your ~/.bashrc file. guaranteed to "works on my machine".
#
# Go straight to the root of the current rails project.
# example:
# ~/workspace/proj/app/models $ rr
# going to /home/user/workspace/proj
# ~/workspace/proj $
#
# /etc/init.d/ $ rr
# /etc/init.d/ $
@abachman
abachman / metaclass-demo.rb
Created April 16, 2009 20:08
Demonstration of a handful of the metaprogramming features of Ruby.
# Demonstration of a handful of the metaprogramming features of Ruby.
#
# This code uses the same class/module configuration as Rails' standard
# acts_as plugins. I was looking for a way to extend the behavior of an
# ActiveRecord model in practice, and this came out of that exploration.
#
# Each "method" of extending the target class is tested and evaluated
# for functionality and a report is printed.
#
# Each method is tested as a class method and an instance method,
// ==UserScript==
// @name Kill Uservoice
// @namespace adam_bachman
// @description Kill Uservoice Tab
// @include *
// ==/UserScript==
(function () {
var uservoice_tab = document.getElementById("uservoice-feedback-tab");
if (uservoice_tab) {
@abachman
abachman / gist:119558
Created May 28, 2009 20:43
Ajax-y link disabling in Rails.
<!--
Imitate <%= submit_tag 'Perform an Action', :disable_with => "" %> button
using Rails' remote_function options.
Requires prototype.js, but could easily be written with any other js framework.
Not production tested.
-->
<span id='my_link'>
#!/bin/bash
# Copy svn:ignore files between directories. Handy when checking out and working
# on branches. This script is specific to my needs, but could be easily
# generalized.
# - Adam Bachman, Sept 2009
usage() {
printf "Copies svn:ignore'd rails configurations from one project to another.\n\n" >&2
printf "Usage: %s /from/dir /to/dir \n\n" $(basename $0) >&2
127.0.0.1 localhost
127.0.1.1 adam-desktop
### @NOPROCRAST ###
127.0.0.1 news.ycombinator.com
127.0.0.1 youtube.com www.youtube.com
127.0.0.1 techmeme.com www.techmeme.com
127.0.0.1 techcrunch.com www.techcrunch.com
127.0.0.1 reddit.com www.reddit.com
127.0.0.1 hacker-newspaper.gilesb.com