This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (define (macro-expand s) | |
| (match s | |
| [(list 'let vs b) | |
| (define xs (map car vs)) | |
| (define es (map cadr vs)) | |
| (macro-expand `((lambda ,xs ,b) ,@es))] | |
| [(list 'let* vs b) | |
| (define xs (map car vs)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>Tiles</title> | |
| <style> | |
| html { | |
| --alt1: oklch(0.68 0.17 276); | |
| --alt2: oklch(0.68 0.17 40); | |
| } | |
| .tiles { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # expected rate to get n drops | |
| def true_exp(n): | |
| if n <= 0: | |
| return 0 | |
| p2 = 1/100 # 2 drops | |
| p1 = 18/100 # 1 drop | |
| p0 = 81/100 # 0 drops |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # expected rate to get n drops | |
| def true_exp(n): | |
| if n <= 0: | |
| return 0 | |
| p_2 = 1/100 # 2 drops | |
| p_1 = 18/100 # 1 drop | |
| p_0 = 81/100 # 0 drops | |
| # E_n = 1 + p_2 E_(n-2) + p_1 E_(n-1) + p_0 E_n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| def simulate(): | |
| kc = 0 | |
| N = 100000 | |
| for i in range(N): | |
| n = 0 | |
| while n < 10: | |
| # roll 1 | |
| if random.randint(1, 10) == 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Clock { | |
| constructor() { | |
| this.time = 0; | |
| this.bucket = new Array(32); | |
| for (let i = 0; i < 32; i++) { | |
| this.bucket[i] = []; | |
| } | |
| this.dirty = []; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
NewerOlder