Skip to content

Instantly share code, notes, and snippets.

View branneman's full-sized avatar

Bran van der Meer branneman

View GitHub Profile
branneman / http-easy.rkt
Last active June 29, 2024 18:58
Racket: How to do HTTP requests
#lang racket/base
(define (base-url path)
(string-append "" path))
; request: GET
; response: plain string body
branneman /
Last active June 29, 2024 16:00
Better local require() paths for Node.js

Better local require() paths for Node.js


When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

branneman /
Last active June 28, 2024 17:49
pyinfo(). License: MIT
def application(environ, start_response):
import sys
if path not in sys.path:
from pyinfo import pyinfo
output = pyinfo()
start_response('200 OK', [('Content-type', 'text/html')])
return [output]
branneman /
Last active June 12, 2024 02:39
Front-End Software Craftsmanship

JavaScript knowledge

  • Operators, operands, operator precedence (unary, binary, ternary)
  • Dynamic Type system: types and conversion
    • Value type vs. Reference type
  • Expression vs. Statement
  • Scope
  • Hoisting
  • Overloading
  • Prototypal inheritance vs. Classical inheritance
  • Instancing
branneman /
Last active May 12, 2024 03:45
Primitive Types & Reference Types in JavaScript

Primitive Types & Reference Types in JavaScript

An explanation of JavaScript's pass-by-value, which is unlike pass-by-reference from other languages.


  • JavaScript has 2 kinds of variable types: primitive and reference.
  • A fixed amount of memory is reserved after creation of every variable.
  • When a variable is copied, it's in-memory value is copied.
  • Passing a variable to a function via a call also creates a copy of that variable.

Primitive Types

branneman / index.html
Created April 13, 2024 13:22
HTML5 Video: MediaSource, SourceBuffer, video segments, etc.
<!doctype html>
<html lang="en">
<meta charset="utf-8" />
content="width=device-width, initial-scale=1, viewport-fit=cover"
<title>video test</title>
branneman / six-nations-table.test.ts
Last active March 23, 2024 14:53
Six Nations table calculator
import { describe, expect, it } from 'vitest'
import { Table, Match } from './six-nations-table'
import {
branneman / Struct.php
Created May 2, 2011 09:53
PHP Struct class
class Struct
* Define a new struct object, a blueprint object with only empty properties.
public static function factory()
$struct = new self;
foreach (func_get_args() as $value) {
branneman / call-apply-bind-proxy.js
Last active February 22, 2024 21:06
JavaScript call() vs apply() vs bind() vs $.proxy()
var fn = function(arg1, arg2) {
var str = '<p>aap ' + this.noot + ' ' + arg1 + ' ' + arg2 + '</p>';
document.body.innerHTML += str;
var context = {
'noot': 'noot'
var args = ['mies', 'wim'];
// Calls a function with a given 'this' value and arguments provided individually.