Skip to content

Instantly share code, notes, and snippets.

@parksoy
parksoy / tmux_cheatsheet.markdown
Created September 11, 2019 21:49 — forked from henrik/tmux_cheatsheet.markdown
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@parksoy
parksoy / dict_namedtuple.py
Created March 18, 2019 23:00 — forked from href/dict_namedtuple.py
Convert any dictionary to a named tuple
from collections import namedtuple
def convert(dictionary):
return namedtuple('GenericDict', dictionary.keys())(**dictionary)
"""
>>> d = dictionary(a=1, b='b', c=[3])
>>> named = convert(d)
>>> named.a == d.a
True
>>> named.b == d.b
@parksoy
parksoy / gist:e52f46880c1054cd81428123e584673a
Created October 6, 2018 00:06
Variability chart in python matplotlib
#https://stackoverflow.com/questions/31845258/pandas-multi-index-plotting
import pandas as pd
import matplotlib.pyplot as plt
from itertools import groupby
import numpy as np
%matplotlib inline
groups = ('Group 1', 'Group 2')
sexes = ('Male', 'Female')
@parksoy
parksoy / gist:60da15ca51b13b0045d0b86c6a5a4494
Created August 29, 2018 22:46
matplotlib many by many plots
fig, ax = plt.subplots(len(set(df_all.structure))-1,len(df_all.columns)-1,figsize=(30.0, 30.0), sharey=False) #, tight_layout=True, sharex=True,
for j, struc in enumerate(set(df_all.structure)): #19 structures
df_onestruc=df_all[df_all.structure==struc]
df_onestruc.index=df_onestruc['index']
df_onestruc=df_onestruc.drop(['structure', 'index'], axis=1)
for i, col in enumerate(df_onestruc.columns): # 18 parameters
ax[i,j].plot(df_onestruc[col])
ax[i,j].grid(True)
ax[i,j].get_yaxis().set_ticks([]) #.set_visible(False)
@parksoy
parksoy / tmux-cheatsheet.markdown
Created August 28, 2018 17:31 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@parksoy
parksoy / gzip_files_in_python.md
Created May 16, 2018 19:53 — forked from john-science/gzip_files_in_python.md
Reading & Writing GZIP Files Faster in Python

Reading & Writing GZIP Files in Python

I have been testing various ways to read and write text files with GZIP in Python. There were a lot of uninteresting results, but there were two I thought were worth sharing.

Writing GZIP files

If you have a big list of strings to write to a file, you might be tempted to do:

f = gzip.open(out_path, 'wb')

for line in lines: