Skip to content

Instantly share code, notes, and snippets.

Idea from @sferik's talk at Baruco 2014

Implicit blocks with yield are faster than explicit blocks with #call.

require 'benchmark/ips'

def explicit(&block)
  block.call
end
@jordelver
jordelver / gist:71ef7394383ab36e4b7e
Last active April 8, 2018 02:01
RestfulGit examples

RestfulGit examples

Things we need to get from the API

(Install jq for these examples http://stedolan.github.io/jq/)

Single commits

curl 'http://0.0.0.0:5000/repos/restfulgit/commits/8990ae2cd9bfa2d94f4fd37ae8026c71bfe7d8ef/' | jq '.'
@jordelver
jordelver / gist:6b436fb90f42d17bf7ce
Last active April 8, 2018 02:01
How to install RestfulGit locally

How to install RestfulGit locally

This works on my Mac, YMMV :-/

Install

Clone the repo

git clone git@github.com:hulu/restfulgit.git

What to put in ActiveRecord classes

Validations and relationships

Normal validations

  • Favour putting these into a Form Object once it becomes anything but the simplest example

Regular relationships (has_many, belongs_to etc)

Mutation

#!/bin/sh
for dotfile in *; do
source="$PWD/$dotfile"
target="$HOME/.$dotfile"
if [[ "$dotfile" != "README" && "$dotfile" != "install.sh" ]]; then
ln -s "$source" "$target"
fi
done
@jordelver
jordelver / gist:8863630
Created February 7, 2014 14:33
Middleman - Disable directory indexes for individual page

Middleman - Disable directory indexes for individual page

Add directory_index: false to the frontmatter of your page

--
directory_index: false
--
namespace :assets do
task :precompile do
sh 'middleman build'
end
end
@jordelver
jordelver / Gemfile
Created January 21, 2014 09:21
Middleman config
# If you have OpenSSL installed, we recommend updating
# the following line to use "https"
source 'https://rubygems.org'
ruby "2.1.0"
gem "middleman", "~> 3.1.0"
gem "middleman-blog"
gem "middleman-livereload"
gem "middleman-syntax"
@jordelver
jordelver / gist:8402408
Last active January 3, 2016 03:29
Learning Go
@jordelver
jordelver / gist:8355554
Last active January 2, 2016 20:19
Git - Fix master if something goes wrong