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
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own twentyten_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since Twenty Ten 1.0
*/
@mutaku
mutaku / sam.py
Created July 18, 2012 17:46
samurai, samurai, samurai
#!/usr/bin/env python
import sys
import random
import pygame
from pygame.locals import *
# window shit
pygame.init()
DS = pygame.display.set_mode((800, 600), 0, 32)
def runsimulation(f):
def checkrun():
if len(changestate) >= 3 and changestate[-3] == changestate[-1]:
m("stuck in loop")
elif not len(changestate) or changestate[-1]:
f()
else:
m(len(changestate), " state changes - finished.")
return checkrun
@mutaku
mutaku / store_credit.py
Created August 7, 2012 21:58
Google code challenge - credit
#!/usr/bin/env python
# Google Code Challenge - Credit Problem
# http://code.google.com/codejam/contest/351101/dashboard#s=p0
import itertools
import bisect
from time import time
def last(array, num):
@mutaku
mutaku / checksublistlength.py
Created August 9, 2012 16:53
make sure all sublists are only one element
def checkpossibility(unsatlist):
if len(sorted(unsatlist, key=len, reverse=True)[0]) > 1:
return False
else:
return True
@mutaku
mutaku / checksublistlength_iterable.py
Created August 9, 2012 17:03
make sure all sublists are only one element - iterable version
def checkpossibility(unsatlist):
try:
for x in sorted(unsatlist, key=len, reverse=True):
if len(x) > 1:
raise Exception
else:
pass
return True
except:
return False
@mutaku
mutaku / mono_book.py
Created October 7, 2012 22:25
build monolithic book file from multiple html pages
##########################
# Import multi-page HTML
# books and write to file
##########################
from BeautifulSoup import BeautifulSoup
import urllib2
import re
import itertools
import bleach
@mutaku
mutaku / palindrome.cpp
Created November 15, 2012 21:23
palindromes (output stuffs here: https://gist.github.com/4219658 )
/* palindrome.cpp
* C++ implementation of palindrome.py
* (https://gist.github.com/4081368)
*
* - Matthew Martz 2012
*/
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
/* Practicing examples from http://web.cse.msu.edu/~cse231/python2Cpp.html
and http://code.google.com/edu/languages/cpp/basics/getting-started.html */
Enter number of digits:
999 - symmetry
start 999999 - stop 100
xx
SsSs
floor : 1001 ceiling : 999
floor : 999 ceiling : 999
floor : 999 ceiling : 999
997799
999 , 999