Skip to content

Instantly share code, notes, and snippets.

View RazerM's full-sized avatar

Frazer McLean RazerM

View GitHub Profile
@RazerM
RazerM / .gitconfig
Last active June 6, 2025 13:52
`git exclude` to add paths to .git/info/exclude
[alias]
exclude = "!f() { \
for file in \"$@\"; do \
relative_path=\"$(realpath --relative-to=. \"${GIT_PREFIX:-.}/$file\")\"; \
if git ls-files --error-unmatch \"$relative_path\" > /dev/null 2>&1; then \
echo \"'$relative_path' is tracked by git\"; \
elif ! git check-ignore -q \"$relative_path\"; then \
echo \"/$relative_path\" >> \".git/info/exclude\"; \
echo \"Added '/$relative_path' to .git/info/exclude\"; \
else \
@RazerM
RazerM / exception_reduce_pickle.py
Created November 2, 2022 22:09
Better way to write __reduce__ for exceptions to manage keyword arguments
class IgnoreError(Exception):
def __init__(self, message, *, line=None):
super().__init__(message)
self.line = line
def __reduce__(self):
cls = type(self)
return cls.__new__, (cls, *self.args), self.__dict__

Keybase proof

I hereby claim:

  • I am razerm on github.
  • I am razerm (https://keybase.io/razerm) on keybase.
  • I have a public key whose fingerprint is B1E2 1C5B B9F8 073E A5EF 7FB7 A39D 7E9B F17F 6F5F

To claim this, I am signing this object:

Invocation: ./configure --prefix-dir=/usr/local/Cellar/openttd/1.3.0
Detecing awk...
Trying: echo "a.c b.c c.c" | tr ' ' \n | awk ' { ORS = " " } /\.c$/ { gsub(".c$", ".o", $0); print $0; }' 2>/dev/null
Result: 'a.o b.o c.o '
checking awk... awk
detecting OS... OSX
executing cc -dumpmachine
returned x86_64-apple-darwin13.0.0
exit code 0
@RazerM
RazerM / gist:5344942
Created April 9, 2013 11:22
LaTeX: Align long equations #snippet
\begin{align}
A &\begin{multlined}[t][.75\textwidth]
\approx B^{3}C^{-2}\frac{D}{E_{\text{test}}}\arctan(CE)\left( f_{0}(G)+2Bf_{1}(G)\vphantom{\frac{3}{4}}\right.\\
\left.+\frac{1}{7}B^{2}\left(f_{0}(G)+f_{2}(G)\right) \right)
\end{multlined}\\
B &\approx 7A
\end{align}
@RazerM
RazerM / gist:5200401
Created March 19, 2013 21:42
LaTeX: Figure #snippet
\begin{figure}[H]
\begin{center}
\includegraphics[width=0.9\textwidth]{filename}
\end{center}
\caption{}
\label{fig:name}
\end{figure}
@RazerM
RazerM / gist:5150731
Last active December 14, 2015 21:19
LaTeX: Number aligned table #snippet
%Needs \usepackage{float} for {H}
\begin{table}[H]
\centering
% table-format is defined as a.b where a is number of figures before decimal point, b is number of decimal places
\begin{tabular}{S[table-format=1]S[table-format=2.1]} %First S sets format for both columns, but each can have different table-format
\toprule
{ Distance (\si{\metre}) } & { Speed (\si{mi\per\hour}) }\\ %Non-number input must be surrounded with { }
\midrule
0 & 0 \\
1 & 1.1 \\
@RazerM
RazerM / gist:5150716
Last active December 14, 2015 21:19
LaTeX: Simple table #snippet
%Needs \usepackage{float} for {H}
\begin{table}[H]
\centering
\begin{tabular}{*{2}{l}rr@{.}l} %The same as llr
\toprule
\multicolumn{2}{c}{Item}\\ %2 columns, centred
\cmidrule(r){1-2} %Trims bar on r.h.s.
Meat & Description & Price (\textsterling) & \multicolumn{2}{c}{Mass (kg)}\\
\midrule
Chicken & Breast & 4.69 & 5 & 2\\
@RazerM
RazerM / gist:5150638
Created March 13, 2013 09:47
LaTeX: Tabbing #snippet
\begin{Tabbing}
\hspace{2em} \TAB=A\hspace{2em} \TAB=B\hspace{2em} \TAB=C\hspace{4em} \TAB=Description\\
Unindented line\\
\TAB>Indented \TAB>\TAB>\TAB>\textbackslash TAB\textgreater\ moves \textbf{only} the current line to the next tab stop\\
\TAB+ Current line unindented.\TAB>\TAB>\TAB>\TAB>\textbackslash TAB+ indents the lines following (but not including) the current line.\\
Following line indented.\TAB-\\
Remove indent.\TAB>\TAB>\TAB>\TAB>\textbackslash TAB- unindents the following lines.\\
Back to unindented.\\
\TAB>\TAB> Two tabs.\TAB>\TAB>\textbackslash TAB commands work as expected when stacked together.\\
\TAB+\TAB> Combined. \TAB>\TAB>\TAB>\textbackslash TAB+\textbackslash TAB\textgreater\ can be used to start the indent immediately and for following lines.\\