Skip to content

Instantly share code, notes, and snippets.

@tyre
tyre / pdf
Created November 16, 2014 05:43
Template PDF output
%PDF-1.7
1 0 obj
<</BitsPerComponent 8/ColorSpace /DeviceRGB/DecodeParms <</BitsPerComponent 8/Colors 3/Columns 96/Predictor 15>>/Filter /FlateDecode/Height 96/Length 19658/Subtype /Image/Type /XObject/Width 96>>
stream
xçΩî\’ï˛{c–’9KjÂBB ≤19ÿÑ¡ c`lÉ3ˇa∆Gú∆€è¡c0—&âhÇÅ@9´[›Í‹]]πn›¯~ª{¸fi[Î≠Wrw’≠{œŸgáo{ü#5;>†Î∫Á˚J†∏NÕ∂≠h4¢Èö]Û √p]+‡#EU_7u?Pt›džV≠™äÆiÆ¢h°xÉ¢jvµ§(äiöA†˙Åœ5æ‹”èF"ûÎ*öéDçP»s|À™ UU<œ’ SUU-∏É¢*ÆÌ¨H,ŒW™’äbÑÕP$ƒs=◊Æîî –MS7 œÛxñc◊tÉÍ•\é7£âèu› ézû„:é
á .Tô s‡[∂]Û=F0!œ˜¢°h$´πÆÔ{äÔVÀE3⁄æsflgøÛ”ΩØæÙň¶´C ÉaÒM«±5MgJ‹îØ3æ≈{|äÑùZM´œ¢R)s
sÛ˝¿`Ù¶Æõ!˘ÕC||1’˜]Êcò!£.J_’5@‚<•4=Âπ~(fƒ\ÀÖBëƒc1´RA¢—xå/≤L™¶E¢q◊ œ´⁄5M—XÂä®Ü“5’q,◊q+•¢¨¢mGtùA" M3y:´(ÇQïZ≠∆Äcâd≠fªÆ√«öah™Èπûi™ ¨\.∞N5ÀÊ‚H,Í{NGk√Íû÷Ωä2”—\Y–nTÀ€™2¨H,°Ú›P%0√ÜLWÛEø\è∑Ãp8(’j’∂+\ûÃ4™öÓ⁄5‰£©∫É“xBeM\«ÆîK©d∫Z©æªÈµûæ˘›Ω=,8r7LÊ¢1€6¯≈‡·Q$]=“WÕp$éÚlñç° ÅÁÜâƒEäbYU#Â[Z≠Rb`¸biEY ó´áÎ∫Ñı.óäËæÌÿ®ÀñH&U
¬lT$Bö·flı7¥x:3ØßWâ5®µ⁄`æ™f«¶¡›™∫Ê&‚qî]ÒÉp<Œ<1,”©ï—¿ÛK˘*ܧ˘õ%B[√±∏m°_
Î∆ö°,»`ˇ‡õØm~i„Îoo›>>9››fi˙Oü˙ƒÂæ"
@tyre
tyre / gist:9040631
Created February 16, 2014 21:06
Ruby quotes
Benchmark.bmbm do |b|
b.report('single quotes') { 37_000_000.times { 'Six sets straight, ace, cut em in the bathroom.' } }
b.report('double quotes') { 37_000_000.times { "Six sets straight, ace, cut em in the bathroom." } }
b.report('%q') { 37_000_000.times { %q{Six sets straight, ace, cut em in the bathroom.} } }
b.report('%Q') { 37_000_000.times { %Q{Six sets straight, ace, cut em in the bathroom.} } }
end
# user system total real
# single quotes 3.480000 0.000000 3.480000 ( 3.481189)
# double quotes 3.510000 0.010000 3.520000 ( 3.507431)
@tyre
tyre / gist:7576558
Created November 21, 2013 05:34
Spotify Open: Free Streaming? No Thanks

You’ve doubtlessly heard something about Spotify coming to the United States. Those crazy Europeans have been rocking out to this streaming music service, according to Wikipedia, since late 2008. The tech press went positively bonkers when Spotify launched in the home of the brave. I’ve played around with the free service since day one, and have to say it is pretty neat.

It’s called Spotify Open and costs zero, although unlimited streaming likely won’t last beyond 2011. That’s a rather generous offering (read: money-pit) to sway numerous freedom-loving users to ditch iTunes and start streaming.

So what did I do?

I bought this EP off of iTunes today. For $4.99. That was free on Spotify.

class ImmutabilityValidator
def validate(record)
if record.persisted?
record.errors.add(:base, "#{record.class.name} cannot be updated after created.")
end
end
end
@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

@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: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: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.

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 -------------------------------------------------
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
}