Skip to content

Instantly share code, notes, and snippets.


dan mackinlay danmackinlay

View GitHub Profile
danmackinlay /
Created Aug 27, 2009
an init.d script for supervisord
#! /bin/sh
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
danmackinlay /
Created Nov 25, 2011
reduce PDF file size by optimising it for screen viewing
# copied from
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo usage: shrinkpdf \<filename\> \<resolution\> \[\<output\>\]
if [ ! -e "$1" ]; then
echo "$1" does not exist. Exiting.
danmackinlay /
Last active Aug 15, 2021
script to decorate .Rmd files with bibliography files from my local zotero installation
#! /usr/bin/env python
Export Zotero biblographies for my blog using betterbibtex export support
From the root of a blogdown blog, run
View Git pre-commit hook for large

Git pre-commit hook for large files

This hook warns you before you accidentally commit large files to git. It's very hard to reverse such an accidental commit, so it's better to prevent it in advance.

Since you will likely want this script to run in all your git repos, a script is attached to add this hook to all git repos you create / clone in the future.

Of course, you can just download it directly to the hooks in an existing git repo.

danmackinlay / .Rprofile
Created Feb 7, 2021
.Rprofile that prevents using linxubrew paths, which breaks compilation.
View .Rprofile
# R should not use the linuxbrew paths.
# this laborious workaround prevents that
.pth = Sys.getenv("PATH")
.pths = unlist(strsplit(.pth, ":"))
.nbrewpthi = as.vector(unlist(lapply(.pths, function (x) !grepl("brew", x))))
Sys.setenv(PATH=paste(.pths[.nbrewpthi], collapse=":"))
print("Changed PATH")
danmackinlay /
Created Oct 5, 2016
Generalized Poisson Distribution for scipy.
import numpy as np
from scipy.stats import rv_discrete
from scipy.special import gamma, gammaln
class gpd_gen(rv_discrete):
A Lagrangian Generalised Poisson-Poisson distribution.
``eta`` is the branching ratio,
danmackinlay / find-pis
Last active Feb 13, 2020 — forked from chr15m/find-pis
Find Raspberry Pi devices on your local networks.
View find-pis
# get broadcast addresses for each network
net=`ifconfig | grep -o -E "Bcast:(.*?) " | cut -f2 -d":"`
# loop over networks running the scan
for n in $net;
# first find SSH machines silently to prime the arp table
nmap -T4 -n -p 22 --open --min-parallelism 100 "$n/24" | grep -e "scan report for" -e "ssh" > /dev/null

Keybase proof

I hereby claim:

  • I am danmackinlay on github.
  • I am danmackinlay ( on keybase.
  • I have a public key ASBW9iWVglwJj-mtImYHR5uYigzQc-aCyVHThu_sQN9umAo

To claim this, I am signing this object:

danmackinlay /
Created Oct 18, 2016
Fork of Alfred Klomp's excellent


Download the script by clicking the filename at the top of the box. Make it executable. If you run it with no arguments, it prints a usage summary. If you run it with a single argument – the name of the pdf to shrink – it writes the result to stdout:

./ in.pdf > out.pdf

You can also provide a second filename for the output:

danmackinlay / gist:1954656
Created Mar 2, 2012
gpu kernel panic report
View gist:1954656
Fri Mar 2 11:04:59 2012
panic(cpu 0 caller 0xffffff7f80a87907): NVRM[0/1:0:0]: Read Error 0x00000100: CFG 0xffffffff 0xffffffff 0xffffffff, BAR0 0xc0000000 0xffffff8115c2d000 0x0a5480a2, D0, P3/4
Backtrace (CPU 0), Frame : Return Address
0xffffff811560ae70 : 0xffffff8000220702
0xffffff811560aef0 : 0xffffff7f80a87907
0xffffff811560af80 : 0xffffff7f80b77a64
0xffffff811560afd0 : 0xffffff7f80b77b24
0xffffff811560b030 : 0xffffff7f80e24749
0xffffff811560b170 : 0xffffff7f80b96bad
0xffffff811560b1a0 : 0xffffff7f80a91282