View benchmark_methods.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark/memory" | |
class A | |
def self.class_method | |
puts 'hello' | |
end | |
def instance_method | |
puts 'hello' | |
end | |
end |
View events_helper_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventsHelperTest < ActionView::TestCase | |
def setup | |
country = Country.create(name: 'Belarus') | |
state = State.create(name: 'Minsk') | |
@event = Event.create(country: country, state: state, name: 'Drinking bear') | |
end | |
def test_url_for | |
n = 10000 | |
Benchmark.bmbm do |x| |
View .tmux.clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# configuration for osx clipboard support | |
set-option -g default-command "reattach-to-user-namespace -l sh" |
View gist:6445658
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#street").select2 | |
minimumInputLength: 1 | |
ajax: | |
url: 'http://kladr-api.ru/api.php' | |
dataType: 'jsonp' | |
data: (term, page) -> | |
token: 'token' | |
key: 'key' | |
cityId: 'cityId' | |
query: term |
View Install_tmux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First install tmux | |
brew install tmux | |
# For mouse support (for switching panes and windows) | |
# Only needed if you are using Terminal.app (iTerm has mouse support) | |
Install http://www.culater.net/software/SIMBL/SIMBL.php | |
Then install https://bitheap.org/mouseterm/ | |
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/ |
View gist:6130212
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
end | |
# app/controllers/dashboard/application_controller.rb | |
module Dashboard | |
class ApplicationController < ::ApplicationController | |
before_filter :authenticate_user! | |
end |
View gist:6130213
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
end | |
# app/controllers/dashboard/application_controller.rb | |
module Dashboard | |
class ApplicationController < ::ApplicationController | |
before_filter :authenticate_user! | |
end |
View gist:5895283
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/constraints/photo_constraint.rb | |
class PhotoConstraint | |
def initialize | |
@types = Photo::TYPES | |
end | |
def self.matches?(request) | |
@types.include?(request.path_parameters[:type]) | |
end | |
end |
View mongo_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db("so_test") | |
end | |
class Client | |
include Mongoid::Document | |
belongs_to :contact | |
field :name, type: String |
View 0. nginx_setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nginx+Unicorn best-practices congifuration guide. Now with SPDY! | |
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies. | |
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module | |
# | |
# Deployment structure | |
# | |
# SERVER: | |
# /etc/init.d/nginx (1. nginx) | |
# /home/app/public_html/app_production/current (Capistrano directory) | |
# |
NewerOlder