Skip to content

Instantly share code, notes, and snippets.

View velipso's full-sized avatar

Sean velipso

View GitHub Profile
function fish_prompt --description 'Write out the prompt'
set -l color_time
set -l color_cwd
set -l suffix
switch "$USER"
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
@velipso
velipso / random-noise-color.html
Created March 5, 2020 02:23
Random noise color
<!doctype html>
<html lang="en">
<head><title>Random Noise Color</title></head>
<body style="background-color: #eef;">
<div id="ranges"></div>
<canvas width="2048" height="1200" style="width: 1024px; height: 600px;" id="cnv"></canvas>
<script>
var cnv = document.getElementById('cnv');
var ctx = cnv.getContext('2d');
@velipso
velipso / faster_atan2.c
Last active March 25, 2024 12:50
Faster atan2 algorithm (worse accuracy)
// public domain
//
// algorithm adopted from:
// https://dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization/
//
// when ran without arguments, it simply calculates the maximum error between
// the functions below and atan2f
//
// it tests all (x,y) values from -100.00 to +100.00
//
@velipso
velipso / sdl2_game_loop.c
Last active September 25, 2023 21:17
SDL2 game loop forcing a certain frame rate
//////////////////////////////////////////////////
//
// EDIT: Warning, this doesn't seem to work well.
//
//////////////////////////////////////////////////
@velipso
velipso / unknown_midi_data.txt
Created May 5, 2017 01:08
Unknown data inside MIDI file
If anyone can figure out what this data is, that would be greeeaaaat. Bytes represented in hex.
Found inside a MIDI file between tracks. Surely it's related to music somehow, like a sample..? Not sure.
I've inserted newlines after 99 and 89, which seem to be very common bytes.
29 40 30 99
26 5a 00 99
30 50 60 89
30 40 00 89
26 40 18 99
@velipso
velipso / to-gif.fish
Created January 18, 2017 20:35
Fish script to convert movies to GIFs using ffmpeg
#!/usr/local/bin/fish
# Usage:
# ./to-gif somefile.mp4 [more files]
#
# Converts to 'somefile.gif'
set palette /tmp/palette.png
# V--------V---- change these if you want :-)
set filters "fps=15,scale=320:-1:flags=lanczos"
@velipso
velipso / JavaScript's Object Model Sucks.md
Created December 3, 2016 05:36
Short explanation on why JavaScript's object model sucks

How do you convert an object to a string?

It started out simple enough:

var s = obj.toString();

Ooops. But wait. What if an object has a toString key inside of it?

@velipso
velipso / astar.js
Last active February 3, 2018 13:44
Single function that implements A-Star pathfinding algorithm in ~75 lines of code
// PUBLIC DOMAIN
//
// Single function that implements A-Star pathfinding algorithm in ~75 lines of code
//
// (why use a huge library..?)
//
// Parameters:
// solid array of booleans (of size width * height) that determine if a tile is solid
// width width of the map
// height height of the map
$ cat smush.c
#include <stdio.h>
#include <stdint.h>
static uint32_t seed = 0, i = 0;
uint32_t smush(){
const uint32_t m = 0x5bd1e995;
const uint32_t k = i++ * m;
seed = (k ^ (k >> 24) ^ (seed * m)) * m;
return seed ^ (seed >> 13);