I hereby claim:
- I am gvx on github.
- I am robinwell (https://keybase.io/robinwell) on keybase.
- I have a public key whose fingerprint is 43E3 C73A 188A 844E 39F1 EEBA E429 16EB 3793 DA2D
To claim this, I am signing this object:
| #!/usr/bin/env python | |
| # coding=utf-8 | |
| # <a class="btn btn-default pull-right" href="https://gist.github.com/TylerShaw/48ead56c19ce905ac513"><i class="fa fa-git"></i> Download the gist here!</a> | |
| # Py2Md started as a little project to do the magical "self documenting code". After thinking about it, I realized self documenting code is great, but it's really not the point. | |
| # Commenting code properly, if only better, is the point. | |
| # This script evolved from me wanting to code better. I often look at other peoples code, or even old code I've written, and it takes me a few minutes to even figure out what each section is doing. | |
| # This will hopefully solve that, not only by forcing me to comment code better, but to publish my code with decent comments. | |
| # This script reads in a python file (either itself, or anything it's | |
| # imported into) and converts the python file into a markdown file. It |
| $ py3.3 time_them.py | |
| default implementation: | |
| 2.1573487099958584 | |
| my implementation: | |
| 0.7448599760100478 | |
| $ py3.3 time_them_2.py | |
| default implementation: | |
| 0.6372028530022362 | |
| my implementation: | |
| 0.20809232600731775 |
| from collections import OrderedDict | |
| from inspect import Parameter, signature | |
| from itertools import chain, starmap | |
| from operator import itemgetter | |
| __all__ = ['namedtuple'] | |
| dict_property = property(lambda self: OrderedDict(zip(self._fields, self)), | |
| doc='dictionary for instance variables (if defined)') |
I hereby claim:
To claim this, I am signing this object:
| return function(name) | |
| local class = require(name) | |
| local classmt = getmetatable(class) | |
| if getmetatable(class) == nil then | |
| local props = {unpack(class)} | |
| for i = #class, 1, -1 do | |
| class[i] = nil | |
| end | |
| local classmt = {} | |
| local instancemt = {__index = class} |
| xxxxxxxx | |
| x x | |
| x xxxx x | |
| x x x x | |
| x x x x | |
| x xxxx x | |
| x x | |
| xxxxxxxx | |
| --- |
| from random import choice | |
| with open('/usr/share/dict/nederlands') as f: | |
| words = f.read().split('\n') | |
| def get_random_pair(): | |
| w1 = choice(words) | |
| w2 = choice(words) | |
| return len(w1) + len(w2), w1, w2 |
| class LinkedList: | |
| next = None | |
| val = None | |
| def __init__(self, val): | |
| self.val = val | |
| def add(self, val): | |
| if self.next is None: | |
| self.next = LinkedList(val) |
| function love.graphics.roundrect(mode, x, y, width, height, xround, yround) | |
| local points = {} | |
| local precision = (xround + yround) * .1 | |
| local tI, hP = table.insert, .5*math.pi | |
| if xround > width*.5 then xround = width*.5 end | |
| if yround > height*.5 then yround = height*.5 end | |
| local X1, Y1, X2, Y2 = x + xround, y + yround, x + width - xround, y + height - yround | |
| local sin, cos = math.sin, math.cos | |
| for i = 0, precision do | |
| local a = (i/precision-1)*hP |
| last = None | |
| with open('index.txt') as f: | |
| for line in f: | |
| new = int(line.decode('utf-8').split('\t', 1)[0]) | |
| if last is not None: | |
| if last - new > 1: | |
| if last - new == 2: | |
| print new + 1 | |
| else: |