This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function map(val, low1, high1, low2, high2) { | |
return (val - low1) / (high1 - low1) * (high2 - low2) + low2; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Checks, if two lines (p1a to p1b) and (p2a to p2b) are crossing. | |
// Points are given as [x, y]. If inifinte1 is true, the first line | |
// will be continued before start and after end points. Same for line 2. | |
// Returns the crossing point as [x, y] or false if there is none. | |
// ATTENTION: this calculation is not completely precice in some cases! | |
function crossingPoint(p1a, p1b, p2a, p2b, infinite1, infinite2) { | |
// vectors from start to end points | |
let d1x = p1b[0] - p1a[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns the difference of two angles given in radians. | |
// The result is always between -PI and PI. | |
function angleDifference(angle1, angle2) { | |
const TWO_PI = Math.PI * 2; | |
let a1 = (angle1 % TWO_PI + TWO_PI) % TWO_PI; | |
let a2 = (angle2 % TWO_PI + TWO_PI) % TWO_PI; | |
if (a2 > a1) { | |
let d1 = a2 - a1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calculates a curve that goes through a number of points. | |
// There are lots of mathematical approaches to do so | |
// (see: https://en.wikipedia.org/wiki/Cubic_Hermite_spline). | |
// The most commonly used seems to be the Catmull–Rom spline. | |
// My approch here is not intended to be a new general | |
// solution to this problem, but it should fit some geometrical | |
// and graphical needs. See | |
// https://hartmut-bohnacker.de/projects/points-to-curve | |
// for more explanation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MIT License | |
Copyright (c) 2019 Hartmut Bohnacker | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Moved to a github repository: | |
https://github.com/bohnacker/data-manipulation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The action "dropable" turns a node into a file drop area and dispatches the custom event "files" when | |
// on or more files were dropped. You'll get an array of files in event.detail. | |
// You can provide filetypes as a string or an array of strings, e.g.: "text/html" or ["image/png", "image/jpeg"] | |
// Matching will be done by searching for the substring, so filetype "image/" will match all images | |
// or "/svg" will match "image/svg+xml". | |
export function dropable(node, filetypes) { | |
if (typeof filetypes === "string") filetypes = [filetypes] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { tick, onMount } from "svelte"; | |
export let readonly = true; // whether the text is readonly | |
export let text = ""; // text to be displayed | |
export let placeholder = ""; // placeholder text | |
export let highlightTag = true; // whether to highlight tags | |
export let tagColor = "DodgerBlue"; // color of tags | |
export let tagList = []; // list of tags for autocompletion | |
export let highlightPerson = true; // whether to highlight persons |
OlderNewer