Skip to content

Instantly share code, notes, and snippets.

View bohnacker's full-sized avatar

Hartmut Bohnacker bohnacker

  • Stuttgart, Germany
View GitHub Profile
@bohnacker
bohnacker / web-api-request.py
Last active December 20, 2018 10:38
Python script to get JSON data from an online source. Seems to work only with Python 2.
import urllib2
import json
opener = urllib2.build_opener()
# An object to collect the results
result = {'episodes':[]}
# Iterate from 1 to 31
for i in range(1, 32):
@bohnacker
bohnacker / add.js
Last active September 4, 2017 10:19
Vector utility functions
/**
* Adds two (or more) vectors.
*
* @function add
* @param {Array|Object} vector1 The first vector
* @param {Array|Object} vector2 The second vector
* @param {Array|Object} [vector3] The third vector, ...
* @return {Object} The resulting vector
*/
function add(v1, v2) {
@bohnacker
bohnacker / map.js
Created September 3, 2017 08:00
Map a value from one range to another
function map(val, low1, high1, low2, high2) {
return (val - low1) / (high1 - low1) * (high2 - low2) + low2;
}