Skip to content

Instantly share code, notes, and snippets.

View vanstee's full-sized avatar
💭
🛠

Patrick Van Stee vanstee

💭
🛠
View GitHub Profile
@vanstee
vanstee / routes.js
Last active December 20, 2015 04:29
// Works but is pretty verbose
App.Router.map(function() {
this.route("users.index", { path: "/users" });
this.route("users.new", { path: "/users/new" });
this.route("user.index", { path: "/users/:user_nickname" });
this.route("user.edit", { path: "/users/:user_nickname/edit" });
});
// Seems to be the best way to use the DSL but the `:user_nickname` param is incorrectly replaced
require 'formula'
class Phantomjs < Formula
homepage 'http://www.phantomjs.org/'
head 'https://github.com/ariya/phantomjs.git'
depends_on :macos => :snow_leopard
def install
system 'yes | ./build.sh'
defmodule Test do
def falsify_var(contents) do
IO.puts(inspect(contents))
case contents do
{ :^, _, [_] } ->
contents
{ var, meta, scope } when is_atom(var) and is_atom(scope) ->
{ var, meta, false }
{ left, meta, right } ->
@vanstee
vanstee / iife.ex
Last active December 18, 2015 19:29
fn ->
do_some_stuff_that_spans_multiple_lines
end.()
User.all.select("users.*, count(*) OVER()").limit(10).first.count
defmodule GenFsm.Behaviour do
defmacro __using__(_) do
quote location: :keep do
@behavior :gen_fsm
def init(args) do
{ :ok, args }
end
def handle_event(_event, state_name, state_data) do

Plan for Fixing Up Grocer

+---------+
| Pusher  |
+---------+
     |
     v
+---------+                                            +----------------+

| Queue |------------------------------------------->| ConnectionPool |

for file in $(find . -type f -name "*.rb"); do cat $file | git stripspace | sponge $file; done
class Item
def does_something
PublishingHouse.new(@document).publish
end
end
it 'publishes the document' do
publishing_house = stub('PublishingHouse')
publishing_house.should_receive(:publish).once
PublishingHouse.should_receive(:new).with(document) { publishing_house }
@vanstee
vanstee / authorized_keys_command.rb
Created February 23, 2013 08:30
Ruby script for AuthorizedKeysCommand that grabs public keys off github with the login
#!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
require 'pry'
class User
attr_accessor :login