Skip to content

Instantly share code, notes, and snippets.

View rrbutani's full-sized avatar
🌴
Back on June 24th

Rahul Butani rrbutani

🌴
Back on June 24th
  • 12:18 (UTC -07:00)
View GitHub Profile
@manveru
manveru / base64.nix
Created September 6, 2023 03:19
Encode to base 64 in pure Nix
{lib, ...}: {
toBase64 = text: let
inherit (lib) sublist mod stringToCharacters concatMapStrings;
inherit (lib.strings) charToInt;
inherit (builtins) substring foldl' genList elemAt length concatStringsSep stringLength;
lookup = stringToCharacters "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
sliceN = size: list: n: sublist (n * size) size list;
pows = [(64 * 64 * 64) (64 * 64) 64 1];
intSextets = i: map (j: mod (i / j) 64) pows;
compose = f: g: x: f (g x);
@AndrasKovacs
AndrasKovacs / ZeroCostGC.md
Last active May 29, 2024 02:20
Garbage collection with zero-cost at non-GC time

Garbage collection with zero cost at non-GC time

Every once in a while I investigate low-level backend options for PL-s, although so far I haven't actually written any such backend for my projects. Recently I've been looking at precise garbage collection in popular backends, and I've been (like on previous occasions) annoyed by limitations and compromises.

I was compelled to think about a system which accommodates precise relocating GC as much as possible. In one extreme configuration, described in this note, there

{-# LANGUAGE GADTs, TypeFamilies #-}
data Type a where
TNat :: Type Int
TFun :: Type a -> Type b -> Type (a -> b)
type Var a = (Type a, String)
data Expr a where
ENat :: Int -> Expr Int
EVar :: Var a -> Expr a
ELam :: Var a -> Expr b -> Expr (a -> b)
@Mic92
Mic92 / 0_description.md
Last active December 15, 2023 19:35
Tvix (79246855d1a0fd9b81be113b16a56379c7641aa1) vs nix (2.19.2) evaluation of the hello package

Tvix is a new implementation of the Nix language and package manager. In this benchmark we test it's performance when instantiating the hello package from nix. Note that at the time tvix does not have its own store implementation yet and it has to execute nix-store whenever it needs to copy files to the store.

@kconner
kconner / macOS Internals.md
Last active July 7, 2024 19:42
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@Dan-Q
Dan-Q / _no_code_page_.php
Last active July 3, 2024 22:38
Hacky PHP to produce a "blank" web page which somehow has content when viewed in Firefox. Sample page at https://danq.me/wp-content/no-code-webpage/, explanation at https://danq.me/nocode
<?php
// half-hearted CSS minification
$css = preg_replace(
array('/\s*(\w)\s*{\s*/','/\s*(\S*:)(\s*)([^;]*)(\s|\n)*;(\n|\s)*/','/\n/','/\s*}\s*/'),
array('$1{ ','$1$3;',"",'} '),
file_get_contents('linked.css')
);
// embed as a data: uri
$base64css = rtrim(strtr(base64_encode($css), '+/', '-_'), '=');
import tweepy, json, time, sys
auth = tweepy.OAuth1UserHandler(
<api keys here>
)
api = tweepy.API(auth)
d = json.loads(open(sys.argv[1]).read().split("=", 1)[1])
// ==UserScript==
// @name @chaoticvibing Twitter Blue Nerd - twitter.com
// @namespace Violentmonkey Scripts
// @match *://*.twitter.com/*
// @match *://*.x.com/*
// @grant none
// @version 1.9.2
// @author @chaoticvibing - GH @busybox11
// @description 11/9/2022, 11:45:28 PM
// @updateURL https://gist.githubusercontent.com/busybox11/53c76f57a577a47a19fab649a76f18e3/raw
@tylerjl
tylerjl / sysdiff.sh
Created November 4, 2022 18:23
Live-diff a changed flake nixosConfigration
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
export SHELL=`which bash`
function usage() {
cat <<EOF
Usage: ${0} <host>
@FCLC
FCLC / A not so brief discussion of Alder Lake, the new AVX512 FP 16 extensions, Sapphire Rapids, its history, and why it requires a custom kernel.md
Last active January 7, 2024 13:23
On AVX512 FP16, Alder Lake, custom kernels, and how "Mistakes were made" has never rang so true

Warning: This is going to be a long one.  

  

I'm assuming general knowledge of x86_64 hardware extensions, and some insight into the workings of large hardware vendors. 

Understanding why AVX512 is useful not only in HPC, but also for gamers in emulation, or more efficient use of executions ports is a bonus. 

You don't need to have published 2 dozen papers on optimizing compute architecture.