Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 10:20 (UTC -07:00)
View GitHub Profile
@codeprimate
codeprimate / deploy.rb
Created July 3, 2013 16:29
Rolling deploy task for Capistrano.
#...
set :rolling_deploy_wait, 60
# Rolling restart of application servers
task :restart, :roles => [:app], :except => {:no_release => true}, :once => true do
servers = find_servers_for_task(current_task)
servers.each_with_index do |s, index|
run "sleep #{index * rolling_deploy_wait}; \
touch #{File.join(current_path,'tmp','restart.txt')}; \
@codeprimate
codeprimate / monit-denyhosts.conf
Created July 1, 2013 17:53
Monit DenyHosts configuration for Ubuntu
# Monit DenyHosts configuration for Ubuntu
check process denyhosts with pidfile /run/denyhosts.pid
start program = "/etc/init.d/denyhosts start"
stop program = "/etc/init.d/denyhosts stop"
if cpu > 90% for 2 cycles then alert
check file denyhosts.conf
with path /etc/denyhosts.conf
if changed checksum then alert
class Conference
FIELDS = [:name, :theme, :training, :conference, :location]
FIELDS.each do |f|
class_eval do
define_method f.to_s do |arg|
instance_variable_set "@#{f}", arg
end
end
end
# Forked to get it working with Rails 3 and RSpec 2
#
# From http://github.com/jaymcgavren
#
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
#
# Use rcov:rspec or rcov:cucumber
# to get non-aggregated coverage reports for rspec or cucumber separately
@codeprimate
codeprimate / capybara_element_hover.rb
Created April 1, 2013 02:23
Capybara Hover Method
module Capybara
module Node
class Element
def hover
@session.driver.browser.action.move_to(self.native).perform
end
end
end
end
@codeprimate
codeprimate / targpg.sh
Created March 4, 2013 00:06
Compress and encrypt with pipes
#!/bin/bash
# Requires tar and gpg
#
tar cpj | gpg -c > Files.tbz.gpg
From 83f158c6970cf31d0036424fc5abf5a1d158dd6d Mon Sep 17 00:00:00 2001
From: Michael Koziarski <[email protected]>
Date: Thu, 24 Jan 2013 09:33:37 +1300
Subject: [PATCH] Add an OkJson backend
Fixes CVE-2013-XXXX
---
.../lib/active_support/json/backends/okjson.rb | 641 ++++++++++++++++++++
.../lib/active_support/json/backends/yaml.rb | 1 +
activesupport/lib/active_support/json/decoding.rb | 2 +-
@codeprimate
codeprimate / ec2.env.sh
Last active December 10, 2015 17:58
OSX ec2-tools setup for a minecraft server
#!/bin/bash
# OSX ec2-tools setup for a minecraft server
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"
export EC2_PRIVATE_KEY=~/.ec2/pk-$EC2_KEYHASH.pem
export EC2_CERT=~/.ec2/cert-$EC2_KEYHASH.pem
export EC2_HOME=/Users/$USER/bin/ec2-tools
export EC2_AMITOOL_HOME=/Users/$USER/bin/ec2-tools
export EC2_PRIVATE_KEY=/Users/$USER/.ec2/pk-$EC2_KEYHASH.pem
@codeprimate
codeprimate / gist:4390600
Created December 27, 2012 18:22
Example SysV init script for a java application From: http://zerocool.is-a-geek.net/?p=139
#!/bin/sh
### BEGIN INIT INFO
# Provides: vsftpdg
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop vsftpdg server
### END INIT INFO
@codeprimate
codeprimate / gist:4356031
Last active December 10, 2015 01:08
Fix "boxes" command installed by Brew
# This will correct the error: "boxes: can't find config file"
sudo ln -s /usr/local/Cellar/boxes/1.1/share/boxes-config /usr/share/boxes