Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Michael Grosser grosser

🎯
Focusing
View GitHub Profile
View gist:17697
ActionController::Routing::Routes.draw do |map|
map.root :controller => 'homepage',:action=>'start'
map.signup '/signup', :controller => "users", :action => "new"
map.login '/login', :controller => "sessions", :action => "new"
map.logout '/logout', :controller => "sessions", :action => "destroy"
map.feedback '/feedback', :controller => "messages", :action => "feedback"
#user special
map.change_password '/change_password/:email_token', :controller => "users", :action => "change_password", :email_token => nil
View tasks_controller.rb
class TasksController < ApplicationController
make_resourceful do
actions :all
response_for :create_failed do |format|
format.html { redirect_to project_url(@task.project)}
end
end
protected
View gist:170853
config.after_initialize do
#CACHE
MEMCACHE_SERVER = case RAILS_ENV
when 'development' then 'localhost:11211'
when 'staging' then '127.0.0.1:11211'
when 'production' then '192.168.2.26:11211'
when 'test' then nil
else raise
end
View gist:189079
Controller:
before_filter :can_create, :only=>%w[new create]
before_filter :can_write, :only=>%w[edit update destroy]
before_filter :can_read, :only=>%w[show]
protected
def can_create
can_do(:create)
end
View README.markdown

Ever wondered how much who adds/removes, its time to find out :D (those are real stats, i just obfuscated the names )

###Results

Git scores (in LOC):
mr-add              :  +482273       -9466
justu               :  +286250       -159905
grosser             :  +152384       -323344
another             :  +121257       -82116
View README.markdown

Ever wondered how much who adds/removes, its time to find out :D (those are real stats, i just obfuscated the names )

###Results

Git scores (in LOC):
mr-add              :  +482273       -9466
justu               :  +286250       -159905
grosser             :  +152384       -323344
another             :  +121257       -82116
View gist:413433
#! /bin/sh
# start / stop script for mongodb
### BEGIN INIT INFO
# Provides: mongod
# Required-Start: \$remote_fs \$syslog
# Required-Stop: \$remote_fs \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
View find_values.rb
# Tag.find_values(:select => :user_id, :limit => 30) --> ["1", "3", "6"]
# Tag.find_values(:select => 'user_id, foobar', :limit => 30, :all=>true) --> [["1","A"], ["3","B"], ["6","C"]]
class ActiveRecord::Base
def self.find_values(options)
sql = self.send(:construct_finder_sql, options.except(:all))
result = connection.select_rows(sql, name)
if options[:all]
result
else
result.map{|v| v[0] }
View Readme.md

Sinatra

ruby 1.9.2 + async_sinatra + thin thin start

ab -n 10000 -c 100 http://localhost:3000/
-> 49ms / request

Node

node server.js