Skip to content

Instantly share code, notes, and snippets.

View rainforest-of-code's full-sized avatar

rainforest-of-code

View GitHub Profile
@rainforest-of-code
rainforest-of-code / render.js
Created May 31, 2012 16:18 — forked from mxriverlynn/render.js
Help me clean this up
// This is the render method in the `ItemView` in my Backbone.Marionette plugin.
// It's a giant method - far too much happening in this one method, and poor
// use of memory with all of the methods that get re-defined on every use.
//
// It desperately needs to be cleaned up. But I can't do something quite as
// simple as just move the inner functions on to the ItemView itself. There
// are too many methods on the ItemView already.
//
// Suggestions? What are some good patterns to clean this up?
//
@rainforest-of-code
rainforest-of-code / Ball.js
Created May 31, 2012 16:27
Follow along code for a Jasmine introduction presentation
function Ball() {
var self = this;
var full = false;
self.inflate = function() {
full = true;
};
self.isFull = function() {
@rainforest-of-code
rainforest-of-code / gist:3845861
Created October 6, 2012 19:29 — forked from prasoonsharma/gist:717903
Data Frame operations in R
# DATA FRAME OPERATIONS IN R
# Create data frame
# A dataset is ~ table (list of vectors)
id <- c(1,2,3)
name <- c("John", "Kirk", "AJ")
age <- c(21,27,18)
employees <- data.frame(ID=id, Name=name, Age=age)
employees
@rainforest-of-code
rainforest-of-code / most_used_css_property_names.js
Created October 12, 2012 21:31 — forked from NV/most_used_css_property_names.js
PhantomJS script to collect most used CSS property names (supported by WebKit)
// phantomjs --web-security=no most_used_css_property_names.js
var urls = [
'http://google.com',
'http://facebook.com',
'http://youtube.com',
'http://yahoo.com',
'https://github.com/',
'http://twitter.com/',
'http://en.wikipedia.org/wiki/Main_Page',
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
  • Buy a mac mini
  • Install 10.8
  • Create a user account for Jenkins
  • Install xcode
  • Turn on screen sharing
  • Turn off energy save sleeping
  • Login as your jenkins user
  • Use ssh-keygen to create a key for github
  • Create a github account for your build machine
  • Add the key to your build machine github account

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end

Ignore line-ending differences when diffing

(You can't use this with git difftool or merge though)

git diff --ignore-space-at-eol

Prefer one branch over another when merging

Beautiful Code

Language Elements

# 49 methods for the price of one
# via @sferik
module Enumerable

# block &amp; yield syntax