Skip to content

Instantly share code, notes, and snippets.

Avatar
🙌
good times

Adam Bachman abachman

🙌
good times
View GitHub Profile
View models_and_the_models_they_love
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 Mar 10, 2009
Take a look at all the models in your project and find out how they're related.
View gist:77142
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 Mar 13, 2009
A bash script for listing directory trees (with color)
View gist:78702
#!/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 Mar 16, 2009
multi-env rake command for rails projects
View gist:79949
#!/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.
View gist:82386
# 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 Apr 16, 2009
Demonstration of a handful of the metaprogramming features of Ruby.
View metaclass-demo.rb
# 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,
View gist:111061
// ==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
Ajax-y link disabling in Rails.
View gist:119558
<!--
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'>
View gist:180371
#!/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
View gist:187630
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
You can’t perform that action at this time.