Skip to content

Instantly share code, notes, and snippets.

@nkint
nkint / gist:a53f536faac80ceecf2bc16040ac62ff
Created December 5, 2016 19:31
regl - basic render to texture
// thanks to https://gitter.im/mikolalysenko/regl
import createRegl from 'regl'
const mat4 = require('gl-mat4')
const cubePosition = [
[-0.5, +0.5, +0.5], [+0.5, +0.5, +0.5], [+0.5, -0.5, +0.5], [-0.5, -0.5, +0.5], // positive z face.
[+0.5, +0.5, +0.5], [+0.5, +0.5, -0.5], [+0.5, -0.5, -0.5], [+0.5, -0.5, +0.5], // positive x face
[+0.5, +0.5, -0.5], [-0.5, +0.5, -0.5], [-0.5, -0.5, -0.5], [+0.5, -0.5, -0.5], // negative z face
@nkint
nkint / index.html
Created October 25, 2016 17:26
Not working zoom buttons
<!DOCTYPE html>
<meta charset="utf-8">
<svg width="960" height="500"></svg>
<div id="gui"></div>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height"),
transform = d3.zoomIdentity;
@nkint
nkint / gist:ce08c57d97631da514bf
Created February 1, 2016 14:25
node.js test coverage with istanbul nom script
{
"name": "test coverage example",
...
"scripts": {
"test": "NODE_ENV=test mocha --colors build/spec --timeout 5000",
"coverage": "NODE_ENV=test ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -R spec"
},
"dependencies": {
@nkint
nkint / gist:c7f4828149bb2bf2d2e1
Created January 13, 2016 15:48
node.js proxy cors
// from https://github.com/dbertella/cheap-flights/blob/master/proxy/server.js
var http = require('http'),
httpProxy = require('http-proxy');
var port = 3000;
var proxy = httpProxy.createProxyServer();
http.createServer(function(req, res) {
@nkint
nkint / gist:b5fc9dfb852852e9ce18
Last active August 29, 2015 14:23
oauth2 token refresher
/*
# random client_id and random client_secret
curl --form client_id='3MVG9Nc1qcT7BbZ1AmkC7gLt_RtFNrY9XCsATBeio3ijPozoP.4qTcKKDGOT5V2V78I.4Ne1RXRTEJjqoZzNC' \
--form client_secret='6092197970455970980' \
--form grant_type=password \
--form username='[email protected]'\
--form password='password' \
https://site.com/services/oauth2/token
@nkint
nkint / gist:b967314206c04263c9a2
Created April 1, 2015 12:18
broken ray caster with pivot
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - interactive cubes</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
@nkint
nkint / gist:a32d07e9845b961ad226
Created February 27, 2015 10:00
qTranslate META
<?php
/*
Plugin Name: qTranslate META
Plugin URI: http://johnjcamilleri.com/2010/01/qtranslate-and-multilingual-meta-tags/
Description: Multilingual support for META tags. Requires qTranslate.
Version: 1.0.2
Author: John J. Camilleri
Author URI: http://johnjcamilleri.com
*/
@nkint
nkint / gist:e51b48b31fc1d6f7508e
Created December 13, 2014 15:17
Nodejs slowly output a file line by line
// to simulate some recordered arduino output that print a value each 100ms on a serial terminal
// thanks to https://github.com/mcollina and https://gist.github.com/walling/
'use strict';
var fs = require('fs'),
split2 = require('split2'),
through = require('through2')
var filename = process.argv[2];
@nkint
nkint / gist:529cf6b5bc2d24238a69
Created December 2, 2014 10:17
Arduino formula to simulate mac breath/organic fade/sleep light
float val = (exp(sin(millis()/2000.0*PI)) - 0.36787944)*108.0;
@nkint
nkint / gist:3397fcea8d67361497fa
Last active August 29, 2015 14:10
Python extract colour from image (tested on Arduino OpenWRT)
from PIL import Image
from math import pow
import colorsys
import urllib, cStringIO
T = 500
URL = 'http://iot.merfobrienzi.it/img.jpg'
basewidth = 80
# http://blog.soulwire.co.uk/code/actionscript-3/colourutils-bitmapdata-extract-colour-palette