@ wrote... (2 years, 6 months ago)

Yesterday I was working on Pygments during a Pycon 2016 sprint and added markdown syntax highlighting (with help from Tim Hatch). My pull request just got merged so version 2.2 will finally highlight GitHub flavored markdown (issue).

Category: tech, Tags: python
Comments: 0
@ wrote... (2 years, 6 months ago)

I was working on Magic Wormhole during a Pycon 2016 sprint and noticed that zipfiles don't preserve file permissions. I'm not the only one who's noticed this (some posts go back over five years) but it still doesn't appear to be fixed.

Anyhow, here's how I did it…

more…

Category: tech, Tags: python
Comments: 1
@ wrote... (5 years, 1 month ago)

For funsies I ported my mazesolver to pypy.

See update 2 for reference.

more…

Category: tech, Tags: mazes, python
Comments: 0
@ wrote... (5 years, 2 months ago)

Python tempdir.mkdtemp() has an annoying feature, it doesn't clean up after itself.

This idea comes from my friend and colleague Mike.

more…

Category: tech, Tags: python
Comments: 0
@ wrote... (5 years, 7 months ago)

This was originally the majority of this post: Start a django project the right way but I've decided to put in it's own post instead.

I'm assuming you're on OSX. If you're on Linux most of these steps will be the same. If you're on Windows… Install VMWare and then install Linux.

I've added a tl;dr at the end.

Although I have tweaked this over the years, the original code came from (I think, I've long since lost the bookmark) klymyshyn.com

more…

Category: tech, Tags: python, shell
Comments: 10
@ wrote... (5 years, 10 months ago)

Although I doubt I'm forging into unknown territory, here is a nice little way I came up with to iterate around a box or square.

def next_coord( w, h ):
    """
    get the next x,y coordinates around your box
    w,h are the width and height of your box

    note, the strange ranges are to prevent getting the corners twice
    this loop configuration goes around clockwise from top left

    for x,y in next_coord(3,3):
        print "(%d,%d)" % (x,y),
    >>> (0,0) (1,0) (2,0) (2,1) (2,2) (1,2) (0,2) (0,1)
    """
    for x in range(0,w-1):        # top
        yield x,0
    for y in range(0,h-1):        # right
        yield w-1,y
    for x in range(w-1,0,-1):     # bottom
        yield x,h-1
    for y in range(h-1,0,-1):     # left
        yield 0,y
Category: tech, Tags: programming, python
Comments: 0
@ wrote... (7 years, 10 months ago)

Continuing from maze solver update, I came across another very large maze at Purpy Pupple wikipedia page. And when I say large, I mean 4000x4000 large. Purpy calls it 2000x2000 but since it is very clearly 4000 pixels by 4000 pixels I'm calling it as 4k.

more…

Category: tech, Tags: mazes, python
Comments: 0
@ wrote... (8 years, 2 months ago)

Here's a follow up to my previous post, maze solver. I've finally gotten around to solving this properly with a breadth-first search. Shortest path is 16031, 11% better than my previous best.

more…

Category: tech, Tags: mazes, python
Comments: 1
@ wrote... (9 years, 1 month ago)

I saw a recent post of the most incredible maze I've ever seen. Well I just had to solve it.

more…

Category: tech, Tags: mazes, python
Comments: 0
@ wrote... (11 years, 6 months ago)

Here's a python script to increment an emails spam score. I call it (potentially several times) after SpamAssassin and before final delivery.

more…

Category: tech, Tags: email, python
Comments: 0