Skip to content

Instantly share code, notes, and snippets.

View carlzulauf's full-sized avatar

Carl Zulauf carlzulauf

  • Unabridged Software
  • Denver, CO
View GitHub Profile
data = <<DATA
foo
bar
start
inside
blah
this is the end
baz
DATA
class Dynamical
def should_not_explode(&block)
5.times { |n| yield n }
end
define_method :works_fine do |&block|
5.times { |n| block.call(n) }
end
def also_works_fine(&block)
@carlzulauf
carlzulauf / meetup.md
Last active August 29, 2015 14:07
Omaha Ruby, October 2014 Lighting Talks
@carlzulauf
carlzulauf / links.md
Last active August 29, 2015 14:06
Omaha Ruby, September 2014 Lighting Talks
@carlzulauf
carlzulauf / soylent
Last active August 29, 2015 14:06
Soylent Waiting
[20] pry(main)> start = Date.parse("May 21st"); (start + 10.weeks + 8.weeks)..(start + 12.weeks + 10.weeks)
=> Wed, 24 Sep 2014..Wed, 22 Oct 2014
@carlzulauf
carlzulauf / _head.haml
Last active August 29, 2015 14:05
Chaining JS controllers off of rails controllers extracted from Underbee (UB)
%head
%title= page_title
%meta{name: "viewport", content: "width=device-width, initial-scale=1.0"}
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= js_action_loader # <---- Helper sets up current controller/action for JS on every page
= csrf_meta_tags
= yield(:head)
if defined?(ActiveRecord::Base)
class ActiveRecord::Base
def self.sample
s = scoped
c = s.count
s.offset(rand(c)).first
end
end
def __clear_lhm(sure = false)
@carlzulauf
carlzulauf / talks.md
Created July 11, 2014 16:48
Omaha Ruby Lightning Talks - July 10th, 2014

Lightning Talks Recap

Here are some links to some of the talks or the topics they covered.

Todd Nichols: Pundit

Jay Hannah: Regular Expressions

@carlzulauf
carlzulauf / talk.rb
Last active August 29, 2015 14:03
Fun With Threads talk
# Class that attempts to have fun with threads
#
# Meant to be used from within pry. Example:
#
# $ pry
# pry(main)> talk = FunWithThreads.new
# pry(main)> cd talk
# pry(#<FWT>)> puts "Hello"
#
@carlzulauf
carlzulauf / http_status_matcher.rb
Last active August 29, 2015 14:03
Custom RSpec matcher for HTTP status codes
# Usage: expect(response).to have_status(:unauthorized)
RSpec::Matchers.define(:have_status) do |expected|
status_code = case expected
when Symbol
Rack::Utils.status_code(expected)
else
expected
end