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 / 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 / tkinter_printer_selection.py
Created February 28, 2012 02:10
Printer selection in a Tkinter Python GUI using lpstat and test printing with lpr
#!/usr/bin/env python
from Tkinter import *
import sys, commands, os
root = Tk()
root.title('Printer Configuration')
root.config(bg="lightblue")
def getPrinter():
nIndex = printerList.curselection()[0]
@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]))]
<?php
/**
* The template for displaying Comments.
*
* The area of the page that contains both current comments
* and the comment form. The actual display of comments is
* handled by a callback to twentyten_comment which is
* located in the functions.php file.
*
* @package WordPress