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 / gist:2842131
Created May 31, 2012 09:07
Sherpa.astro.ui module fails to load
In [33]: import sherpa.astro.ui as ui
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/disk/caleuche_1/trive/Arbejde/LARS-COS/<ipython console> in <module>()
/home/trive/Softwarebuild/python_packages/lib/python2.6/site-packages/sherpa/astro/ui/__init__.py in <module>()
19
20 import sherpa.all
---> 21 import sherpa.astro.all
@thriveth
thriveth / gist:4112851
Created November 19, 2012 18:54
Keymap in Vim to scroll while keeping the cursor vertically centered in the window.
" Alt+j/k scrolls text up/down while
" keeping the cursor in center line.
nnoremap <A-j> jzz
nnoremap <A-k> kzz
@thriveth
thriveth / gist:4114981
Created November 19, 2012 23:55
TeX example to use in Vim tutorial
\begin{description}
\item[Item1]{Something I feel like telling about}
\item[Item1]{Something else I also feel like telling about}
%... Many items go here
\end{description}
@thriveth
thriveth / Twilight.vim
Last active December 13, 2015 22:59
Clone for Vim of the TextMate color scheme Twilight. Made automatically with [http://coloration.sickill.net/](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 …
" Vim color file
" Converted from Textmate theme Twilight using Coloration v0.3.2 (http://github.com/sickill/coloration)
" 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
thriveth / gist:5216313
Last active December 15, 2015 06:29
Conky rc file, slightly modified version of the conky-hardy found on noobslab.
# 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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
@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 / 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 / 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]