Skip to content

Instantly share code, notes, and snippets.

View SaulDoesCode's full-sized avatar
🕳️
Just being happy

Saul van der Walt SaulDoesCode

🕳️
Just being happy
View GitHub Profile
@SaulDoesCode
SaulDoesCode / CF.md
Last active June 20, 2024 15:42
CohesionfieldSpec.md

Semantic Units and Relationships

The Coherence Field is designed to capture the essence of 3D objects by breaking them down into smaller, abstract components: Color semantic units. These units can be thought of as "meaningful" building blocks that convey information about the object's properties (e.g., color).

Relationships between these semantic units are crucial in determining the final rendered image. The CF tracks relationships like Above, Below, LeftOf, RightOf, and AttachedTo, which seem to govern the spatial arrangement of the Color units.

Rendering and Visualization

The render_to_array method is responsible for transforming the Cohesion Field into a 2D RGB array, effectively "painting" the image. This process involves calculating the position of each semantic unit based on its relationships with others (via calculate_position) and then drawing the unit onto the array using its color information (via draw_semantic_unit).

@SaulDoesCode
SaulDoesCode / list.js
Last active April 15, 2021 19:49
it's a circular doubly linked list with convenient methods
const List = (...values) => {
const list = {
length: 0,
each(fn, node = list.first, dir = 'next') {
let l = list.length
if (fn && node && l)
while (l--) {
if (fn(node.value, node, list) === false) break
node = node[dir]
}
@SaulDoesCode
SaulDoesCode / msgpack.js
Created October 25, 2018 19:00
Adaptation of Yves Goergen's MIT github.com/ygoe/msgpack.js
const msgpack = {}
{ // adapted from Yves Goergen's MIT github.com/ygoe/msgpack.js
const pow32 = 0x100000000 // 2^32
msgpack.encode = data => {
let array = new Uint8Array(128)
let length = 0
append(data)
function append(data) {
data == null || data === NaN || data === Infinity ? appendByte(0xc0) :
@SaulDoesCode
SaulDoesCode / haal.js
Last active February 9, 2020 15:56
HTTP CLIENT: proxy powered fetch wrapper inspired by wretch, simplifying browser side http. Haal dinge met hierdie gemaklike stuk javascript http gereedskap, vireenvoudig jou, programmeering nou! N.b werk slegs op nuwer webwerf besoekers.
/*
haal.post('https://abc.xyz/', {
body: {
token: 'moocow24',
action: 'update-condition',
data: '42'
}
})
// (haal['get/post/put/patch...'] / haal)(enpoint, options)['json/text/blob...']
.json((data, res) => console.log('Good: ', data)),
@bradtraversy
bradtraversy / docker-help.md
Last active June 26, 2024 19:53
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@lucasmenendez
lucasmenendez / deep-object-watcher.js
Last active July 14, 2018 11:15
Deep watcher over objects
if (!Object.prototype.deepWatch) {
Object.prototype.deepWatch = function(f) {
let res = {};
Object.keys(this).forEach(k => {
let src = this[k];
if (Array.isArray(src)) {
res[k] = new Proxy(src, {
set(src, i, val) {
if (i !== "length") f.call(this, src, [...src, val]);
return Reflect.set(...arguments);
@SaulDoesCode
SaulDoesCode / example.html
Last active June 3, 2018 17:35
tired of frameworks? here's a framework! you'll need the latest browsers to run it and so-on. have fun? Don't worry it only weighs 5352 bytes and it doesn't bite. It's post-modern art I tell you!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="Saul van der Walt">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>festoon.js</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css">
<style>
body {
@SaulDoesCode
SaulDoesCode / emitter.js
Created May 2, 2018 12:36
emitter with proxy powers
const infinify = (fn, reflect = false) => new Proxy(fn, {
get: (fn, key) =>
reflect && key in fn ? Reflect.get(fn, key) : fn.bind(undefined, key)
})
export default (host = {}, listeners = new Map()) => Object.assign(host, {
listeners,
emit: infinify((event, ...data) => {
if (listeners.has(event)) {
for (const h of listeners.get(event)) {
@CarlMungazi
CarlMungazi / mithril-hyperscript.md
Last active May 16, 2018 07:54
Understanding mithril's hyperscript function

Earlier this year at work we re-wrote an internal framework we used to create SPA e-learning courses. After briefly trying out React, Angular 2, Ember and Vue, we settled on mithril (https://mithril.js.org). If I were to compare it to the frameworks we tried out, I would say it's more like React but with a simpler, smaller codebase. By the way, if you like geeking out on code articles, the articles from mithril's old site have some real nuggets of gold (http://lhorie.github.io/mithril-blog/).

A few months after the re-write was done, I dug into mithril's codebase to gain a deeper understanding and this is what I found...

The main entry point into mithril's source code is the m() function, which is a hyperscript function that, according to the docs (https://mithril.js.org/hyperscript.html), represents an element in a mithril view. It's demonstrated below as:

m("div", {id: "box"}, "hello")
// equivalent HTML:
// <div id="box">hello</div>
import turtle
bob = turtle.Turtle()
bob.goto(-675, 350)
bob.goto(-675, 0)
bob.backward(10)
bob.pensize(1000)
bob.color("blue")
bob.forward(2000)
bob.goto(-680, 400)