Skip to content

Instantly share code, notes, and snippets.

View joeheyming's full-sized avatar
💭
Cautiously Optimistic

Joe Heyming ¯\_(ツ)_/¯ joeheyming

💭
Cautiously Optimistic
View GitHub Profile
@joeheyming
joeheyming / simpsons.sh
Created May 18, 2020 16:05
Download all the simpsons episodes
#!/bin/bash
LINKS=$(curl --silent http://pixa.club/en/the-simpsons/ | grep -E 'href="/en/the-simpsons/season-[0-9]+/epi' | tr -d ' ' | awk -F'"' '{print $2}' | gsort --version-sort | tail -n+250 )
# echo "LINKS = $LINKS"
cd ~/simpsons;
# exit 1
set -x
for link in $LINKS; do
echo $link;
season=$(basename $(dirname $link));
@joeheyming
joeheyming / garagerelay
Created June 16, 2018 19:30
Garage door init
#! /bin/bash
# /etc/init.d/garagerelay
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting Relay"
/usr/local/bin/gpio write 7 0
/usr/local/bin/gpio mode 7 out
@joeheyming
joeheyming / server.js
Created June 16, 2018 19:29
garage door app
//Requires
const express = require('express');
const app = express();
const path = require('path');
const chalk = require('chalk');
const { exec } = require('child_process');
const morgan = require('morgan');
//Static Routes
app.use('/dist', express.static(path.join(__dirname, 'dist')));
@joeheyming
joeheyming / Hack Github Contributions
Last active November 26, 2015 01:09
Paste this code into your developer tools when looking at github contributions. Click the cells you want to highlight.
$('rect').click(function(e) {
var target = e.target,
$target = $(target);
if (target.count === undefined || target.count === 5) {
target.count = 0;
}
if (target.count === 0) {
$target.attr('fill', '#eeeeee');
} else if (target.count === 1) {
@joeheyming
joeheyming / test-byte-compile.el
Created November 12, 2015 17:56
How to write an ert test that makes sure your project has no byte-compile warnings.
(require 'ert)
(require '<<<YOUR EMACS LISP PACKAGE UNDER TEST>>>)
(ert-deftest no-byte-compile-warnings ()
"Byte-compile should not emit warnings"
(byte-compile-file "<<<YOUR EMACS PACKAGE.el>>>")
(switch-to-buffer "*Compile-Log*")
(let ((lines (buffer-substring (point-min) (point-max))))
(should (not (string-match "Warning:" lines)) )
)
@joeheyming
joeheyming / Makefile
Last active December 3, 2015 06:39
Example emacs project test targets
.PHONY : test
EMACS ?= emacs
CASK ?= cask
LOADPATH = -L .
ELPA_DIR = \
.cask/$(shell $(EMACS) -Q --batch --eval '(princ emacs-version)')/elpa
@joeheyming
joeheyming / .travis-yml
Created November 12, 2015 17:50
Example emacs lisp travis yml
language: emacs-lisp
env:
matrix:
- EMACS=emacs24
- EMACS=emacs-snapshot
global:
- CASK=$HOME/.cask/bin/cask
before_install:
- sudo add-apt-repository -y ppa:cassou/emacs
- sudo add-apt-repository -y ppa:ubuntu-elisp/ppa
@joeheyming
joeheyming / .git_push_bash_completion
Last active October 28, 2015 00:25
This bash completion looks at the last few commits and allows you to tab complete the commit id. No more typing git push origin somecommit:master
function pushCommit() {
git push origin $1:master;
}
function _pushCommit() {
local RECENT_COMMITS=`git log --pretty=oneline master..HEAD`
COMPREPLY=()
local cur
cur=$(_get_cword)
@joeheyming
joeheyming / breaktime.el
Last active August 25, 2015 23:18 — forked from camdez/breaktime.el
/u/joeheyming's Emacs break timer (modified)
;;; See: https://www.reddit.com/r/emacs/comments/3icpo7/take_a_break_every_3_hours/
(defvar breaktime-timer nil
"Holds the running break timer (if any).")
(defvar breaktime-wait "3 hours"
"How long to wait for the next break.")
(defun breaktime--set-next-breaktime ()
"If we kill a breaktime buffer, set another wait timeout"
(when (string= (buffer-name) "*breaktime*")
(setq breaktime-timer (run-at-time breaktime-wait nil 'breaktime--take-a-break))))
@joeheyming
joeheyming / treewalk
Created July 30, 2015 22:48
treewalk example
/**
* @param {object[]} dependencies A list of steps to do at each depth of the tree.
* dependencies[0] is invoked first, then we call dependencies[1] on each child action. etc.
* @param {function} dependencies.request A function that returns a promise.
* @param {function:object[]} dependencies.onSuccess A function to call after the promise from dependencies.request finishes.
* This function should return a list of objects to invoke the next depth dependency on.
*
* @param {function} onFinish What to do when everything node has been traversed.
*/
DataLoader.walkTree = function(dependencies, onFinish) {