Skip to content

Instantly share code, notes, and snippets.

@coreyhaines
coreyhaines / message_pusher.rb
Last active August 29, 2015 13:56
Isolate integration with Pubnub (from the Slottd.com codebase)
# Isolating integration with Pubnub allowed me to swap origin in a central location.
# This seems like a trivial wrapping, almost not worth it at all.
# However, doing this allowed me to quickly fix a production issue associated with out-of-date gem's hard-coding of
# origin for request URL.
# Always worth abiding by the Eliminate Duplication (of knowledge) rule of simple design. In this case, knowledge of how
# to integrate with Pubnub.
module ManagesMessaging
class MessagePusher
def initialize(config = Config::Pubnub::Config)
@pusher = Pubnub.new(config[:pub_key], config[:sub_key], config[:secret], config[:ssl])

Keybase proof

I hereby claim:

  • I am coreyhaines on github.
  • I am coreyhaines (https://keybase.io/coreyhaines) on keybase.
  • I have a public key whose fingerprint is 54F2 B6B8 2BAB 7E8C E4E7 AEB4 068D 395B 477F 888D

To claim this, I am signing this object:

@coreyhaines
coreyhaines / abstract.txt
Created August 1, 2014 23:43
How Does The Internet Work (abstract)
How Does The Internet Work
The internet (and the world-wide web) is a wonderful tool for both personal and business use. The details of how it works, though, are often considered a mystery known only to a select few. For example, what's the difference between the "internet" and the "world-wide web"?
The truth is, nobody really knows how it works (just like "how do airplanes actually fly"). Since the early days, when it was given to us by benevolent space aliens, though, research has been able to discern some basic "facts" about its internal operations. In this lunch-and-learn, we'll spend some time going over what we have been able learn.
We'll start with a bit of history of the internet and the related world-wide web. Next, we'll go over some of the inner-workings, striving to answer such questions as:
- What is the difference between the internet and the world-wide web?
- What are web servers and web browsers?
- What is a URL and by what magic does that correspond to a picture of a kitten in our web brow
@coreyhaines
coreyhaines / abstract.txt
Last active August 29, 2015 14:05
Lambda Madness Talk Abstract
Title:
To create the world, you must first define True
(fun with lambdas)
Abstract:
Perhaps you've seen lambdas in Ruby. Ever wondered what would happen if you went crazy with them? What if they were all you had? What if you only allowed them to take a single parameter?
In this fun talk, we'll start with nothing but the lowly single-parameter lambda and slowly build the world. Of course, to do that, we'll need a testing library, so we'll build that (and explore what True means if we only have lambdas). Then, we'll move onto lists and build the basics of the Enumerable functions (map, select, etc). Can we do this with just the lowly lambda? (spoiler: Yes)
This talk will cover things that are very clearly in the "Do try this at home" zone. So, come along with me and take a deep dive into what can be done when you start with nothing.
(this is based on some fun playing that @joshcheek and I did earlier this year)
@coreyhaines
coreyhaines / not sure I like this
Last active August 29, 2015 14:16
Using super() in rspec's subject
# Phew! Turns out this was generated by transpec, not by a human!
before do
@admin = User.create(username: "user", password: "password", password_confirmation: "password")
end
subject{ @admin }
describe '#remember_token' do
subject { super().remember_token }
it { is_expected.not_to be_blank }
@coreyhaines
coreyhaines / prompt.sh
Created March 26, 2015 22:09
My prompt
export PROMPT_COMMAND='prompt_status=$?'
export PS1='$(if [[ $prompt_status == 0 ]]; then echo "¯\_(ツ)_/¯"; else echo "ᕕ( ᐛ )ᕗ"; fi) 🐈 $'
@coreyhaines
coreyhaines / abstract
Last active August 29, 2015 14:18
Craft Conf Abstract
# abstract for my talk at Craft Conf 2015 (http://craft-conf.com/2015)
You've probably heard about the lambda calculus, building up our computing structures from just the treasured lambda. But how much have you played with it?
In this talk, armed only with Vim and the CLI, we'll explore some interesting topics in building up our world with just the lambda and the thought process while doing it. While you probably don't want to program day-to-day at this level, it definitely can help with how you think about your regular programming.
This talk consists almost entirely of live coding. FUN TIMES!
@coreyhaines
coreyhaines / filters.rb
Created April 5, 2015 05:51
The boss of metaprogramming
# You know you are the boss, when you take this
def filter(questions_query)
filter_categories filter_incomplete questions_query
end
def filter_incomplete(query)
filtering_on?(:incomplete) ? query.incomplete : query
end
def filter_categories(query)
filtering_on?(:categories) ? query.in_categories(*@original_params[:categories]) : query
Idea based on this tweet exchange:
coreyhaines: Architecture where ever class is its own gem, communicating via drb. #thoughtleadering #thoughtlendering
coreyhaines: better yet, every method is its won gem, classes are built up by requiring gems that monkey-patch. #truth
josh_cheek: @coreyhaines As each method is a gem, it needs its a namespace, so it's defined in a module… Compose classes by including method's modules.
coreyhaines: @josh_cheek I do like the idea of composing via module inclusions, as well. Interesting.
coreyhaines: Seriously, though, the idea of defining classes via including single-method modules appeals to me.
So, here's my thought for the workshop. It is based a bit on some of the value that I saw doing coderetreats.
title: Super Awesome Happy Fun Coding Workshop, Great Job
@coreyhaines
coreyhaines / gist:8545bc5624d50bdae14c
Last active August 29, 2015 14:22
Type-based stack
class TypeStack {
public void push(T obj);
public T pop<T>();
public T peek<T>();
}
var stack = new TypeStack();
stack.push("hello");
var o = new OtherType();
stack.push(o);