Skip to content

Instantly share code, notes, and snippets.

View flxf's full-sized avatar

Felix Fung flxf

View GitHub Profile
@flxf
flxf / gist:bcff9d0b4633f5e28ed3
Created July 2, 2014 17:23
FFProbe gives me contradictory information
~/workspace/ (master):ffprobe -show_format -show_streams -show_data -of json original.mp4
ffprobe version 2.2.3 Copyright (c) 2007-2014 the FFmpeg developers
built on Jun 3 2014 06:51:16 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.2.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libavresample 1. 2. 0 / 1. 2. 0
@flxf
flxf / fabric_clipping_group.js
Created March 16, 2014 19:54
A ClippedGroup class for FabricJS. Renders group behind a clipping rectangle.
fabric.ClippedGroup = fabric.util.createClass(fabric.Group, {
type: "clipped_group",
// default clip options
clipTop: 0,
clipLeft: 0,
clipWidth: 0,
clipHeight: 0,
render: function(ctx) {
@flxf
flxf / list_challenge_todo.user.js
Created November 28, 2012 09:49
Display incomplete list items at the top of list challenges.
// ==UserScript==
// @name List Challenges TODO
// @description Display incomplete list items at the top of list challenges.
// @namespace ffx
// @version 1
// @match http://www.listchallenges.com/100foods/
// @match http://www.listchallenges.com/bannedbookschallenge/
// @match http://www.listchallenges.com/beerlistchallenge/
// @match http://www.listchallenges.com/booklistchallenge/
// @match http://www.listchallenges.com/candylistchallenge/
@flxf
flxf / gist:4123045
Created November 21, 2012 04:39
Simple Keypoint Search
NUM_BLURS = 5;
H_SIZE = 13; % By choice
orig = imread('image1.jpg');
orig = mat2gray(orig);
[ rows, columns ] = size(orig);
blurs = cell(NUM_BLURS);
dog = cell(NUM_BLURS - 1);
@flxf
flxf / gist:4122715
Created November 21, 2012 02:44
Finding local extrema in a difference of gaussians
function ret = islocalextrema(search, x, y, z)
val = search{x}(i, j);
is_min = true;
is_max = true;
for a = -1 : 1
for b = -1 : 1
for c = -1 : 1
if (val >= search{x + a}(y + b, z + c))
is_min = false;
elseif (val <= search{x + a}(y + b, z + c))
@flxf
flxf / cumulative-contributions.py
Created August 25, 2012 05:16
Sum of contributions in your Mozilla Add-on's statistics (exported as JSON)
import json
import sys
input_filename = sys.argv[1]
input_file = open(input_filename)
contributions_raw = input_file.read()
input_file.close()
contributions = json.loads(contributions_raw)
print sum([ contribution['total'] for contribution in contributions ])
@flxf
flxf / README.md
Last active October 4, 2015 21:58
Returns the controller file responding to a URL for Rails

Find out where a route leads

This is written for Rails 2 if you're still using that

In any sufficiently advanced Rails app, the routing system is indistinguishable from magic. Maybe you've gotten a bug report for some part of the app you've never worked on before. Maybe it's a naughty POST request that you want to avoid reproducing. routes_navigate.rb is a quick and easy tool to put in your scripts directory to figure out the Controller#Action as well as the file.

Examples