Skip to content

Instantly share code, notes, and snippets.

View blairanderson's full-sized avatar

Blair Anderson blairanderson

View GitHub Profile
@blairanderson
blairanderson / gist:5453560
Last active December 16, 2015 15:09
stubs with controller tests
context "using OpenStruct to stub" do
fake_article = OpenStruct.new(valid?:true)
Article.stub(:create).and_return(fake_article)
post :create
end
context "stubbing some shit" do
# after you test the before_filter, it can be stubbed for future tests
before do
controller.stub(:require_login).and_return(true)
@blairanderson
blairanderson / how-to-drink.markdown
Last active December 16, 2015 16:29
How to drink in ireland. From a post on reddit, the words are not mine.

The only thing I've noticed that visitors to Ireland of partying age get wrong, consistently, is the 'rounds' system in a Pub.

If you are in a pub and drinking with anyone, stranger, friend, classmate, workmate it doesn't matter and you are about to order a drink, it is extremely rude not to offer to buy your companions a drink too. This is not some trick, you'll notice immediately that people will offer to get you a drink when you are out with them. They are not being super nice and friendly to a visitor, they are doing it under the implicit agreement that you will buy the next drink for them.

If the group is too big it will generally break up into smaller rounds, generally appropriately sized to the amount of drinks the group is expecting to have that night. If there are 10 people out it will likely break up into approximately 2 to 3 rounds, based on who arrived when, and who has finished their drink faster. When you find yourself in a round, stick with it. Don't start buying drinks for someone in an

@blairanderson
blairanderson / guide_to_delivering.md
Last active December 16, 2015 17:29 — forked from parkerl/Lews_guide_to_delivering.md
How to Deliver Features

Opinionated Guide to Delivering Features


  1. First, understand the story.

Do you understand the story completely? If not, talk to the product owner to clarify your understanding.

Is the story a logically cohesive grouping of functionality? If not, can it be broken into multiple stories?

Do the points assigned make sense given your current level of understanding of the story? If not, can it be broken into multiple stories?

@blairanderson
blairanderson / delaything.js
Created May 1, 2013 05:08
my first jquery GIST. i'm really having fun with jquery this project. i hope to be saving more and more of these in the future found here: http://stackoverflow.com/a/11263756/1536309 proven here: http://jsfiddle.net/6RKHf/ i was hoping to show a list of options on a hover that lasts more than 4 seconds
var timeoutId;
$("#NewsStrip").hover(function() {
if (!timeoutId) {
timeoutId = window.setTimeout(function() {
timeoutId = null; // EDIT: added this line
$("#SeeAllEvents").slideDown('slow');
}, 2000);
}
},
function () {
@blairanderson
blairanderson / job_board.md
Created May 4, 2013 05:55
Jobs Board from RailsConf 2012

#Job Board from RailsConf 2013

-DailyKos

-Zencoder

-Linode

-NEO

-Braintree

-ThoughtWorks

-Crowdint

-FunnyOrDie!!!

class ETL
def self.transform(old)
result = {}
old.each do |key,value|
value.each do |new_key|
result[new_key.downcase] = key
end
end
return result
end
class Palindromes
def initialize(args)
@max = args[:max_factor]
@min = args[:min_factor] || 1
end
def generate
factors = (@min..@max).to_a
uniq_products = factors.map do |f|
@blairanderson
blairanderson / rails4controller.rb
Created May 26, 2013 19:44
this is what a new scaffolded controller looks like. muy interesante
class BurritosController < ApplicationController
before_action :set_burrito, only: [:show, :edit, :update, :destroy]
# GET /burritos
# GET /burritos.json
def index
@burritos = Burrito.all
end
# GET /burritos/1
@blairanderson
blairanderson / simulator.js
Created July 12, 2013 19:19
this is a 3d robot simulator
Plane2D = function() {
var directions = ["north", "east", "south", "west"];
this.rightOf = function(direction){
var currentIndex = directions.indexOf(direction);
return directions[(currentIndex+1 + directions.length) % directions.length]
}
this.leftOf = function(direction){
var currentIndex = directions.indexOf(direction);
return directions[(currentIndex-1 + directions.length) % directions.length]
# ...
gem 'carrierwave'
gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL