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 / 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
@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 / 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
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 / 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
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
@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
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 / ruby-memoization-operator
Created January 6, 2016 18:42
Implementing the Ruby memoization operator ||= in Swift
//: Implementing Ruby's memoization operator in Swift
// From: https://airspeedvelocity.net/2014/06/10/implementing-rubys-operator-in-swift/
// define operator properties
infix operator ||= {
associativity right
precedence 90
assignment
}
@natebird
natebird / gist:4287c2790f766c502318
Created February 23, 2016 16:55
Terrible Comcast customer service
Nate: My Issue: I can’t login / create new login account for new account number
Ramjot: I am here to assist you.
Ramjot: I can definitely help you with the login information.
Ramjot: It’s really difficult to remember passwords, we tend to forget. I am here to help you with your password reset.
Ramjot: For the account security, may I ask you a few questions?