Skip to content

Instantly share code, notes, and snippets.

View steveklabnik's full-sized avatar
🦀
Rustacean

Steve Klabnik steveklabnik

🦀
Rustacean
View GitHub Profile
@steveklabnik
steveklabnik / proposal.md
Created June 25, 2012 17:44
Development and Philosophy

We spend most of our times obsessing about the actual act of programming. Is this method name too long? Should I refactor this code? How do I fix this bug? However, sometimes, large gains can be made by drawing in experience from totally different fields.

I think there's a lot a programmer can learn from the study of epistemology, logic, metaphysics, moral and political philosophy, and aesthetics. In this talk, I'll give an overview of a bunch of interesting thinkers, philosophical problems, and how they relate to the worlds of software development, open source, and startups.

@steveklabnik
steveklabnik / foo.rb
Created June 25, 2012 20:03
A question about testing stuffs
def foo(arg)
@collaborator.foo(arg)
rescue
@collaborator.set_auth_credentials(credentials)
@collaborator.foo(arg)
end
# How can I make foo throw an exception the first time, but not the second time? The test currently loops infinitely.
@steveklabnik
steveklabnik / Gemfile
Created July 24, 2012 21:52
Hypermedia Proxy pattern in JSON
source :rubygems
gem 'sinatra'
@steveklabnik
steveklabnik / log.txt
Created August 19, 2012 09:59
A fun shell script from #euruku
$ history | awk {'print $2, $3, $4'} | sort | uniq -c | sort -k1 -rn | head -n 30
610 git status
568 git commit -m
491 git add .
252 git push origin
176 bundle
138 rails s
128 ls
120 git commit --amend
114 git reset --hard
@steveklabnik
steveklabnik / 01.rb
Created September 6, 2012 00:35
rubylearning
Struct.new("Point", :x, :y) #=> Struct::Point
origin = Struct::Point.new(0,0) #=> #<struct Struct::Point x=0, y=0>
$ rspec
F
Failures:
1) Person compares birthdays
Failure/Error: joe.birthday.should == jon.birthday
expected: "7/6/1986"
got: "5/6/1986" (using ==)
# ./spec/person_spec.rb:9:in `block (2 levels) in'
@steveklabnik
steveklabnik / todo.txt
Created September 27, 2012 15:14
Resque 2.0 Todo
____ ___________ ____ __ ________ ___ ____
/ __ \/ ____/ ___// __ \/ / / / ____/ |__ \ / __ \
/ /_/ / __/ \__ \/ / / / / / / __/ __/ / / / / /
/ _, _/ /___ ___/ / /_/ / /_/ / /___ / __/_/ /_/ /
/_/ |_/_____//____/\___\_\____/_____/ /____(_)____/
=====================================================
## Here's what needs to be done
class Audio < ActiveRecord::Base
def self.sync!
[Audio::ProgramAudio, Audio::DirectAudio, Audio::EncoAudio].each do |klass|
klass.sync!
end
end
class EncoAudio < Audio
def self.sync!
AudioSyncher.new(foo, bar).sync_awaiting_audio_if_file_exists!
@steveklabnik
steveklabnik / _comment.html.erb
Created October 9, 2012 06:05
Presenters in Rails?
<article>
<header>
<h3><%= comment.author %></h3>
</header>
<%= comment.body %>
</article>
@steveklabnik
steveklabnik / some_controller.rb
Created October 14, 2012 01:07
Some thoughts on real ViewModels for Draper 2.0
class SomeController < AC::Base
def show
foo = Foo.first
bar = Bar.first
show_model = ShowViewModel.new(foo, bar)
render show_model
end
end