Instantly share code, notes, and snippets.

🏠
Working from home

# Stewart Parkstewartpark

🏠
Working from home
• Sort options
Last active Aug 29, 2015
Projecteuler.net Problem 381
View p381.py
 #!/usr/bin/env python """ Projecteuler Problem 381 Wilson's theorem """ import fastlib import math
Last active Aug 29, 2015
Foo.bar zombit monitoring
View zombit.py
 def intersect(P, i): ps = [] for p in P: if p[0] <= i[0] and p[1] >= i[0]: ps.append(p) elif p[0] <= i[1] and p[1] >= i[1]: ps.append(p) elif p[0] >= i[0] and p[1] <= i[1]: ps.append(p) return ps
Created Oct 11, 2015
taco-recommend.md
View gist:ed4327df81accd192bf2
 Ezpz. :D https://taco-spolsky.github.io/?____valueOf#|checksum=9284326|Stewart Park=
Created Oct 11, 2015
View drchrono2.py
 from __future__ import print_function from collections import OrderedDict N = input() raw_records = map(lambda x: raw_input(), xrange(N)) records = OrderedDict() # Since the syntactic correctness is given in the example, and also the order of the names can be simplified to the length of the name, occurence = lambda x, y: len(x) - len(x.replace(y, '')) order = lambda x: (10 * len(x.split())) - occurence(x, '.')
Created Oct 13, 2015
View xor_dec.py
 #!/usr/bin/env python3 from functools import lru_cache """ The encryption equation is given as: D_i = (129M_i) XOR (M_(i-1)) (mod 256) where D denotes a encrypted string, M is the message. Thus, the message equation derived from the original equation should be:
Created May 25, 2013
Hello world!
View test.java
 import java.lang.*; import java.lang.reflect.*; public class test extends ClassLoader{ byte[] b = {(byte)0xCA,(byte)0xFE,(byte)0xBA,(byte)0xBE,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x32,(byte)0x00,(byte)0x1D,(byte)0x0A,(byte)0x00,(byte)0x06,(byte)0x00,(byte)0x0F,(byte)0x09,(byte)0x00,(byte)0x10,(byte)0x00,(byte)0x11,(byte)0x08,(byte)0x00,(byte)0x12,(byte)0x0A,(byte)0x00,(byte)0x13,(byte)0x00,(byte)0x14,(byte)0x07,(byte)0x00,(byte)0x15,(byte)0x07,(byte)0x00,(byte)0x16,(byte)0x01,(byte)0x00,(byte)0x06,(byte)0x3C,(byte)0x69,(byte)0x6E,(byte)0x69,(byte)0x74,(byte)0x3E,(byte)0x01,(byte)0x00,(byte)0x03,(byte)0x28,(byte)0x29,(byte)0x56,(byte)0x01,(byte)0x00,(byte)0x04,(byte)0x43,(byte)0x6F,(byte)0x64,(byte)0x65,(byte)0x01,(byte)0x00,(byte)0x0F,(byte)0x4C,(byte)0x69,(byte)0x6E,(byte)0x65,(byte)0x4E,(byte)0x75,(byte)0x6D,(byte)0x62,(byte)0x65,(byte)0x72,(byte)0x54,(byte)0x61,(byte)0x62,(byte)0x6C,(byte)0x65,(byte)0x01,(byte)0x00,(byte)0x04,(byte)0x6D,(byte)0x61,(byte)0x69,(byte)0x6E,(byte)0x01,(byte)0x00,(byte)0x
Last active Jan 21, 2016
Aggregate the console output of `ag` and git blame it.
View aggregate_gb.py
 from collections import Counter, defaultdict from subprocess import check_output import sys import re name_extractor=re.compile(r"\(.+?\)") e=defaultdict(set) try: while True:
Created Jan 29, 2016
Merge sort
View mergesort.py
 """ Merge sort """ first = lambda l: l[0] if len(l) else None last = lambda l: l[-1] if len(l) else None first_half = lambda l: l[:len(l)/2] last_half = lambda l: l[len(l)/2:] merge = lambda a, b: ( [first(a)] + merge(a[1:], b) if first(a) < first(b) else [first(b)] + merge(a, b[1:])
Created Feb 7, 2016
View down_tumblr_video.py
 from pyquery import PyQuery as pq import requests open('./video.mp4', 'wb').write(requests.get(pq(url=pq(url='http://dogvideos.tumblr.com/post/93519938318/videohall-how-dogs-react-to-human-barking')('iframe').attr('src'))('video source').attr('src')).content)
Last active Feb 25, 2016
Monty Hall Problem
View monty_hall_simul.py
 """ https://en.wikipedia.org/wiki/Monty_Hall_problem """ import random def do_game(change_selection): # Initial door doors = [1, 0, 0]
You can’t perform that action at this time.