Skip to content

Instantly share code, notes, and snippets.


Thøger Rivera-Thorsen thriveth

View GitHub Profile
thriveth /
Created Aug 24, 2018
Python script to return a zsh-formatted string to show battery status in your prompt.
#!/usr/bin/env python3
# -*- coding=utf-8 -*-
""" This script requires acpi to be installed """
import math
import subprocess
import sys
# Output
batt_info = subprocess.check_output("acpi").split(b',')
batt_info = [l.strip() for l in batt_info]
thriveth /
Last active Jun 13, 2017
Small Python script that returns a string encoding (linux) laptop battery status. Each char represents 10%. a `-` means empty, `🞂` means charging, and `🞀` means running on battery power. Strongly inspired by Steve Losh's zsh prompt, but changed quite a …
#!/usr/bin/env python
# coding=UTF-8
import math, subprocess, sys
batt_info = subprocess.check_output('acpi').split(b',')
batt_info = [l.strip() for l in batt_info]
percnt = int(batt_info[1][:-1])
total_slots, slots = 10, []
if batt_info[0].split()[-1] == 'Charging':
thriveth /
Last active Sep 9, 2016
Python, Chaco, TRaits(UI) -based interactive Voigt profile editor. Good to play around with to understand how b and N affect the profile.
#!/usr/bin/env python
# encoding: utf-8
# Copyright 2013, 2016 T. Emil Rivera-Thorsen
''' To run: python vp-interactive-py
import scipy as sp
import scipy.constants as con
thriveth /
Last active Aug 29, 2015 — forked from kgullikson88/
Interpolation with error propagation
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline as spline
class ErrorPropagationSpline(object):
Does a spline fit, but returns both the spline value and associated uncertainty.
def __init__(self, x, y, yerr, N=1000, *args, **kwargs):
See docstring for InterpolatedUnivariateSpline
thriveth /
Created Jan 22, 2014
A color blind/friendly color cycle for Matplotlib line plots. Might want to shuffle it around a bit more,but already not it gives kinda good contrasts between subsequent colors, and shows reasonably well in colorblind filters (though not in pure monochrome).
CB_color_cycle = ['#377eb8', '#ff7f00', '#4daf4a',
'#f781bf', '#a65628', '#984ea3',
'#999999', '#e41a1c', '#dede00']
def fill_between_steps(x, y1, y2=0, h_align='mid', ax=None, **kwargs):
''' Fills a hole in matplotlib: fill_between for step plots.
Parameters :
x : array-like
Array/vector of index values. These are assumed to be equally-spaced.
If not, the result will probably look weird...
y1 : array-like
View Plotting.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
thriveth / gist:5216313
Last active Dec 15, 2015
Conky rc file, slightly modified version of the conky-hardy found on noobslab.
View gist:5216313
# Use Xft?
use_xft yes
xftfont DejaVu Sans:size=8
xftalpha 0.6
text_buffer_size 2048
# Update interval in seconds
update_interval 1
# This is the number of times Conky will update before quitting.
thriveth / Twilight.vim
Last active Dec 13, 2015
Clone for Vim of the TextMate color scheme Twilight. Made automatically with [](Coloration) and modded to fix a few remaining eyesores: * More subdued error messages. * Stronger, but not too strong, highlighting of Search and IncSearch terms. * Different folding colors * Tweaked to change folding colors, search and …
View Twilight.vim
" Vim color file
" Converted from Textmate theme Twilight using Coloration v0.3.2 (
" Tweaked to change folding colors, search and incsearch highlight and better Tructure / Special colors
" (That is, closer to the original)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
thriveth / gist:4114981
Created Nov 19, 2012
TeX example to use in Vim tutorial
View gist:4114981
\item[Item1]{Something I feel like telling about}
\item[Item1]{Something else I also feel like telling about}
%... Many items go here