Skip to content

Instantly share code, notes, and snippets.

View tjhanley's full-sized avatar
🏒

Thomas Hanley tjhanley

🏒
View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
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')
@JoshCheek
JoshCheek / gist:443394
Created June 18, 2010 08:14
YUI RTE Image Upload For Rails
# A Rails back end for yui rich text editor's image uploader
# http://allmybrain.com/2009/07/01/example-image-upload-with-yui-rich-text-editor-270/
# In this example, I created a model to store the images, with paperclip, on Amazon s3
# If you aren't familiar with Paperclip, I think there is a Railscast about it
# ===== THE MIGRATION =====
class CreateUploadedImages < ActiveRecord::Migration
def self.up
create_table :uploaded_images do |t|
@yuya-takeyama
yuya-takeyama / binarytree.rb
Created February 5, 2011 14:32
Binary Tree implemented in Ruby.
module BinaryTree
class Node
attr_reader :word, :count, :left, :right
include Enumerable
def initialize(word)
@word, @count = word, 1
end
@jasoncodes
jasoncodes / gist:1223731
Created September 17, 2011 07:45
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
@mrsweaters
mrsweaters / setup.sh
Created February 5, 2012 04:18 — forked from erotte/server_setup.md
Vagrant Box Setup Ruby 1.9.3/Nginx/Passenger/MySQL
#!/usr/bin/env bash
# login as root and run this script via bash & curl:
apt-get update
apt-get install -y build-essential bison openssl libreadline5 libreadline5-dev curl \
git-core zlib1g zlib1g-dev libopenssl-ruby libcurl4-openssl-dev libssl-dev \
libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev \
mysql-client mysql-server
@finack
finack / application.rb
Created March 17, 2012 06:18
Example Chef Deploy Revision for Rails 3+
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]
@mmalawski
mmalawski / 10.8 Rails Development Environment
Created October 7, 2012 14:20
Mac OSX Mountain Lion guide to installing Ruby,Rails,MySQL,Mon
# Mac OSX Mountain Lion
# Ruby on Rails Development Environment
# RVM
curl -L https://get.rvm.io | bash -s stable && rvm install 1.9.3 && rvm install 1.8.7
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source ~/.bash_profile
# Disable rarely used RDOC
@tjhanley
tjhanley / add_1_to_n.rb
Last active March 1, 2016 16:06
Simple Problems
def add_1_to_n(n)
return n <= 0 ? 0 : n + add_1_to_n( n - 1 )
end
puts add_1_to_n(10) #=> 55
@leemark
leemark / full-viewport-animated-background.html
Last active March 29, 2023 22:00
Full-screen animated gif background
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>horse</title>
<link href='http://fonts.googleapis.com/css?family=Spirax' rel='stylesheet' type='text/css'>
</head>
<body>
<h1>Sallie Gardner at a Gallop</h1>
</body>
@cmattson
cmattson / stupid_devise_tricks.md
Last active August 2, 2021 21:15
Stupid Devise Tricks

Stupid Devise Tricks

Devise can be a daunting beast even if you've used it frequently. For new users, it can be especially baffling as the documentation often assumes a familiarity with its inner workings. To help bridge the gap, here are some frequent scenarios and possible solutions.

###Oh my God, it's complaining about unknown methods! What?!

This most commonly occurs because you have enabled features in your Devise model (e.g. user.rb) but didn't create the associated fields with a migration.

Devise's tendrils are manifold; each feature has an associated symbol in your model's devise block, field(s) in your database, and configuration options in your Devise initializer.