Skip to content

Instantly share code, notes, and snippets.

View hopsoft's full-sized avatar

Nate Hopkins hopsoft

View GitHub Profile
@hopsoft
hopsoft / gist:9216801
Created February 25, 2014 20:15
Install Docker with devicemapper driver
echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
apt-get -y --force-yes update
apt-get -y --force-yes install lxc-docker
echo "DOCKER_OPTS=\"-s=devicemapper\"" > /etc/default/docker
service docker restart
@hopsoft
hopsoft / about.md
Last active August 29, 2015 14:08
A simple JavaScript test framework
@hopsoft
hopsoft / transition.rb
Last active August 29, 2015 14:10
Han Transition Wrapper in Ruby
require "active_support/all"
require "forwardable"
class Transition
extend Forwardable
def_delegators :params, :to_query, :to_json
def initialize(han_transition)
@han_transition = han_transition.symbolize_keys
@params = han_transition[:params].symbolize_keys
@hopsoft
hopsoft / gist:7a2afcb46ce14b5441ff
Created December 15, 2014 03:32
Rails Modeling Example
# Models
# app/models/user.rb
class User < ActiveRecord::Base
has_many :articles
has_many :videos
has_many :photos
end
# app/models/article.rb
@hopsoft
hopsoft / gist:2452e372572a15f4b1ad
Created January 15, 2015 18:31
Easy way to create a Rails fixture stub
require "model_probe"
User.extend ModelProbe
User.fixture
@hopsoft
hopsoft / some_controller_test.rb
Last active August 29, 2015 14:13
Fix routing for engine controller tests in Rails 4.0.xxx
require 'test_helper'
module ExampleEngine
class SomeControllerTest < ActionController::TestCase
setup do
@routes = ExampleEngine::Engine.routes
end
test "index response" do
@hopsoft
hopsoft / example_component.js
Last active August 29, 2015 14:24
React Component Structure
(function (app) {
var components = (app.components || (app.components = {}));
app.components.ExampleComponent = React.createClass(
mixins: [],
propTypes: {...},
getInitialState: function () {
return {
@hopsoft
hopsoft / gist:c7a2dd88b50039ed4eb9
Created July 18, 2015 11:32
Module Directories
app/assets/javascripts/modules
lib/assets/javascripts/modules
vendor/assets/javascripts/modules
@hopsoft
hopsoft / lodash.js
Created July 18, 2015 11:36
Lodash Manifest File
// vendor/assets/javascripts/modules/lodash.js
//= require lodash
@hopsoft
hopsoft / assets.rb
Last active August 29, 2015 14:25
Module Asset Config
# config/initializers/assets.rb
Rails.application.config.tap do |config|
config.assets.version = "1.0"
paths = Dir[
Rails.root.join("app/assets/javascripts/modules/**/*"),
Rails.root.join("lib/assets/javascripts/modules/**/*"),
Rails.root.join("vendor/assets/javascripts/modules/**/*")
]