Skip to content

Instantly share code, notes, and snippets.

View jaigouk's full-sized avatar

Jaigouk Kim jaigouk

View GitHub Profile
#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
@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)
require 'rubygems'
puts ENV["GEM_HOME"]
require 'mongoid'
require 'mongoid/version'
puts "Using Mongoid: #{Mongoid::VERSION}"
Mongoid.master = Mongo::Connection.new.db("mongoid_playground")
class Animal
@jaigouk
jaigouk / 0_README.md
Created May 14, 2011 17:06 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@jaigouk
jaigouk / edge_template.rb
Created September 17, 2012 21:09
rails template for ember.js, mongoid, omniauth. generated rails app is at https://github.com/jaigouk/rails-mongoid-omniauth-emberjs
# This script is designed to be used with Ruby on Rails' new project generator:
#
# rails new my_app -m thisfile -T -O
#
# For more information about the template API, please see the following Rails
# guide:
#
# http://edgeguides.rubyonrails.org/rails_application_templates.html
# create rvmrc file
@pragdave
pragdave / gist:4981930
Created February 19, 2013 00:13
The Ruby 2 prepend() method makes method chaining a lot easier.
module SystemHook
private
def system(*args)
super.tap do |result|
puts "system(#{args.join(', ')}) returned #{result.inspect}"
end
end
end
class Object
@ziazek
ziazek / deploy_phoenix
Created June 10, 2017 05:32
nginx configuration
upstream deploy_phoenix {
server 127.0.0.1:8888;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# REDIRECT HTTP www.example.com to HTTPS example.com

Getting started

First add your twitter username and password. Then server.rb and once it's started open websocket.html in your browser. You should see some tweets appear. If not take a look at the javascript console.

@alexellis
alexellis / README.md
Last active May 23, 2019 07:24
OpenFaaS Cloud Community Cluster instructions
@benedikt
benedikt / active_model_serializers.rb
Created March 2, 2012 17:40
Makes mongoid and active_model_serializers play nicely together
# config/initializers/active_model_serializers.rb
Mongoid::Document.send(:include, ActiveModel::SerializerSupport)
Mongoid::Criteria.delegate(:active_model_serializer, :to => :to_a)