Skip to content

Instantly share code, notes, and snippets.

View iitalics's full-sized avatar

Milo iitalics

  • Somerville, MA
View GitHub Profile
/// Returns the next smallest integer with the same hamming weight as the input.
pub fn snoob(x: u32) -> u32 {
let mut ntz = x.trailing_zeros();
if x == 0 {
ntz = 0;
}
let least_one = x & x.wrapping_neg(); // nightly: x.isolate_least_significant_one()
let ripple = x + least_one;
let ones = (x ^ ripple).unbounded_shr(2 + ntz);
ripple | ones
class Clock {
constructor() {
this.time = 0;
this.bucket = new Array(32);
for (let i = 0; i < 32; i++) {
this.bucket[i] = [];
}
this.dirty = [];
}
xxx $ yarn run --help
Multiple commands match your selection:
0. yarn run
1. yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] <scriptName> ...
Run again with -h=<index> to see the longer details of any of those commands.
xxx $ yarn run --help -h=1
Unknown Syntax Error: Unsupported option name ("--help").
#include <inttypes.h>
#include <math.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <jack/jack.h>
#include <jack/types.h>
static pthread_mutex_t io_mx;
GC: 0:min3 @ 152,693K(+65,683K); free 11,733K(-38,877K) 81ms @ 3491
FPS dropped: 10.162107446423168
GC: 0:MAJ4 @ 149,144K(+96,376K); free 14,272K(-14,272K) 95ms @ 3652
FPS dropped: 8.99780766307428
#lang racket/base
(require
racket/class
racket/gui/base
racket/draw)
(define lim-x0 10.0)
(define lim-y0 10.0)
(define lim-x1 340.0)
$ apt update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
(* This module, [S], defines a very minimal syntax tree that we are going to try to
convert into A-normal form (ANF). ANF is an intermediate form that makes control flow
explicit and lifts intermediate values into named variables. We are going to start with
a very basic lowering algorithm and gradually refine it until it is robust. *)
module S = struct
type name = string [@@deriving show]
type t =
| Var of name
| Int of int
use std::io::BufRead;
use std::{fmt, mem};
fn main() {
let a = Alloc::new();
let input = "(meow () (1 . (2 3)) ( x y z . w ))";
let mut rd = std::io::Cursor::new(input);
let mut p = Parser::new(&a);
while let Some(t) = token(&mut rd).unwrap() {
p.token(t).unwrap();
$ cat main.ml
let alt x y =
let rec seq1 () =
Seq.Cons (x, seq2)
and seq2 () =
Seq.Cons (y, seq1)
in seq1
$ ocamlopt -dclambda main.ml