This file contains hidden or 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
// Plugin: jQuery.draggable | |
// Author: Arjan Haverkamp - webgear.nl | |
// Version: 1.0 | |
// Date: 2019-01-30 | |
(function($) { | |
$.fn.draggable = function(options) { | |
var $document = $(document), settings = $.extend({ | |
// These are the defaults. |
This file contains hidden or 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
/* HTML: | |
<input type="file" id="filepicker"> | |
<canvas id="outCanvas"></canvas> | |
*/ | |
filepicker.addEventListener("change", () => { | |
createImageBitmap(filepicker.files[0]) | |
.then(response => { | |
outCanvas.width = response.width; | |
outCanvas.height = response.height; |
This file contains hidden or 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 convertImageToCanvas(image) { | |
var canvas = document.createElement("canvas"); | |
canvas.width = image.width; | |
canvas.height = image.height; | |
canvas.getContext("2d").drawImage(image, 0, 0); | |
return canvas; | |
} | |
function convertCanvasToImage(canvas) { | |
var image = new Image(); |
This file contains hidden or 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
/** | |
* Very simple file drop plugin | |
* @author Arjan Haverkamp - webgear.nl | |
* @date 2019-01-21 | |
*/ | |
(function($) { | |
$.fn.FileDropper = function(options) { | |
var settings = $.extend({ | |
// These are the defaults. |
This file contains hidden or 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
#!/bin/bash | |
# | |
#-------------------------------------------------------------------- | |
# This script retrieves a list (in XML format) of connected clients | |
# on a Compal CH7465LG modem/router. | |
# This modem is provided by various ISPs, a.o: | |
# - UPC Connect Box (CH) | |
# - Irish Virgin Media Super Hub 3.0 (IE) | |
# - Ziggo Connectbox (NL) | |
# - Unitymedia Connect Box (DE) |
This file contains hidden or 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
/** | |
* Convert any color string to an [r,g,b,a] array. | |
* @author Arjan Haverkamp (arjan-at-avoid-dot-org) | |
* @param {string} color Any color. F.e.: 'red', '#f0f', '#ff00ff', 'rgb(x,y,x)', 'rgba(r,g,b,a)', 'hsl(180, 50%, 50%)' | |
* @returns {array} [r,g,b,a] array. Caution: returns [0,0,0,0] for invalid color. | |
*/ | |
const colorValues = color => { | |
const div = document.createElement('div'); | |
div.style.backgroundColor = color; | |
document.body.appendChild(div); |
This file contains hidden or 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
const ColorSteps = (() => { | |
/** | |
* Convert any color string to an [r,g,b,a] array. | |
* @author Arjan Haverkamp (arjan-at-avoid-dot-org) | |
* @param {string} color Any color. F.e.: 'red', '#f0f', '#ff00ff', 'rgb(x,y,x)', 'rgba(r,g,b,a)', 'hsl(180, 50%, 50%)' | |
* @returns {array} [r,g,b,a] array. Caution: returns [0,0,0,0] for invalid color. | |
* @see https://gist.github.com/av01d/8f068dd43447b475dec4aad0a6107288 | |
*/ | |
const colorValues = color => { |
This file contains hidden or 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
/** | |
* One liner to convert a base64 string to a binary Uint8Array | |
* | |
* Example: | |
* const dataURL = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2w....'; | |
* console.log(convertDataURIToBinary(dataURL)); | |
*/ | |
const convertDataURIToBinary = dataURI => | |
Uint8Array.from(window.atob(dataURI.replace(/^data[^,]+,/,'')), v => v.charCodeAt(0)); |
This file contains hidden or 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
<?php | |
class Base62 { | |
private $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
public function base62Encode(int $num): string { | |
$res = ''; | |
do { | |
$res = $this->chars[$num % 62] . $res; |
This file contains hidden or 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
/** | |
* Calculate bearing (in degrees, 0-360) between two lat/lng points. | |
*/ | |
const Point2PointBearing = (lat1, lng1, lat2, lng2) => { | |
const toRad = num => num * Math.PI / 180; | |
const toDeg = num => num * 180 / Math.PI; | |
lat1 = toRad(lat1); | |
lng1 = toRad(lng1); | |
lat2 = toRad(lat2); |
OlderNewer