Skip to content

Instantly share code, notes, and snippets.

View drewsberry's full-sized avatar

Drew - Account Moved drewsberry

View GitHub Profile
@drewsberry
drewsberry / katextest.rb
Created September 20, 2014 13:12
KaTeXifier test
require 'execjs'
def convert(content)
singledollar = /(?<![\$])\$([^$]+)\$(?!\$)/
doubledollar = /\$\$([^$]+)\$\$/
path_to_katex = "../public/js/katex.min.js"
katexsrc = open(path_to_katex).read
katex = ExecJS.compile(katexsrc)
@drewsberry
drewsberry / convert.zsh
Created March 16, 2015 19:59
Convert all eps files in folder to cropped pdf
#!/bin/zsh
files=(*)
for f in $files; do
if [[ $(echo $f | rev | cut -c1-3 | rev) == "eps" ]]; then
echo "Converting $f..."
basename=$(echo $f | rev | cut -c1-4 --complement | rev)
epspdf --bbox $f
pdfcrop --noverbose ${basename}.pdf ${basename}.pdf
@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 / ublock-filter.md
Created March 30, 2015 15:18
ublock Analytics Filter

ublock Allow Google Analytics

  • Go to ublock settings and select the "Filters" tab

  • In the box, copy the following filter rule in:

    @@||google-analytics.com^

  • Click "Apply changes"

  • You're done

@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 / UE4-build.bat
Last active February 21, 2024 07:33
UE4 Windows command line building
:: Build client
RunUAT BuildCookRun -project="full_path.uproject"^
-noP4 -platform=Win64^
-clientconfig=Development -serverconfig=Development^
-cook -allmaps -build -stage^
-pak -archive -archivedirectory="Output Directory"
:: Cook client
RunUAT BuildCookRun -project="full_project_path_and_project_name".uproject^
-noP4 -platform=Win64^
@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,