Skip to content

Instantly share code, notes, and snippets.

View jaigouk's full-sized avatar

Jaigouk Kim jaigouk

View GitHub Profile
require "test_helper"
describe Phase do
before do
# Timecop.travel computes an offset between what we currently think Time.now is (recall that we support nested traveling) and the time passed in.
# joe = User.find(1)
# joe.purchase_home()
# assert !joe.mortgage_due?
# # move ahead a month and assert that the mortgage is due
# Timecop.freeze(Time.now.to_date + 30) do
require 'test_helper'
describe SearchEngine::Searchable do
it "should accept partial path" do
end
it "should accept page param and return cached results" do
end
@jaigouk
jaigouk / REFACTORING-Controller.rb
Last active August 29, 2015 14:08
skinny controller
#Let's extract some registration logic out of our controllers into a UserRegistration class.
#This class should take user_params as arguments to its constructor,
#which are used to initialize a new User (not create).
#This newly initialized user should be available as an attr_reader.
#You'll also want to move the valid_background_check? method
#into this new class as a private method, we'll use this later to finish creating the User.
class UsersController < ApplicationController
def create
@user = User.new(user_params)
#Let's take a look at the welcome method of the User model.
#This method is doing way too many things,
#you really need to split it up into separate private methods.
#Create the following private methods:
#send_welcome_email, enable_welcome_tour, enable_welcome_promotion.
#Then move the code from the welcome method into each one.
#Make sure to still call each method from within the welcome method.
class User < ActiveRecord::Base
.fc {
direction: ltr;
text-align: left; }
.fc table {
border-collapse: collapse;
border-spacing: 0; }
.fc .btn {
line-height: 1.2em; }
html .fc {
require 'net/http'
require 'uri'
require 'json'
base = "http://letsrevolutionizetesting.com/challenge.json"
1.upto(100) do |i|
uri = URI.parse(base)
header = {'Content-Type' => 'application/json'}
# --------------------------------------------------
# Setting up a Laravel app on dokku in a Vagrant box
# --------------------------------------------------
# First: cloning the dokku repo
$ git clone https://github.com/progrium/dokku
$ cd dokku
# Start, configure & provision a new vagrant box using the Vagrantfile from the repo
$ vagrant up

Deploy your own PaaS!

Setting up Dokku with DigitalOcean and Namecheap

..or how I made my own heroku in a few hours for $3.98.

This write-up owes a great deal to dscape's Node.js Deployments with Docker, Dokku, & Digital Ocean, the dokku project itself, and the fine folks working on dokku's issues. I took dscape's article as a starting point when trying this out but found some details lacking so I documented my own process for getting dokku up and running.

1. Get a domain

@jaigouk
jaigouk / nginx.conf
Last active August 29, 2015 14:13 — forked from dnprock/nginx.conf
# Sticky session module for nginx
# https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/
# nginx configure command: ./configure --with-http_ssl_module --add-module=../nginx-sticky-module-ng/ --sbin-path=/usr/local/sbin --with-http_gzip_static_module
upstream vida_node_server {
sticky path=/;
server 127.0.0.1:3000 max_fails=3 fail_timeout=30s;
server [server2]:3000 max_fails=3 fail_timeout=30s;
}
upstream haproxy {
server 127.0.0.1:9000;
}
upstream stats {
server 127.0.0.1:9999;
}
server {
listen 80; ## listen for ipv4; this line is default and implied