This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base; end; | |
class Post < ActiveRecord::Base; end; | |
class Comment < ActiveRecord::Base; end; | |
class AuthorSerializer < ActiveModel::Serializer | |
attributes :id, :name :created_at, :updated_at | |
end | |
class PostSerializer < ActiveModel::Serializer | |
attributes :id, :body :created_at, :updated_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
main() { | |
if [ ! -p .test-commands ]; then | |
mkfifo .test-commands | |
fi | |
while true; do | |
cmd=$(cat .test-commands) | |
if [[ $cmd == "" ]]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/hash.c w/hash.c | |
index 007508a..6f39e47 100644 | |
--- i/hash.c | |
+++ w/hash.c | |
@@ -2402,6 +2402,28 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash) | |
return ary; | |
} | |
+static int | |
+hash_comprised_i(VALUE key, VALUE value, VALUE arg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/hash.c w/hash.c | |
index 007508a..6f39e47 100644 | |
--- i/hash.c | |
+++ w/hash.c | |
@@ -2402,6 +2402,28 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash) | |
return ary; | |
} | |
+static int | |
+hash_contain_i(VALUE key, VALUE value, VALUE arg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'redcarpet' | |
desc "generate index.html from README.md" | |
file "index.html" => "README.md" do |task| | |
puts "Processing README.md to generate a new index.html..." | |
# `r` means we're using the "read" mode with the file | |
# we need a String for Redcarpet, it doesn't accept File objects. | |
string = File.open(task.prerequisites.first, 'r') { |file| file.read } | |
markdown = ::Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions = {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# here's a quick recipe to run a performance test | |
# with this method, you can: | |
#-> easily choose the examples you want included from your existing specs | |
#-> define the target number of total iterations you'd like, no limit | |
#-> tune the transaction mix by specifying frequency metadata for each example | |
#-> be happy that the transaction mix is fairly homogeneous over the test interval | |
# (ideally you'd run this with acceptance (webrat/capybara) specs, but you | |
# could employ this technique for any rspec test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ======================================================================================= # | |
# NOTE: This is relatively outdated, you should use the DetectSyntax package | |
# from Package Control instead: http://wbond.net/sublime_packages/community#sort-installs | |
# ======================================================================================= # | |
# Instructions: put this inside of the following folder on a Mac: | |
# /Users/<yourusername>/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/ | |
# ======================================================================================= # | |
import sublime, sublime_plugin | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rack/contrib/try_static" | |
use Rack::TryStatic, :root => "build", :urls => %w[/], :try => ['index.html', '/index.html'] | |
require "rack/contrib/static_cache" | |
use Rack::StaticCache, :urls => ['/'], :root => 'build' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OS X Mountain Lion clean install Rails development environment setup using MySQL, imagemagick, homebrew and rvm. Rough steps, your mileage or your needs may vary: | |
- Install XCode from the App Store. | |
- Launch XCode > Preferences > Downloads > Install the Command Line Tools | |
- Install XQuartz version 2.7.2 http://xquartz.macosforge.org/trac/wiki/X112.7.2 | |
- Install git, I used git-osx-installer version 1.7.11.3 http://code.google.com/p/git-osx-installer/downloads/list | |
- Install Ruby 1.9.3 with rvm, run this command on a terminal and follow the instructions: curl -L https://get.rvm.io | bash -s stable --ruby | |
- Install MySQL using the DMG installer, I used version 5.1.63 found here http://dev.mysql.com/downloads/mysql/5.1.html I use this to get the files needed for the mysql2 gem to install, I don't install the prefpane or the init script since I use MAMP as my MySQL server on my Mac. | |
- Install homebrew: https://github.com/mxcl/homebrew/wiki/installation | |
- Install ghostscript, from a terminal: brew install ghosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given a controller in need of refactoring into multiple controllers, how | |
# can I redirect to new controller actions based upon a feature flag? | |
# | |
# The current code "works" but doesn't exercise the controller action. | |
# | |
# Rails 2.3 or 3.0 methods accepted | |
class BetterController | |
def overview | |
# .. a small amount of auth/permissions code |
OlderNewer