Skip to content

Instantly share code, notes, and snippets.

View nateberkopec's full-sized avatar

Nate Berkopec nateberkopec

View GitHub Profile
@nateberkopec
nateberkopec / mixpanel_init.js.coffee
Created November 13, 2012 21:09
mixpanel_init.js.coffee
$ ->
active_tracker.track_links()
active_tracker.track_forms()
# be sure to load Mixpanel's javascript before this, so window.mixpanel exists.
window.active_tracker = new Object
active_tracker.track_links = (selector = 'a[data-event-name]') ->
$.each $(selector), (index, value) ->
letter frequency
A .08167
B .01492
C .02780
D .04253
E .12702
F .02288
G .02022
H .06094
I .06973
@nateberkopec
nateberkopec / db.rake
Created November 20, 2012 00:57 — forked from xaviershay/db.rake
db:structure:load for Rails 3.1
namespace :db do
namespace :test do |schema|
schema[:clone_structure].abandon
desc "OVERWRITTEN - load the development_structure file using psql shell"
task :clone_structure => ["db:structure:dump", "db:test:purge"] do
config = ActiveRecord::Base.configurations['test']
cmd = "psql #{psql_options} < db/development_structure.sql"
system cmd
end
# how can I change this middleware to only call Raven.captureException when a message is placed in the retries queue, let's say, for the third time?
module Raven
class Sidekiq
def call(worker, msg, queue)
begin
yield
rescue => ex
Raven.captureException(ex)
raise

Hey Mike,

I wanted to write out a full reply rather than continue a back-and-forth Twitter conversation. I don't want to be "that guy" that publicly does a "drive-by-shit-on" regarding an open-source project. I realize how much time and effort it takes to keep a project like minitest-rails running!

I think my problem with minitest-rails is part philosophical, part practical. Practically, it was a bitch to get working. That's weird to me. I figured the point of minitest-rails would be to just drop it into my Rails project's gemfile and minitest should "just work". But after about 3 hours of trying, it just wouldn't. I ended up writing my own helpers to get minitest working with Rails, and it ended up being a) simpler than I expected, and b) much clearer than what minitest-rails was doing. I'm sure I maybe just missed a few details here and there with minitest-rails that prevented my tests from working, but I'll attach the very minimal code that was required to get minitest working. My question is - why can't

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>*|Giver|* bought you a coffee tasting box subscription!</title>
</head>
<body leftmargin="0" marginheight="0" marginwidth="0" offset="0" topmargin="0" style="background-color:#bba993;-webkit-text-size-adjust:none;padding:0;margin:0;width:100%">
<center>
<table border="0" cellpadding="0" cellspacing="0" height="100%" id="backgroundTable" width="100%" style="margin:0;padding:0;width:100%;height:100%;background-color:#669999"><tr>
<td align="center" valign="top" style="border-collapse:collapse">
#
# Insert an automatic text MIME part into HTML e-mail.
# (c) Daniel Doubrovkine, Art.sy 2012
# MIT License
#
class ActionMailerWithTextPart < ActionMailer::Base
def collect_responses(headers)
responses = super(headers)
html_part = responses.detect { |response| response[:content_type] == "text/html" }
@nateberkopec
nateberkopec / gist:4511691
Created January 11, 2013 15:50
sandi metz from parley
.....................
First, the setup:
What problem are we're trying to solve? I'd call it coupling and I'll use the example from poodr to describe my take on it.
When Gear knows the name of Wheel, Wheel is a bit glued into Gear. Imagine that Gear has a gear_inches method that needs to get a Wheel's diameter.
def gear_inches
@nateberkopec
nateberkopec / install_ruby.md
Last active May 6, 2019 01:45
install ruby, rbenv, and latest ruby

$ brew update

$ brew install rbenv

$ brew install ruby-build

append eval "$(rbenv init -)" to your bash profile

$ rbenv install 1.9.3-p327

@nateberkopec
nateberkopec / gist:4635584
Created January 25, 2013 16:06
craft.sass
// COLOR SCHEMES
$leche: #BBA993
$caramel: #CC9966
$shit-brown: #330000
$craft-red: rgb(238, 64, 55)
$dark-red: #660000
$satan-grey: #666
$tres-gris: #333
// FONTS