Skip to content

Instantly share code, notes, and snippets.

View bloudermilk's full-sized avatar

Brendan Loudermilk bloudermilk

View GitHub Profile
@bloudermilk
bloudermilk / simple-git-flow.sh
Created March 20, 2013 23:48
A simple git workflow
#
# Starting
#
# Start a new feature branch
git checkout -b my_feature
# Make changes
# Add/Commit
require "csv"
require "net/http"
require "json"
require "pry"
class String
def super_strip
gsub(/(^\W+|\W+$)/, "")
end
end

Keybase proof

I hereby claim:

  • I am bloudermilk on github.
  • I am bloudermilk (https://keybase.io/bloudermilk) on keybase.
  • I have a public key whose fingerprint is B54D E33B 3320 0EA7 A7AA 6852 AB19 6B5D 5009 CE58

To claim this, I am signing this object:

@bloudermilk
bloudermilk / gravatar.rb
Created February 26, 2016 23:31
Test whether or not a user has Gravatar
require "net/http"
class GravatarGenerator
URL_FORMAT = "http://www.gravatar.com/avatar/%s"
LAST_MODIFIED_TEST_STRING = "Wed, 11 Jan 1984 08:00:00 GMT"
def self.test(email)
url = URI(URL_FORMAT % generate(email))
Net::HTTP.start(url.host, url.port) do |http|
@bloudermilk
bloudermilk / com.bloudermilk.reddit_image_downloader.plist
Created October 11, 2013 23:56
Automate reddit_image_downloader on OS X with launchctl/launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.bloudermilk.reddit_image_downloader</string>
<key>ProgramArguments</key>
<array>
<string>/Users/bloudermilk/.rbenv/versions/1.9.3-p327-perf/bin/ruby</string>
<string>/Users/bloudermilk/.rbenv/versions/1.9.3-p327-perf/bin/reddit_image_downloader</string>
@bloudermilk
bloudermilk / yo.md
Last active December 22, 2015 08:18
yo yo yo

Yo yo yo

yo yo yo

hey hey hey

server server server

local local local

@bloudermilk
bloudermilk / database_cleaner.rb
Created July 25, 2013 23:07
Example DatabaseCleaner config for fast tests
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
@bloudermilk
bloudermilk / bind_role.js
Created April 10, 2013 22:52
Backbone extension to bind roles to Views
// Automatically instantiates views based on the `role` attribute.
//
// Example:
// AA.Views.Workflow = Backbone.View.extend();
// AA.Views.Workflow.bindRole("workflow");
Backbone.View.bindRole = function (role) {
var view = this;
$(function () {
$("@" + role).each(function () {

N.B. Things that are starred with * are local variable

  • Ok, first generate a new rails app using this format:
    • rails new app_name
    • rails new amit_test_blog
  • Ok, next sketch out your models.
    • We're going to have two models for this blog: User and Post
    • One users can have many posts and many posts can belong to one users
    • Figure out the fields in each model.
    • Users will have these: field:type
@bloudermilk
bloudermilk / chronic_attribute.rb
Created February 7, 2013 02:34
Puts Chronic in front of date, time, and datetime attributes to allow for flexile input (anything supported by Chronic)
module ChronicAttribute
extend ActiveSupport::Concern
module ClassMethods
def chronic(*attrs)
attrs.each do |attr|
define_method "#{attr}=" do |value|
if value.is_a? String
with_utc do
self[attr] = Chronic.parse(value)