Skip to content

Instantly share code, notes, and snippets.

View jakubfiala's full-sized avatar

Jakub Fiala jakubfiala

View GitHub Profile
@jakubfiala
jakubfiala / custom_console.js
Created February 1, 2016 14:05
this small script intercepts the standard console methods and provides a way of accessing their messages, as well as stack traces, which is really cool. it formats the stack traces for popular browsers
//==========================================================
// CUSTOM JAVASCRIPT CONSOLE
// built by jakub fiala
//
// this small script intercepts the standard console methods
// and provides a way of accessing their messages,
// as well as stack traces, which is really cool.
// it formats the stack traces for popular browsers
//
// contributions welcome!
@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 / 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 / meyda-v2-offline.js
Last active April 25, 2020 17:47
Offline feature extraction in Meyda v2
//Because meyda v2 doesn't really have an offline extraction API, we need to manually require some stuff
var jsfft = require("./node_modules/meyda/node_modules/jsfft/")
var complex_array = require("./node_modules/meyda/node_modules/jsfft/lib/complex_array.js")
var extractors = require("./node_modules/meyda/dist/node/featureExtractors.js")
var meyda_utils = require("meyda").utils
//this is a simple class for streaming WAV data as Float32Arrays
//available at https://gist.github.com/jakubfiala/cb9de100fdd4f043d46e
//we're not going to use its streaming functionality for simplicity
var WavManager = require("./wav-manager.js")
var fs = require('fs')
@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 / 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