Skip to content

Instantly share code, notes, and snippets.

View faun's full-sized avatar
🌵

Faun faun

🌵
View GitHub Profile
class TripsController < ApplicationController
class Action < ApplicationController::Action
end
class New < Action
expose(:trip) { Trip.new(params[:trip]) }
end
class Create < New
def call
FactoryGirl.find_definitions
@faun
faun / spec_helper.rb
Last active December 11, 2015 19:48
spec/spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
#...
@faun
faun / application.rb
Last active December 11, 2015 19:48
config/application.rb
module MyApp
class Application < Rails::Application
#...
config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
@faun
faun / Gemfile
Last active December 11, 2015 19:48
Gemfile
source 'https://rubygems.org'
gem 'rails', '~> 3.2.11'
#...
group :test, :development do
gem "rspec-rails", "~> 2.0"
gem 'capybara', "~> 2.0.2"
gem "factory_girl_rails", "~> 4.0"
require 'nokogiri'
RSpec::Matchers.define :have_xml do |xpath, text|
match do |body|
doc = Nokogiri::XML::Document.parse(body)
nodes = doc.xpath(xpath)
nodes.empty?.should be_false
if text
nodes.each do |node|
node.content.should == text
end
@faun
faun / glacier_restore.rb
Created November 17, 2012 01:53
Restore files from Amazon Glacier in blulk
#!/usr/bin/env ruby
require 'base64'
require 'openssl'
require 'digest/sha1'
require 'net/http'
require "uri"
require 'time'
DEBUG = false
@faun
faun / pre-commit
Last active October 22, 2022 14:54
Pre-commit hook to prevent committing invalid ruby files or binding.pry Runs cane on *.ruby files, jshint on *.js files and coffeelint on *.coffee files # place this file in ./script/pre-commit # and install with: # chmod +x ./script/pre-commit # ln -s ../../script/pre-commit .git/hooks/pre-commit
#!/bin/bash
## START PRECOMMIT HOOK
files_modified=`git status --porcelain | egrep "^(A |M |R ).*" | awk ' { if ($3 == "->") print $4; else print $2 } '`
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
## use ruby defined in project
source .rvmrc
for f in $files_modified; do
@faun
faun / ios-media-queries.sass
Created November 28, 2011 21:33 — forked from adamstac/ios-media-queries.sass
iOS Media Queries for iPhone/iPod, iPad & Retina and Non-Retina Devices
.ipad-only,
.iphone-only,
.retina-only,
.non-retina-only,
.retina-iphone-only,
.non-retina-iphone-only
display: none
// iPad Only
@media only screen and (device-width: 768px)
@faun
faun / build.sh
Created September 6, 2011 21:55 — forked from kossnocorp/USAGE.md
Install latest MacVim with Drawer
git clone -b split-browser https://github.com/alloy/macvim.git && cd macvim && ./configure --with-features=huge --enable-cscope --enable-rubyinterp --enable-pythoninterp --enable-perlinterp && make && sudo rm -rf /Applications/MacVim.app && sudo mv ./src/MacVim/build/Release/MacVim.app /Applications