Skip to content

Instantly share code, notes, and snippets.

View bvandgrift's full-sized avatar

Ben Vandgrift bvandgrift

View GitHub Profile
# http://neovore.com / somethingfamiliar(at)gmail.com
# dirt simple twitter retweeter with twibot
require 'twibot'
#-- in ./config/bot.yml:
#login: your_user_name
#password: your_password
#include_friends: true
#-- EOF
if @foo.save && @bar.save
# if @foo fails, then @bar.save never gets called. BAD!
end
# instead:
if @foo.save & @bar.save
# both methods get called regardless
end
@bvandgrift
bvandgrift / delighter.rb
Created November 18, 2009 17:27
yank twitter links into delicious
#!/usr/bin/env ruby
# = Delighter - pull your twitter links into delicious.
#
# Takes the first link and submits it to delicious. The description
# will be the text up to the beginning of the link, the tags whatever
# hashtags are on the tweet. Let me know if you improve on this, it was
# pretty q&d.
#
# author: Ben Vandgrift <br/>
@bvandgrift
bvandgrift / add_view_paths.rb
Created November 30, 2010 16:20
prepending and appending to the view search paths in rails3
# throw something like this in an initializer
ActionController::Base.class_eval do
self.prepend_view_path "first/search/here"
# then the defaults (app/views/*)
self.append_view_path "then/search/here"
end
# an example, say you want a theme, and the name is stored in App.theme_name?
ActionController::Base.class_eval do
self.prepend_view_path "themes/#{App.theme_name}"
@bvandgrift
bvandgrift / biscuit_block_testing.rb
Created September 2, 2011 01:02
looking for a better test pattern for code passed in as blocks.
# any help with the following would be awesome (@bvandgrift)
# here's the problem code (ish)
# testing the stuff in the 'chunkify' block sucks
def make_breakfast
# ...
dough_for_biscuits = DoughBro.new
dough_for_biscuits.chunkify do |chunk|
if chunk.any?
the_good_stuff = roll_dem_biscuits(chunky)
@bvandgrift
bvandgrift / declarative_auth_role_seed.rb
Created July 3, 2012 15:29
seed roles for declarative_authorization based on config/authorization_rules.rb. store in lib/seeds/
Role.delete_all
role_names = Authorization::Engine.instance.roles
role_names.each { |name| Role.find_or_create_by_name!(name) }
@bvandgrift
bvandgrift / capybara cheat sheet
Created July 17, 2012 20:10 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@bvandgrift
bvandgrift / how-we-grow.rb
Created July 19, 2012 12:02
how we grow as people
expect {
touched.each { |life| experience << life unless life.empty? }
}.to change direction
@bvandgrift
bvandgrift / gist:3289868
Created August 7, 2012 22:08 — forked from dayanand-sourcebits/gist:1626596
ripple.yml for multiple node
# Configure Riak connections for the Ripple library.
development:
#http_port: 8092
# pb_port: 8087
nodes:
- host: 192.168.31.2
http_port: 8092
- host: 127.0.0.1
http_port: 8091
@bvandgrift
bvandgrift / xkcd-clickdrag.sh
Created September 20, 2012 13:09
lazy? i am. so here's xkcd #1110's images.
#!/bin/env bash
for x in `seq 1 20`; do
for y in `seq 1 20`; do
for n in n s; do
for e in e w; do
wget "http://imgs.xkcd.com/clickdrag/${x}${n}${y}${e}.png"
sleep 1
done
done