Skip to content

Instantly share code, notes, and snippets.

@raggleton
raggleton / shutup_root.md
Created February 12, 2016 10:41
How to shut up ROOT

To turn off messages like:

Info in <TCanvas::Print>: png file my_plot.png has been created

add in:

gErrorIgnoreLevel = kWarning
#!/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 / .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
" 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 / 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 / plot_two_pandas.py
Created April 21, 2015 09:57
Make 2 side-by-side hists or scatter plots from two pandas dataframes
def plot_two_hists(var, df1, df2, title1, title2, xlabel, ylabel, **kwargs):
"""function to make 2 side-by-side hists to compare 2 dataframes"""
fig2, ax2 = plt.subplots(nrows=1, ncols=2)
fig2.set_size_inches(24, 8)
plt.subplots_adjust(wspace=0.2)
df1[var].plot(kind="hist", ax=ax2[0], title=title1, **kwargs)
ax2[0].set_xlabel(xlabel)
ax2[0].set_ylabel(ylabel)