Skip to content

Instantly share code, notes, and snippets.

@jart
jart / ckd-kamil-128.c
Created July 22, 2023 15:11
c23 stdckdint.h test vectors
#include <stdio.h>
#include <ckdint.h>
#include <stdint.h>
#include <inttypes.h>
typedef signed __int128 int128_t;
typedef unsigned __int128 uint128_t;
#define TBIT(T) (sizeof(T) * 8 - 1)
#define TMIN(T) (((T) ~(T)0) > 1 ? (T)0 : (T)((uint128_t)1 << TBIT(T)))
#!/bin/sh
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
#!/usr/bin/env python2
import BaseHTTPServer
import SocketServer
import base64
import httplib
import mimetypes
import os
import shutil
import ssl
@jart
jart / blc.S
Last active June 10, 2023 06:58
Binary Lambda Calculus Virtual Machine for x64 Linux in 400 bytes
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
╞══════════════════════════════════════════════════════════════════════════════╡
│ Copyright 2022 Justine Alexandra Roberts Tunney │
│ │
│ Permission to use, copy, modify, and/or distribute this software for │
│ any purpose with or without fee is hereby granted, provided that the │
│ above copyright notice and this permission notice appear in all copies. │
│ │
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
@jart
jart / lolc.sh
Last active June 7, 2023 15:44
Run C code in Bash
#!/bin/bash
# lolc.sh - run c code in bash
# by justine tunney <jtunney@gmail.com>
# licensed mit or apache 2.0
runc() {
local bin=$(mktemp -u)
gcc -xc -o ${bin} /dev/stdin || return
chmod u+x ${bin}
${bin} "$@"
@jart
jart / equiv
Created April 18, 2023 03:35
equiv -- checks if integral c expressions are equivalent
#!/usr/bin/env python3
# -*- python -*-
#
# SYNOPSIS
#
# equiv -- checks if integral c expressions are equivalent
#
# EXAMPLES
#
# $ equiv '(gn1 & 1) || (gn1 != gn2)' '(gn1 & 1) | (gn1 ^ gn2)'
@jart
jart / fastio.py
Created October 23, 2016 06:44
Multithreaded Python os.walk
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@jart
jart / cosmoc++
Last active September 8, 2022 13:37
Cosmopolitan Libc Toolchain
#!/bin/sh
# replacement for c++ command
#
# we assume you run the following beforehand
#
# sudo chmod 1777 /opt
# cd /opt
# git clone https://github.com/jart/cosmopolitan cosmo
# cd cosmo
# make -j
@jart
jart / dawkins.markdown
Created June 8, 2014 19:28
How Dawkins Got Pwnd by Mencius Moldbug (37,941 words)

How Dawkins got pwnd

By Mencius Moldbug c. Sep 2007

Part 1

Richard Dawkins recently wrote a book called The God Delusion. You've probably heard of it.

Professor Dawkins is a great scientist and one of my favorite writers. And I have no quarrel at all with his argument. I was raised as a scientific atheist, and I've never seen the slightest reason to think otherwise. These days I prefer the word "nontheist" - for reasons which will shortly be clear - but there's no substantive difference at all. Except in the context of role-playing games, I have no interest whatsoever in gods, goddesses, angels, devils, dryads, water elementals, or any such presumed metaphysical being.

Nonetheless, it's my sad duty to inform the world that Professor Dawkins has been pwned. Perhaps you're over 30 and you're unfamiliar with this curious new word. As La Wik puts it:

@jart
jart / illumination.sh
Last active June 20, 2022 18:58
Rational Illumination for PC and TV w/ IBM Scratchpad
#!/bin/sh
fricas -nosman <<EOF
E := [_
-- Standard Illumination Model for Computers_
--_
-- Is defined as a system of linear equations, where negative_
-- colors don't exist and is solved by computing the point at_
-- which they all intersect the one which needs to be defined_
-- as the Planckian locus of the illuminant._