Skip to content

Instantly share code, notes, and snippets.

View matthewhudson's full-sized avatar

Matthew Hudson matthewhudson

View GitHub Profile
@matthewhudson
matthewhudson / gist:8486693
Created January 18, 2014 05:46
Parrish's Law
During discussions of syncing, the chance that someone will mention #git approach 1
@matthewhudson
matthewhudson / cipher.coffee
Created March 20, 2014 19:26
CoffeeScript Nodejs Cipher
crypto = require 'crypto'
key = 'monkeybutt'
cipher = crypto.createCipher 'aes128', key
decipher = crypto.createDecipher 'aes128', key
encrypt = (plaintext) ->
encrypted = cipher.update plaintext, 'utf8', 'base64'
encrypted += cipher.final 'base64'
@matthewhudson
matthewhudson / jquery.backgroundParallax.coffee
Created June 13, 2014 20:02
Nifty background parallax effect (requires underscore.js)
# Note that when compiling with coffeescript, the plugin is wrapped in another
# anonymous function. We do not need to pass in undefined as well, since
# coffeescript uses (void 0) instead.
do ($ = jQuery, window, document) ->
# window and document are passed through as local variable rather than global
# as this (slightly) quickens the resolution process and can be more efficiently
# minified (especially when both are regularly referenced in your plugin).
# Create the defaults once
@matthewhudson
matthewhudson / keybase.md
Created September 18, 2014 01:22
keybase.md

Keybase proof

I hereby claim:

  • I am matthewhudson on github.
  • I am matthewhudson (https://keybase.io/matthewhudson) on keybase.
  • I have a public key whose fingerprint is 7B45 9A21 41FC FCD3 46EF B079 43BE B01D 5135 4390

To claim this, I am signing this object:

@matthewhudson
matthewhudson / devicejs-refactor.js
Last active December 21, 2018 16:08
First pass at a device.js refactor from CoffeeScript to JavaScript
/*jslint browser: true, indent: 2 */
'use strict';
// Device.js
// (c) 2014 Matthew Hudson
// Device.js is freely distributable under the MIT license.
// For all details and documentation:
// http://matthewhudson.me/projects/device.js/
Verifying that +matthewhudson is my openname (Bitcoin username). https://onename.io/matthewhudson
import uuid
import hashlib
import base64
def generate_unique_id():
return base64.b32encode(
hashlib.sha256(uuid.uuid4().bytes).digest())[:12].lower()
def generate_access_token():
return base64.b32encode(hashlib.sha256(uuid.uuid4().bytes).digest())[:52]
@matthewhudson
matthewhudson / streamDecodedVideo.js
Created May 25, 2019 08:14 — forked from yoannmoinet/streamDecodedVideo.js
Stream video back in correct format.
import ffmpeg form 'fluent-ffmpeg';
const filePath = '/Users/yoann/Desktop/video.avi';
const route = (req, res) => {
res.writeHead(200, getHeaders({'Content-Type': 'video/mp4'}));
ffmpeg(filePath)
.format('mp4')
.addOptions([
'-movflags frag_keyframe+faststart'
])
@matthewhudson
matthewhudson / atom-macos-context-menu.md
Created May 25, 2019 08:52 — forked from idleberg/atom-macos-context-menu.md
“Open in Atom” in macOS context-menu

Open in Atom

  • Open Automator
  • Create a new Service
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /usr/local/bin/atom -n "$@"
  • Set “Pass input” to as arguments
  • Save as Open in Atom
@matthewhudson
matthewhudson / style.css
Created June 19, 2019 01:15
CSS Custom Properties
/*
Found these unfamiliar `--` prefixes on a page and started researching: https://www.learn-html.org/en/Basic_Elements
You can prefix a double dash to define custom CSS properties: https://drafts.csswg.org/css-variables/
Browser support is solid: https://caniuse.com/#feat=css-variables
*/
:root {
--blue: #000;
--indigo: #6610f2;
--purple: #6f42c1;
--pink: #e83e8c;