Skip to content

Instantly share code, notes, and snippets.

View kontur's full-sized avatar

Johannes Neumeier kontur

View GitHub Profile
@kontur
kontur / gist:5a7ed7b76041597fb820
Created July 14, 2014 13:50
Detect windows phone browser with no font face support
/(Windows Phone)|(XBLWP)|(ZuneWP)/.test(navigator.userAgent)&&$("body").addClass("no-fontface");
@kontur
kontur / gist:9fcbaef1b7396927d569
Created July 28, 2014 11:17
Javascript regexp to extract matrix values from a String into an Array
// via http://stackoverflow.com/a/14397066/999162
var matrixToArray = function(str){
return str.match(/(-?[0-9\.]+)/g);
};
matrixToArray('rgba(0, 0, 0, 0.5)'); // => ['0', '0', '0', '0.5']
matrixToArray('matrix(1, 0, 0, 1, -770, 0)'); // => ['1', '0', '0', '1', '-770', '0']
#!/bin/sh
echo "[post-rewrite hook: $1]"
# noah grant
# quick script to call bower install and npm install automatically if
# bower.json or package.json are changed, respectively
# this assumes one top-level file for each
changedfiles=( `git diff-tree --no-commit-id --name-only HEAD@{1} HEAD` )
@kontur
kontur / gist:65243806495e437a510d
Created August 12, 2014 13:48
Enable gzip/deflate to apache .htaccess / vhost config
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript application/json
</IfModule>
@kontur
kontur / Fullscreen
Created October 2, 2014 06:30
Make a processing sketch run in fullscreen
boolean sketchFullScreen() {
return true;
}
void setup() {
size(displayWidth, displayHeight);
}
@kontur
kontur / test.less
Last active August 29, 2015 14:18
Odd less @import error when *not* using colons after @ımport statement
body {
// surprisingly this will not throw an error, but it won't import the file neither
.mx({ @import: "test2.less"; });
}
body {
// this will throw an error:
// SyntaxError: Cannot read property 'rules' of undefined in /Users/johannes/test/less-bug/test.less on line 7, column 3:
// 6 body {
// 7 .mx({ @import "test2.less"; });
@kontur
kontur / gist:794b04537a9bea84c40c
Last active August 29, 2015 14:19
Arduino get direction / bearing from two geolocations
/*
* Arduino geolocation bearing calculation based on two geolocation latitude-longitude values
* Johannes 'kontur' Neumeier, 2015
* https://gist.github.com/kontur/794b04537a9bea84c40c
*/
void setup() {
Serial.begin(9600);
Serial.println(getDirection(60.1650338, 24.8768908, 60.1243045, 26.2730065));
}
@kontur
kontur / Scroller.js
Created July 27, 2017 07:44
Scroller - takes element, scroll() calls, and continues native-ish scrolling after last scroll() call
/**
* Helper class that simulates some-of-what nativish
* scrolling that continues after dragging (explicit calls to scroll())
* have stopped
*/
// libraries
import $ from "./Zepto"
export default class Scroller {
@kontur
kontur / extract_stylespace_from_designspace.py
Last active February 25, 2020 12:18
A helper script to extract the main stylespace structure from a designspace, use for with https://github.com/daltonmaag/statmake
"""
A helper script to try extract some reasonable defaults for a stylespace
document from a designspace.
You will in all likelyhood need to manually edit this generated stylespace, but
this saves a lot of the typing.
NOTE: That this assumes a well defined and valid designspace!
"""
from fontTools import designspaceLib as dsLib
@kontur
kontur / css
Created April 10, 2020 07:59
Magic Carpet... aka positioning a 100% wide element inside the layout flow
.magic-carpet {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
// fixed height
height: 250px;