Skip to content

Instantly share code, notes, and snippets.

View IkarosKappler's full-sized avatar
💭
I want to build a submarine one day.

Ikaros Kappler IkarosKappler

💭
I want to build a submarine one day.
View GitHub Profile
@IkarosKappler
IkarosKappler / extend-lilgui-colorwithalpha.css
Last active July 8, 2024 19:57
A color-with-alpha extension for lil-gui, adding the missing `alpha` control input.
input[type="range"] {
-webkit-appearance: none;
appearance: none;
background: transparent;
cursor: pointer;
}
/***** Chrome, Safari, Opera, and Edge Chromium *****/
input[type="range"]::-webkit-slider-runnable-track {
height: 0.5rem;
@IkarosKappler
IkarosKappler / evenlyPolygon.js
Last active December 17, 2021 19:03
Evenly distribute n vertices along a path or polygon.
/**
* The main function.
*
* @param {Polygon} polygon
* @param {number} pointCount - Must not be negative.
*/
var ep = function (polygon, pointCount) {
if (pointCount <= 0) {
throw new Error("pointCount must be larger than zero; is " + pointCount + ".");
}
@IkarosKappler
IkarosKappler / svg-test-path-data.js
Last active February 19, 2021 21:12
SVG path test data with absolute and relative commands
// Intend: create a shape with all available SVG path commands.
// Result: two shapes, one with absolute commands only, the second with relative commands only.
// Aim: test my SVG path transform algorithm if it works (scale and translate).
var drawScalingTestPath = function() {
// Define a shape with SVG path data attributes only with _absolute_
// path commands.
var svgDataAbsolute = [
'M', -10, -7.5,
'V', -10,
@IkarosKappler
IkarosKappler / ColorsetMalachite.ts
Created October 28, 2020 13:53
A set of green shades making up some malachite (the mineral) gradient
// Import your preferred Color class
import { Color } from "./datastructures/Color";
// A mix of green shades
// Example at https://www.int2byte.de/public/plot-boilerplate/screenshots/screenshots-fullcolor/screenshot-20201027-0-multiple-circle-intersection-malachite.png
export const WebColorsMalachite : Array<Color> = [
Color.makeRGB(0,21,6),
Color.makeRGB(0,30,12),
Color.makeRGB(0,52,28),
Color.makeRGB(0,81,47),
@IkarosKappler
IkarosKappler / bash_confirm_yes_no.sh
Created December 18, 2019 23:13
A bash snippet to request a Y/N confirmation from the user.
#!/bin/bash
while true; do
read -p "Do you really wish to do this thing? (y/n)? " yn
case $yn in
[Yy]* ) echo "Doing the thing now."; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
@IkarosKappler
IkarosKappler / bbtree.js
Last active December 19, 2018 19:41
A simple balanced binary search tree implemenation (based on https://github.com/mourner/bbtree)
/**
* A simple balanced binary search-tree class I adapted from an implementation
* by https://github.com/mourner.
*
*
* Original implementation (basically a demo/test class) found at
* https://github.com/mourner/bbtree
*
*
* I just added a closure and a utility function to iterate over the set.
@IkarosKappler
IkarosKappler / MouseHandler.js
Created April 2, 2018 14:35
A simple javascript mouse handler.
/**
* A simple mouse handler for demos.
* Use to avoid load massive libraries like jQuery.
*
* Usage:
* new MouseHandler( document.getElementById('mycanvas') )
* .drag( function(e) {
* console.log( 'Mouse dragged: ' + JSON.stringify(e) );
* if( e.params.leftMouse ) ;
* else if( e.params.rightMouse ) ;
@IkarosKappler
IkarosKappler / site-config
Created December 4, 2017 19:09
Configuration | Nginx user_dir public_html with PHP execution (+fastCGI)
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name _;
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Deny access to all dotfiles
location ~ /\. {
@IkarosKappler
IkarosKappler / webaudio.polyfill.js
Created November 15, 2017 16:23
WebAudio API Polyfill for Safari Browsers
/**
* Safari does handle web audio a bit different.
*
* Original found at
* https://gist.github.com/laziel/7aefabe99ee57b16081c
*
* Modified by Ikaros Kappler
* @date 2017-11-15
**/
@IkarosKappler
IkarosKappler / Graph.class.js
Created May 31, 2017 22:38
A very simple Javascript graph/relation class for storing connecting nodes data.
/**
* A simple graph class.
*
* @author Ikaros Kappler
* @date 2017-05-30
* @modified 2017-05-31 Fixed the 'undirected' param and the getConnected function.
* @version 1.0.1
**/
var Graph = (function() {