Skip to content

Instantly share code, notes, and snippets.

View xandkar's full-sized avatar
🤔
quis custodiet ipsos custodes?

Siraaj Khandkar xandkar

🤔
quis custodiet ipsos custodes?
View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active November 16, 2024 13:18
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@hirrolot
hirrolot / a-preface.md
Last active November 16, 2024 13:35
A complete implementation of the positive supercompiler from "A Roadmap to Metacomputation by Supercompilation" by Gluck & Sorensen

This is the predecessor of Mazeppa.

Supercompilation is a deep program transformation technique due to V. F. Turchin, a prominent computer scientist, cybernetician, physicist, and Soviet dissident. He described the concept as follows [^supercompiler-concept]:

A supercompiler is a program transformer of a certain type. The usual way of thinking about program transformation is in terms of some set of rules which preserve the functional meaning of the program, and a step-by-step application of these rules to the initial program. ... The concept of a supercompiler is a product of cybernetic thinking. A program is seen as a machine. To make sense of it, one must observe its operation. So a supercompiler does not transform the program by steps; it controls and observes (SUPERvises) the running of the machine that is represented by th

#!/usr/bin/env bash
# usage: split.sh <source_branch> <target_branch> [<main_branch>]
# example: split.sh origin/wip-feature-dirty feature-clean origin/main
# I often work on long-living dirty feature branches, saving garbage "wip"
# checkpoints, before I fully understand what am I even doing.
# When the feature is finished and tested, I end up with the garbage log that's
# mostly meaningless, but not quite. I find it hard to separate sensible commit
@hirrolot
hirrolot / CoC.ml
Last active November 13, 2024 04:32
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@JayKickliter
JayKickliter / jeep-mods.md
Last active May 26, 2024 20:21
My Jeep mods

DSCF7893-HDR

  • Teraflex Falcon Nexus EF 2.2 Steering Stabilizer
  • Teraflex Falcon Shocks 3.3 Adjustable Piggyback front & rear. Rear has skid plate.
  • 3" lift
  • TigerShark Super Winch 9500 With Synthetic Line
  • Metal cloak Frame built Front bumper
  • Metal cloak front and rear Control Arms
  • Metal cloak Rear Track Bar (installed 6Months ago.
  • Metal cloak Tie rod and Drag link
@adamhjk
adamhjk / service.rs
Created May 28, 2020 14:34
tonic with tracing, opentelemetry, and context propagation
use opentelemetry::api::propagation::text_propagator::HttpTextFormat;
use tracing::{debug, info};
use tracing_futures::Instrument as _;
use tracing_opentelemetry::OpenTelemetrySpanExt as _;
#[tonic::async_trait]
impl crate::protobuf::kubernetes_server::Kubernetes for Service {
async fn kubernetes_deployment_component_get(
&self,
mut request: tonic::Request<crate::protobuf::KubernetesDeploymentComponentGetRequest>,
@ordian
ordian / README.md
Last active March 21, 2024 14:44
HOWTO: heap profiling with jemallocator
  1. Make sure your rust application uses https://github.com/gnzlbg/jemallocator as the global memory allocator (when in doubt, grep jemallocator in your Cargo.lock).
  2. Install jemalloc (we'll only need jeprof), dot, ps2pdf and libunwind on your system. Enable jemallocator's profiling feature (if jemallocator is an indirect dependency, one trick to do is to add a dependency jemallocator = { version = "*", features = ["profiling"] } to your app and let cargo select the || of features for you).
  3. export _RJEM_MALLOC_CONF=prof:true,lg_prof_interval:32,lg_prof_sample:19. lg_prof_interval sets how often profile dump should be written to disk measured in allocated bytes. The value is passed as a power of two, which is 2^32 in our case, i.e. every 4 GiB of allocations of long-lived objects (see https://github.com/jemalloc/jemalloc/wiki/Use-Case%3A-Heap-Profiling). lg_prof_sample:19 tells jemalloc to take a profiling sample every 2^19 = 512 KiB.
  4. Running your binary should produce a bun
@mjarkk
mjarkk / My void linux install - Dell XPS 15 9560 (4k).md
Last active April 1, 2023 00:22
How i've installed voidl inux on my laptop

void linux - dell xps 15 9560 (4k)

How i've installed void inux (xfce) on my laptop

Image and flash

The install iso i've used: void-live-x86_64-{version_here}-xfce.iso from: https://a-hel-fi.m.voidlinux.org/live/current/
To flash the iso i've used rufus with it's default settings.

before installing

I like to start with a clean disk so i'll start

@swlaschin
swlaschin / effective-fsharp.md
Last active October 20, 2024 12:47
Effective F#, tips and tricks

Architecture

  • Use Onion architecture

    • Dependencies go inwards. That is, the Core domain doesn't know about outside layers
  • Use pipeline model to implement workflows/use-cases/stories

    • Business logic makes decisions
    • IO does storage with minimal logic
    • Keep Business logic and IO separate
  • Keep IO at edges

@pervognsen
pervognsen / vex.c
Last active October 23, 2022 11:02
// The stack is 8-byte aligned.
#define ALIGN(p) ((uint64_t *)(((uintptr_t)(p) + 7) & ~7))
#define STACK(stack, size) uint64_t *_stack = ALIGN(stack), *_stack_end = (uint64_t *)((char *)(stack) + size)
#define PUSH(x) do { memcpy(_stack, &x, sizeof(x)); _stack += (sizeof(x) + 7) / 8; } while (0)
#define POP(x) do { _stack -= (sizeof(x) + 7) / 8; memcpy(&x, _stack, sizeof(x)); } while (0)
#if __GNUC__
// Use computed gotos on GCC-compatible compilers (including Clang).
#define JOIN(x, y) x##y
#define LABEL(name) JOIN(label, name)