Skip to content

Instantly share code, notes, and snippets.

@mattsnider
mattsnider / bootstrap.sh
Last active February 1, 2023 22:02
This is a shell script I use to bootstrap new dev machines (OSX) and servers (Ubuntu). It will ensure everything I need for python, node.js, and git is installed. After running bootstrap, I just need to clone my project and run the initialization script in my project to complete the setup.
#!/bin/bash
# expects python is installed with OS distribution
# single line command for execution
# wget -O - <RAW_URL> | bash
# determine environment
if hash apt-get 2>/dev/null; then
echo "Bootstrapping UBUNTU"
UBUNTU=true
// Modified from http://mattsnider.com/cross-browser-and-legacy-supported-requestframeanimation/
// LICENSE: MIT: http://mattsnider.com/projects/license/
(function(w) {
"use strict";
// most browsers have an implementation
w.requestAnimationFrame = w.requestAnimationFrame ||
w.mozRequestAnimationFrame || w.webkitRequestAnimationFrame ||
w.msRequestAnimationFrame;
w.cancelAnimationFrame = w.cancelAnimationFrame ||
@mattsnider
mattsnider / hashHackReceiver.js
Created March 30, 2013 21:02
Cross-Domain Iframe Receiver Using Hack-Hack
var HashHack = {
PREFIX: '#hhMessage=',
aCallbacks: [],
sLastHash: '',
handleInterval: function() {
var sHash = window.location.hash,
sDecodedHash, sMessage, i;
if (sHash !== HashHack.sLastHash) {
@mattsnider
mattsnider / mirror_files.py
Created June 25, 2013 20:40
This tool can be used to mirror files from a source directory to a destination directory. You can specify one file using `destination` and `source` or define many files using `source_map` (a csv with source,destination file per line).
"""
This tool can be used to mirror files from a source directory to a destination
directory. You can specify one file using `destination` and `source` or define
many files using `source_map` (a csv with source,destination file per line).
"""
import argparse
import os
import time
@mattsnider
mattsnider / hashHackSender.js
Created March 30, 2013 21:03
Cross-Domain Iframe Receiver Using Hack-Hack
var HashHack = {
PREFIX: '#hhMessage=',
postMessage: function(el, sMessage) {
if ('string' === typeof el) {
el = document.getElementById(el);
}
var sUrl = el.src.replace(/#.*/, '');
el.src = sUrl + HashHack.PREFIX + encodeURIComponent(sMessage);
@mattsnider
mattsnider / window_messenger.js
Created April 12, 2013 01:05
JavaScript only messaging system for communicating between windows/tabs
(function(w, d) {
"use strict";
// simple cookie writer
function createCookie(sName, sValue, sPath, sDomain, iMillis) {
var aCookie = [encodeURI(sName) + "=" + encodeURI(sValue)],
expires, oDate;
if (iMillis) {
oDate = new Date();
oDate.setTime(oDate.getTime() + iMillis);
@mattsnider
mattsnider / annotation.js
Last active October 8, 2017 16:47
JavaScript function for annotating other JavaScript
function annotate(fnToAnnotate) {
// already annotation aware, use the original annotation chain
if (fnToAnnotate.by) {
return fnToAnnotate;
}
var aAnnotationChain = [fnToAnnotate];
function applyChainFunctions(fn) {
fn.by = function(fnAnnotation, arg1, /*...*/ argN) {
@mattsnider
mattsnider / iOSAndjQueryMobileBase.html
Created August 23, 2013 01:27
A Django template extending the Django-HTML5-Boilerplate package using jQueryMobile to create a base template for a mobile HTML5 application. https://github.com/mattsnider/django-html5-boilerplate http://jquerymobile.com/
{% extends 'dh5bp/base_script_in_head.html' %}
{% load staticfiles %}
{% load url from future %}
{% block title %}{APP_TITLE}{% endblock %}
{% block head %}
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-startup-image" href="{% static '{STATIC_IMAGE_PATH}/startup-image.png' %}">
@mattsnider
mattsnider / Arecibo Install.md
Last active December 21, 2015 09:39
Steps for installing Arecibo intern project
@mattsnider
mattsnider / simple_javascript_event_wrapper.js
Created February 15, 2013 23:24
Dead simple wrapper for event functions in JavaScript. Adds addListener and removeListener to the global namespace.
(function(w) {
// Create the Event Function wrappers
if (w.addEventListener) {
// standards compliant method
w.addListener = function(el, eType, fn, capture) {
el.addEventListener(eType, fn, capture);
};
w.removeListener = function (el, eType, fn, capture) {
el.removeEventListener(eType, fn, capture);
};