Skip to content

Instantly share code, notes, and snippets.

View sampollard's full-sized avatar

Sam Pollard sampollard

View GitHub Profile
@sampollard
sampollard / fix_pdf.sh
Last active October 13, 2020 21:19
Tricks to embed fonts inside pdfs for paper submissions
#!/bin/bash
# Embed fonts in pdf files. This may be needed for R graphics.
# You can check if fonts are embedded using pdffonts (on mac, xpdf-pdffonts); check the emb column
mkdir -p unembedded
cp *.pdf unembedded/
for f in unembedded/*; do
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -sOutputFile=$(basename $f) -f $f
done
# Other things you may need to do to pass the IEEE pdf eXpress (pdf-express.org)
@sampollard
sampollard / singularity.md
Last active March 15, 2019 20:05
Singularity: Did You Bring Enough to Share with the Class?

Singularity: Did You Bring Enough to Share with the Class?

Motivation

I wanted to use singularity for my own selfish purposes; when presenting my research I want it to be easy for someone else to try.

Installing Singularity

The Easy Way

sudo apt install singularity.

@sampollard
sampollard / iq.sh
Last active March 9, 2021 22:36
Totally accurate IQ calculator based only on your full name
#!/bin/bash
echo "$1" | awk -F'[\-.]' '{print NF*15+70}'
@sampollard
sampollard / onlycite.tex
Created August 5, 2019 20:55
Print out only citations given a .bib file
% Only generate citations. Build with latexmk -pdf
\documentclass{article}
\begin{document}
\nocite{*}
\bibliographystyle{plain}
\bibliography{mybib}
\end{document}
# A xterm-256color based TERMINFO that adds the escape sequences for italic.
# Follow instructions at
# https://apple.stackexchange.com/questions/266333/how-to-show-italic-in-vim-in-iterm2
# Basically, check italic text in settings, then type
# tic -o ~/.terminfo xterm-256color.terminfo.txt
# and make sure to export TERM=xterm-256color in your ~/.profile
xterm-256color|xterm with 256 colors and italic,
sitm=\E[3m, ritm=\E[23m,
use=xterm-256color,
@sampollard
sampollard / ital.sh
Created April 8, 2020 04:06
Italicise every other character in LaTeX
#!/bin/bash
# usage: ital.sh <filename>
echo '/\\begin{document}/+,/\\end{document}/-s/\(.\)\(.\)/\\emph{\1}\2/g | w' | vim -e "$1"
@sampollard
sampollard / ctrl.ahk
Last active November 16, 2024 23:29
Vim in Windows
; How to view scancodes
; Right-click, "run this script" on this file (not the compiled file!)
; Right click and select "Open"
; View -> Key History and Script Info
; Now you can type things, press F5 to refresh; they appear bottom-up
#NoEnv ; Compatibility with future AutoHotkey releases
SendMode Input ; Tutorials say this is good
;Capslock::Esc ; Map Capslock to Escape
;+Capslock::Capslock ; Map Shift-Capslock to Capslock
Capslock::LCtrl ; Map Capslock to Control
@sampollard
sampollard / settings.json
Last active October 29, 2020 23:22
Windows Terminal Settings
// This file was initially generated by Windows Terminal 1.3.2651.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@sampollard
sampollard / roman-name-generator.sh
Last active August 30, 2020 06:36
Generate Random Names
#!/bin/bash
# Generates random roman names plus its gender
# Names copied from https://www.behindthename.com/names/usage/ancient-roman
# First preprocessed by
# awk 'FNR%2 {print $1 " " $2}' roman-names.txt > roman-names.csv
# Surnames copied from https://en.wikipedia.org/wiki/List_of_Roman_nomina
CNT=$1
if [ "$#" -ne 1 ]; then
CNT=5
fi
@sampollard
sampollard / negativebox.tex
Last active October 7, 2020 05:57
Highlight a part of a bounding box in Tikz. Use with \negativebox{x1,y1}{x2,y2} inside tikzpicture
\newcommand\negativebox[2]{%
\def\opc{0.75}
\def\opcol{white}
% Left
\fill[opacity=\opc, color=\opcol]
let
\p{sw} = (current bounding box.south west),
\p{nw} = (current bounding box.north west),
\p1 = (#1)
in (\p{sw}) rectangle (\x1, \y{nw});%