Skip to content

Instantly share code, notes, and snippets.

View thriveth's full-sized avatar

T. Emil Rivera-Thorsen thriveth

View GitHub Profile
@thriveth
thriveth / Evil-General.org
Created November 5, 2022 17:23
Evil-mode setup and keybindings managed with General.el

Evil-mode & friends

EVIL itself

(use-package evil
  :init
  (setq evil-want-keybinding nil)	;
  (setq evil-want-integration t)
  :config
  (define-key evil-normal-state-map (kbd "C-h") 'evil-window-left)
@thriveth
thriveth / init.el
Created October 28, 2022 01:41
minimal-ish Emacs config to work with Bibliographies and references
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(require 'use-package)
(setq custom-file (expand-file-name "emacs-custom.el" user-emacs-directory))
(load custom-file)
@thriveth
thriveth / battery_prompt.py
Created August 24, 2018 11:00
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
thriveth / batt_stat_string.py
Last active June 13, 2017 22:09
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 http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/#my-right-prompt-battery-capacity, 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
thriveth / vp-interactive.py
Last active September 9, 2016 18:04
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
# trive@astro.su.se
''' To run: python vp-interactive-py
'''
import scipy as sp
import scipy.constants as con
@thriveth
thriveth / error_interpolation.py
Last active August 17, 2022 11:15 — forked from kgullikson88/error_interpolation.py
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
thriveth / CBcolors.py
Created January 22, 2014 14:52
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.