Skip to content

Instantly share code, notes, and snippets.

View danhigham's full-sized avatar

Dan Higham danhigham

View GitHub Profile
@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]
@danhigham
danhigham / ZIP-PDFdownloader.rb
Created January 15, 2011 15:03
Downloads files from a page if they are pdf or zip!
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'hpricot'
doc = Hpricot(open('http://www.stanford.edu/class/cs193p/cgi-bin/drupal/downloads-2010-winter'))
(doc/"a").each do |x|
@danhigham
danhigham / scrape_it.rb
Created April 21, 2011 11:38
Hpricot script to extract sunrise and sunset dates from http://www.timeanddate.com/worldclock/astronomy.html
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'hpricot'
doc = Hpricot(open("http://www.timeanddate.com/worldclock/astronomy.html?n=136&month=12&year=2010&obj=sun&afl=-11&day=1"))
sunrise_rows = (doc/"table.spad tr")
@danhigham
danhigham / rubyconfvids.rb
Created May 22, 2011 08:03
Script to download all Scotland Ruby 2011 videos
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'hpricot'
dependencies = [:wget, :curl]
dependencies.each { |program| !`which #{program.to_s}`.empty? || STDERR.puts( "Requires #{program}") }
index_doc = Hpricot(open("http://confreaks.net/events/scotlandruby2011"))
$(document).ready ->
$("#fb-root").append "<script type=\"text/javascript\" src=\"#{document.location.protocol}//connect.facebook.net/en_GB/all.js\" async=\"true\"></script>"
window.fbAsyncInit = () ->
FB.init
appId: '172659579460514'
status: true
cookie: true
xfbml: true