Skip to content

Instantly share code, notes, and snippets.

View bradherman's full-sized avatar

Bradley Herman bradherman

View GitHub Profile
#!/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'
@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
@bradherman
bradherman / gist:5314957
Created April 4, 2013 22:33
Array method that will pull out and return matching items from the array, leaving non-matching items in the original.
class Array
def pop_if!(&block)
a,b = self.partition(&block)
self.replace(b)
a
end
end
@bradherman
bradherman / gist:3991226
Created November 1, 2012 02:18
An Open Letter to Best Buy
As a kid, I couldn't remember anything better than getting to go to Best Buy. All the gadgets and games made it seem almost magical. I could play with the newest and greatest gaming consoles, watch the biggest and best tv's, and get a glimpse at the future of technological achievement. It was awesome. As I grew older, I continued to go to Best Buy for all of my electronic entertainment needs. Through high school and college, I'd show up on Tuesdays to purchase the newest dvd's and video games I'd been anticipating for weeks or months with what little money I had earned working through summers and weekends. I remember buying my first flat screen CRT TV at Best Buy and thinking it was amazing. I remember buying my first HDTV there years later. I waited outside of Best Buy for nearly a day in the rain for the new XBOX 360. I waited outside of another Best Buy for over a day in below freezing weather through snow and sleet for the Playstation 3. Just a few months ago, I purchased another XBOX 360 and a
@bradherman
bradherman / Gemfile
Created September 14, 2012 03:39
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
# Integrates with memegenerator.net
#
# Y U NO <text> - Generates the Y U NO GUY with the bottom caption
# of <text>
#
# I don't always <something> but when i do <text> - Generates The Most Interesting man in the World
#
# <text> ORLY? - Generates the ORLY? owl with the top caption of <text>
#
# <text> (SUCCESS|NAILED IT) - Generates success kid with the top caption of <text>
@bradherman
bradherman / css.css
Created June 28, 2012 20:31
Dynamic placeholders w/ html5
input {
font-family:Courier;
padding:8px;
font-size:16px;
width:50%;
}
input::-webkit-input-placeholder {
color: #ddd;
font-style:italic;
# typical route
get '/my_model' do
# return query results if search param, otherwise return all
if params[:relation_id]
MyModel.all(:relation_id => params[:relation_id], :order => :name.asc)
else
MyModel.all(:order => :name.asc)
# start off with the hash
timezones = {}
# then build the hash
(-12..12).to_a.each do |i|
timezones["utc"+i] = 0
end
@bradherman
bradherman / gist:1980931
Created March 5, 2012 20:36
Google docs stylesheet for use w/ stylish
#gbx3, #gbx4 {height:20px !important;}
#gb {font:10px/27px Arial,sans-serif !important;height:2px !important;}
.docs-title-inner {font-size:16px !important;}
.gbt {line-height:18px !important;}
.docs-menubar {height:28px !important;}
#docs-bars {height:4px !important;background:black !important;}
#docs-bars:hover {height:auto !important;background:none !important;}
#docs-menubar, #docs-toolbar-wrapper {display:none !important;}
#docs-bars:hover #docs-menubar, #docs-bars:hover #docs-toolbar-wrapper {display:block !important;}