Skip to content

Instantly share code, notes, and snippets.

View stevecrozz's full-sized avatar

Stephen Crosby stevecrozz

View GitHub Profile
@stevecrozz
stevecrozz / object.rb
Last active December 14, 2015 02:39
RuntimeError: can't modify frozen hash In every one of these cases I've tracked down in the past, the error was in freezing an object that should not have been frozen. The backtrace telling you where the modification was attempted is often unhelpful. A snippet like this can help in a pinch to track down who froze your object.
class Object
attr_accessor :last_frozen_by
def freeze
@last_frozen_by = caller
super
end
end
/**
* OSSUARY: Your Backbone's final RESTing place
*/
/**
* create an Ossuary
*
* An Ossuary is for backbone collection management. You can add as many
* backbone collections as you'd like to an Ossuary. An Ossuary provides one
* simple interface for accessing data whether or not it has already been
@stevecrozz
stevecrozz / gist:10086528
Created April 8, 2014 03:13
sane sshd_config, no password auth
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
@stevecrozz
stevecrozz / site.rb
Created May 3, 2015 20:33
octopress-hooks-shim
module Octopress
module Hooks
class Site < Jekyll::Plugin
def self.inherited(subclass)
i = subclass.new
if i.respond_to? :reset
# now it's called after_reset
Jekyll::Hooks.register :site, :after_reset, &i.method(:reset)
end
-----BEGIN CERTIFICATE-----
MIIDLjCCAhagAwIBAgIBAjANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET
MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FudGEgQmFyYmFyYTETMBEG
A1UECgwKUmlnaHRTY2FsZTESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTE1MDUyMTIx
MzUzOFoXDTE3MDUyMDIxMzUzOFowHzEdMBsGA1UEAwwUbG9naW4ucmlnaHRzY2Fs
ZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDlyxaiBz4DyCgF
VlFZAJ+5B+T30EihdVDMACxpRqHa7CmZq275R59/J+Kqve+pApF74bNYmB34RBPf
3agVsX5j7M4naU6SlLDKLgohCamR4kETBj1Df2wMp68AzOuBRauesjl78LN/hWPM
b757bz5cSYYirSXOixDJVBZqiCyc6ueDZXFKv9RKRgubvq/fNFY7bb0Ia7LC4qWI
hNBf3PlNipG0Vtyi11Aq4lihBCp4Jm8YKOvtBdjiaGOmhPIPwcBnQVZ6i8APR7Ip
@stevecrozz
stevecrozz / parser.rb
Last active December 2, 2015 06:54
Query Syntax Parser
require 'pry'
class MagicBullshit
def self.inherited(subclass)
subclass.prepare
end
def self.prepare
@words = {}
end
@stevecrozz
stevecrozz / capistrano-bitbucket-tasks.rb
Created December 10, 2015 01:44
Capistrano Install deploy keys
ask :bitbucket_username, nil
ask :bitbucket_password, nil
set :bitbucket_deploy_key_path, '/home/ubuntu/.ssh/id_rsa.pub'
set :bitbucket_deploy_key_label, 'capistrano-bitbucket'
desc 'Generate SSH key pair'
task :generate_ssh_keys do
on roles(:all) do
execute '[ -f ~/.ssh/id_rsa ] || ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""'
end
# No good. Configuration options are bound to environment names
if ENV['RAILS_ENV'] == 'production' || ENV['RAILS_ENV'] =~ /integ|stage/
logger = RightSupport::Log::SystemLogger.new('my_service')
else
logger = Logger.new(STDOUT)
end
@stevecrozz
stevecrozz / config-newrelic.rb
Created February 26, 2016 19:49
Install newrelic capistrano task
ask(:newrelic_license_key, '')
desc 'Install newrelic-sysmond'
task :install_newrelic_sysmond do
on roles(:all) do
unless test("command -v nrsysmond-config >/dev/null 2>&1")
execute 'echo deb http://apt.newrelic.com/debian/ newrelic non-free | sudo tee /etc/apt/sources.list.d/newrelic.list'
execute 'curl --silent https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -'
sudo 'apt-get update'
sudo 'DEBIAN_FRONTEND=noninteractive apt-get install -y newrelic-sysmond'
#! /bin/bash
CONSUL_ENV_CMD=$(cat <<EOF
bundle exec cmdb shim --env \
--user www-data \
--consul-url=http://consul:8500 \
--consul-prefix ${RS_DEPLOYMENT_UNIT}/library \
--consul-prefix ${RS_DEPLOYMENT_UNIT}/common
EOF