Skip to content

Instantly share code, notes, and snippets.

View eriksachse's full-sized avatar
🔘

Erik Sachse eriksachse

🔘
View GitHub Profile
import random
max_ramp_value = op('select1')[0]
pulse_count = 0
def onStart(me):
global pulse_count
pulse_count = 0
return
from html.parser import HTMLParser
class ImageParser(HTMLParser):
def __init__(self):
super().__init__()
self.image_rows = [] # list of [url, caption]
self.current_img = None
self.in_caption_div = False
self.in_caption_p = False
self.current_caption = ''
@eriksachse
eriksachse / webscrape.py
Created September 27, 2025 08:29
For tiktok tutorial
# me - this DAT.
# webClientDAT - The connected Web Client DAT
# statusCode - The status code of the response, formatted as a dictionary with two key-value pairs: 'code', 'message'.
# headerDict - The header of the response from the server formatted as a dictionary. Only sent once when streaming.
# data - The data of the response
# id - The request's unique identifier
def onConnect(webClientDAT, id):
return
@eriksachse
eriksachse / GLSL-Noise.md
Created December 28, 2022 09:27 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
const WaveShaderMaterial = shaderMaterial(
// uniforms
{ uTime: 0, uTexture: new THREE.Texture() },
// vertex
glsl'
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
@eriksachse
eriksachse / queryLayoutSubpage.js
Last active November 20, 2021 09:03
Kirby QL layout query with subpages
layout: {
query: "page.layout.toLayouts",
select: {
columns: {
query: "layout.columns",
select: {
blocks: {
select: {
content: {
select: {
function useKeyPress(targetKey) {
// State for keeping track of whether key is pressed
const [keyPressed, setKeyPressed] = useState<boolean>(false);
// If pressed key is our target key then set to true
function downHandler({ key }) {
if (key === targetKey) {
setKeyPressed(true);
}
}
// If released key is our target key then set to false
@eriksachse
eriksachse / useWindowDimensions.jsx
Created September 24, 2021 15:35
get window size hook
import { useState, useEffect } from "react";
export default function useWindowDimensions() {
const hasWindow = typeof window !== "undefined";
function getWindowDimensions() {
const width = hasWindow ? window.innerWidth : null;
const height = hasWindow ? window.innerHeight : null;
return {
width,
@eriksachse
eriksachse / PostFX.js
Created May 23, 2021 19:13 — forked from luruke/PostFX.js
Simple example of postprocessing in three.js
/*
To use it, simply declare:
`const post = new PostFX(rendering);`
Then on update, instead of:
`rendering.render(scene, camera);`
replace with:
`post.render(scene, camera);`
*/
import {