Skip to content

Instantly share code, notes, and snippets.

@rpmuller
rpmuller / parse_orgtable.py
Created November 19, 2015 20:22
Parse an orgmode table into a Pandas dataframe
def parse_orgtable(s):
"""Parse an org-table (input as a multiline string) into a Pandas data frame."""
# This didn't quite work, because spaces messed things up
#import cStringIO
#table = pd.read_table(cStringIO.StringIO(s),sep='|',skiprows=[1],skipinitialspace=True)
#table = table.drop(table.columns[[0,-1]],1)
# I suppose I could have simply run strip() on all of the resulting column names, since that was the problem
def parseline(l):
w = l.split('|')[1:-1]
return [wi.strip() for wi in w]
@bzg
bzg / emacs-strip.el
Last active January 2, 2023 21:22
Emacs, naked
;; Prevent the cursor from blinking
(blink-cursor-mode 0)
;; Don't use messages that you don't read
(setq initial-scratch-message "")
(setq inhibit-startup-message t)
;; Don't let Emacs hurt your ears
(setq visible-bell t)
;; You need to set `inhibit-startup-echo-area-message' from the
;; customization interface:
def parseline(line,format):
"""\
Given a line (a string actually) and a short string telling
how to format it, return a list of python objects that result.
The format string maps words (as split by line.split()) into
python code:
x -> Nothing; skip this word
s -> Return this word as a string
i -> Return this word as an int
@rpmuller
rpmuller / Sympy Circuit Plot.ipynb.json
Last active April 24, 2022 18:09
Quantum Circuit Plotting with SymPy
{
"metadata": {
"name": "Sympy Circuit Plot"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@rpmuller
rpmuller / Tight Binding.ipynb
Created May 30, 2013 01:31
Tight Binding program to compute the band structure of simple semiconductors. Expands on the basic Harrison parameters. Parameters taken from Vogl, Hjalmarson and Dow, [A Semiempirical Tight-Binding Theory of the Electronic Structure of Semiconductors](http://www.sciencedirect.com/science/article/pii/0022369783900641), J. Phys. Chem. Sol. 44 (5)…
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rpmuller
rpmuller / svg-display.ipynb
Last active January 23, 2019 05:53
IPython's SVG display functionality, in conjunction with the ease of making SVG strings using ElementTrees, makes it really easy to have a nice drawing canvas inside of IPython.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takluyver
takluyver / ipytables.py
Created March 6, 2013 11:57
IPyTables
class TableCell(object):
bg_colour = None
def __init__(self, value, header=False, bg_colour=None, text_colour=None):
self.value = value
self.header = header
self.bg_colour = bg_colour
self.text_colour = text_colour
def _make_css(self):
@stefanv
stefanv / sparks.py
Created November 17, 2011 00:25
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <stefan@sun.ac.za>
"""
USAGE: