Skip to content

Instantly share code, notes, and snippets.

@svs
svs / foos2.rb
Last active December 21, 2015 19:29
module FoosController
class Index < ControllerAction
def get
@foos = Foo.all
succeed_with(FooPresenter.new(@foos).to(format)) # if you want more control over presentation, hand off to the presenter
end
end # Index
class Create < ControllerAction
def post
class FoosController < ApplicationController
def index
###
end
def show
###
end
require 'active_support/core_ext/string/inflections'
class Router
attr_reader :env, :route
def initialize(routes, env)
@env = env
@routes = routes
end
class ChessApp
def self.routes
@routes ||= ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
resources :games, :only => [:index, :create, :show, :update]
end
end
end
@svs
svs / gist:6354584
Created August 27, 2013 14:51
actiondispatch
@routes ||= ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
resources :games, :only => [:index, :create, :show, :update]
end
end
@routes.recognize_path("/games", {:method => 'GET'}) # => {:action => "index", :controller => "games"}
@svs
svs / gist:6065669
Last active December 20, 2015 03:39
$git log --grep "help me"
(END)
$git log --grep "save me"
(END)
flog app/controllers | head -10 rvm:ruby-2.0.0-p195
6097.5: flog total
23.8: flog/method average
438.8: AController#overall
311.8: Ad::IQController#create
226.7: AController#level_meter
204.9: QController#topic_level_selector
168.2: M::ApiController#flip
140.2: TController#index
$ wc -l spec/**/*.rb | sort -r | head -10
zsh: no matches found: spec/**/*.rb
@svs
svs / wc
Last active December 19, 2015 11:18
$ wc -l **/*.rb | sort -r | head -10
7104 total
720 models/question.rb
468 controllers/god_controller.rb
407 controllers/analytics_controller.rb
382 controllers/admin/god_controller.rb
258 models/user.rb
252 controllers/mobile/api_controller.rb
167 controllers/admin/foo_controller.rb
140 models/quux.rb
require 'mechanize'
a = Mechanize.new
results = {}
last_id = 647
(1..last_id).map do |id|
begin
page = a.get("http://cfp.euruko2013.org/users/#{id}/selections")
d = page.