Skip to content

Instantly share code, notes, and snippets.

View drewsberry's full-sized avatar

Drew - Account Moved drewsberry

View GitHub Profile
@drewsberry
drewsberry / preamble.tex
Created March 18, 2015 02:11
Preamble defining new maths commands for LaTeX
% New definition of square root:
% it renames \sqrt as \oldsqrt
\let\oldsqrt\sqrt
% it defines the new \sqrt in terms of the old one
\def\sqrt{\mathpalette\DHLhksqrt}
\def\DHLhksqrt#1#2{%
\setbox0=\hbox{$#1\oldsqrt{#2\,}$}\dimen0=\ht0
\advance\dimen0-0.2\ht0
\setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
{\box0\lower0.4pt\box2}}
@drewsberry
drewsberry / Makefile
Last active August 29, 2015 14:17
Template LaTeX Makefile
# You only need to change these top two lines
BASE=your-main-file
DEP=your-dependencies.tex
SRC=$(BASE).tex
PDF=$(BASE).pdf
LATEXMK=latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S"
LATEXMKCONT=latexmk -pvc -pdf -pdflatex="pdflatex --shell-escape --interaction=nonstopmode %O %S"
TMP=$(BASE).pdfsync *~ *.tmp *.bbl *.blg *.aux *.end *.fls *.log *.out *.fdb_latexmk
@drewsberry
drewsberry / press-the-button.js
Last active August 29, 2015 14:19
Press the button...
// First go to www.reddit.com/r/thebutton and unlock the button by clicking on it once
var theButton = document.getElementById("thebutton");
var theButtonTimer10s = document.getElementById("thebutton-s-10s");
var theButtonTimer1s = document.getElementById("thebutton-s-1s");
var ColourToTime = {
blue: "5",
green: "4",
yellow: "3",
@drewsberry
drewsberry / docky-chrome-fix.sh
Last active August 29, 2015 14:20
Docky fix Chrome icon
sudo sed -i '/Group\]\|Desktop Entry/a StartupWMClass=Google-chrome-stable' /usr/share/applications/google-chrome.desktop && \
rm ~/.cache/docky/docky.desktop.*.cache && \
killall docky && \
docky &> /dev/null && \
disown
@drewsberry
drewsberry / wifi-fix
Created July 16, 2015 17:12
Samsung Ubuntu Network Manager wifi suspend fix
#!/bin/sh
# This was put here by Drew Silcock on 16th July 2015 in an attempt to fix
# Wi-Fi issues on Ellen's Samsung laptop. It should be placed under
# `/etc/pm/sleep.d/`.
case "${1}" in
resume|thaw)
service network-manager stop
killall wpa_supplicant
@drewsberry
drewsberry / winmain-argv.cpp
Last active September 9, 2015 16:06
Get argv equivalent in WinMain()
#include <windows.h>
#include <atlstr.h>
#include <cstdlib>
#define NOTUSED(var) (void)(var)
#define FLAG_STR "--help"
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
@drewsberry
drewsberry / rename.ps1
Created September 15, 2015 09:34
Powershell rename utility
Dir | Rename-Item -NewName { $_.name -replace "orig", "repl" }
@drewsberry
drewsberry / batch-convert.sh
Last active September 30, 2015 10:41
Batch resize png images with bash and ImageMagick
#!/bin/sh
convert_path="C:/Program Files/ImageMagick/convert.exe"
target_path="."
target_ext="png"
echo "Warning, this will overwrite the current images."
read -r -p "Do you want to continue? [y/N] " response
response=${response,,} # tolower
@drewsberry
drewsberry / dollars-to-html.py
Created September 18, 2014 15:16
Replace equations $ ... $ or $$ ... $$ with KaTeX HTML using Python
import re
import execjs
def find_equations(string):
""" Take in a string, and convert everything between $ ... $ into an inline
equation and everything between $$ ... $$ into a centred equation. """
doubledollar = re.compile(ur"\$\$([^$]+)\$\$")
singledollar = re.compile(ur"(?<![\$])\$([^$]+)\$(?!\$)")
@drewsberry
drewsberry / keybase.md
Created November 30, 2015 09:03
Keybase identity proof

Keybase proof

I hereby claim:

  • I am drewsberry on github.
  • I am drewsberry (https://keybase.io/drewsberry) on keybase.
  • I have a public key whose fingerprint is 32AE 9006 2229 F440 8D5A 3716 F68B AB3B 4A08 2356

To claim this, I am signing this object: