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
# Add your own tasks in files placed in lib/tasks ending in .rake, | |
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | |
require File.expand_path('../config/application', __FILE__) | |
Dontspreadit::Application.load_tasks | |
begin | |
require 'rspec/core/rake_task' | |
Rake::Task['default'].clear |
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 FakeSchema | |
attr_reader :defs, :diff | |
def self.define(*, &block) | |
$schema = new | |
$schema.instance_eval(&block) | |
end | |
def initialize | |
@defs = {} |
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 'fileutils' | |
class ProcessRunner | |
PIDFILE_MODE = (::File::CREAT | ::File::EXCL | ::File::WRONLY) | |
LOG_DIR_MODE = 0o0755 | |
LOG_FILE_MODE = 0o0644 | |
attr_reader :name, :pidfile, :logfile | |
def initialize(opts = {}) |
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
#!/usr/bin/env ruby | |
# Installs the latest version of a gem to the "vendor/gems" directory, which can be referenced from the Gemfile | |
# Expects the gem to be in the "vendor/gems" directory | |
# | |
# @usage Sudo is used because it writes to a directories in "vendor/gems" | |
# | |
# sudo ruby script/unpack <gem> | |
# | |
require 'pathname' |
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:/tmp/unicorn.prism.sock fail_timeout=0; | |
} | |
server { | |
listen 8081; | |
server_name localhost; | |
location / { | |
root /Users/rbuckley/apps/prism/public; |
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
$ rspec-scaffold lib/app.rb | |
/Users/rbuckley/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/fileutils.rb:252:in `mkdir': Permission denied @ dir_s_mkdir - /lib (Errno::EACCES) | |
from /Users/rbuckley/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/fileutils.rb:252:in `fu_mkdir' | |
from /Users/rbuckley/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/fileutils.rb:226:in `block (2 levels) in mkdir_p' | |
from /Users/rbuckley/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/fileutils.rb:224:in `reverse_each' | |
from /Users/rbuckley/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/fileutils.rb:224:in `block in mkdir_p' | |
from /Users/rbuckley/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/fileutils.rb:210:in `each' | |
from /Users/rbuckley/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/fileutils.rb:210:in `mkdir_p' | |
from /Users/rbuckley/apps/gems/rspec-scaffold/lib/rspec/scaffold/file_writer.rb:20:in `write!' | |
from /Users/rbuckley/apps/gems/rspec-scaffold/lib/rspec/scaffold.rb:44:in `testify_file' |
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
# @usage Start and stop a ruby process that just logs to a file every couple seconds, but can be interrupted gracefully | |
# | |
# ruby script/wb | |
# kill -INT `cat tmp/pids/wb.pid` | |
# | |
require "logger" | |
require "fileutils" | |
PID_FILE = File.expand_path("../../tmp/pids/wb.pid", __FILE__) | |
LOG_FILE = File.expand_path("../../log/wb.log", __FILE__) |
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
# This file can be required from "config/unicorn.rb" so the thread will run alongside the master process | |
# This will kill any rogue memory-greedy unicorn processes | |
unicorn_worker_memory_limit = 220_000 | |
Thread.new do | |
loop do | |
begin | |
lines = `ps -e -www -o pid,rss,command | grep '[u]nicorn_rails worker'`.split("\n") | |
lines.each do |line| | |
parts = line.split(' ') |
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
module VersionableApi | |
def self.extended(base) | |
base.class_eval do | |
def call_versioned_method(name) | |
VersionableApi.controllers[self.class].call_action(self, name) | |
end | |
end | |
end | |
class << self |
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
module Usable | |
def config | |
@config ||= Config.new | |
end | |
def use(mod, options = {}) | |
send :include, mod unless self < mod | |
if block_given? | |
yield config | |
else |
NewerOlder