Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Mercer drmercer

View GitHub Profile
@drmercer
drmercer / IntentFilterToReceiveFromSpecificApp.xml
Last active Oct 27, 2015
An intent filter that only accepts intents from a certain application package. (For Android development)
View IntentFilterToReceiveFromSpecificApp.xml
<!-- 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
@drmercer
drmercer / Git updateInstead backwards emulation
Last active Jun 15, 2018
A pair of git hooks for emulating receive.denyCurrentBranch=updateInstead on older git versions (MIT)
View Git updateInstead backwards emulation
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 / pre-commit
Last active Apr 19, 2017 — forked from wesbos/commit-msg
ESLint 3.0 Git Pre Commit Hook
View pre-commit
#!/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 / trash-temps.sh
Created Oct 2, 2017
A shell script to remove old files prefixed with "temp_"
View trash-temps.sh
#!/bin/bash
# Trashes 'temp_*' files (that haven't been accessed in the past day)
# anywhere inside the home directory.
processFile() {
trash "$1" && echo "Trashed $1"
}
export -f processFile
@drmercer
drmercer / keybase.md
Created Oct 5, 2017
Proof of GitHub for keybase
View keybase.md

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 / git-gud
Last active Oct 13, 2017
Put this script somewhere in your $PATH. Then you can type "git gud" for help with the last git command you used
View git-gud
#!/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 / jQuery-coverage.js
Last active Oct 18, 2017
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.
View jQuery-coverage.js
/*
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 / jquery-thread.js
Last active Nov 14, 2017
A jQuery-promise-making wrapper around a Worker thread
View jquery-thread.js
function makeThreadedFn(fn) {
var blob = new Blob([
"var main=" + fn.toString() + ";\n"+
"// Generated message handler:\n"+
"onmessage=function(e) {\n"+
" var id = e.data.id;\n"+
" function msg(x) {\n"+
" x.id = id;\n"+
" postMessage(x);\n"+
" };\n"+
@drmercer
drmercer / instructions.md
Last active Jan 11, 2019 — forked from ccarnley7/instructions.md
A dark theme for Slack - works with your existing sidebar theme
View instructions.md
  • Open the “ssb-interop.js” file
  • Mac: Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
  • Windows: C:\Users\<USERNAME>\AppData\Local\slack\app-<VERSION>\resources\app.asar.unpacked\src\static\ssb-interop.js
  • Add this snippet of code at the bottom:
document.addEventListener('DOMContentLoaded', function() {
    $.ajax({
        url: 'https://gist.github.com/drmercer/003815071f3bddc581107a38e602e59e/raw/d279c406ae85428555d6ced1c3d16b30b37bd8b0/slackDarkTheme.css',