Skip to content

Instantly share code, notes, and snippets.

@uucidl
uucidl / traverse_children.ion
Last active December 9, 2018 09:48
Traversing Hierarchies
// Depth first traversal algorithm.
//
// (credit to Alexander Stepanov in Elements Of Programming)
//
// One of the benefits is that the visitor can implement pre or post traversal algorithms, and combine them in one single piece.
//
// @generic in T, the node value type
func traverse_children_recursively(tree_root: T*, step_visitor: func(step: TraversalStep, node: T*))
{
step_visitor(TraversalStep_PRE, tree_root);
@uucidl
uucidl / test_metal_with_sdl2.c
Created November 11, 2018 21:42
Testing metal on my macs. My dear Mac Mini does not support it
#include "SDL2.framework/Headers/SDL.h"
#define sdl2_guard(__expr) \
if ((__expr) != 0) { \
fprintf(stderr, "SDL Error: '%s'\n", SDL_GetError()); \
assert(0); \
}
#include <assert.h>
@uucidl
uucidl / README.md
Last active October 29, 2018 09:01
Rokusa (Pure)

Some useful code written in ion

@uucidl
uucidl / 00ctztree.md
Last active December 22, 2020 08:31
Octave Tree

CTZTree

A tree can be produced by counting the number of trailing zeros from an input integer index.

This count ('c') of trailing zeros (or position of the lowest bit) comes back every 2^c sample, i.e. corresponds to a frequency of 2^-c

Furthermore every sample corresponds with one and only one octave.

@uucidl
uucidl / ZZ_CodeResources.md
Last active October 5, 2018 12:33
Task_api
@uucidl
uucidl / canoscan_build.sh
Created January 22, 2018 22:04
little program to use if you're canoscan lide30 scanner says "device not configured"
#!/usr/bin/env bash
export C_INCLUDE_PATH=/usr/local/include/libusb-1.0
export LIBRARY_PATH=/usr/local/lib
(O=canoscan ; cc canoscan_unit.c -o "${O}" -lusb-1.0 && printf "PROGRAM\t%s\n" "${O}")
@uucidl
uucidl / atan_approx.c
Last active January 4, 2018 00:12
Approximations
// Atan approximation
// https://www.dsprelated.com/showarticle/1052.php#tabs1-comments
#include <math.h>
#include <stdio.h>
double atan_approx(double z)
{
double m = z<0? -1.0:1.0;
z *= m;
@uucidl
uucidl / 00-Rhetorics.org
Last active January 25, 2018 10:32
Rhetorics

Techniques of persuasion.

Has had a bad rap throughout ages. Appears necessary in democratic societies. Preserved under authoritarian systems for justice and theology, and for elite groups. In western republic democracies, mainly practiced by professional politicians (elective nobility) and lawyers. Porosity between the two groups.

More and more essential in the companies that want to emphasize group problem solving and collaboration. Practiced without knowing it, in a dry style, by engineers via their communications and documentations.

Skill

  • Magic/Mysterium. In classical times it was clear that it takes time to develop know-how. Practice. Initiation. Hence roles of schools as safe space for learning and practice.
  • Eloquence
@uucidl
uucidl / repro.c
Last active August 20, 2017 17:56
Reproduction of an optimizer bug with Visual Studio 2017
/* Repro optimizer issue with Visual Studio 2017 */
/* @language: c99 */
/*
# Visual Studio 2015 (working)
--
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe
cl.exe -Fe:repro.exe repro.c -nologo -FC -EHsc -Z7 -Oi -GR- -Gm- -O2 -Z7 -W4 -WX -DEBUG
@uucidl
uucidl / adl_barrier_idiom.cpp
Last active April 9, 2023 03:10
ADL Barrier Idiom
// What you do when you want to prevent ADL from kicking in, and force your
// users to use fully qualified names.
namespace module
{
struct Foo { int a, b; }; // struct defined in one namespace
namespace functions
{
void Flaggerbify(Foo* foo); // function defined in another