Skip to content

Instantly share code, notes, and snippets.

View jamiehodge's full-sized avatar

Jamie Hodge jamiehodge

  • Zendesk
  • Copenhagen, Denmark
View GitHub Profile
@jamiehodge
jamiehodge / libxml2.rb
Last active December 11, 2015 12:58
Libxml2 homebrew formula
require 'formula'
class Libxml2 < Formula
homepage 'http://xmlsoft.org'
url 'ftp://xmlsoft.org/libxml2/libxml2-2.9.0.tar.gz'
sha256 'ad25d91958b7212abdc12b9611cfb4dc4e5cddb6d1e9891532f48aacee422b82'
keg_only :provided_by_osx
fails_with :llvm do
@jamiehodge
jamiehodge / resource.rb
Last active December 10, 2015 23:28
Decoupling Webmachine dispatcher and resource life cycles
# Please ignore this solution. It's too complicated :-(
require "webmachine"
class MyResource
include Webmachine::Resource::Callbacks
include Webmachine::Resource::Tracing
attr_reader :model, :request, :response
@jamiehodge
jamiehodge / webmachine.markdown
Last active May 7, 2020 22:21
Webmachine state machine and resource callbacks

Webmachine State Machine

General

  • Service available?
    • callback: service_available?
    • false: 503 Service Unavailable
  • Known method?
    • callback: known_methods
  • absent: 501 Not Implemented
@jamiehodge
jamiehodge / method_override.rb
Last active December 10, 2015 14:28
Webmachine method override
require "webmachine"
class MethodOverride < Webmachine::Resource
def allowed_methods
override_method!
%w(GET PUT DELETE)
end
private
require 'bundler/setup'
require 'roar/representer/json'
require 'roar/representer/feature/hypermedia'
require 'webmachine'
class Product
include Roar::Representer::JSON
include Roar::Representer::Feature::Hypermedia
property :name
@jamiehodge
jamiehodge / libav.rb
Created December 20, 2012 08:56
Homebrew Libav formula
require 'formula'
class Libav < Formula
homepage 'http://libav.org/'
url 'http://libav.org/releases/libav-9_beta2.tar.xz'
sha1 'acb7ffbcded06e5f04e8fd0f7dbcc923fd95df3f'
head 'git://git.libav.org/libav.git'
option "without-x264", "Disable H264 encoder"
require 'formula'
class Ffmpeg < Formula
homepage 'http://ffmpeg.org/'
url 'http://ffmpeg.org/releases/ffmpeg-1.0.tar.bz2'
sha1 'bf1f917c4fa26cf225616f2063e60c33cac546be'
head 'git://github.com/jamiehodge/FFmpeg.git'
option "without-x264", "Disable H264 encoder"
@jamiehodge
jamiehodge / 4444.patch
Created December 9, 2012 22:44
Prores 4444 patch
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 375dc52..4a27841 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -40,6 +40,7 @@ enum {
PRORES_PROFILE_LT,
PRORES_PROFILE_STANDARD,
PRORES_PROFILE_HQ,
+ PRORES_PROFILE_4444,
};
@jamiehodge
jamiehodge / slides.md
Created December 3, 2012 09:40
Hypermedia APIs

!SLIDE

Hypermedia APIs

"Follow your nose"

— Roy T. Fielding

!SLIDE

"build scalable, flexible implementations that do not simply run on the Web, but that actually exist in the Web"

@jamiehodge
jamiehodge / test.rb
Created November 9, 2012 09:26
Sinatra + Puma + Rubinius 2.0
require "sinatra/base"
require "puma"
require "rack/handler/puma"
require "minitest/autorun"
require "net/http"
require "slim"
class App < Sinatra::Base
post "/" do