Skip to content

Instantly share code, notes, and snippets.

View weedySeaDragon's full-sized avatar
🏠
Working from home

Ashley Engelund weedySeaDragon

🏠
Working from home
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')
@jamster
jamster / git_commit_parser.rb
Created March 22, 2011 17:32
quick script to parse git logs and turn them to a data structure
# Usage:
# git log | ruby git_commit_parser.rb
# https://gist.github.com/881641
# By: Jason Amster
# [email protected]
require 'rubygems'
require 'pp'
logs = STDIN.read
logs = logs.split("commit ")
@bowsersenior
bowsersenior / stooge_loader.rb
Created May 18, 2011 23:18
A demo of YAML anchors, references and nested values
require 'rubygems'
require 'yaml'
# A demonstration of YAML anchors, references and handling of nested values
# For more info, see:
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/
stooges = YAML::load( File.read('stooges.yml') )
# => {
# "default" => {
@ianmurrays
ianmurrays / deploy.rb
Created July 21, 2011 17:26
Runs test locally before deploying on capistrano.
set :test_log, "logs/capistrano.test.log"
namespace :deploy do
before 'deploy:update_code' do
puts "--> Running tests, please wait ..."
unless system "bundle exec rake > #{test_log} 2>&1" #' > /dev/null'
puts "--> Tests failed. Run `cat #{test_log}` to see what went wrong."
exit
else
puts "--> Tests passed"
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@chetan
chetan / yardoc_cheatsheet.md
Last active November 11, 2024 08:27
YARD cheatsheet
@jrochkind
jrochkind / gist:2161449
Created March 22, 2012 18:40
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

Startup
=======
run pig locally:
$ magicpig -x local script.pig # doesn't work
expand pig macros:
$ magicpig -dryrun script.pig
Commands
========
@loicdescotte
loicdescotte / Forcomptran.md
Last active May 27, 2023 06:27
Scala for comprehension translation helper

Scala for comprehension translation helper

"For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.

yield keyword is used to aggregate values in the resulting structure.

This composition can be used on any type implementing this methods, like List, Option, Future...

@bergonom
bergonom / truncate_table.rb
Created March 15, 2013 22:43
Truncate a single table across multiple db types. I made this a private method in my application controller (app/controllers/application_controller.rb). Adapted from: https://gist.github.com/tvdeyen/3246525
def truncate_table table_name
config = Rails.configuration.database_configuration
connection = ActiveRecord::Base.connection
connection.disable_referential_integrity do
next if connection.select_value("SELECT count(*) FROM #{table_name}") == 0
case config[Rails.env]["adapter"]
when "mysql", "mysql2", "postgresql"
connection.execute("TRUNCATE #{table_name}")
when "sqlite", "sqlite3"
connection.execute("DELETE FROM #{table_name}")