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 / checkurl.py
Created December 14, 2012 04:14
Check that a URL goes somewhere
from urllib2 import urlopen
URLfail = False
try:
code = urlopen(the_url).code
if code >= 400:
URLfail = True
except:
URLfail = True
@mutaku
mutaku / printer_jobs_strings.py
Last active December 17, 2015 09:09
Create a print job string for page range by supplying a total range of pages and an exclude list (such as graphical pages or ones simply not needed).
'''Create a print job string for page range by supplying
a total range of pages and an exclude list (such as graphical
pages or ones simply not needed).
Example:
In [1]: from printer_jobs_strings import make_print_string
In [2]: pages = range(0, 25)
In [3]: exclude = [3, 6, 7, 8, 15, 24]
In [4]: make_print_string(pages, exclude)
Out[5]: '0-2,4-5,9-14,16-23'
@mutaku
mutaku / old_post_handler.py
Created May 16, 2013 18:55
Rip out old posts from wordpress XML export, convert to markdown, and put in a new database structure.
from django.core.files.uploadedfile import InMemoryUploadedFile
import cStringIO
import StringIO
from urllib2 import urlopen
from PIL import Image as PILImage
import re
import os
from xml.dom import minidom
from mutaku.blog.models import Post, Image
from mutaku.tools.extras import findext
@mutaku
mutaku / grabdragndrop.py
Created May 23, 2013 18:26
Test handling multiple drag and drops to raw_input
def grabber():
s = raw_input("files: ")
delim = "C:\\"
files = [delim+x for x in s.split(delim) if x]
return files
@mutaku
mutaku / problem_1.py
Created May 29, 2013 20:45
Project Euler Toiling
def multiples(max, div):
results = list()
for i in range(1, max):
if not all(map(lambda x: i % x, div)):
results.append(i)
return results
a = multiples(1000, [3, 5])
sum(a)
@mutaku
mutaku / problem_a.py
Last active December 17, 2015 21:19
Ural Championship 2013 Problem Set
# Problem A. Graphics Settings
'''
Example input:
1
vsync 10
640 480 10000000
2
Off vsync
Resolution 320 240
'''
# 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/
#
# For help with conky, please see:
@mutaku
mutaku / season_3.js
Last active December 19, 2015 01:29
PoE Race Season Schedule
var c = [{"id":"Descent (S03D001)","url":null,"event":false,"registerAt":null,"startAt":"2013-06-29T00:00:00Z","endAt":"2013-06-29T01:00:00Z","rules":[],"ladder":[]},{"id":"1 Hour No Proj Party (S03F002)","url":null,"event":false,"registerAt":null,"startAt":"2013-06-29T03:00:00Z","endAt":"2013-06-29T04:00:00Z","rules":[],"ladder":[]},{"id":"135 Minute Solo (S03C003)","url":null,"event":false,"registerAt":null,"startAt":"2013-06-29T07:00:00Z","endAt":"2013-06-29T09:15:00Z","rules":[],"ladder":[]},{"id":"90 Min Immolation Solo (S03F004)","url":null,"event":false,"registerAt":null,"startAt":"2013-06-29T12:00:00Z","endAt":"2013-06-29T13:30:00Z","rules":[],"ladder":[]},{"id":"90 Minute Turbo Solo (S03C005)","url":null,"event":false,"registerAt":null,"startAt":"2013-06-29T14:00:00Z","endAt":"2013-06-29T15:30:00Z","rules":[],"ladder":[]},{"id":"1 Hour Party (S03F006)","url":null,"event":false,"registerAt":null,"startAt":"2013-06-29T21:00:00Z","endAt":"2013-06-29T22:00:00Z","rules":[],"ladder":[]},{"id":"Descent (S03
@mutaku
mutaku / tkwatchdog.py
Last active August 3, 2018 16:56
monitor directory for file changes
import multiprocessing
import os
import sys
import time
import Queue
import threading
from tkwindow import Report
from watchdog import WatchDog