Routes Indiana jones style, with canvas.
A Pen by Kristoffer Snabb on CodePen.
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', |
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); |
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 |
// 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; |
// 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 |
// 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; |
Routes Indiana jones style, with canvas.
A Pen by Kristoffer Snabb on CodePen.
Drag and drop an image to the canvas which then performs simple rotation on the image.
A Pen by Kristoffer Snabb on CodePen.
package main | |
import "net/http" | |
func handler(w http.ResponseWriter, r *http.Request) { | |
w.Write([]byte("hello world")) | |
} | |
func main() { | |
http.HandleFunc("/", handler) |