Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Claudio Poli masterkain

I may be slow to respond.
Block or report user

Report or block masterkain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:3920f630e42d2aa318ca
-- drop_table(:users)
-> 0.0156s
-- create_table(:users)
-> 0.0034s
-- add_index(:users, :preferences, {:using=>:gin})
-> 0.0040s
-- initialize_schema_migrations_table()
-> 0.0207s
#=> Ruby 2.2.0
#=> ActiveRecord 4.2.0
masterkain / gist:a192c5982f5c46f80ebd
Created Feb 21, 2015
custom rails json dump load class
View gist:a192c5982f5c46f80ebd
require 'oj'
# Macro in model:
# serialize :payload, ActiveSupport::OJSON
# payload is a text data type in postgres
module ActiveSupport
module OJSON
class << self
View gist:f4ada8799b81667229e4
cap staging foreman:setup
DEBUG [b77dc6fe] Running ~/.rvm/bin/rvm version on
DEBUG [b77dc6fe] Command: ~/.rvm/bin/rvm version
DEBUG [b77dc6fe]
DEBUG [b77dc6fe] rvm 1.25.25 (master) by Wayne E. Seguin <>, Michal Papis <> []
DEBUG [b77dc6fe]
DEBUG [b77dc6fe] Finished in 2.093 seconds with exit status 0 (successful).
rvm 1.25.25 (master) by Wayne E. Seguin <>, Michal Papis <> []
DEBUG [9b4d75a0] Running ~/.rvm/bin/rvm current on
View gist:3229234
{"item_photo":{"item_id":"10","content_type":"image/jpeg","original_filename":"test.jpg","photo_data":"/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABQAAD/4QNxaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENl aGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4 OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MSA2NC4xNDA5NDksIDIwMTAvMTIvMDctMTA6 NTc6MDEgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5 OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHht bG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0i aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1w PSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9 InhtcC5kaWQ6MDM4MDExNzQwNzIwNjgxMTk1RkVBNDIxMDE4OTQzMTUiIHhtcE1NOkRvY3VtZW50 SUQ9InhtcC5kaWQ6OEVBNjU2ODU2OUE3MTFFMTlDMDQ4RDBGMTVBOUYwMkYiIHhtcE1NOkluc3Rh bmNlSUQ9InhtcC5paWQ6OEVBNjU2ODQ2OUE3MTFFMTlDMDQ4RDBGMTVBOUYwMkYiIHhtcDpDcmV
masterkain / nginx_rails_3_1
Created Apr 17, 2012 — forked from shapeshed/nginx_rails_3_1
Nginx Config for Rails 3.1 with Unicorn and Asset Pipeline
View nginx_rails_3_1
upstream app {
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0;
server {
listen 80;
rewrite ^/(.*)$1 permanent;
server {
masterkain / Gemfile
Created Mar 1, 2012
Sidekiq GitHub issue reporter
View Gemfile
gem 'sidekiq'
gem 'octokit'
masterkain / routes.rake
Created Jan 7, 2012
Journey + Graphviz
View routes.rake
namespace :routes do
desc "Writes doc/routes.html. Requires Graphviz (dot)"
task :visualizer => :environment do'doc', 'routes.html'), 'wb') do |f|
f.write Rails.application.routes.router.visualizer
View gist:1129946
require "resque"
require "resque/failure/multiple"
require "resque/failure/redis"
# Configure Resque connection from config/redis.yml. This file should look
# something like:
# development: localhost:6379
# test: localhost:6379:15
# production: localhost:6379
Resque.redis = YAML.load_file(Rails.root + 'config/redis.yml')[Rails.env]
View topic.rb
# @topic =[:topic])
# @topic.this_user = current_user
class Topic < ActiveRecord::Base
belongs_to :user
attr_accessor :this_user
def validate_on_update
# Make sure that this_user is an instance of User, otherwise just use the id
errors.add(:user, "Only the topic creator can update the topic") if user_id !=;
View array.rb
class Array
def splice(start, len, *replace)
self[start, len] = replace
ruby-1.8.7-p352 :008 > initial_array = [:a, :c, :h, :g, :t, :m]
=> [:a, :c, :h, :g, :t, :m]
ruby-1.8.7-p352 :009 > initial_array.splice(2, 2, :test)
You can’t perform that action at this time.