Skip to content

Instantly share code, notes, and snippets.

View matthutchinson's full-sized avatar
🧐
`¯\_(ツ)_/¯`

Matthew Hutchinson matthutchinson

🧐
`¯\_(ツ)_/¯`
View GitHub Profile
@matthutchinson
matthutchinson / shell_helpers.rb
Created August 31, 2014 19:50
Babushka shell command patched to work with rbenv and .ruby-version
# rbenv shell helper patch
module Babushka
module ShellHelpers
# Run +cmd+ via #shell, raising an exception if it doesn't exit
# with success.
def shell! *cmd, &block
opts = cmd.extract_options!
cmd = cmd.first if cmd.map(&:class) == [Array]
@matthutchinson
matthutchinson / poolsider
Created February 5, 2015 20:32
Grab all http://poolside.fm tracks from SoundCloud with this one weird trick!
#!/bin/sh -x
# no python3 (pip3) or curl? use this
# brew install python3 curl
# https://github.com/flyingrub/scdl
# pip3 install scdl
curl -s http://poolsideapi2.herokuapp.com/tracks?p=2 | grep -o '"scUrl": ".*",$' | sed -E 's/("scUrl": "|",.*$)//g' | xargs -I 'url' scdl -l url --hidewarnings
@matthutchinson
matthutchinson / thx.sh
Last active August 29, 2015 14:15
THX startup sound :)
# brew install sox
echo '(play -q -n synth sine F2 sine C3 remix - fade 0 4 .1 norm -4 bend 0.5,2399,2 fade 0 4.0 0.5 &)' >> ~/.bash_profile
# via https://twitter.com/climagic/status/467322823631831040
#!/usr/bin/env ruby
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
self.rank = rank
self.suit = suit
end
@matthutchinson
matthutchinson / github-key.rb
Last active February 17, 2016 17:02
Send your SSH key to GitHub, with optional OTP auth
# install gems with;
# gem install io-console github_api --no-ri --no-rdoc
require 'github_api'
require 'io/console'
# Bypass annoying deprecation warning between the
# github_api gem and the faraday gem
Faraday::Builder = Faraday::RackBuilder
119006,15849,364397,"",""
287931,25665,1615619,"",""
249087,36798,1421176,"",""
131271,48647,1489200,"",""
207525,53651,1489200,"",""
207556,53812,1489200,"",""
207424,54991,1489200,"",""
243232,55069,1489200,"",""
182615,56985,1489200,"",""
92903,0,20326,"",""
@matthutchinson
matthutchinson / archive
Last active July 27, 2016 13:57
clone github repos and zip them
#!/bin/bash
filecontent=( `cat "repo_list" `)
for repo in "${filecontent[@]}"
do
echo $repo " - cloning ..."
git clone -q [email protected]:$repo
done
class HomeSerializer < ApplicationSerializer
def _links
{
order_volume_forecasts: { href: order_volume_forecasts_url }
slots: { href: slots_url },
micro_contracts: { href: micro_contracts_url }
}
end
end
#!/usr/bin/env ruby
class LinkedListNode
attr_accessor :value, :next_node
def initialize(value, next_node = nil)
@value = value
@next_node = next_node
end
end
@matthutchinson
matthutchinson / fzf_migrations
Last active June 12, 2018 08:33
Run rails migration commands via aliases with auto-completion for version numbers (via fzf)
#!/bin/bash
# TDLR; run rails migration commands via aliases with auto-completion for version numbers (via fzf)
#
# brew install fzf
# curl https://gist.githubusercontent.com/matthutchinson/6c1bc7681b323d4d2ef5d5a55626a5cf/raw/fzf_migrations > ~/.fzf_migrations
# source ~/.fzf_migrations
#
# Then run these commands to migrate:
#