Skip to content

Instantly share code, notes, and snippets.

View danhigham's full-sized avatar

Dan Higham danhigham

  • ZScaler
  • Portland, OR
View GitHub Profile
@danhigham
danhigham / app.js
Created November 22, 2013 16:13
Faye server in a Gist!
var http = require('http'),
faye = require('faye');
var server = http.createServer(),
bayeux = new faye.NodeAdapter({mount: '/'});
bayeux.attach(server);
server.listen(process.env.PORT);
@danhigham
danhigham / remote_shell_agent.rake
Last active December 29, 2015 02:49
Rake task to communicate with a faye server and provide connectivity to it's application container
namespace :remote_shell_agent do
module Faye
class Transport::Http < Transport
def request(envelopes)
content = encode(envelopes)
params = build_params(@endpoint, content)
request = create_request(params)
@danhigham
danhigham / Gemfile
Last active December 29, 2015 18:09
Download a mixcloud stream!
source 'http://rubygems.org'
gem 'httparty'
gem 'nokogiri'
@danhigham
danhigham / dvdrip.bash
Last active December 31, 2015 03:09
Bash script to sit in a loop and continuously rip vobs from a DVD. When it's done a disk it sends a notification email, ejects the draw and waits for another disc.
#!/usr/bin/env bash
SUBJECT="DVD is done ripping"
EMAIL="email@gmail.com"
EMAILMESSAGE="./emailmessage.txt"
while [ 1 ]
do
echo "Waiting for new disk.."
@danhigham
danhigham / console-server.go
Last active August 29, 2015 13:56
Proxying server for Cloud Foundry that also provides a web console for the application container
package main
import (
"bufio"
"code.google.com/p/go.net/websocket"
"github.com/kr/pty"
"io"
"flag"
"fmt"
"log"
@danhigham
danhigham / get_service.rb
Last active August 29, 2015 14:00
Retrieve service details from CF
#!/usr/bin/env ruby
require 'cfoundry'
require 'json'
endpoint = 'https://api.run.pivotal.io'
app_name = 'my_app'
client = CFoundry::Client.get endpoint
client.login :username=> ENV['cf_user'], :password => ENV['cf_pass']
@danhigham
danhigham / Gemfile
Created May 29, 2014 23:45
Simple rack app to show headers in a get request.
source 'https://rubygems.org'
gem 'rack'
@danhigham
danhigham / bucket_sync.rb
Created February 6, 2015 23:51
Script to sync files between Riak CS buckets bound to a CF app to a single S3 account
#!/usr/bin/env ruby
require 'json'
require 'uri'
require 'bundler'
require 'fog'
Bundler.require
Excon.defaults[:ssl_verify_peer] = false
@danhigham
danhigham / play_mixcloud.rb
Last active August 29, 2015 14:20
Stream mixcloud mixes directly to MPlayer (requires nokogiri and mplayer)
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'net/http'
require 'uri'
require 'fileutils'
server_range = (13..20)
@danhigham
danhigham / shutdown_vms_in_rp.rb
Last active August 29, 2015 14:21
Shutdown and destroy all VMs in a resource pool
#!/usr/bin/env ruby
require 'rbvmomi'
vcenter_host = ARGV[0]
username = ARGV[1]
password = ARGV[2]
dc_name = ARGV[3]
rp_name = ARGV[4]