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
$ heroku pg:cachehit --remote production | |
name | ratio | |
----------------+------------------------ | |
index hit rate | 0.99929808820146663449 | |
cache hit rate | 1.00 |
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
# Requires Ruby 1.9 and OS X | |
# The letters in your game... include repeats | |
game_letters = %w() | |
# Words that have been played already | |
played = %w() | |
def to_hash(letters) | |
letters.inject({}) do |h,l| | |
h[l] ||= 0 |
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
heroku pgbackups:capture --remote production && heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging |
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
# set backup interval | |
# cron_hour = if node[:backup_interval].to_s == '24' | |
# "1" # 0100 Pacific, per support's request | |
# # NB: Instances run in the Pacific (Los Angeles) timezone | |
# elsif node[:backup_interval] | |
# "*/#{node[:backup_interval]}" | |
# else | |
# "1" | |
# 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
module ApplicationHelper | |
def md(text) | |
text = text || '' | |
# in very clear cases, let newlines become <br /> tags | |
text.gsub!(/^[\w\"\<][^\n]*\n+/) do |x| | |
x =~ /\n{2}/ ? x : (x.strip!; x << " \n") | |
end | |
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, space_after_headers: true) | |
markdown.render(text).html_safe | |
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
# Uses https://github.com/brandonaaron/jquery-mousewheel | |
fixScrolling: (elem) -> | |
$('body').on 'mousewheel', elem, (e, d) -> | |
$elem = $(elem) | |
height = $elem.height() | |
scrollHeight = $elem.get(0).scrollHeight | |
if (d < 0 && (this.scrollTop is (scrollHeight - height)) || (d > 0 && this.scrollTop is 0)) | |
e.preventDefault() |
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 'open-uri' | |
require 'securerandom' | |
url = 'http://bntp-production.imgix.net/uploads/photos/file/14/4a902ce7e2.jpg' | |
file = open(url) | |
puts file.class | |
# at this point you can read from it and use it just like | |
# the file you read from disk |
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 'net/https' | |
require 'uri' | |
class RunDMS | |
def self.snitch(id, options={}, &block) | |
dead_man = new(id, options) | |
block.call | |
dead_man.snitch | |
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
module HandleFunkyFormats | |
extend ActiveSupport::Concern | |
included do | |
rescue_from ActionView::MissingTemplate do | |
if params[:format] | |
redirect_to format: nil | |
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
module Griddler | |
class Address | |
def initialize(address) | |
@address = address | |
end | |
def some_method_name(type=:hash) | |
if type == :hash | |
parsed_address | |
else |