Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Owens intjonathan

View GitHub Profile
View usage example
>> puts `zip -h`
Copyright (c) 1990-2006 Info-ZIP - Type 'zip "-L"' for software license.
Zip 2.32 (June 19th 2006). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
The default action is to add or replace zipfile entries from list, which
can include the special name - to compress standard input.
If zipfile and list are omitted, zip compresses stdin to stdout.
-f freshen: only changed files -u update: only changed or new files
-d delete entries in zipfile -m move into zipfile (delete files)
-r recurse into directories -j junk (don't record) directory names
View create_story_table.rb
class CreateStoryTable < ActiveRecord::Migration
def self.up
create_table :stories do |t|
t.string :title
t.integer :journal_id
t.integer :user_id
t.integer :account_id
t.timestamps
end
View add_stories_count_to_journals.rb
class AddStoriesCountToJournals < ActiveRecord::Migration
def self.up
add_column :journals, :stories_count, :integer
end
def self.down
remove_column :journals, :stories_count
end
end
View gist:2589851
<item>
<title>[caution] - Memory &gt; 80%</title>
<link>https://rpm.newrelic.comhttps://rpm.newrelic.com/accounts/68507/servers/748391?tw%5Bdur%5D=last_3_hours&amp;tw%5Bend%5D=1335834058</link>
<pubDate>Mon, 30 Apr 2012 22:43:28 +0000</pubDate>
</item>
<item>
<title>[caution] - Memory &gt; 80%</title>
<link>https://rpm.newrelic.comhttps://rpm.newrelic.com/accounts/68507/servers/748391?tw%5Bdur%5D=last_3_hours&amp;tw%5Bend%5D=1335746488</link>
<pubDate>Sun, 29 Apr 2012 21:57:28 +0000</pubDate>
</item>
@intjonathan
intjonathan / pre-commit.sh
Created Sep 7, 2012
pre-commit hook (add to .git/hooks/pre-commit) to refuse to commit debugger strings
View pre-commit.sh
#!/bin/sh
# Refuse to commit files with the string NOCOMMIT, debugger, or merge markers present.
#
files=$(git diff-index --name-status --cached HEAD | grep -v ^D | cut -c3-)
if [ "$files" != "" ]
then
for f in $files
do
@intjonathan
intjonathan / pagerduty-ring-through.js
Created Sep 8, 2012
on{x} recipe to make pagerduty texts always play ringtone, then play annoying sound every minute until unlocked
View pagerduty-ring-through.js
// =====================================================================
// Crank up the volume and play an annoying sound every minute when you
// get a text from PagerDuty. Put things back when you unlock the screen.
// @intjonathan
// =====================================================================
var strVersion = 'v0.3';
var lngInterval = 1*60*1000; // 1 minute
var strAlarmFilePath = "file:///mnt/sdcard/Music/Ringer.mp3";
@intjonathan
intjonathan / gist:7254263
Last active Dec 27, 2015
puppetdb with newer postgres
View gist:7254263
class { "postgresql::globals":
version => '9.3',
manage_package_repo => true,
}
# This installs postgres for you
class { '::puppetdb':
database_password => hiera('profile::puppetdb::pg_puppetdb_password'),
java_args => {'-Xmx' => '2g', '-Xms' => '2g'},
}
View pe-3-agent-upgrade.sh
#!/bin/bash
pushd .
cd /tmp/
# Remove PE 2.6.1
curl -o /tmp/pe26.tar.gz "http://chi-boss.newrelic.com/pe-installer/puppet-enterprise-2.6.1-el-6-x86_64.tar.gz"
tar xzf /tmp/pe26.tar.gz
sudo /tmp/puppet-enterprise-2.6.1-el-6-x86_64/puppet-enterprise-uninstaller -p -y
@intjonathan
intjonathan / upgrade-nodes-pe3.sh
Created Dec 3, 2013
Pass a list of FQDNs and it'll nuke PE2 and install PE3.1
View upgrade-nodes-pe3.sh
#!/bin/bash
for host in "$@"; do
echo "Doing $host"
ssh -tt "${host}" 'curl https://gist.github.com/intjonathan/7663914/raw/17e2638f5db32db2c2d8d7dea80c4c1f8ac09847/pe-3-agent-upgrade.sh | bash'
ssh -tt chi-ops-provision-1 "sudo puppet node deactivate ${host}; sudo puppet cert clean ${host}"
done
@intjonathan
intjonathan / nagiosdb.rb
Last active Aug 29, 2015 — forked from jfryman/nagiosdb.rb
Update nagios configuration from puppetdb using stock puppet nagios_ resources.
View nagiosdb.rb
#!/usr/bin/env ruby
#
# Nagios/PuppetDB config generator
# https://gist.github.com/jfryman/6290985
#
# Based on concept from puppetdb-external-naginator
# https://github.com/favoretti/puppetdb-external-naginator
#
# Generates nagios configs from puppet(db) exported resources.
#
You can’t perform that action at this time.