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
@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
class Notable < ActiveRecord::Base
self.abstract_class = true
has_many :notes, :as => :notable
accepts_nested_attributes_for :notes
end
class User < Notable
end
# how bad of form is this?
# Using the scale given at:
# http://docs.google.com/drawings/pub?id=1yAsORHdSy8MZo3Wc9RdtL-yJ_z8YpqRKe1_A1TXkkCA&w=960&h=720
# and in light of ruby best practices.
class Document
attr_accessor :foo, :bar
def initialize
if block_given?
module Paperclip
class Geometry
def self.from_file file
parse("100x100")
end
end
class Thumbnail
def make
src = Test::FileHelper.fixture_file('white_pixel.jpg')
dst = Tempfile.new([@basename, @format].compact.join("."))
@abachman
abachman / auto confirm js popups in cucumber.feature
Created June 2, 2010 21:06
Accomodating rails' default javascript-driven "delete" link behavior in Cucumber.
# web_steps.rb
When /^I am going to confirm all js popups on this page$/ do
# hackish, but not unreasonable.
page.evaluate_script("window.alert = function(msg) { return true; }")
page.evaluate_script("window.confirm = function(msg) { return true; }")
end
# some_feature.feature
# note that "I am going to confirm..." has to be called after arriving on
# a page and before pressing links that use confirm (delete, in most cases)
# Bohconf
class Bohconf < Processing::App
def setup
background 0
frame_rate 30
no_stroke
@xy = []
400.times {
The Tabular plugin: http://github.com/godlygeek/tabular
" nice indentation for Cucumber scripts (if you're not already nesting)
:'<,'>Tabularize /^.*\(Given\|And\|When\|Then\) /l0
So that:
Scenario: Admin user should be able to access categories index from form library page
Given I am an admin user with the login "administrator" and the password "administrator"
And there is a active study
class ToHaml
def initialize(path)
@path = path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
puts "converting #{file}"
# run html2haml on the input file in erb mode with strict parsing
# on the input (xhtml mode)