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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
layout Proc.new { |controller| controller.request.xhr? ? 'ajax' : 'test' } | |
end |
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 Array | |
def splice(start, len, *replace) | |
self[start, len] = replace | |
self | |
end | |
end | |
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) |
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
# @topic = Topic.new(params[: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 != this_user.id; |
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 "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] |
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
namespace :routes do | |
desc "Writes doc/routes.html. Requires Graphviz (dot)" | |
task :visualizer => :environment do | |
File.open(Rails.root.join('doc', 'routes.html'), 'wb') do |f| | |
f.write Rails.application.routes.router.visualizer | |
end | |
end | |
end |
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
gem 'sidekiq' | |
gem 'octokit' |
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
upstream app { | |
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name www.app.com; | |
rewrite ^/(.*) http://app.com/$1 permanent; | |
} | |
server { |
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
{"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 |
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
cap staging foreman:setup | |
DEBUG [b77dc6fe] Running ~/.rvm/bin/rvm version on 162.243.255.230 | |
DEBUG [b77dc6fe] Command: ~/.rvm/bin/rvm version | |
DEBUG [b77dc6fe] | |
DEBUG [b77dc6fe] rvm 1.25.25 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] | |
DEBUG [b77dc6fe] | |
DEBUG [b77dc6fe] Finished in 2.093 seconds with exit status 0 (successful). | |
rvm 1.25.25 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] | |
DEBUG [9b4d75a0] Running ~/.rvm/bin/rvm current on 162.243.255.230 |
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 'oj' | |
# Macro in model: | |
# serialize :payload, ActiveSupport::OJSON | |
# | |
# payload is a text data type in postgres | |
# | |
module ActiveSupport | |
module OJSON | |
class << self |