Skip to content

Instantly share code, notes, and snippets.

View ohookins's full-sized avatar
🤔
Thinking

Oliver Hookins ohookins

🤔
Thinking
View GitHub Profile
@ohookins
ohookins / gist:3690514
Created September 10, 2012 11:52
S3 Bucket Versioning
1.8.7 :018 > bucket = s3.buckets['oliver-test-versioning']
=> #<AWS::S3::Bucket:oliver-test-versioning>
1.8.7 :026 > bucket.enable_versioning
=> nil
1.8.7 :027 > bucket.versioned?
=> true
1.8.7 :029 > bucket.versions.each { |v| puts v.class }
AWS::S3::ObjectVersion
AWS::S3::ObjectVersion
AWS::S3::ObjectVersion
@ohookins
ohookins / gist:3801133
Created September 28, 2012 17:25
mplayer homebrew build diff for HEAD
diff -ruN mplayer.orig/configure mplayer/configure
--- mplayer.orig/configure 2012-09-28 16:12:45.000000000 +0200
+++ mplayer/configure 2012-09-28 16:13:10.000000000 +0200
@@ -48,8 +48,6 @@
fi
if ! test -e ffmpeg ; then
- echo "No FFmpeg checkout, press enter to download one with git or CTRL+C to abort"
- read tmp
if ! git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git ffmpeg ; then
@ohookins
ohookins / gist:3801137
Created September 28, 2012 17:27
mplayer homebrew build diff for latest release
diff --git a/configure b/configure
index bbfcd51..5734024 100755
--- a/configure
+++ b/configure
@@ -48,8 +48,6 @@ if test -e ffmpeg/mp_auto_pull ; then
fi
if ! test -e ffmpeg ; then
- echo "No FFmpeg checkout, press enter to download one with git or CTRL+C to abort"
- read tmp
@ohookins
ohookins / gist:3819110
Created October 2, 2012 13:25
libfdk_aac vs nero aac
NOT WORKING:
[15:19:42.767] GET http://localhost:5000/media_011012/1mT1O677gwdP-libfdk_aac.mp4 [HTTP/1.1 200 OK 18ms]
[15:19:42.739] JWPLAYERVIEWPLAY ([ViewEvent type="jwplayerViewPlay" data="null" id=mediaplayer1-right client=FLASH MAC 11,4,402,265 version=5.10.2295]) @ http://localhost:5000/
[15:19:42.741] JWPLAYERMEDIABEFOREPLAY ([MediaEvent type="jwplayerMediaBeforePlay" id="mediaplayer1-right" client="FLASH MAC 11,4,402,265" version="5.10.2295"]) @ http://localhost:5000/
[15:19:42.743] JWPLAYERMEDIALOADED ([MediaEvent type="jwplayerMediaLoaded" id="mediaplayer1-right" client="FLASH MAC 11,4,402,265" version="5.10.2295"]) @ http://localhost:5000/
[15:19:42.745] JWPLAYERPLAYERSTATE ([PlayerStateEvent type="jwplayerPlayerState" oldstate="IDLE" newstate="BUFFERING" id="mediaplayer1-right" client="FLASH MAC 11,4,402,265" version="5.10.2295" message="null"]) @ http://localhost:5000/[15:19:42.746] JWPLAYERMEDIABUFFER ([MediaEvent type="jwplayerMediaBuffer" bufferPercent="0" position="0" id="mediaplayer1-right"
@ohookins
ohookins / gist:3910413
Created October 18, 2012 08:15
Chef seems to lack unique resource naming...
root@squeeze:/var/chef/cookbooks/test/recipes# cat foo.rb
execute "load" do
command "/bin/echo 'load called from test::foo'"
action :nothing
end
file "/tmp/foo" do
action :touch
notifies :run, "execute[load]", :immediately
end
@ohookins
ohookins / gist:4119222
Created November 20, 2012 16:54
S3 bucket walker
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
require 'optparse'
def run(options)
# Set up credentials and buckets
s3 = AWS::S3.new({
:access_key_id => options[:key],
@ohookins
ohookins / gist:4119264
Created November 20, 2012 17:00
S3 bucket walker exception
Exception in thread "RubyThread-61: ./s3_ls.rb:3" java.lang.ArrayIndexOutOfBoundsException: 18
at org.jruby.util.MurmurHash.hash32(MurmurHash.java:33)
at org.jruby.RubyString.strHashCode(RubyString.java:1216)
at org.jruby.RubyString.hashCode(RubyString.java:1206)
at org.jruby.RubyHash.internalGetEntry(RubyHash.java:506)
at org.jruby.RubyHash.op_asetForString(RubyHash.java:910)
at org.jruby.RubyHash.fastASetCheckString19(RubyHash.java:879)
at org.jruby.RubyHash.op_aset19(RubyHash.java:905)
at org.jruby.RubyHash$INVOKER$i$2$0$op_aset19.call(RubyHash$INVOKER$i$2$0$op_aset19.gen)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:202)
@ohookins
ohookins / gist:4275490
Created December 13, 2012 10:16
Pulling out the type of error from a JSON unmarshalling in Go...
if reflect.TypeOf(err).String() != "*json.SyntaxError" {
t.Errorf("Badly formed input should have resulted in json.SyntaxError, but didn't.")
return
}
@ohookins
ohookins / mysql_async.rb
Last active December 13, 2015 20:29
Asynchronous queries with mysql2 gem and IO.select
# Set up the three different clients to different hosts, and a starting time
client1 = Mysql2::Client.new()
client2 = Mysql2::Client.new()
client3 = Mysql2::Client.new()
start_time = Time.now()
# Run the first query
query1 = "SELECT SLEEP(5);"
puts "Running Query:\n >> #{query1}\n\n"
client1.query(query1, :async => true)
@ohookins
ohookins / gist:5013420
Last active September 29, 2020 06:01
Worker Pool example in Go
package main
import (
"fmt"
"net/http"
"os"
"sync"
)
var (