Skip to content

Instantly share code, notes, and snippets.

@heisters
heisters / google-safe-browsing-lookup.rb
Last active December 13, 2015 17:28
Check all the links in a wordpress export (or really any text file) against Google Safe Browsing
# This is a version of https://github.com/juliensobrier/google-safe-browsing-lookup-ruby,
# modified to work against Ruby 1.9.2 and not blow up when malformed URLs are encountered.
#
# The library requires an API key from Google.
# Sign up for a free key a http://code.google.com/apis/safebrowsing/key_signup.html
#
# See README.rdoc for more information about Google Safe Browsing v2 API
# and this library.
#
# Author:: Julien Sobrier (mailto:julien@sobrier.net)
@heisters
heisters / colorThreshold.cpp
Last active October 9, 2015 19:17
Function for elegantly performing range thresholding with arbitrary colors and ranges with OpenCV
// This code is modified from the working version to remove coupling with the original
// application, and hasn't been tested in its new form. So, it's enough to give you
// the basic idea, but may not entirely work ;)
//
// It assumes the src image is in HSV and the dst image is grayscale.
//
// CvScalar red = cvScalar(179, 255, 255);
// CvScalar lowOffset = cvScalar(-20, -150, -150); // find colors down to h = 159, s = 105, v = 105
// CvScalar highOffset = cvScalar(20, 0, 0); // find colors up to h = 19, s = 255, v = 255 (h wraps/is mod 179)
// colorThreshold(img, thresholded, red, lowOffset, highOffset);
@heisters
heisters / bumper.sh
Created August 16, 2012 00:12
Using FFMPEG to splice a bumper onto an excerpt of a movie
#!/bin/bash
in="$1"
bumper_img="$2"
seek="$3" # "hh:mm:ss" or # of seconds
length="$4" # "hh:mm:ss" or # of seconds
ffmpeg \
-f image2pipe -vcodec ppm -i <(
ffmpeg \
@heisters
heisters / hack.sh
Created April 11, 2012 15:57 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@heisters
heisters / jasmine.yml
Created January 28, 2012 21:31
Sinatra + Sprockets + Jasmine + Coffeescript
src_files:
- assets/javascripts/app.js.coffee
- assets/spec.js.coffee
# ...
stylesheets:
- assets/stylesheets/app.css
@heisters
heisters / Canvas.cpp
Created November 18, 2011 18:59
ofxFenster helper for rendering a single "canvas" across multiple screens
#include "Canvas.h"
Canvas * Canvas::p_Instance = NULL;
Canvas * Canvas::Instance(){
if(!p_Instance) p_Instance = new Canvas();
return p_Instance;
}
Canvas::Canvas(){
@heisters
heisters / testApp.cpp
Created November 16, 2011 22:41
reproduce gluPerspective in openFrameworks w/ ofxFenster and glFrustum
// useful as a basis for rendering parts of the image across multiple monitors
// see also http://www.opengl.org/wiki/GluPerspective_code
// and https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/gl/ofGLRenderer.cpp#L315
void testApp::draw(){
ofxFenster * win = ofxFensterManager::get()->getActiveWindow();
ofPoint size = win->getWindowSize();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float halfFovTan = tanf(60 * PI / 360.0);
@heisters
heisters / participant_list.rb
Created July 23, 2011 01:24
Fix ParticipantList bug
require 'ruote/svc/participant_list'
class Ruote::ParticipantList
def instantiate_with_arg_normalization pinfo, opts={}
pinfo = [pinfo, {}] if pinfo.is_a?(String) # This will get all breaky if we ever pass options to the participant definition
instantiate_without_arg_normalization(pinfo, opts)
end
alias_method_chain :instantiate, :arg_normalization
end
@heisters
heisters / fei.rb
Created July 23, 2011 01:21
Fix FlowExperssionId bug
require 'ruote/fei'
class Ruote::FlowExpressionId
def initialize(h)
@h = h
class << h; include Ruote::HashDot; end
# Howcast: don't use sub_wfid if we arleady have a subid
@h['subid'] = @h.delete('sub_wfid') if @h['sub_wfid'] && !@h['subid']
# TODO : for 2.1.13, remove this
@heisters
heisters / patient.rb
Created July 7, 2011 21:05
polling ruote wait_for
# A set of tools for pausing the current thread until a Ruote process reaches a
# certain state. See Workflow::Patient::wait_for for the main entry point.
module Workflow::Patient
# the number of seconds between polling Ruote
TICK = 0.1
# the maximum number of seconds to wait
TIMEOUT = 10
# raised if Workflow::Patient::TIMEOUT is exceeded
class TimeoutError < Timeout::Error; end