Skip to content

Instantly share code, notes, and snippets.

New Project!

Michael Sanford michaelsanford

New Project!
Block or report user

Report or block michaelsanford

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
View angular-cache-service.js
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Rx';
interface CacheContent {
expiry: number;
value: any;
}
/**
* Cache Service is an observables based in-memory cache implementation
@michaelsanford
michaelsanford / .jshintrc
Last active May 7, 2017 — forked from ScheerMT/.jshintrc
.jshintrc for ES6, updated for jshint 2.9 with every available option (no deprecations), without comments
View .jshintrc
{
"bitwise" : true,
"curly" : true,
"eqeqeq" : true,
"esversion" : 6,
"forin" : true,
"freeze" : true,
"funcscope" : false,
"futurehostile" : true,
"iterator" : false,
View CrossScriptingFilter.java
package com.greatwebguy.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
@michaelsanford
michaelsanford / pizza.js
Last active Jan 27, 2017
Will there be pizza? 👍🏽🍕
View pizza.js
(() => {
"use strict";
/**
* Attendees to JS-Montreal often don't know if there will be pizza or not. This aims to make it more clear.
* Traditionally, pizza is available if the meetup starts at 6 PM, but not if it starts at 7.
*
* @see https://www.meetup.com/js-montreal/
*/
@michaelsanford
michaelsanford / clean-local-merged-branches.sh
Last active Oct 18, 2016
Interactively delete local branches which have been merged upstream. In my case, that's into `develop`.
View clean-local-merged-branches.sh
#!/bin/bash
MERGED_INTO=${1:-"develop"}
statistics() {
echo
echo "Remaining local branches:"
git branch
echo
echo "These local branches are not merged into ${MERGED_INTO}:"
@michaelsanford
michaelsanford / harpa-js-is.js
Created Aug 25, 2016
JSConfIS Northern Lights JS IS - Dance Party
View harpa-js-is.js
const { totalCols } = config
function update(currentLights, time) {
const colIndex = Math.round(time * 20 % totalCols)
const newLights = new Lights()
const colour = Color().hsl(time * 200 % 360, 100, 50)
const offsets = [1, 15, 29, 43];
@michaelsanford
michaelsanford / notify-on-dns-propagated.sh
Created May 25, 2016
Email when a DNS change has propagated to a certain nameserver.
View notify-on-dns-propagated.sh
#!/usr/bin/env bash
# The IP to which you just updated your DNS
NEW_IP="127.0.0.1"
# The domain for which you're awaiting propagation
DOMAIN="EXAMPLE.COM"
# Polling interval in seconds
WAIT=30
@michaelsanford
michaelsanford / nuke-mysql-conditional-comments
Last active Aug 29, 2015
Nuke mysql conditional comment markers in vim
View nuke-mysql-conditional-comments
Two vim editor commands to nuke mysql conditional comment markers in
MySQL dumps, but not the statement within them:
: %s/\/\*!\d\+\s//g
: %s/\*\///g
Or you can use sed:
sed -i 's/\/\*!\d\+\s//g' dump.sql
sed -i 's/\*\///g' dump.sql
@michaelsanford
michaelsanford / gcap.sh
Last active Aug 29, 2015
Android screenshot (Glass, Wear, mobile)
View gcap.sh
#!/usr/bin/env bash
##
# Screencaps, pulls, and deletes the png from a device.
#
# gcap [w | a | device identifier]
#
# For debugging over Bluetooth (i.e., Android Wear), see
# https://developer.android.com/training/wearables/apps/bt-debugging.html
#
@michaelsanford
michaelsanford / remove-old-kernels
Created Jun 16, 2014
Remove outdated kernel images
View remove-old-kernels
##
# One-liner for my own reference taken from the excellent article by Mark McBride (read it!):
# http://markmcb.com/2013/02/04/cleanup-unused-linux-kernels-in-ubuntu/
##
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
You can’t perform that action at this time.