Skip to content

Instantly share code, notes, and snippets.

View matthewhudson's full-sized avatar

Matthew Hudson matthewhudson

View GitHub Profile
@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:

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 / jQuery External Link _target=blank
Created October 26, 2011 16:12
Automatically open external links in a new window.
@matthewhudson
matthewhudson / JavaScript Class
Created November 1, 2011 19:31
Best-practive JavaScript class: "that" is public, "my" is private to the object.
var constructor = function (spec, my) {
var that = {};
var my = my || {};
// This function is private.
my.privateFunction = function() {
return true;
};
// This function is public.
@matthewhudson
matthewhudson / hackerhub.json
Created December 12, 2011 15:36
Hackerhub Profile
{
"settings" : {
"id" : "matthewhudson",
"name" : "Matthew Hudson",
"avatar" : "http://www.matthewghudson.com/Matthew-Hudson.jpg",
"enable_search" : true
},
"content" : {
"tumblr" : {
"title" : "Blog",
@matthewhudson
matthewhudson / Ubuntu s3fs install
Created December 13, 2011 01:50
Ubuntu s3fs install & dependencies.
# Install prerequisites before compiling:
apt-get install build-essential
apt-get install libfuse-dev
apt-get install fuse-utils
apt-get install libcurl4-openssl-dev
apt-get install libxml2-dev
apt-get install mime-support
# Download and Install
wget http://s3fs.googlecode.com/files/s3fs-1.61.tar.gz
@matthewhudson
matthewhudson / duzournix
Created December 13, 2011 02:52
Basic EC2 LAMP stack.
# Install LAMP.
sudo yum install -y httpd php mysql-server mysql php-mysql
# Start Apache & MySQL.
sudo service httpd start
sudo service mysqld start
# Setup MySQL with root account credentials.
mysqladmin -u root password 'branches'
@matthewhudson
matthewhudson / httpd.conf
Created December 13, 2011 03:37
A "ready-to-go" httpd.conf. Turns on .htaccess files, and some performance tuning.
#
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
#
# Do NOT simply read the instructions in here without understanding