Skip to content

Instantly share code, notes, and snippets.

View nateberkopec's full-sized avatar

Nate Berkopec nateberkopec

View GitHub Profile
@nateberkopec
nateberkopec / gist:5289274
Created April 2, 2013 01:33
current status
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░██░░░░░░██░░█████░░░██░░░░░░█████░░░
░░██░░░░██░░██░░░██░░██░░░░░██░░░██░░
░░░██░░██░░░██░░░██░░██░░░░░██░░░██░░
░░░░████░░░░██░░░██░░██░░░░░██░░░██░░
░░░░░██░░░░░██░░░██░░██░░░░░██░░░██░░
░░░░░██░░░░░██░░░██░░██░░░░░██░░░██░░
░░░░░██░░░░░░█████░░░██████░░█████░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░█████░░░██░░░██░░░█████░░░█████░░░
@nateberkopec
nateberkopec / kill_me_now.rb
Created March 29, 2013 19:49
kill_me_now.rb
Product.metaclass.send(:define_method, name.to_s) do
-> { Product.send(:relation).order(order_text) }
end
@nateberkopec
nateberkopec / secure_headers.rb
Created March 28, 2013 19:44
Example of a simple Rack middleware for scrubbing your Rack headers of sensitive information.
class Rack::SecureHeaders
def initialize(app, options = {})
@app, @options = app, options
end
def call(env)
response = @app.call(env)
# [status, headers, response] = response
number_of_colors = 60 #number of colors you want to generate in total.
z = 12 #"set size"
ang = 180/(z)
s = 30 #desired saturation constant, 1 to 100
v = 50 #desired value/lightness constant, 1 to 100
complement = (0..z/2).map{|i| (0..180).step(ang).map{|h| [[h + i,s,v], [h + i + 180,s,v] }}
triad = (0..z/2).map{|i| (0..180).step(ang).map{|h| [[h + i,s,v], [h + i + 60,s,v], [h + i + 120,s,v]] }}
module Mokha
class HomeController < Mokha::BaseController
def index
@view = Mokha::HomePresenter.new
@view.user = User.includes(:ratings).find(current_user)
@view.user.track('Opened Mokha')
end
@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
@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: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
#
# 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" }
<!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">