Skip to content

Instantly share code, notes, and snippets.

View terkelg's full-sized avatar
🔵
Git'n stuff done

Terkel terkelg

🔵
Git'n stuff done
View GitHub Profile
global.THREE = require("three");
const canvasSketch = require('canvas-sketch');
const Random = require('canvas-sketch-util/random');
const gradientHeight = 512;
const settings = {
dimensions: [ 2048, gradientHeight * 2 ]
};

Using server-sent events

Why and how?

  • Documentation: https://web.dev/articles/eventsource-basics
  • Use case: broadcasting data from server to browsers
  • Benefits:
    • Easy to understand and implement (only a few lines of code)
    • No library is needed
  • Can use same HTTP(S) authentication as elsewhere in the app (which can’t be done with websockets)
@mattdesl
mattdesl / sketch.js
Created November 9, 2019 15:27
canvas-sketch + dat.gui
const canvasSketch = require("canvas-sketch");
const { GUI } = require("dat.gui");
const data = {
background: "#de6060",
number: 0.35
};
const settings = {
dimensions: [2048, 2048],

Modules for Creative Coding

This workshop encourages students to make use of npm modules to build complex and interesting artworks.

If you find a module you want to use, like riso-colors, you can install it from your project folder like so:

npm install riso-colors

About

Interpolating between things using lerp.

function lerp (start, end, t) {
  return start * (1 - t) + end * t;
}
@droustchev
droustchev / _README.md
Last active April 8, 2021 21:55
tmux vim navigation

I recently tried out the fantastic vim-tmux-navigator tmux plugin. Unfortunately, some the default key bindings conflict with some of the key bindings my fuzzy finder of choice uses. I wanted to remap them to the default vim split navigation commands that are prefixed with C-w, and found the solution of hjdivad in his gist. However, I wanted a simpler solution, so after some more digging I stumbled upon this reddit post and ultimately came up with the following solution, which doesn't rely on key bindings that unbind themselves, but uses tmux's 'key-tables'.

@ayamflow
ayamflow / rotate-uv.glsl
Created January 16, 2018 23:24
Rotate UV in GLSL
vec2 rotateUV(vec2 uv, float rotation)
{
float mid = 0.5;
return vec2(
cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,
cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid
);
}
vec2 rotateUV(vec2 uv, float rotation, vec2 mid)
@romainl
romainl / dynaline.gif
Last active March 20, 2024 10:11
How to add dynamic highlighted parts to your status-line
dynaline.gif
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
// needed for no_std