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
@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
@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 / youtube_playlist_bookmarklet
Created March 18, 2011 01:35
bookmarklet to get all video links in youtube playlist displayed in alert
javascript:
if (typeof jQuery == 'undefined') {
var jQ = document.createElement('script');
jQ.type = 'text/javascript';
jQ.onload=runthis;
jQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
document.body.appendChild(jQ);
}
else {
runthis();
@mutaku
mutaku / gist:996599
Created May 28, 2011 04:33
imgur python
class UploadImage():
"""
Upload images to imgur
returns either .error or .imageURL
TO DO:
POSSIBLE TO DO:
- add stats and image info functions
- allow for full JSON responses instead of having to manually parse XML
@mutaku
mutaku / repair mysql
Created February 28, 2012 02:23
fix MySQL jams
mysqlcheck -u root -p --auto-repair --all-databases
@mutaku
mutaku / python_dir_walk.py
Created February 28, 2012 02:26
python directory walking
import os
d = os.walk(some_dir)
m = {}
for root,dir,files in d:
m[root] = files
for key in m.keys():
print "Key => ",key," is ",len(key.split('/'))
@mutaku
mutaku / sorting_auth_data.sh
Created March 1, 2012 03:19
BASH sorting of brute force attempts
# finding authentication errors in all message log files
grep -r "authentication error" messages* | awk '{split($0,a," "); print a[NF],a[NF-2]}' > attempts
# username
cut -d ' ' -f2 attempts | sort -k 2,2 | uniq -c | sort -nr > attempts_username
# IP
cut -d ' ' -f1 attempts | sort | uniq -c | sort -nr > attempts_ip
@mutaku
mutaku / sc-dl.js
Created March 9, 2012 01:51 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);
@mutaku
mutaku / iters_lists.py
Created March 13, 2012 02:55
iters of iters of iters of lists of lists of lists
x = [[[1, 2, 3, 4], [9, 8, 7, 6]], [[10, 20, 30, 40], [90, 80, 70, 60]]]
from itertools import chain
[[y[i] for y in list(chain.from_iterable(x))] for i in range(0,len(x[0][0]))]
@mutaku
mutaku / gist:2033550
Created March 14, 2012 02:30
matrix transposition
from itertools import chain
[[y[i] for y in list(chain.from_iterable(x)) if y[i] and y[i] < 200] for i in range(0,len(x[0][0]))]