Skip to content

Instantly share code, notes, and snippets.

@tyre
tyre / gist:4045730
Created November 9, 2012 13:46
Keyword Arguments + iVars
2.0.0-preview1 :001 > class Walrus
2.0.0-preview1 :002?> attr_accessor :bubbles
2.0.0-preview1 :003?> def initialize(bubbles: @bubbles)
2.0.0-preview1 :004?> end
2.0.0-preview1 :005?> end
=> nil
2.0.0-preview1 :006 > Walrus.new bubbles: 'It works!'
=> #<Walrus:0x007fe8a1e78e48>
2.0.0-preview1 :007 > _.bubbles
=> nil

What exactly does ::SomeModule do? I first expected that it was a method like any other, getting called in the context it was in, so I went into irb to confirm.

1.8.7 :001 > class A; class B; end; end
 => nil 
1.8.7 :002 > A.send(:::, :B)
SyntaxError: compile error
(irb):2: syntax error, unexpected tSYMBEG, expecting tCONSTANT
A.send(:::, :B)
          ^
deals:
idle_timeout: 1800
dir: ~/ls/deals
rvm: foreman start
app_port: 3000
server_port: 4000
kill_with: KILL
cupcake:
idle_timeout: 300
dir: ~/ls/cupcake
// automatically adds JS bindings to attach Google Analytics tracking
//
// defaults
//
// class: ga-track all elements with this class will have
// handlers attached on DOM ready
//
// data-ga-binding: click the binding on which to fire the tracking
//
// data-ga-event: _trackEvent the analytics event send to Google
function rails_console {
local version=$(rails -v | grep -o 'Rails [0-9]' | grep -o '[0-9]')
if [[ "$version" == "2" ]]; then
./script/console
elif [[ "$version" -gt "2" ]]; then
rails c
fi
}
require 'benchmark'
iterations = 2000000
Benchmark.bmbm do |x|
x.report('double equals') { iterations.times { true == true } }
x.report('triple equals') { iterations.times { true === true } }
end
# Rehearsal -------------------------------------------------
@tyre
tyre / gist:5522214
Last active December 19, 2023 05:02
Why I Say Dumb Shit

I say a lot of stupid things. Some examples:

  • I told an English professor (in London, no less) that Lil Wayne was a better linguist than Shakespeare.
  • I've said that C is an uninteresting language and no longer relevant.
  • I told Obama's former Economic Advisor that I thought most of Economics was made up.

You might roll your eyes and say,"You don't know what you are talking about. You are young and näive."

You would be correct, and that's exactly the point.

@tyre
tyre / gist:5561992
Last active December 17, 2015 05:59
Stop developing for the 90% use case

TLDR:

Please stop overvaluing your time at the expense of your users. It is easy to get caught up in a features pissing contest with that other startup down the road, but don't lose sight of your mission. Take one problem that people have and solve it. Well. All of it. All of the time.

Last year I read the wonderfully concise essay Half, Not Half-Assed by the 37 Signals team.

It took me more than five minutes to figure it out, but the time spent thinking was definitely worth it. Talking with coworkers, friends, or conference attendees about those handful of paragraphs reinforces this.

@tyre
tyre / gist:5703963
Last active December 18, 2015 01:28
Things to know.
  • Web Application
    • Front End
      • HTML
        • DOM
          • Document fragments
          • Location
        • Elements
        • Attributes
          • Classes
  • Id
@tyre
tyre / gist:5961515
Last active December 19, 2015 13:19
Product Managers Love Features Like Engineers Love Commits

Product managers love features because they are demonstrable proof that shit happened. It can boil down to a shift in blame: you can't blame me that the customer didn't like it, look at this list of things that got done! It's bigger than anyone else's list! It's an objective measure, where 3 hastily crapped out features are better than 1 awesome feature.

Engineers have an equivilent: commits and lines of code. If I'm worried about other engineers or my boss viewing me as unproductive, I can just show a montrous diff and what are you going to say? 'Just Shit It Out' create a massive mess, but at least I can wave my arms around and brag about the sheer quantity of crap that I produced. A phrase we had in college was 'quantity is its own quality.' We were justifying purchasing 2 handles of plastic-bottle vodka over 2 bottles of the nicer stuff.

Quality is harder. It's harder because it takes more thought, more work, and you often get less cumulative things in the end. Oh, you refactored the core logi