Skip to content

Instantly share code, notes, and snippets.

View ejetzer's full-sized avatar

Émile Jetzer ejetzer

  • Polytechnique Montréal
  • Verdun, Québec
View GitHub Profile
@ejetzer
ejetzer / Dragon Curve.py
Created November 28, 2013 00:32
Dragon Curve
from scene import *
from math import atan, cos, sin, sqrt, log
ratio = 0.5
def bump(start, end):
x1, y1 = start
x2, y2 = end
length = sqrt((x2-x1)**2 + (y2-y1)**2)
midx = (x2 + x1) / 2
@ejetzer
ejetzer / Sierpinski Triangle.py
Created November 28, 2013 00:33
Sierpinski Triangle
from scene import *
def draw_triangle(a, b, c):
for pt in (a, b, c):
nxt = {a:b, b:c, c:a}[pt]
line(pt[0], pt[1], nxt[0], nxt[1])
def more(a, b, c):
# a, b, c are 2-tuples
# Find the midpoints of a, b, c
@ejetzer
ejetzer / Demonstration.py
Created November 28, 2013 00:35
Demonstration
from math import sqrt, pi
# Program examples
def double(some_number):
return 2 * some_number
def dbl(n):
return 2*n
@ejetzer
ejetzer / Error detection.py
Created October 11, 2015 01:07
Error detection.py
import numbers, decimal, fractions, sympy, itertools
def permutations(p):
res = set()
for i in range(len(p)):
for q in itertools.permutations(p, i):
res.add(q)
return res
def compose(funcs):
@ejetzer
ejetzer / NNWM Wordcount.py
Created November 9, 2015 11:30
NNWM Wordcount.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys, requests, hashlib
if sys.version_info.major == 2: input = raw_input
# You can get you key from http://nanowrimo.org/api/wordcount
KEY = '8996ghhhftdgn87j'
@ejetzer
ejetzer / Untitled.py
Created January 21, 2016 00:01
Untitled.py
# coding: utf-8
import webbrowser
due = 'due://x-callback-url/add?title=%s&hourslater=4&x-success=pythonista://&x-error=pythonista://&x-source=Pythonista'
webbrowser.open(due % 'a')
print 'a'
webbrowser.open(due % 'b')
print 'b'
@ejetzer
ejetzer / Untitled.py
Created January 21, 2016 00:02
Untitled.py
# coding: utf-8
import webbrowser
due = 'due://x-callback-url/add?title=%s&hourslater=4&x-success=pythonista://&x-error=pythonista://&x-source=Pythonista'
webbrowser.open(due % 'a')
print 'a'
webbrowser.open(due % 'b')
print 'b'
@ejetzer
ejetzer / Compile Tasks.py
Created January 23, 2016 16:50
Compile Tasks.py
# coding: utf-8
import appex, dialogs, scene
import plistlib, copy, webbrowser, urllib, time
# check out http://handleopenurl.com/
db = 'Tasks.txt'
url = 'omnifocus://task/%s'
due = 'due://x-callback-url/add?title=%s&hourslater=4&x-success=pythonista://&x-error=pythonista://&x-source=Pythonista'
@ejetzer
ejetzer / Share Task.py
Created January 23, 2016 16:53
Share Task.py
# coding: utf-8
import appex, dialogs, scene
import plistlib, copy, webbrowser, urllib, time
# check out http://handleopenurl.com/
url = 'omnifocus://task/%s'
def get_tasks(shared):
@ejetzer
ejetzer / Compile Tasks.py
Created January 23, 2016 17:31
Compile Tasks.py
# coding: utf-8
import appex, dialogs, scene
import plistlib, copy, webbrowser, urllib, time
# check out http://handleopenurl.com/
db = 'Tasks.txt'
url = 'omnifocus://task/%s'
due = 'due://x-callback-url/add?title=%s&hourslater=4&x-success=pythonista://&x-error=pythonista://&x-source=Pythonista'