Skip to content

Instantly share code, notes, and snippets.

View eeropic's full-sized avatar

Eero Pitkänen eeropic

View GitHub Profile
@eeropic
eeropic / prompt.mjs
Last active October 22, 2024 06:07
simple prompt wrapper for nodejs readline
import readline from 'readline'
export const prompt = query => new Promise(resolve => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
rl.question(query, function(answer){
resolve(answer)
rl.close()
@eeropic
eeropic / blender_pip_install.sh
Last active October 11, 2024 05:38
Install python modules to be used inside Blender (osx)
#!/bin/bash
BLENDER_APP_PATH="/Applications/Blender.app"
if [ ! -d "$BLENDER_APP_PATH" ]; then
echo "Blender not found in /Applications. Please make sure Blender is installed."
exit 1
fi
BLENDER_PYTHON=$(find "$BLENDER_APP_PATH" -type f -name "python3*" | head -n 1)
@eeropic
eeropic / fix-objc.sh
Last active January 6, 2024 04:05
Glyphs2 osx 13.6.3 python fix
pip2 install pyobjc
@eeropic
eeropic / y_for_x_unitbezier_paperjs.js
Created September 28, 2022 10:28
solve y for x with unit beziers in range of x [0,1] for animation etc purposes
// http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/UnitBezier.h
class UnitBezier {
constructor(p1x,p1y,p2x,p2y){
// Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).
this.cx = 3.0 * p1x;
this.bx = 3.0 * (p2x - p1x) - this.cx;
this.ax = 1.0 - this.cx - this.bx;
this.cy = 3.0 * p1y;
this.by = 3.0 * (p2y - p1y) - this.cy;
this.ay = 1.0 - this.cy - this.by;
@eeropic
eeropic / gettype.js
Created September 13, 2022 13:09
get object prop type
const getType = x => Array.isArray(x) ? 'array' : typeof x;
@eeropic
eeropic / color_proportions.js
Created November 12, 2021 14:20
paperjs color palette color proportions tool
const calcWeights = cutoffs => {
let weights = [cutoffs[0]]
for(let i = 1; i < cutoffs.length; i++){
let weight = cutoffs[i] - cutoffs[i-1]
weights.push(weight)
}
weights.push(1 - cutoffs.at(-1))
return weights
}
@eeropic
eeropic / lua_tips_touchosc.md
Last active September 13, 2021 12:04
Lua tips for TouchOSC scripting (Lua 5.1)
  • You can omit parenthesis in function calls, if your argument is a string or a table
myFunc"hello"
myFunc{1,2,3}
  • Variable number of function arguments
@eeropic
eeropic / scriptui-svg-alpha.jsx
Created September 2, 2021 09:04
scriptui-svg alpha
// @target aftereffects
// altKeyPressed(win), optKeyPressed(mac) ctrlKeyPressed, cmdKeyPressed(mac), shiftKeyPressed, capsLockKeyPressed, numLockKeyPressed
// leftButtonPressed, middleButtonPressed, rightButtonPressed, mouseOver, hasFocus,
//encapsulate the script in a function to avoid global variables
(function (thisObj) {
default xml namespace = "http://www.w3.org/2000/svg";
var xmlString = """
<!-- Generator: Adobe Illustrator 23.1.1, SVG Export Plug-In -->
@eeropic
eeropic / keys.txt
Created August 18, 2021 16:25
zigsim arkit face tracker osc keys
faceposition
facerotation
facelefteyeposition
facerighteyeposition
facelookatposition
faceeyeblinkleft
faceeyeblinkright
faceeyelookdownleft
faceeyelookdownright
faceeyelookinleft
@eeropic
eeropic / gzip.js
Last active June 10, 2021 14:41
gzip-js
// https://github.com/beatgammit/gzip-js/blob/master/lib/gzip.js
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const gzip = require('gzip-js');
},{"gzip-js":6}],2:[function(require,module,exports){
(function () {
'use strict';
var table = [],
poly = 0xEDB88320; // reverse polynomial