This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Image | |
import sys | |
import glob | |
# Trim all png images with alpha in a folder | |
# Usage "python PNGAlphaTrim.py ../someFolder" | |
try: | |
folderName = sys.argv[1] | |
except : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function (window, jQuery){ | |
/* --------------------------------------------------------------------------- | |
* utilities | |
*/ | |
var document = window.document; | |
var location = window.location; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* amd plugin for loading css specifically for components that | |
* have a custom tag-name. the stylesheet has to include | |
* the css-property `cursor` with a value different from `auto` within a css-rule | |
* for the tag-name. | |
* | |
* the `display: block` property might have served well this purpose since it | |
* has to be set just like the html5shiv does. however, then again we might | |
* actually want a custom tag that is `display: inline` which is the default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* typr - deep type checking with error reports | |
* MIT licence | |
*/ | |
;(function (root) { | |
'use strict'; | |
/* --------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import escapeRegExp from "lodash.escaperegexp"; | |
/** | |
* used to create regular expressions that match if all needle-chars appear in | |
* the same order w/ any number of inbetween chars. | |
*/ | |
export function fuzzyRegExp(needle: string) { | |
return new RegExp(needle.split("").map(escapeRegExp).join(".*?"), "i"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// beware, parser uses regexes | |
// =========================== | |
var minifyHtml = (function(){ | |
var rePreserveTags = /<(pre|style|script(?![^>]*?src))[^>]*>[\s\S]*?<\/\1>/gi, | |
rePreserveStrings = /("|')(?:\\\1|[^\1])*?\1/g, | |
reInsertStrings = /__str(\d+)__/g, | |
reInsertTags = /<preserved>/g, | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// promisify $.ajax with Q | |
// ======================= | |
var ns = {}; | |
ns.ajax = (function($, Q){ | |
var defaults = { | |
type: 'GET', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# decorators | |
from functools import wraps | |
from django.http import HttpRequest | |
ALLOWED_HEADERS = ( | |
'content-type', | |
'accept', | |
'origin', | |
'authorization', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir flaskapp && cd flaskapp | |
touch config.py run.py shell.py app.db requirements.txt | |
mkdir app | |
touch app/__init__.py app/constants.py | |
mkdir app/static app/templates | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def keygen( mac ): | |
bytes = [int(x, 16) for x in mac.split(':')] | |
c1 = (bytes[-2] << 8) + bytes[-1] | |
(s6, s7, s8, s9, s10) = [int(x) for x in '%05d' % (c1)] | |
(m7, m8, m9, m10, m11, m12) = [int(x, 16) for x in mac.replace(':', '')[6:]] | |
k1 = (s7 + s8 + m11 + m12) & (0x0F) |