Skip to content

Instantly share code, notes, and snippets.

" activates filetype detection
filetype plugin indent on
" activates syntax highlighting among other things
syntax on
" The width of a TAB is set to 4.
" Still it is a \t. It is just that
" Vim will interpret it to be having
" a width of 4.
{
"added_words":
[
"diboson",
"Majorana",
"Higgs",
"collider",
"hadronic",
"leptonic",
"Feynman",
@raggleton
raggleton / .gitconfig
Last active April 29, 2021 11:30
gitconfig, without username, etc
[color]
ui = true
[alias]
b = branch
ca = commit --amend
can = commit --amend --no-edit
co = checkout
cb = checkout -b
cp = cherry-pick
cpc = cherry-pick --continue
@raggleton
raggleton / list_import_versions.py
Created March 22, 2021 11:38
List versions of imported packages
import sys
import types
def list_import_versions():
imports = []
for val in globals().values():
if isinstance(val, types.ModuleType) and val.__name__ != 'builtins':
full_name = val.__name__
version = getattr(sys.modules[full_name], '__version__', None) # skips builtins
if version:
@raggleton
raggleton / pointer_demo.cc
Created January 21, 2021 08:36
Testing raw pointer deletion. Compile with `g++ -o demo -g -O0 -Wall pointer_demo.cc `
#include <iostream>
#include <vector>
using namespace std;
class A {
public:
A(): thing(nullptr) {}
@raggleton
raggleton / findDuplicateMusic.py
Created December 26, 2018 21:20
Find duplicate music files and empty dirs
#!/usr/bin/env python
"""Look for "bad" directories with duplicate files (xxx.mp3 vs xxx 1.mp3),
empties, only artwork, etc
"""
import os
import re
@raggleton
raggleton / get_pr_id.py
Created November 12, 2018 15:51
How to get github PR unique ID using python2/3
#!/usr/bin/env python
"""
Get the Github Pull Request unique ID.
Needed for posting comments, etc
"""
from __future__ import print_function
import json
@raggleton
raggleton / Makefile
Created September 14, 2016 09:20
Quick latex makefile
all:
latexmk -bibtex -pdf -interaction=nonstopmode paper.tex
open paper.pdf
#!/usr/bin/env python
"""
Go through TeX files and count words, plot things.
TODO:
- improve timezone handling
- only count commits where tex file changed?
- add PDF pagecount?
"""
@raggleton
raggleton / jupyter_plot_save_helpers.py
Last active July 3, 2016 14:06
Functions/decorators to help make saving plots in ipython notebooks easier.
import os
from copy import deepcopy
from contextlib import contextmanager
# Global bool to turn on/off plot saving for all plots in notebook
SAVE_PLOTS = True
def save_plot(filename):