Skip to content

Instantly share code, notes, and snippets.

View patrickmclaren's full-sized avatar

Patrick McLaren patrickmclaren

View GitHub Profile
@patrickmclaren
patrickmclaren / dnsmasq OS X.md
Created November 17, 2017 18:55 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.

Requirements

Install

@patrickmclaren
patrickmclaren / pre-commit
Last active October 5, 2015 20:20
Git Pre-Commit for Style Checkers
#!/bin/bash
#
# Checks staged files for linter exceptions
# Add to PROJECT_ROOT/.git/hooks/, and make executable (i.e. chmod +x .git/hooks/pre-commit)
LINTERS_STATUS=0
function linter {
local name=${1}
local pattern=${2}
package com.patrickmclaren.examples.asyncfragments;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.res.Configuration;
import android.os.Bundle;
public class FragmentActivity extends Activity {
@patrickmclaren
patrickmclaren / build.gradle
Last active August 29, 2015 14:17
Example Gradle build with Mockito
apply plugin: 'com.android.application'
android {
...
}
repositories {
mavenCentral()
}
@patrickmclaren
patrickmclaren / new_polynomial_matrix.py
Last active December 21, 2015 21:09
Determine the conditions under which a polynomial matrix has rank less than or equal to n.
##############################################################################
# System Libraries
##############################################################################
from collections import defaultdict
from sage.all import *
import itertools
##############################################################################
# Debugging
@patrickmclaren
patrickmclaren / dotfiles.py
Last active December 21, 2015 16:09
Bootstrap dotfiles. Keep them symlinked to home directory, but store them elsewhere, without a dot (i.e. not hidden).
#!/usr/bin/python
import os
import sys
import subprocess
from stat import *
##############################################################################
# Routine Functions
@patrickmclaren
patrickmclaren / pocr.py
Last active December 21, 2015 15:59
Embed OCR text in PDF.
#!/usr/bin/python
import subprocess
import os
import sys
import argparse
from argparse import RawTextHelpFormatter
FNULL = open(os.devnull, 'w')
@patrickmclaren
patrickmclaren / arxiv.py
Last active October 14, 2015 00:37
Search arXiv from the command line with this python script.
#!/usr/bin/env python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the