Skip to content

Instantly share code, notes, and snippets.

View bradherman's full-sized avatar

Bradley Herman bradherman

View GitHub Profile
@bradherman
bradherman / gist:8052588
Created December 20, 2013 09:47
Shelfari API example
curl 'http://www.shelfari.com/ws/json/ShelfariService.ashx' --data-binary '{"id":0,"method":"getShelfBooks","params":{"0":2504331,"1":2504331,"2":2,"3":"","4":"dateadded","5":2,"6":40,"7":0,"8":160}}' --compressed
0 - id of lookup
1 - id of you
2 - type of search (0: all, 1: favorites, 2: plans to read, 3: wishlist, 4: read, 5: owns, 6: reading, 100: common)
3 - leave blank
4 - sort type (dateadded, rating, opinions, datepublished, author, title)
5 - page
6 - 40
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
# config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 60
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
Thanksgiving:
Spatchcocked turkey
http://www.seriouseats.com/2014/11/video-how-to-spatchcock-turkey-thanksgiving.html
Porcini gravy - http://www.seriouseats.com/recipes/2013/11/porcini-mushroom-turkey-gravy-thanksgiving-recipe.html
Brussel sprout gratin - http://www.seriouseats.com/2014/11/the-food-lab-creamy-cheesy-brussels-sprouts-gratin-side-dish-thanksgiving.html
Ranch potatoes - https://www.hiddenvalley.com/recipe/809/ranch-mashed-potatoes/
earFrank,
Iloveyoufromnowun
tildeathdouspart.Rightno
w,youlivingsofa rawayfro
mmeiskillingm e,butIk
nowinmyhearttha tweare
doingtherightthi ng.An
d,youaretry ingtog etthingsstr aight
sowecanlivetherefor everandspendali feti
metogether.Idon't wanttoloseyouforanyon
HAI
CAN HAS STDIO?
I HAS A NUMBEZ_ARAY
MAKE NUMBEZ_ARAY A BUKKIT
GIMMEH NUMBEZ_ARAY
I IZ MAX_SLISE NUMBEZ_ARAY MKAY
KTHXBYE
def rle(str)
current = {}
str.chars.each_with_object([]) do |char, arr|
if current.empty?
current = {"#{char}": 1}
elsif current.keys.first == char.to_sym
current[:"#{char}"] += 1
else
arr << current
current = {"#{char}": 1}
@bradherman
bradherman / blur.rb
Created August 10, 2016 05:04 — forked from christianroman/blur.rb
Blurring images in Rails with Paperclip custom processor
module Paperclip
class Blur < Processor
def initialize file, options = {}, attachment = nil
super
@format = File.extname(@file.path)
@basename = File.basename(@file.path, @format)
end