Skip to content

Instantly share code, notes, and snippets.

Matt Snider mattsnider

Block or report user

Report or block mattsnider

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattsnider
mattsnider / iOSAndjQueryMobileBase.html
Created Aug 23, 2013
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/
View iOSAndjQueryMobileBase.html
{% 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 Dec 21, 2015
Steps for installing Arecibo intern project
View Arecibo Install.md
View requestanimationframe.js
// 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 / mirror_files.py
Created Jun 25, 2013
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).
View mirror_files.py
"""
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 / bootstrap.sh
Last active Dec 16, 2015
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.
View bootstrap.sh
#!/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
@mattsnider
mattsnider / window_messenger.js
Created Apr 12, 2013
JavaScript only messaging system for communicating between windows/tabs
View window_messenger.js
(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 / hashHackSender.js
Created Mar 30, 2013
Cross-Domain Iframe Receiver Using Hack-Hack
View hashHackSender.js
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 / hashHackReceiver.js
Created Mar 30, 2013
Cross-Domain Iframe Receiver Using Hack-Hack
View hashHackReceiver.js
var HashHack = {
PREFIX: '#hhMessage=',
aCallbacks: [],
sLastHash: '',
handleInterval: function() {
var sHash = window.location.hash,
sDecodedHash, sMessage, i;
if (sHash !== HashHack.sLastHash) {
@mattsnider
mattsnider / annotation.js
Last active Oct 8, 2017
JavaScript function for annotating other JavaScript
View annotation.js
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 / simple_javascript_event_wrapper.js
Created Feb 15, 2013
Dead simple wrapper for event functions in JavaScript. Adds addListener and removeListener to the global namespace.
View simple_javascript_event_wrapper.js
(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);
};
You can’t perform that action at this time.