Skip to content

Instantly share code, notes, and snippets.

Kyle Tolle kyletolle

Block or report user

Report or block kyletolle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kyletolle
kyletolle / deep_each.rb
Last active Feb 19, 2019
deep_each.rb - a multidimensional each for Ruby
View deep_each.rb
two_d_grid =
[
[ 1, 2, 3, 4, 5 ],
[ 6, 7, 8, 9, 10 ],
[ 11, 12, 13, 14, 15]
]
puts "Basic 2D each"
two_d_grid.each do |row|
row.each do |cell|
@kyletolle
kyletolle / node-http-post-listener.js
Created Sep 11, 2013
A simple http server that listens for POST events at port 9000 and will print out the data it receives. Tweak the statusCode if you want to return something else like 500. This is useful for setting up as the url for a webhook and viewing/verifying the data that gets sent to that URL.
View node-http-post-listener.js
var app = require('http').createServer(handler);
var statusCode = 200;
app.listen(9000);
function handler (req, res) {
var data = '';
if (req.method == "POST") {
req.on('data', function(chunk) {
@kyletolle
kyletolle / alias_method_matcher.rb
Last active Jan 19, 2016
RSpec alias_method matcher
View alias_method_matcher.rb
# spec/support/matchers/alias_method_matcher.rb
# RSpec matcher for alias_method.
# Orignal idea borrowed from: https://gist.github.com/1950961
# Usage:
#
# describe Boomerang do
# let(:boomerang) { described_class.new }
# let(:subject} { boomerang }
# it { is_expected.to alias_method(:in_flight?).to(:in_air?) }
View alleys.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kyletolle
kyletolle / README.md
Created Jan 23, 2014
US States Colored by Name Length
View README.md
@kyletolle
kyletolle / README.md
Created Jan 22, 2014
US States Colored by Name Length
@kyletolle
kyletolle / no_side_effects.rb
Created Oct 24, 2013
Which method of internal processing looks or feels best? Were the internal methods used have side effects, or no?
View no_side_effects.rb
def Cherry
def initialize(cherry)
@cherry = cherry
end
def process
@cherry = remove_pit(@cherry)
@cherry = twist_stem(@cherry)
end
@kyletolle
kyletolle / hash_constant.rb
Created Oct 24, 2013
hash constant example
View hash_constant.rb
irb(main):017:0> HASH = { a: a, b: b }
=> {:a=>#<Object:0x007f892b9a3b00>, :b=>#<Object:0x007f892b940af0>}
irb(main):018:0> HASH[:a] = Object.new
=> #<Object:0x007f892b9c3b58>
irb(main):019:0> HASH
=> {:a=>#<Object:0x007f892b9c3b58>, :b=>#<Object:0x007f892b940af0>}
irb(main):020:0> HASH[:c] = Object.new
=> #<Object:0x007f892b9d1b18>
irb(main):021:0> HASH = {}
(irb):21: warning: already initialized constant HASH
@kyletolle
kyletolle / hash_freeze.rb
Created Oct 24, 2013
hash freezing example
View hash_freeze.rb
irb(main):007:0> a
=> #<Object:0x007f892b8e6208>
irb(main):008:0> a = Object.new
=> #<Object:0x007f892b93a1f0>
irb(main):009:0> b = Object.new
=> #<Object:0x007f892b940af0>
irb(main):010:0> c = Object.new
=> #<Object:0x007f89291125d8>
irb(main):011:0> h = { a: a, b: b, c: c }
=> {:a=>#<Object:0x007f892b93a1f0>, :b=>#<Object:0x007f892b940af0>, :c=>#<Object:0x007f89291125d8>}
@kyletolle
kyletolle / fulcrum-webhook-example.json
Last active Dec 23, 2015
Fulcrum Webhook JSON example
View fulcrum-webhook-example.json
{
"webhook":{
"name":"Test Webhook",
"url":"http://example.com/webhook_endpoint",
"active":true,
"id":"c2178436-e8da-4630-a1a6-5e03c0880eca",
"created_at":"2013-09-17T20:18:10Z",
"updated_at":"2013-09-17T20:18:10Z"
}
}
You can’t perform that action at this time.