Skip to content

Instantly share code, notes, and snippets.

View bscott's full-sized avatar
🏠
Working from home

Brian Scott bscott

🏠
Working from home
View GitHub Profile

This gist is the source code for http://gary.beagledreams.com/page/go-websocket-chat.html

Copyright (c) 2013 Gary Burd

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@bscott
bscott / cpu_watch
Last active August 29, 2015 14:04
CPU_Watcher
#!/bin/bash
while [ 1 ];
do
echo
echo checking for run-away process ...
CPU_USAGE=$(uptime | cut -d"," -f4 | cut -d":" -f2 | cut -d" " -f2 | sed -e "s/\.//g")
CPU_USAGE_THRESHOLD=900
PROCESS=$(ps -eLf)
TOPPROCESS=$(ps -eLf | grep "livemerge" | ps -eo pid -eo pcpu -eo command | sort -k 2 -r | grep -v PID | head -n 1)
# TODO, make this more dynamic
region = node[:domain]
ext_ip = node[:cloud_v2][:public_ipv4]
ext_ip = ext_ip.gsub!(".",",")
if region.include?("us")
osp_public_queue_name = "osp_US_public_queue"
elsif region.include?("ap")
osp_public_queue_name = "osp_AP_public_queue"
elsif region.include?("eu")
@bscott
bscott / chef_provisioning
Created April 19, 2015 01:07
chef_provision with chefdk 0.4.0
Running handlers:
[2015-04-18T18:04:26-07:00] ERROR: Running exception handlers
Running handlers complete
[2015-04-18T18:04:26-07:00] ERROR: Exception handlers complete
[2015-04-18T18:04:26-07:00] FATAL: Stacktrace dumped to /Users/bscott/Development/oncam/chef_provisioner/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 3.899676 seconds
[2015-04-18T18:04:26-07:00] ERROR: Unable to activate cheffish-1.1.2, because chef-zero-3.2.1 conflicts with chef-zero (~> 4.0)
heroku config --long | ruby -pe "\$_ = \$_.gsub(/(\w+)\s+=> (.+)/, 'export \1=\2')" > /tmp/$$ && source /tmp/$$; rm /tmp/$$
@bscott
bscott / Redis-Installer.sh
Created April 28, 2011 19:38
Redis Installer Script
curl http://redis.googlecode.com/files/redis-2.0.4.tar.gz | tar zx
cd redis-2.0.4
make
sudo cp redis-server /usr/local/sbin
sudo cp redis-cli /usr/local/bin
sudo mkdir /var/lib/redis /etc/redis
sudo sed -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel debug$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf
curl -G https://gist.github.com/gists/257849/download | tar -zxO > redis-server
chmod u+x redis-server
mv redis-server /etc/init.d
@bscott
bscott / Redis-Installer.sh
Created November 9, 2011 18:38
Redis Installer Script
curl http://redis.googlecode.com/files/redis-2.4.2.tar.gz | tar zx
cd redis-2.4.2
make
sudo cp redis-server /usr/local/sbin
sudo cp redis-cli /usr/local/bin
sudo mkdir /var/lib/redis /etc/redis
sudo sed -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel debug$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf
curl -G https://gist.github.com/gists/257849/download | tar -zxO > redis-server
chmod u+x redis-server
mv redis-server /etc/init.d
@bscott
bscott / nagios stage
Created December 28, 2011 21:16
nagios_stage
class nagios {
include nagios::install, nagios::config, nagios::service
}
class cleanup {
tidy { "/etc/nagios3/hosts.d/"
}
}
import "definitions/*.pp"
class munin {}
class cleanup {
exec { "rm -rf /etc/munin/munin-conf.d/*" }
}
import "definitions/*.pp"
@bscott
bscott / storage.rb
Created January 13, 2012 17:06
def_items
def items
@lists.collect(&:items).flatten
end