Skip to content

Instantly share code, notes, and snippets.

@coreyhaines
coreyhaines / Get raw json from EventBoard
Last active January 2, 2016 14:29
EventBoard Stuff Thanks to Pete Hodgson @ph1 for figuring this out.
# List of conferences
curl -d {} -H "Content-Type:application/json" https://eventboard.falafel.com/ConferenceService2/ConferenceListEx
# The 59 specifies the version according to the latest version that is present in the DataVersion attribute of the conference list above
curl http://cdn.eventboard.falafel.com/conferencecatalogs/codemash2014.59.data.json
@coreyhaines
coreyhaines / blow_it.rb
Created November 7, 2013 21:01
Does this blow method cache? Global? Just for class?
def method_missing(method, *args, &block)
if helper.respond_to?(method)
self.class_eval "def #{method}(*args, &block); helper.send('#{method}', *args, &block); end"
self.send(method, *args, &block)
else
super
end
end
Design Patterns often are discussed with a negative tone. We laugh at Java developers and their heavy classes with the patterns encoded in the name. After all, who wants to try to understand the AbstractBaseClassFactoryManager? But don't most Ruby developers spend their time in a framework that glorifies a select few patterns to the point where the idea of writing code outside these patterns is considered heretical? On the other hand, Evolutionary Design says we are supposed to let the design come out over time, listening to the feedback we get from the combination of tests and refactoring, planning as little ahead as possible. What's a developer to do?
Ideally, Design Patterns are used as communication, not construction, as description, not prescription. In this talk, we'll discuss using patterns as a goal, as guides when iterating and evolving our system's design. Rather than thinking "I'll solve this with a strategy pattern," we can say that our design is heading "towards a strategy pattern" or we ended u
🐈 $ baseline up ruby
/Users/coreyhaines/Documents/codes/test/.baseline/Vagrantfile:14:in `<top (required)>': undefined method `configure' for Vagrant:Module (NoMethodError)
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:115:in `load'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:115:in `block in procs_for_source'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config.rb:41:in `block in capture_configures'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config.rb:36:in `synchronize'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config.rb:36:in `capture_configures'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:114:in `procs_for_source'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:51:in `block in set'
@coreyhaines
coreyhaines / Applications
Last active December 21, 2015 05:39
Installing new computer
Chrome
Alfred
Dropbox
1Password
Sizeup
Twitter
Coconut Battery
Dash
XCode
Caffeine
class Array
def except(*e)
self - e
end
end
# >> [1, 2, 3].except 2
# => [1, 3]
# >> [1, 2, 3].except 3
# => [1, 2]
@coreyhaines
coreyhaines / command line
Created July 25, 2013 02:47
redirecting standard error
ruby dots.rb 2> dups.log
class EmailJob
include SuckerPunch::Job
def perform(user_id)
UserMailer.welcome(user_id).deliver
end
end
module SuckerPunch
module Job
@coreyhaines
coreyhaines / ffnn
Created June 22, 2013 23:16
Result of constructor:construct_Genotype(ffnn, rng, pts, [1,3,2]).
{cortex,{cortex,7.293444414396203e-11},
[{sensor,7.293444414396207e-11}],
[{actuator,7.293444414396204e-11}],
[{neuron,{1,7.293444414396202e-11}},
{neuron,{2,7.293444414396202e-11}},
{neuron,{2,7.293444414396202e-11}},
{neuron,{2,7.2934444143962e-11}},
{neuron,{3,7.293444414396198e-11}},
{neuron,{3,7.293444414396196e-11}},
{neuron,{4,7.29344441439619e-11}}]}.
@coreyhaines
coreyhaines / An example using tap
Last active December 18, 2015 11:39
Adds a tap method for Objective-C
// This allows me to replace something like the following (common in initializers)
if(obj) {
//do something, perhaps set up the object with a bunch of properties
}
return obj;
// with doing this
return [obj tap:^(id obj) {
// do something, perhaps set up the object with a bunch of properties
// Bonus: you don't have to check for nil, as this block won't get call if obj is nil.