Skip to content

Instantly share code, notes, and snippets.

View matthewhudson's full-sized avatar

Matthew Hudson matthewhudson

View GitHub Profile
@forresto
forresto / noflo.json
Last active January 16, 2017 16:32
photobooth app flowhub demo: flowhub.io/demo/photobooth/
{
"properties": {
"name": "photobooth",
"environment": {
"runtime": "html",
"src": "preview/iframe.html",
"width": 300,
"height": 300,
"content": " <video id=\"vid\" autoplay loop width=\"640\" height=\"480\" style=\"display:none;\"></video>\n <canvas id=\"out\" width=\"640\" height=\"480\" style=\"max-width:100%;\"></canvas>\n\n<input id=\"slider\" type=\"range\" min=\"0\" max=\"1\" value=\"0.5\" step=\"0.01\"></input>\n <button id=\"start\">start camera</button>\n <button id=\"prev\">prev</button>\n <button id=\"next\">next</button>\n <button id=\"save\">save</button>\n\n<style>\n #saved img { width: 160px; height: 120px;}\n</style>\n<div id=\"saved\"></div>",
"type": "noflo-browser"
@danfinlay
danfinlay / How to download streaming video.md
Last active April 15, 2025 14:37
How to download a streaming video with Google Chrome

How to download streaming video

Streaming just means a download that they don't want you to keep. But Chrome's developer tools make it easy to access what's really going on under the hood.

Open Developer Tools

From the page where you want to download some things, go into your chrome menu to open the developer tools. You can either:

1.  (On a mac): Command-option-J
2. (On a PC): Control-alt-J
@cerebrl
cerebrl / 1-securing-express.md
Last active February 23, 2025 17:02
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
@Stuk
Stuk / exec.js
Created August 14, 2013 00:15
Wrap Node's `child_process.spawn` with a promise interface that rejects if the process has an error, or exits with a code other than zero.
var spawn = require("child_process").spawn;
var Q = require("q");
/**
* Wrap executing a command in a promise
* @param {string} command command to execute
* @param {Array<string>} args Arguments to the command.
* @param {string} cwd The working directory to run the command in.
* @return {Promise} A promise for the completion of the command.
*/
@philipcristiano
philipcristiano / faces_example.py
Created June 18, 2013 14:10
Resize and crop an image based on OpenCV detected faces
import sys
from PIL import Image, ImageDraw
try:
import cv
except ImportError:
print 'Could not import cv, trying opencv'
import opencv.cv as cv
@SlexAxton
SlexAxton / .zshrc
Last active March 24, 2025 17:35
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@martinnormark
martinnormark / AlertView.js
Created February 7, 2013 10:25
Twitter Bootstrap Alert view for Backbone.js
(function () {
MyApp.AlertView = Backbone.View.extend({
tagName: "div",
className: "alert fade",
template: ["<a href=\"#\" data-dismiss=\"alert\" class=\"close\">&times;</a>", "<strong>{{ title }}</strong>", "{{ message }}"].join("\n"),
@barelyknown
barelyknown / gist:4011968
Created November 4, 2012 13:40
Calculate All Moves For A Word in Letterpress Board
# requires a board_tiles method that returns an array of objects that respond to the letter method
def board_tiles_by_letter
by_letter = {}
('A'..'Z').each { |letter| by_letter[letter] = [] }
board_tiles.each { |board_tile| by_letter[board_tile.letter] << board_tile }
by_letter
end
def every_play(word)
@matthewhudson
matthewhudson / functions.php
Created September 4, 2012 13:41 — forked from abecoffman/functions.php
Adds Facebook Graph meta tags to Wordpress blog pages and thumbnail support to your Wordpress theme
<?php
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
function the_facebook_graph_data() {
// setup the default site attributes
$graph;
$graph["site_name"] = "YOUR_SITE_NAME";
@bergie
bergie / buildfilename.fbp
Created July 13, 2012 16:35
JSON-LD to Jekyll converter with NoFlo
# We need to process the date into suitable for filename
'dc:date' -> KEY GetDate(GetObjectKey)
'10' -> LIMIT CleanDate(SubStr)
Split(Split) OUT -> IN GetDate() OUT -> IN CleanDate()
# We also need the URL name for the filename
'dc:name' -> KEY GetName(GetObjectKey)
Split() OUT -> IN GetName()
# And finally we need the format