Skip to content

Instantly share code, notes, and snippets.

View natebird's full-sized avatar
🌐
Working online

Nate Bird natebird

🌐
Working online
View GitHub Profile
@natebird
natebird / advent-day-1.swift
Created December 17, 2015 21:03
AdventOfCode
//: Playground - noun: a place where people can play
import Foundation
func calculateFloor(input: String) -> Int {
let opening_parentheses_count = input.stringByReplacingOccurrencesOfString(")", withString: "").characters.count
let closing_parentheses_count = input.stringByReplacingOccurrencesOfString("(", withString: "").characters.count
let result = opening_parentheses_count - closing_parentheses_count
Verifying that +natesbird is my openname (Bitcoin username). https://onename.io/natesbird
@natebird
natebird / keybase.md
Created March 17, 2014 18:48
keybase identity proof

Keybase proof

I hereby claim:

  • I am natebird on github.
  • I am natebird (https://keybase.io/natebird) on keybase.
  • I have a public key whose fingerprint is 3134 7710 4658 445B 62AC D7CF 5A09 49BD 44FE 9C23

To claim this, I am signing this object:

ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require File.dirname(__FILE__) + '/blueprints'
require 'faker'
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
class MiniTest::Unit::TestCase
include MiniTest::ActiveRecordAssertions
@natebird
natebird / devise.rb
Last active December 19, 2015 21:39 — forked from wkrsz/devise.rb
#config/initializers/devise.rb
config.warden do |manager|
manager.strategies.add :token_header_authenticatable, TokenHeaderAuthenticatable
manager.default_strategies(:scope => :user).unshift :token_header_authenticatable
end
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@natebird
natebird / upgrade_to_refinery_two.rb
Created March 12, 2012 00:41 — forked from jadehopepunk/upgrade_to_refinery_two.rb
Migration to convert from refinery 1.0.8 to refinery 2.0
class UpgradeToRefineryTwo < ActiveRecord::Migration
def self.up
# For refinerycms-authentication
rename_table :roles_users, :refinery_roles_users
rename_table :roles, :refinery_roles
rename_table :user_plugins, :refinery_user_plugins
rename_table :users, :refinery_users
remove_column :refinery_users, :persistence_token
remove_column :refinery_users, :perishable_token
remove_column :refinery_users, :remember_token
@natebird
natebird / lockit.rb
Created March 2, 2011 19:28
authorization.rb
class Authorization
extend Lockdown::Access
#----------------------------------------------------------------------------
# Public
#----------------------------------------------------------------------------
# Access to all methods on the home controller
permission 'home'
@natebird
natebird / gist:738957
Created December 13, 2010 12:52 — forked from Arcath/gist:481321
def gravatar_url(email,options = {})
require 'digest/md5'
hash = Digest::MD5.hexdigest(email)
url = "http://www.gravatar.com/avatar/#{hash}"
options.each do |option|
option == options.first ? url+="?" : url+="&"
key = option[0].to_s
value = option[1].to_s
url+=key + "=" + value
end