Skip to content

Instantly share code, notes, and snippets.

View itdaniher's full-sized avatar

itdaniher itdaniher

  • mosslandia
View GitHub Profile
@itdaniher
itdaniher / summary.md
Created October 27, 2011 01:31
How do I use 'stash' in Git?

If you've made some changes, need to stop what you're doing, and not commit, you probably want to use git's stash feature, which saves your changes and restores you to a clean copy of HEAD.

Here's how to do it:

 git stash save

...saves your local changes.

 git stash apply stash@{0}
@itdaniher
itdaniher / summary.md
Created October 27, 2011 01:34
How do I get a listing of attached USB devices in OSX?

OSX lacks the usbutils package. Sometimes you feel compelled to do hardware development in OSX, and it's nice to know if a device is enumerating properly.

To pull this off, run

 system_profiler SPUSBDataType

It may be helpful to alias this command to lsusb.

You can either make a script containing the above command or add

@itdaniher
itdaniher / backup.py
Created November 4, 2011 19:15
rsync backup script using hardlinks, written by someone in python
#!/usr/bin/env python
# Script for automatic backup of files to a fileserver using rsync.
# Directories to backup and details about the remote fileserver and
# exclude patterns must be entered in the backup script itself.
# See 'User Configurable Parameters' below.
#
# Backup consists of three functions controlled by commandline arguments:
#
# /etc/backup sync
@itdaniher
itdaniher / ihex.py
Created November 10, 2011 20:46
Lightweight IHEX parser written in Python
#
# -----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <it.daniher@gmail.com> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy us a beer in return.
#
# Ian Daniher, 2010-06-30
# based off of information contained at http://en.wikipedia.org/wiki/Intel_HEX
# -----------------------------------------------------------------------------
@itdaniher
itdaniher / .eaglerc
Created November 10, 2011 23:28
Ian's .eaglerc, with random crap mostly removed.
# EAGLE Parameter File (generated by EAGLE Version 5.11.0 - DO NOT EDIT!)
Attribute.HeaderA = "1 0:100 1:100 2:100 3:25 4:100"
Brd.Key.A+BS = "Undo"
Brd.Key.A+F2 = "Window fit"
Brd.Key.A+F7 = "Group"
Brd.Key.A+F9 = "Ripup"
Brd.Key.A+F10 = "Grid mm 1 on; Grid alt mm 0.1;"
Brd.Key.A+F11 = "display none; display 17 20 21 23 27 31 45 51; display -25 -26 -28;"
Brd.Key.F2 = "Window;"
@itdaniher
itdaniher / .eaglerc
Created November 10, 2011 23:28
Ian's .eaglerc, with random crap mostly removed.
# EAGLE Parameter File (generated by EAGLE Version 5.11.0 - DO NOT EDIT!)
Attribute.HeaderA = "1 0:100 1:100 2:100 3:25 4:100"
Brd.Key.A+BS = "Undo"
Brd.Key.A+F2 = "Window fit"
Brd.Key.A+F7 = "Group"
Brd.Key.A+F9 = "Ripup"
Brd.Key.A+F10 = "Grid mm 1 on; Grid alt mm 0.1;"
Brd.Key.A+F11 = "display none; display 17 20 21 23 27 31 45 51; display -25 -26 -28;"
Brd.Key.F2 = "Window;"
@itdaniher
itdaniher / iupacAtW.py
Created June 2, 2012 02:28
scrape atomic weight information from IUPAC
import urllib
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib.urlopen("http://www.chem.qmul.ac.uk/iupac/AtWt/index.html").read())
t = soup.findAll("table")[2]
print [ [item.text for item in row.findAll("td")] for row in t.findAll("tr") ]
@itdaniher
itdaniher / rle.py
Last active October 23, 2021 11:26
Run Length Encoding, Two Ways
import numpy as np
import itertools
def rle(x):
where = np.flatnonzero
x = np.asarray(x)
n = len(x)
if n == 0:
return np.array([], dtype=int)
starts = np.r_[0, where(~np.isclose(x[1:], x[:-1], equal_nan=True)) + 1]
@itdaniher
itdaniher / bench.py
Created January 30, 2017 20:58
python-blosc / python-lz4 profiling
import uuid
import timeit
import lz4
import os
from timeit import Timer
import sys
import blosc
DATA = open(sys.argv[1], "rb").read()
LZ4_DATA = lz4.block.compress(DATA)
@itdaniher
itdaniher / compress_ptr.py
Created January 30, 2017 21:08
python-blosc profiling
"""
Small benchmark that compares a plain NumPy array copy against
compression through different compressors in Blosc.
"""
from __future__ import print_function
import numpy as np
import time
import blosc
import ctypes