Skip to content

Instantly share code, notes, and snippets.

View AddressValidator.java
import java.util.zip.CRC32;
public class AddressValidator {
public static byte[] base16Decode(String s) {
byte[] buf = new byte[s.length() / 2];
for (int i = 0; i < s.length() / 2; ++i) {
byte hi = Byte.parseByte(s.substring(i * 2, (i * 2) + 1), 16);
byte lo = Byte.parseByte(s.substring((i * 2) + 1, (i * 2) + 2), 16);
buf[i] = (byte)((hi << 4) | lo);
}
View hbooker.js
setInterval(() => {
document.getElementById("manage_tsukkomi").click();
console.log(performance.now());
}, 300000);
View ImportHidden.hs
module ImportHidden where
import DynFlags
import FastString
import Language.Haskell.TH.Syntax
import Module
import Packages
import TcRnMonad (TcM)
import TcSplice ()
import Unsafe.Coerce
View Test.hs
{-# LANGUAGE DerivingVia #-}
module Test where
import Control.Monad.State.Lazy
import System.Random
newtype Bayes a = Bayes { unBayes :: State StdGen a }
deriving (Functor, Applicative, Monad) via (State StdGen)
@TerrorJack
TerrorJack / podman-shell.nix
Created Dec 1, 2020 — forked from adisbladis/podman-shell.nix
Use podman within a nix-shell
View podman-shell.nix
{ pkgs ? import <nixpkgs> {} }:
let
# To use this shell.nix on NixOS your user needs to be configured as such:
# users.extraUsers.adisbladis = {
# subUidRanges = [{ startUid = 100000; count = 65536; }];
# subGidRanges = [{ startGid = 100000; count = 65536; }];
# };
@TerrorJack
TerrorJack / locale-test.hs
Created Nov 18, 2020
Repro program for "commitBuffer: invalid argument (invalid character)"
View locale-test.hs
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text.IO as T
main :: IO ()
main = T.putStrLn "日本語"
View llvm-nm-asterius.py
#!/usr/bin/env python3
import ast
import subprocess
import sys
if __name__ == "__main__":
r = subprocess.run(["wasm2wat", "--enable-all", sys.argv[2]],
capture_output=True,
check=True,
@TerrorJack
TerrorJack / TLS.hs
Last active Nov 10, 2020
Thread-local storage in Haskell that doesn't leak memory.
View TLS.hs
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnliftedFFITypes #-}
{-# OPTIONS_GHC -Wall #-}
module TLS
( TLS,
newTLS,
freeTLS,
View my_ghc_api.py
#!/usr/bin/env python3
import glob
import os
import re
import shutil
import subprocess
ghc_repo_url = "https://gitlab.haskell.org/ghc/ghc.git"
ghc_repo_branch = "ghc-8.8.4-release"
View gh-load-diff.js
Array.from(document.querySelectorAll("*")).filter(b => b.innerText && b.innerText === "Load diff").forEach(b => b.click())