Skip to content

Instantly share code, notes, and snippets.

View bradherman's full-sized avatar

Bradley Herman bradherman

View GitHub Profile
@bradherman
bradherman / num_problem.rb
Created April 12, 2011 14:21
wrote this real quick to solve a tough math problem for a girl at work... she got it right
a = c = (-50..50).to_a
b = d = (-50..-1).to_a + (1..50).to_a
for i in 0..100
for j in 0..99
for k in 0..100
for l in 0..99
e = Float(a[i])
f = Float(b[j])
g = Float(c[k])
<?xml version="1.0"?>
<ArrayOfItemImport>
<ItemImport>
<Skuid>037000061946</Skuid>
<BrandName>Head and Shoulders</BrandName>
<Manufacturer>Head and Shoulders</Manufacturer>
<ProductCode>anti-dandruff-shampoo</ProductCode>
<ProductName>classic clean shampoo</ProductName>
<ProductDescription>The original head &amp;amp; shoulders anti-dandruff shampoo . Mild enough to use every day, it will thoroughly cleanse your hair and care for your scalp. You&amp;rsquo;ll be left with up to 100% flake free hair* that feels soft and fresh, light and easy to manage. &lt;br /&gt;</ProductDescription>
<UniqueIdentifier>anti-dandruff-shampoo</UniqueIdentifier>
@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;}
# start off with the hash
timezones = {}
# then build the hash
(-12..12).to_a.each do |i|
timezones["utc"+i] = 0
end
# 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)
@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;
# 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 / 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
@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 / 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