Skip to content

Instantly share code, notes, and snippets.

View ruevaughn's full-sized avatar

Chase Jensen ruevaughn

View GitHub Profile
@ruevaughn
ruevaughn / application.log
Created April 3, 2012 18:22
The application.log file of my rails app
Started POST "/tickets/1/comments" for 127.0.0.1 at 2012-04-03 12:16:25 -0600
Processing by CommentsController#create as HTML
Parameters: {"utf8"=>"✓", "comment"=>{"text"=>"Is it out yet?"}, "tags"=>"", "commit"=>"Create Comment", "ticket_id"=>"1"}
State Load (0.0ms) SELECT "states".* FROM "states" 
User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 LIMIT 1
Ticket Load (0.0ms) SELECT "tickets".* FROM "tickets" WHERE "tickets"."id" = ? LIMIT 1 [["id", "1"]]
Project Load (0.0ms) SELECT "projects".* FROM "projects" WHERE "projects"."id" = 1 LIMIT 1
Permission Load (0.0ms) SELECT "permissions".* FROM "permissions" WHERE "permissions"."user_id" = 2
 (0.0ms) SAVEPOINT active_record_1
Ticket Load (0.0ms) SELECT "tickets".* FROM "tickets" WHERE "tickets"."id" = 1 LIMIT 1
@ruevaughn
ruevaughn / rake_routes.rb
Created April 6, 2012 20:52
output of rake routes for my rails app
resources :sites, except: [:new, :edit, :index, :show, :update, :destroy, :create] do
member do
get :home
get :about_us
get :faq
get :discounts
get :services
get :contact_us
get :admin
get :posts
@ruevaughn
ruevaughn / rake_routes.rb
Created April 6, 2012 20:56
Entire Rake File with rake routes output
Jensenlocksmithing::Application.routes.draw do
get "log_out" => "sessions#destroy", as: "log_out"
get "log_in" => "sessions#new", as: "log_in"
#scope "(:locale)", :defaults => { :locale => "en" } do
#scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
resources :sites, except: [:new, :edit, :index, :show, :update, :destroy, :create] do
member do
get :home
@ruevaughn
ruevaughn / rake_routes.rb
Created April 6, 2012 23:01
Rake Routes for locksmith
Jensenlocksmithing::Application.routes.draw do
get "log_out" => "sessions#destroy", as: "log_out"
get "log_in" => "sessions#new", as: "log_in"
get "sites/services"
scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
resources :sites, except: [:new, :edit, :index, :show, :update, :destroy, :create] do
collection do
get :home
get :about_us
@ruevaughn
ruevaughn / routes.rb
Created April 7, 2012 21:23
Rake Routes trying to match internationalization
Jensenlocksmithing::Application.routes.draw do
scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
get "log_out" => "sessions#destroy", as: "log_out"
get "log_in" => "sessions#new", as: "log_in"
resources :sites, except: [:new, :edit, :index, :show, :update, :destroy, :create] do
collection do
get :home
get :about_us
@ruevaughn
ruevaughn / categories_controller.rb
Created April 21, 2012 21:16
Implementing the SQL structured Nested Set gem, allowing for infinite nesting. This allows for drag and dropable lists.
class CategoriesController < ApplicationController
before_filter :add_breadcrumbs
before_filter :authorize, only: [:new, :create, :new_subcategory, :update, :edit]
def new
add_breadcrumb "New Category", new_category_path
@category = params[:id] ? Category.find(params[:id]).children.new : Category.new
@count = Category.count
end
def new_subcategory
@ruevaughn
ruevaughn / gist:3950150
Created October 25, 2012 02:42
Thanking Nick in Ruby
class ThankYou
def initialize(name, custom_message = nil)
@name = name
custom_message.nil? ? @custom_message = "Thank you" : @custom_message = custom_message
end
def greet
puts "#{@custom_message}, #{@name}"
end
defmodule Rumbl.Auth do
import Plug.Conn
import Comeonin.Bcrypt, only: [checkpw: 2, dummy_checkpw: 0]
def init(opts) do
Keyword.fetch!(opts, :repo)
end
def call(conn, repo) do
test "requires user authentication on all actions", %{conn: conn} do
Enum.each([
get(conn, video_path(conn, :new)),
get(conn, video_path(conn, :index)),
get(conn, video_path(conn, :show, "123")),
get(conn, video_path(conn, :edit, "123")),
put(conn, video_path(conn, :update, "123", %{})),
post(conn, video_path(conn, :create, %{})),
delete(conn, video_path(conn, :delete, "123")),
], fn conn ->
@ruevaughn
ruevaughn / coming_soon_multiple_args_kwargs.rb
Created July 13, 2018 23:27
As per our discussion at Verisys - Passing multiple arguments using a hash rather than listing them all out,
# Coming soon to a ruby script near you!