Skip to content

Instantly share code, notes, and snippets.

@alexmic
alexmic / problem_79.py
Created October 5, 2013 22:24
Project Euler problem #79.
from collections import defaultdict, deque
def find_number_universe(keylog):
numbers = set()
for attempt in keylog:
for num in attempt:
numbers.add(num)
return numbers
"""
py.test demo
~~~~~~~~~~~~
#yolo
"""
from pytest import raises, mark, fixture
import os
import pytest
from alembic.command import upgrade
from alembic.config import Config
from project.factory import create_app
from project.database import db as _db
@alexmic
alexmic / data.json
Last active December 31, 2015 06:18
Microtemplates example, read from JSON file.
{
"webpage": {
"title": "Stackoverflow"
},
"cover_artists": [
{
"name": "Ozzy",
"nicknames": ["Ozzman", "Ozzster"]
},
{
@alexmic
alexmic / pixel_count.py
Last active March 29, 2023 22:10
Counts the number of pixels per letter of the English alphabet.
from operator import itemgetter
from PIL import Image, ImageDraw, ImageFont
# Make a lowercase + uppercase alphabet.
alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet += ''.join(map(str.upper, alphabet))
# We'll use Helvetica in big type.
@alexmic
alexmic / example.py
Last active August 29, 2015 13:56
Sketch for how I'd like a simple REST service framework to work
from swiss import Api
from swiss.resources import Resource, Group
from swiss.auth import BasicAuth, noauth
from swiss.fields import parse, serialize, parselize
from swiss.fields import String, Int, Boolean
# simple dicts for schemas and serialization
schema = {
'name': String,
### Keybase proof
I hereby claim:
* I am alexmic on github.
* I am alexmic (https://keybase.io/alexmic) on keybase.
* I have a public key ASBJlx8-MALgeEzpRMR4ItUwCq1N2t9rvwH706qs8ZJmpwo
To claim this, I am signing this object: