Skip to content

Instantly share code, notes, and snippets.

View ksnabb's full-sized avatar

Kristoffer Snabb ksnabb

  • Reaktor Innovations
  • Helsinki, Finland
View GitHub Profile
vpc = stack.add_resource(VPC(
'Vpc',
CidrBlock='10.0.0.0/16',
EnableDnsSupport=True,
EnableDnsHostnames=True
))
public_subnet1 = stack.add_resource(Subnet(
'PublicSubnet1',
AvailabilityZone='eu-west-1a',
@ksnabb
ksnabb / gist:9a22a9f67a11a410d00e
Created May 4, 2015 06:37
Retrieve images of products according to ean code
package main
import (
"bytes"
"encoding/json"
"image"
"image/color"
"image/draw"
"image/jpeg"
"io/ioutil"
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@ksnabb
ksnabb / gulpfile.js
Last active August 29, 2015 14:09
Gulp file to compile static files. This is created to reduce work that I do over and over again for each new project.
var gulp = require('gulp');
var jade = require('gulp-jade');
var browserify = require('browserify');
var uglify = require('gulp-uglify');
var transform = require('vinyl-transform');
var stylus = require('gulp-stylus');
var nib = require('nib');
// templates
@ksnabb
ksnabb / geometry.js
Created September 30, 2014 18:35
speed calculation accoring to start end point and time
// calculate the speed according to two points and two times
(function(root) {
// speed is returned in m / s
// points given as arrays of length 2 and coordinates in meters
// times are given in milliseconds
var speed = function(startPoint, endPoint, startTime, endTime) {
var distance = this.distance(startPoint, endPoint);
var timeDiff = (endTime - startTime) / 1000;
return distance / timeDiff;
@ksnabb
ksnabb / geometry.js
Created September 29, 2014 19:07
Calculate current position according to start point destination point speed and time
// calculate a new point according to start point, destination, speed and time.
(function(root) {
// start and destination are points given as arrays of length 2
// speed is in m/s
// time is in seconds
var currentPosition = function(start, destination, speed, time) {
var distanceTravelled = speed * time;
// calulate the diff x and diff y to be travelled
@ksnabb
ksnabb / geometry.js
Created September 29, 2014 18:07
calculate distance between two points
// Calculate distance between two given points on a plane
(function(root) {
// a and b are given as arrays of length 2
var distance = function(a, b) {
return Math.sqrt(Math.pow(b[0] - a[0], 2) + Math.pow(b[1] - a[1], 2));
};
root.distance = distance;
@ksnabb
ksnabb / Tracks.markdown
Created September 27, 2014 11:06
A Pen by Kristoffer Snabb.
@ksnabb
ksnabb / Canvas-image-rotation.markdown
Created September 13, 2014 09:34
A Pen by Kristoffer Snabb.
@ksnabb
ksnabb / hello.go
Last active August 29, 2015 14:06
Hello world golang web application
package main
import "net/http"
func handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello world"))
}
func main() {
http.HandleFunc("/", handler)