Skip to content

Instantly share code, notes, and snippets.

View bscott's full-sized avatar
🏠

Brian Scott bscott

🏠
View GitHub Profile
@bscott
bscott / chef.js
Created November 4, 2013 16:53
http://localhost:8081/chef?type=json
app.get('/chef', function(req, res) {
var conf = appUtil.parseConfig();
appUtil.getChefNodes(function(result) {
if (req.query.type && (req.query.type == 'xml')) {
res.set('Content-Type', 'text/xml');
res.render('xml.ejs', {baseUrl: 'http://localhost:8080', user: conf['chef']['node_name'], org: conf['chef']['organization'], nodeItems:result});
} else if (req.query.type == 'json') {
res.set('Content-Type', 'application/json');
res.json('nodeItems:result');
} else {
@bscott
bscott / ridley.rb
Created November 19, 2013 20:58
Ridley
ridley.data_bag.find("listsvc").find("DEV"){ |dbi| dbi["0"]["deploy"] = true; dbi.save }
data_bag = ridley.data_bag.find("listsvc")
data_bag_item = data_bag.item.find("DEV")
data_bag_item["0"]["deploy"] = true
data_bag_item.save
@bscott
bscott / GIT_SSH.sh
Created December 11, 2013 19:03
GIT_SSH env var
!/bin/bash
ssh -i /home/deploy/.ssh/id_rsa $1 $2
@bscott
bscott / martini.go
Created December 27, 2013 09:09
Martini Go Webframework
package main
import "github.com/codegangsta/martini"
func main() {
m := martini.Classic()
m.Get("/", func() string {
return "Hello world!"
})
m.Run()

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)
@bscott
bscott / hab-install.sh
Last active June 22, 2016 04:37
hab-install.sh
#!/bin/sh
# Fails on unset variables & whenever a command returns a non-zero exit code.
set -eu
# If the variable `$DEBUG` is set, then print the shell commands as we execute.
if [ -n "${DEBUG:-}" ]; then set -x; fi
# Download URL for a `core/hab` Habitat slim archive
_url='https://api.bintray.com/content/habitat/stable/linux/x86_64/hab-$latest-x86_64-linux.tar.gz'
_q="?bt_package=hab-x86_64-linux"
@bscott
bscott / CToGoString.go
Created April 27, 2017 15:52
ByteArrayToString
func CToGoString(c []byte) string {
n := -1
for i, b := range c {
if b == 0 {
break
}
n = i
}
return string(c[:n+1])