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?
| $ 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); |
| // 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 |
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?
| #!/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" |
| 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 |
| ////////////////////////////////////////////////// | |
| // | |
| // EDIT: Warning, this doesn't seem to work well. | |
| // | |
| ////////////////////////////////////////////////// | |
| // 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 | |
| // |
| <!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'); |
| 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 |
I love zed, but boy do they like cramming in a bunch of annoying features.
It's taken me a while to track down how to disable some of them, so here are my current settings:
Requires:
{
"features": {