Skip to content

Instantly share code, notes, and snippets.

View colematt's full-sized avatar
:shipit:
Secret Squirrel

Matthew Cole colematt

:shipit:
Secret Squirrel
View GitHub Profile
@colematt
colematt / factorial.c
Created August 24, 2026 14:08
Hyperref within a listing environment
#include <stdio.h> // printf
#include <stdlib.h> // EXIT_SUCCESS
unsigned int factorial(unsigned int n); /*@\label{lst:factorial:prototype}@*/
unsigned int factorial(unsigned int n){ /*@\label{lst:factorial:implementation}@*/
if (n == 0) /* edge case */
return 1;
else if (n == 1) /* base case */
return 1;
@colematt
colematt / main.tex
Last active August 24, 2026 14:07
Using bibtex within beamer presentations
\documentclass{beamer}
\usepackage[style=ieee]{biblatex}
\setbeamertemplate{bibliography item}{\insertbiblabel}
\usepackage{blindtext}
\usepackage{graphicx} % Required for inserting images
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{knuth,
@colematt
colematt / chronology.sty
Last active August 24, 2026 14:02
Using datenumber, timeline, and chronology packages
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{chronology}[2023/08/20 v2.0 - Horizontal Timeline]%
\RequirePackage{calc}%
\RequirePackage{tikz}%
\RequirePackage{xparse}%
% Defining counters and lengths
\newcounter{step}\newcounter{stepstart}\newcounter{stepstop}%
\newcounter{yearstart}\newcounter{yearstop}\newcounter{deltayears}%
\newlength{\xstart}\newlength{\xstop}%
\newlength{\unit}\newlength{\timelinewidth}%
@colematt
colematt / main.c
Created August 24, 2026 13:54
Multiple Listings with Minted
typedef int (*fp)(int);
int square(int a){
return (a * a);
}
int main(){
fp func = square;
int a = func(3);
return 0;
}
@colematt
colematt / Makefile
Created August 18, 2026 19:50
Pick a random word from Wordnet
all: main
.PHONY: clean
clean:
$(RM) main *~ \#*\#
@colematt
colematt / Mac Keyboard Symbols.md
Created April 21, 2026 15:29 — forked from jlyonsmith/Mac Keyboard Symbols.md
List of Mac/Apple keyboard symbols

Common symbols

Modifiers

When a key combination is displayed, the modifiers are written in the order presented here. For example, Control + Option + Shift + Command + Q would be written as ⌃⌥⇧⌘Q.

Sym Key Alt
⌃ Control
⌥ Option

Using clipboard from shell in MacOS

Copy standard output to the clipboard

cat file.txt | pbcopy

Capture from standard error to the clipboard

@colematt
colematt / filesig.py
Created February 3, 2025 19:26
[Determine file type from magic numbers] #python3
#!/usr/bin/env python3
import sys
import os.path
def isELF(path):
with open(path, "rb") as fp:
return tuple(fp.read(4)) == (0x7F, 0x45, 0x4C, 0x46)
def isUniversalMachO(path):
@colematt
colematt / transforms.py
Created December 5, 2024 04:14
[Matrix Transformations Without Numpy] #python
#!/usr/bin/env python3
def transpose(matrix):
"Swap the rows and columns of a 2-D matrix."
return [list(row) for row in zip(*matrix, strict=True)]
def rotate(matrix):
"""
Rotate a matrix 90 degrees clockwise
@colematt
colematt / landscape-tabular.tex
Created June 27, 2024 02:56
[Lanscape, Full-page Tabular] #latex
% LaTeX tabular which is oriented in landscape and takes the entire page
\begin{landscape}
\begin{table}[h]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|}
\hline
Header 1 & Header 2 & Header 3 \\ \hline
Item 1 & Item 2 & Item 3 \\ \hline
Item 4 & Item 5 & Item 6 \\ \hline