Skip to content

Instantly share code, notes, and snippets.

View mutaku's full-sized avatar
🌌
Latent Layer 5

Matthew Martz mutaku

🌌
Latent Layer 5
View GitHub Profile
def local_difference(p, data, constrain_metric, change_metric, walk_length=10):
"""Identify difference from local smoothing
p is an x declaration of dataset data
"""
p = int(p)
constrain_data = functools.reduce(getattr,
[data] + constrain_metric.split('.'))
change_data = functools.reduce(getattr,
[data] + change_metric.split('.'))
@mutaku
mutaku / get_mm_description.py
Last active May 5, 2016 19:52
Metamorph experiment description from PDF summary
import PyPDF2 as PDF
import os
f = "C:\\User Data\\Nikon\\4_12_2016\\Multi Dimensional Acquisition Summar.pdf"
pdf_obj = PDF.PdfFileReader(open(f, 'rb'))
pdf_text = pdf_obj.getPage(0).extractText()
description = pdf_text.split('\n')[-1].split('Description')[-1].split('Printed on')[0]
# OR
descriptions = dict()
@mutaku
mutaku / anagram.py
Created March 29, 2016 18:17
anagramamama
# ver a
def anagram(str_a, str_b):
return sorted([ord(x) for x in str_a]) == sorted([ord(y) for y in str_b])
# ver b
def anagram(str_a, str_b):
if len(str_a) == len(str_b):
return sorted(str_a) == sorted(str_b)
return False
We'll begin with a box, and the plural is boxes;
but the plural of ox became oxen not oxes.
One fowl is a goose, but two are called geese,
yet the plural of moose should never be meese.
You may find a lone mouse or a nest full of mice;
yet the plural of house is houses, not hice.
If the plural of man is always called men,
why shouldn't the plural of pan be called pen?
If I spoke of my foot and show you my feet,
and I give you a boot, would a pair be called beet?
@mutaku
mutaku / filter_matrix_cell_size.m
Created May 5, 2015 19:04
Filter a cell matrix by size of each element - subthresholding
% Filter dataMatrix to eliminate elements which contain fewer than 50 subelements
% i.e. subthresholding dataMatrix
dataMatrix(find(cellfun('size', dataMatrix, 1) < 50)) = cell(1);
@mutaku
mutaku / serial.sh
Created November 20, 2014 15:11
Grab all the current Serial episodes via RSS feed
wget -q -O- http://feeds.serialpodcast.org/serialpodcast | grep -o "<enclosure[ -~][^>]*" | grep -o "http://[ -~][^\"]*" | xargs wget -c
desktop ~ $ cat .conkyrc
# conky configuration
#
# The list of variables has been removed from this file in favour
# of keeping the documentation more maintainable.
# Check http://conky.sf.net for an up-to-date-list.
#
# For ideas about how to modify conky, please see:
# http://crunchbanglinux.org/forums/topic/59/my-conky-config/
#
# Trying to filter on a hybrid_property
# This should return all but one of them (12 out of 13)
In [590]: active = db.session.query(db.Trade).filter(db.Trade.active == True).all()
# Nope
In [591]: active
Out[591]: []
# Try this?
In [592]: active = db.session.query(db.Trade).filter(db.Trade.active).all()
@mutaku
mutaku / road_cc_convert_bookmarklet.js
Last active January 1, 2016 17:29
Convert Pounds to US Dollars on road.cc reviews
javascript: (
function () {
var data = document.getElementsByClassName("review-price");
for (var i = 0; i < data.length; i++) {
if (data[i].innerHTML.indexOf("£") != -1) {
data[i].innerHTML = '$' + Math.round(data[i].innerText.replace('£', '') * 1.6479 * 100) / 100;
}
}
}())
In [1]: # Cadence measured by count ~10x during ride
In [2]: # Averaged 102 rpm (with a range of 96-122)
In [3]: 102 * 30 # rpm * min
Out[3]: 3060
In [4]: 17 + 133 + 89 # steps measured by fitbit intervals
Out[4]: 239