Skip to content

Instantly share code, notes, and snippets.

View jakubfiala's full-sized avatar

Jakub Fiala jakubfiala

View GitHub Profile
@jakubfiala
jakubfiala / vercajch.js
Created June 22, 2020 19:27
js functions that i need often and i am NOT making another npm package, fuck that
// like python's range, yields numbers from start to end (not inclusive)
export const range = function* (start, end, step = 1) {
let index = start;
while (index < end) {
yield index;
index++;
}
}
// like python's enumerate, yields [index, item]
@jakubfiala
jakubfiala / glslsandbox.js
Last active May 22, 2020 18:15
Does exactly what glslsandbox.com does. Nothing more, nothing less :) You call createRenderer, give it a fragment shader as a string, and it gives you a canvas and a draw function, to which you pass the time, mouse X and Y coordinates, and the width/height (resolution) of the canvas.
export const loadShader = (context, type, source) => {
const shader = context.createShader(type);
// Send the source to the shader object
context.shaderSource(shader, source);
// Compile the shader program
context.compileShader(shader);
// See if it compiled successfully
if (!context.getShaderParameter(shader, context.COMPILE_STATUS)) {
console.error('An error occurred compiling the shaders: ' + context.getShaderInfoLog(shader));
context.deleteShader(shader);
@jakubfiala
jakubfiala / boomerang.sh
Created July 25, 2018 06:56
A script to loop an mp4 video similarly to Instagram's boomerang
#!/usr/bin/env bash
set -o errexit
set -o nounset
if [[ "$#" -ne 2 ]]; then
echo "Usage: ./boomerang.sh src_file out_file"
fi
SRC=$1
OUT=$2
@jakubfiala
jakubfiala / glslsandboxes
Created May 3, 2018 19:14
a list of my GLSL Sandbox sketches (ones I'm proud of anyway)
http://glslsandbox.com/e#46760.1
@jakubfiala
jakubfiala / iterm_profile.json
Created January 21, 2018 21:16
Profile for iTerm2
{
"Badge Text" : "",
"Working Directory" : "\/Users\/jakub",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0,
"Blue Component" : 0,
"Red Component" : 0
},
"Rows" : 25,
@jakubfiala
jakubfiala / ohwell.sublime-snippet
Created January 19, 2018 15:53
Sublime Text snippets
<snippet>
<content><![CDATA[
¯\_(ツ)_/¯
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ohwell</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@jakubfiala
jakubfiala / .bashrc
Last active January 13, 2021 08:32
dotfiles
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@jakubfiala
jakubfiala / seq.js
Created January 17, 2018 16:23
Web Audio sequencing function
// creates a Sequence for the given AudioContext, which changes the `param` of the `node` according to a specified `seq` array with a given `smoothness`
// Example of a `seq` array:
// [ [0, 440], [1, 220], [1.5, 330], [2, 440] ]
// English: set the value to 440 immediately, then to 220 after 1 second, then to 330 after 1.5 seconds, then return to 440 after 2 seconds
//
// returns an object containing 3 methods:
//
// - `playOnce` will perform the sequence once
// - `loop` will loop the sequence indefinitely
// - `stop` will stop looping the sequence
@jakubfiala
jakubfiala / sequence.js
Last active June 20, 2017 14:10
A simple Web Audio sequencer function
// creates a Sequence for the given AudioContext, which changes the `param` of the `node` according to a specified `seq` array with a given `smoothness`
// Example of a `seq` array:
// [ [0, 440], [1, 220], [1.5, 330], [2, 440] ]
// English: set the value to 440 immediately, then to 220 after 1 second, then to 330 after 1.5 seconds, then return to 440 after 2 seconds
//
// returns an object containing 3 methods:
//
// - `playOnce` will perform the sequence once
// - `loop` will loop the sequence indefinitely
// - `stop` will stop looping the sequence
@jakubfiala
jakubfiala / directories_model.graphql
Last active November 1, 2017 00:56
Example of creating data schemae using Google's protocol buffers and Facebook's GraphQL Schema Language
# this defines a new field type
scalar HTML
# this defines a new object type
type Institution {
# the ! denotes a required field
name: String!
location: String
}