Skip to content

Instantly share code, notes, and snippets.

@jthemphill
jthemphill / facts.tla
Created Mar 22, 2021
TLA+ spec for HHVM's live type-to-file reverse index
View facts.tla
------------------------------- MODULE facts -------------------------------
EXTENDS Integers
CONSTANTS
NumFiles,
NumTypes,
NumRequests,
FinalClock
View accidentalcopy.cc
// % g++ --std=c++14 accidentalcopy.cc -o accidentalcopy
// % ./accidentalcopy
// This prints the output:
//
// 42 = 42
// 42 = 42
// accidentalcopy(13656,0x117fc45c0) malloc: *** error for object 0x7fd967402b20: pointer being freed was not allocated
// accidentalcopy(13656,0x117fc45c0) malloc: *** set a breakpoint in malloc_error_break to debug
#include <iostream>
View slow_iters.s
.section __TEXT,__text,regular,pure_instructions
.globl __ZN10slow_iters5tests8iter_any17h9958878595c8e553E
.p2align 4, 0x90
__ZN10slow_iters5tests8iter_any17h9958878595c8e553E:
.cfi_startproc
pushq %rbp
Lcfi0:
.cfi_def_cfa_offset 16
Lcfi1:
.cfi_offset %rbp, -16
View slow_iters.mir
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn tests::iter_any::{{closure}}(_1: &mut [closure@src/lib.rs:4:24: 4:35], _2: &i32) -> bool {
let mut _0: bool; // return pointer
scope 1 {
let _3: i32; // "x" in scope 1 at src/lib.rs:4:26: 4:27
}
let mut _4: i32;
bb0: {
View slow_iters.ll
; ModuleID = 'slow_iters.cgu-0.rs'
source_filename = "slow_iters.cgu-0.rs"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-darwin"
%"unwind::libunwind::_Unwind_Exception" = type { i64, [0 x i8], void (i32, %"unwind::libunwind::_Unwind_Exception"*)*, [0 x i8], [6 x i64], [0 x i8] }
%"unwind::libunwind::_Unwind_Context" = type {}
@ref.5 = internal unnamed_addr constant [1 x i32] [i32 1], align 4
@jthemphill
jthemphill / oneplayer.py3
Last active Jun 16, 2017
Attempt to solve JT's tea game for a single player
View oneplayer.py3
import collections
import copy
import heapq
from typing import (Any, Dict, Iterator, List, NewType, Set, Tuple, TypeVar)
SMALL_T: int = 2
BIG_T: int = 3
JEFF_SOLUTION = 32
GOAL = 50
View make_a_number.py
import itertools
def solve(n, xs):
for t in make_trees(xs):
if eval_tree(t) == n:
return print_tree(t)
def make_trees(xs):
if len(xs) == 1:
yield ('unit', xs[0])