Skip to content

Instantly share code, notes, and snippets.

@drmercer
drmercer / jQuery-coverage.js
Last active October 18, 2017 19:48
A jQuery plugin for tracking HTML "coverage" of jQuery selectors - it helps you figure out which selectors aren't actually selecting any elements, which may signify dead code.
/*
Include using
<script type="text/javascript" src="https://cdn.rawgit.com/drmercer/7da5b9dbe1a3e0b3ccc43c7fff8a1ec5/raw/86dba4b108a0ac3f1889f06c9db9454d88f770b1/jQuery-coverage.js"></script>
Be sure to include it after you've loaded jQuery.
*/
window.jqcoverage = (function ($) {
"use strict";
@drmercer
drmercer / git-gud
Last active October 13, 2017 05:32
Put this script somewhere in your $PATH. Then you can type "git gud" for help with the last git command you used
#!/bin/bash -i
last_command=$(fc -ln | grep -v 'git gud' | grep -E '^\s*git' | tail -n 1 | cut -d ' ' -f 3)
if [ -n "$last_command" ] ; then
git help "$last_command"
echo "(now ur gud at 'git $last_command')"
else
echo "No recent git command found :("
fi
@drmercer
drmercer / keybase.md
Created October 5, 2017 05:30
Proof of GitHub for keybase

Keybase proof

I hereby claim:

  • I am drmercer on github.
  • I am drmercer (https://keybase.io/drmercer) on keybase.
  • I have a public key ASDrfHmLQpiMB3kbo2_jSTdtx2AMb1yxzq9zsmXDOsycxgo

To claim this, I am signing this object:

@drmercer
drmercer / pre-commit
Last active April 19, 2017 21:12 — forked from wesbos/commit-msg
ESLint 3.0 Git Pre Commit Hook
#!/bin/sh
# Get a list of all JS files currently staged for commit
files=$(git diff --cached --name-only | grep '\.jsx\?$')
# Prevent ESLint help message if no files matched
if [ -z "$files" ] ; then
echo "(No JavaScript files to lint.)"
exit 0
fi
@drmercer
drmercer / Git updateInstead backwards emulation
Last active June 15, 2018 15:43
A pair of git hooks for emulating receive.denyCurrentBranch=updateInstead on older git versions (MIT)
These two git hooks could be placed in your (remote) repository's `hooks` directory to emulate the behavior of
receive.denyCurrentBranch=updateInstead on older versions of git that don't support that option for that setting.
Make sure both are executable, and don't put any file extensions on them.
These hooks are licensed under the MIT license (found in the `~LICENSE` file).
@drmercer
drmercer / IntentFilterToReceiveFromSpecificApp.xml
Last active October 27, 2015 18:12
An intent filter that only accepts intents from a certain application package. (For Android development)
<!-- This is a mock AndroidManifest.xml file, to show you the general context of this intent filter -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.danmercer.ponderizer" >
<application ... >
...
<!-- Accept text via ACTION_SEND only from the Github Android app ("com.github.mobile") -->
<activity