This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
from aiohttp import web | |
web.Application(middlewares=[cors_factory]) | |
ALLOWED_HEADERS = ','.join(( | |
'content-type', | |
'accept', | |
'origin', | |
'authorization', | |
'x-requested-with', |
This file contains hidden or 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
#!/bin/bash | |
# ------------------------------------------------------------------------------ | |
# strict mode | |
set -euo pipefail; IFS=$'\n\t' | |
# ------------------------------------------------------------------------------ | |
# notes | |
# | |
# - `[` represents the command `test`, use `[[` builtin instead. | |
# - `-a` and `-o` are deprecated, use `&&` and `||` instead. |
This file contains hidden or 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
const latin1 = ( | |
'A,A,A,A,Ae,A,AE,C,E,E,E,E,I,I,I,I,D,N,O,O,O,O,Oe,-,Oe,U,U,U,Ue,Y,Th,ss,' + | |
'a,a,a,a,ae,a,ae,c,e,e,e,e,i,i,i,i,d,n,o,o,o,o,oe,-,oe,u,u,u,ue,y,th,y' | |
).split(','); | |
function slugifyChar(chr) { | |
return latin1[chr.charCodeAt(0) - 0xC0]; | |
} | |
function slugify(str) { |
This file contains hidden or 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
/** | |
* magnifying glass for images | |
* @licence MIT | |
*/ | |
(function () { | |
/** avoid subpixel rendering */ | |
function px (n) { | |
return Math.floor(n) + 'px' |
This file contains hidden or 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
# example nginx config | |
# ------------------------------------------------------------------------------ | |
# serve static files from volume mounted at /public | |
# serve backend api expsosed by container "backend" on port 5000 | |
# ------------------------------------------------------------------------------ | |
user nginx; | |
worker_processes 1; | |
events { |
This file contains hidden or 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
const canvasContext = document | |
.createElement("canvas") | |
.getContext("2d") as CanvasRenderingContext2D; | |
/** | |
* measures text with the [canvas API](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/measureText) | |
* [avoiding expensive reflows](https://gist.github.com/Yukiniro/876826e1450b1f8cf755d2cea83cda65). | |
*/ | |
export function measureText(text: string, font: string = "normal 16px serif") { | |
canvasContext.font = font; |