Skip to content

Instantly share code, notes, and snippets.

View cgcostume's full-sized avatar

Daniel Limberger cgcostume

View GitHub Profile
@cgcostume
cgcostume / happyAnd.js
Last active April 8, 2022 08:23
join elements of an array of strings using a ', ' and for the last one use an ' and ', e.g., for a readable author list
const happyAnd = (strings) =>
strings.length === 0 ? '' : strings.reduce((text, value, i, array) =>
text + (i < array.length - 1 ? ', ' : array.length > 2 ? ', and ' : ' and ') + value);
@cgcostume
cgcostume / erf-kernel.js
Last active November 18, 2020 08:23
gauss-error-based separated blur kernel
factorize = (x) => x == 0 ? 1 : x * factorize(x - 1);
// Computation of the gauss-error (which gives the accumulated area below the normal
// distribution) using its Maclaurin series (https://en.wikipedia.org/wiki/Error_function)
erf = (z, n) => {
const lower = (n) => factorize(n) * (2.0 * n + 1.0);
const upper = (n, z) => Math.pow(-1, n) * Math.pow(z, 2.0 * n + 1.0);
@cgcostume
cgcostume / webgl-operate frame capture.ts
Created September 14, 2020 15:36
frame capture in webgl-operate
controller.postFrameEvent$.pipe(rxjs.operators.first()).subscribe(() => {
const img = gloperate.FrameCapture.capture(renderer._defaultFBO);
const data = gloperate.FrameCapture.createDataURL(img, 'image/png');
console.log(data);
})
@cgcostume
cgcostume / benchmark.ts
Last active July 23, 2020 15:29
benchmark snippet (mostly for webgl-operate)
const benchmark = function() {
/* canvas.frameSize = [320, 240]; */
canvas.controller.multiFrameNumber = 1;
renderer._camera.eye = [Math.sin(0), 1.0, Math.cos(0)];
renderer._camera.center = [0.0, 0.0, 0.0];
canvas.controller.update(true);
const rotations = 4;
@cgcostume
cgcostume / raspbee-pi-3-howto.md
Last active November 2, 2023 20:27
Configuration of a Raspbee (with deCONZ/phoscon) and node-RED server using docker and docker-compose on a Raspberry Pi 3

Raspbee on Raspberry Pi 3

Preparations

The following steps describe the prerequisites for the actual raspbee setup (deCONZ/phoscon and node-RED):

  1. Flash (e.g., using Etcher) raspbian-buster-lite onto SD card (e.g., 16GB).

  2. Create an empty ssh file on the SD card's boot partition.

@cgcostume
cgcostume / rename.py
Last active August 29, 2021 18:06
Rename Image Files using EXIF or other available Timestamp Data (date taken) as new Filename
import os
import glob
import re
import exifread
import sys
import datetime
import pytz
from tzlocal import get_localzone
from time import sleep
@cgcostume
cgcostume / shadir.py
Created January 31, 2020 19:53
Create a data base with Directory Hashes
import argparse
import hashlib
import math
import numpy
import os
import sqlite3
import sys
import locale
locale.setlocale(locale.LC_ALL, '')
@cgcostume
cgcostume / shaall.py
Created January 31, 2020 19:52
Iterate over all Files within a Directory and Output File Paths and Hashes
import argparse
import hashlib
import math
import os
import sqlite3
import sys
import locale
locale.setlocale(locale.LC_ALL, '')
@cgcostume
cgcostume / firefly-iii-pi-4-howto.md
Last active February 17, 2024 16:26
Configuration of a firefly-iii server using docker and docker-compose on a Raspberry Pi 4

Firefly III on Raspberry Pi 4

Preparations

The following steps describe the prerequisites for the actual firefly setup:

  1. Flash (e.g., using Etcher) raspbian-buster-lite onto SD card (e.g., 16GB).

  2. Create an empty ssh file on the SD card's boot partition.

@cgcostume
cgcostume / GLSL pseudo-rand
Created April 29, 2019 08:42
from "The Book of Shaders" by Patricio Gonzalez Vivo & Jen Lowe (https://thebookofshaders.com/10/)
float r = fract(sin(dot(uv, vec2(12.9898,78.233))) * 43758.5453123);