Skip to content

Instantly share code, notes, and snippets.

View akx's full-sized avatar
👹
rer

Aarni Koskela akx

👹
rer
View GitHub Profile
@akx
akx / keybase.md
Created December 30, 2014 21:46
keybase.md

Keybase proof

I hereby claim:

  • I am akx on github.
  • I am akx (https://keybase.io/akx) on keybase.
  • I have a public key whose fingerprint is F17E B101 CF83 E615 2EA9 E039 4290 C4D8 F0EB 87DF

To claim this, I am signing this object:

#!/bin/bash
# Patch apllying tool template
# v0.1.2
# (c) Copyright 2013. Magento Inc.
#
# DO NOT CHANGE ANY LINE IN THIS FILE.
# 1. Check required system tools
_check_installed_tools() {
local missed=""
@akx
akx / get_package_licenses.py
Created June 2, 2015 05:50
Get installed package licenses in the current virtualenv
# -*- coding: utf-8 -*-
from pip import get_installed_distributions
def process_dist(dist):
license = None
metadata = None
if dist.has_metadata('PKG-INFO'):
metadata = dist.get_metadata('PKG-INFO')
if dist.has_metadata('METADATA'):
#!/bin/bash
# This script builds (a subset of) the AlkuThree-Light font
# from source files made public by Opetushallitus (oph.fi).
# Whether or not this infringes on copyrights or other rights
# is anyone's guess.
#
# Prerequisites: wget & fontforge
# Optionally: fonttools (ttx) for repeatable builds
# (sha1 should probably be 5d2eba6728246b7050500b3c8cac4780f99f4728)
# -- encoding: UTF-8 --
def dims_to_volume(dims):
return dims[0] * dims[1] * dims[2]
# Taken from http://www.consumerreports.org/cro/2012/01/best-in-cargo-capacity-and-fuel-economy/index.htm
# [].slice.call(document.querySelector("table").querySelectorAll("td+td+td")).map(function(t){return parseFloat(t.innerHTML)})
cargo_volume_cuft = [
61, 61.5, 70.5, 70.5, 62, 32, 28.5, 35.5, 33, 26, 37, 31.5, 28.5, 30.5, 36, 33, 32.5, 26, 26, 25.5, 35, 35, 31.5,
31, 28, 26.5, 32, 32, 31, 30, 29.5, 28, 33.5, 40.5, 36.5, 34.5, 35.5, 37.5, 34.5, 33.5, 33.5, 33.5, 47, 40.5, 40.5,
import inspect, types
verboten = set(["queryset", "initial", "error_messages"])
NotNone = object()
memo = set()
def _make_ctor_args(obj):
params = []
namesSeen = set()
allArgs = []
for cls in inspect.getmro(obj.__class__):
@akx
akx / squeeze.py
Created February 3, 2012 08:55
Squeeze - HTML5 compressor
# -- encoding: utf-8 --
""" A fairly advanced HTML/HTML5 compressor. """
from __future__ import with_statement
import re
from itertools import chain
HTML5_BLOCKS = set(
'head body title link '
'article aside nav section '
@akx
akx / gist:1878050
Created February 21, 2012 18:41 — forked from neilj/gist:1532562
Sugared DOM: Better Than Templates
# Note: This is actually Coco (http://github.com/satyr/coco), not CoffeeScript.
# I haven't tested this, just wanted to see how concise I could make of the Coco implementation.
el = let
doc = document
directProperties = {
class: \className, \className, \defaultValue,
for: \htmlFor, html: \innerHTML, text: \textContent, \value
}
booleanProperties = {+checked, +defaultChecked, +disabled, +multiple, +selected}
@akx
akx / verbatim.py
Created April 16, 2012 09:33
Django verbatim templatetag
from django import template
register = template.Library()
class VerbatimNode(template.Node):
def __init__(self, text):
self.text = text
def render(self, context):
@akx
akx / predict.py
Created October 5, 2015 11:50
Python 4.0 prediction
from dateparser import parse
import numpy as np
import datetime
data_points = []
for l in """
1.4 25 October 1996
1.5 17 February 1998
2.0 16 October 2000
2.5 19 September 2006