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 / gist:1599924
Created January 12, 2012 11:13
Download Progress
# download zip file
source = open(feed_url,
:content_length_proc => lambda { |t|
start = Time.now
if t && 0 < t
content_length = t / 100
end
},
:progress_proc => lambda { |s|
@danhigham
danhigham / mp4convert.rb
Created April 1, 2012 16:30
Ruby script to convert .m4a files to mp3 (install lame and faad2 via homebrew first)
#!/usr/bin/ruby
require 'rubygems'
require 'mp4info'
path = ARGV[0]
Dir.foreach(path) do |file|
file_path = File.join path, file
@danhigham
danhigham / hello.rb
Created August 6, 2012 17:55
Serving images
require 'sinatra'
get '/hi' do
"<html><head></head><body><img src=\"/images/javelin-2012-hp.jpg\" /></body></html>"
end
get %r{/images/(.+)} do |c|
File.read(c)
end
@danhigham
danhigham / Gemfile
Created October 17, 2012 14:05
Example of how to use the vmc library to do an automatic mysql backup of a named service
source :rubygems
source "http://rubygems.org"
gem 'vmc', '0.3.18'
gem 'caldecott', '>=0.0.5'
@danhigham
danhigham / node-pg-example.js
Created November 5, 2012 16:28
Node PG example
/*
* GET home page.
*/
var pg = require('pg');
exports.index = function(req, res){
var conString = "tcp://127.0.0.1/postgres";
var out = "";
@danhigham
danhigham / gist:4654412
Created January 28, 2013 10:15
Sample manifest.yml for node app with env variable
---
applications:
- name: nodetestdh01
framework: node
runtime: node08
memory: 64M
instances: 1
url: nodetestdh01.${target-base}
path: .
env:
@danhigham
danhigham / Markdown-Terminal.sublime-snippet
Created January 29, 2013 12:13
Sublime snippet to create terminal blocks in markdown
<snippet>
<content><![CDATA[
<pre class="terminal">
$1
</pre>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>term</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.markdown</scope> -->
@danhigham
danhigham / Gemfile
Last active October 27, 2018 15:44
Simple ruby script to download the contents of an application running on Cloud Foundry to a zip file
source :rubygems
gem 'cfoundry'
gem 'uuidtools'
@danhigham
danhigham / dump_controller.rb
Created February 6, 2013 15:49
Dump Controller
require 'cfoundry'
require 'tempfile'
require 'zip/zip'
require 'tunnel-vmc-plugin/tunnel'
CF_ENDPOINT = 'http://api.cloudfoundry.com'
class DumpController < ApplicationController
def new
@danhigham
danhigham / Gemfile
Last active December 13, 2015 16:49
Simple session persistence with Redis and Sinatra
source :rubygems
gem 'sinatra'
gem 'redis'
gem 'httparty'