Skip to content

Instantly share code, notes, and snippets.

View shicholas's full-sized avatar
🏁
small victories add up

nick shicholas

🏁
small victories add up
  • Earth
View GitHub Profile
@shicholas
shicholas / circle.yml
Last active December 17, 2015 14:09
circle.yml for rails and yeoman
## Customize the test machine
machine:
timezone:
America/Los_Angeles # Set the timezone
# Version of ruby to use
ruby:
version:
1.9.3-p392
@shicholas
shicholas / bowling.rb
Created June 4, 2013 03:58
Pair Programming Session w/ @marksim
class Bowling
def initialize
@rolls = []
end
def roll(pins)
@rolls << pins
end
@shicholas
shicholas / string_calculator.rb
Last active December 18, 2015 15:49
LVRUG Kata 6/19/13 with many thanks to @marksim
module StringCalculator
String.class_eval do
def calc
raise NoNegativeNumbers.new(numbers.select{|n| n < 0}) if numbers.any?{|n| n < 0}
numbers.inject(0, &:+)
end
private
@shicholas
shicholas / funding.js
Created July 5, 2013 21:36
Gon and AngularJS in a Rails 4 App
// app/assets/javascripts/controllers/funding.js
var FundingCtrl = ['$scope', function($scope) {
$scope.funding = gon.funding;
}
];
@shicholas
shicholas / rss_messenger.rb
Last active December 23, 2015 23:19
RssMessenger Kata 9/25/2013 - Instantiate the class with RSSMessenger.new(<url of your favorite rss>).create_messages and you will see a unique list of messages!
# -*- coding: utf-8 -*-
require 'feedzirra'
require 'fileutils'
class RSSMessenger
attr_reader :feed
def initialize(feed)
@feed = process_feed(feed)
@shicholas
shicholas / spec_helper_full.rb
Created October 21, 2013 17:47
cut up spec_helper to get the tests running even faster!
require_relative "spec_helper_model"
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
@shicholas
shicholas / Guardfile
Created April 11, 2014 15:02
Guardfile, whoops
guard :rspec, notification: true, cmd: 'rspec --color --format nested --tty', all_after_pass: true, spec_paths: ["spec/actions", "spec/decorators", "spec/forms", "spec/models", "spec/services"] do
watch(%r{^spec/(actions|decorators|forms|models|services)/.+_spec\.rb$})
watch(%r{^spec/(actions|decorators|forms|models|services)_spec_helper\.rb$}) { |m| "spec/#{m[1]}" }
watch(%r{^spec/support_(actions|decorators|forms|models|services)/(.+)\.rb$}) { |m| "spec/#{m[1]}" }
watch(%r{^app/(actions|decorators|forms|models|services)/(.+)\.rb$}) { |m| "spec/#{m[1]}/#{m[2]}_spec.rb" }
watch('/spec/base_spec_helper.rb') { ["spec/actions", "spec/decorators", "spec/forms", "spec/models", "spec/services"] }
watch(%r{^spec/support_common/(.+)\.rb$}) { ["spec/actions", "spec/decorators", "spec/forms", "spec/models", "spec/services"] }
end
@shicholas
shicholas / intro.md
Last active August 29, 2015 14:00
Replacing Controllers and Routes with Action Objects

I've been intrigued with the idea of action objects seen at the LVRUG podium app and have been thinking how these objects can replace controllers altogether. The more I think about it, I think these classes can replace both controllers and routing if they were namespaced and inherited in a standardized way.

Take the example from the podium app (as of 4/30/2014):

module Topics
  class DisplayTopics
    attr_defaultable :reader_factory, -> { Repositories::Reads::ReadTopics }

 def call(&amp;block)
@shicholas
shicholas / example_shared_example.rb
Last active August 29, 2015 14:01
Checkout Specs
RSpec.shared_examples 'not advance without payment info' do
it 'does not let user advance without payment info' do
click_button 'Preview'
expect(page).to have_content 'Must input payment info'
end
end
@shicholas
shicholas / commentary.md
Last active August 29, 2015 14:03
Fizzbuzz

Fizzbuzz

There are many ways to do this kata, including defining a refinement on the integer class as I did here. There are also many ways to print the fizzbuzz data including converting an integer to its representative in fizzbuzz or creating an array of numbers up to that integer with their fizzbuzz contents.

Printing to STDOUT

To print each element of an array to STDOUT it can be as simple as requiring a