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
@carlzulauf
carlzulauf / sax_issue.rb
Created April 4, 2014 23:07
Issue with overcoming errors when using nokogiri's SAX parser
require 'nokogiri'
class Doc < Nokogiri::XML::SAX::Document
include Enumerable
def initialize(xml)
@xml = xml
end
def each(&block)
@carlzulauf
carlzulauf / strategies.md
Created April 9, 2014 22:27
Strategies for Personal Information Security

Our personal information isn't really secure. It probably never has been, but our increasing reliance on digital services and the constant public disclosure of large breaches is only making that clearer.

You can't protect your personal information. Its already in the hands of third parties. All we can really do is take some steps to reduce the pain when our information falls into the wrong hands.

  • Never use a debit card or any other card backed by real money. Not online, not in person. Maybe even ask your bank for an old-fashioned ATM card and get rid of the debit card altogether. When someone does make fraudulent charges, you don't want to have your real money disappear while you wait for your banks fraud department to investigate and refund. With a credit card the fraudster is merely racking up temporary debt that will disappear when the investigation is complete. In the meantime you can use one of your other credit cards (you should have at least two) and your real money is never touched.
  • Use a passwo
Backbone.ajax = function(){
var old_function = Backbone.ajax
return function() {
// do some stuff before calling the old function
result = old_function.apply(arguments)
// do some stuff after calling the old function
@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
@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 / 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

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 / _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)
@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 / links.md
Last active August 29, 2015 14:06
Omaha Ruby, September 2014 Lighting Talks