Skip to content

Instantly share code, notes, and snippets.

View benknoble's full-sized avatar
💚
reproductive rights are human rights

D. Ben Knoble benknoble

💚
reproductive rights are human rights
View GitHub Profile
@samth
samth / doc.md
Created April 19, 2022 18:08
annotated Racket disassembly

Annotations by @mflatt.

For the function (define (add m n) (+ m n)), in Aarch64:

 0: ff0a00f1         (subs xzr x23 #x2)          ; are there two arguments?
 4: 01040054         (b.ne (+ pc #x80)) ; => 84  ; jump to slow path if not
 8: 1e0001aa         (orr x30 x0 x1)             ; "or" to combine mask bits
 c: df0b40f2         (ands xzr x30 #x7)          ; zero low bits => both are fixnums
10: a1000054         (b.ne (+ pc #x14)) ; => 24  ; jump to slow path if not
@b-layer
b-layer / breakdown.awk
Created March 19, 2021 10:31
An awk script I threw together to break down strings for explanation in Stack Exchange answers.
# 1. Take any string such as this regex \v<[1-9]\d{,2}\ze(\d{3})*>
# 2. Indicate separations with a delimiter char like underscore
# 3. Run awk like so:
#
# awk -v RS='_' -f {thisfile} <<< '\v_<_[1-9]_\d_{,2}_\ze_(_\d_{3}_)_*_>'
# Result:
# \v<[1-9]\d{,2}\ze(\d{3})*>
# \v #
@shhyou
shhyou / example.rkt
Created February 4, 2021 16:03
Print loaded modules
#lang racket/base
(require racket/pretty)
(require syntax/parse)
(module sub racket/base
)
(require 'sub)
// every line is an expression
false
gVJPCHzOvIqKeIT5otZ.pLkpaauz.j1UTF6A_VQtORjVs3ZSNW0EuSw.oe1SAMEO9B7wJWiQvcpi||(z7pZlv7g6Qqfb.sHhRe4ka3ujCxdzSsYyfJb3_u3Znfau)
2||this>=!new h2eQwBfTTO15aMLP2GDQVdmbSUWm9Pq[dfGDBIHkS_un[(27)]]/true
false
new lPIWkLJR[false]
this[this[new int[cMPs5UCZlb()]]]
wqWZTDl0o94nTbP_ipiwrmwpGDx5[this((((-mBB.ojGVeRpCdIRp_kyjJH47tseEAicb.glzkwm_8lYWIc8cl))))]*mzKpxr7L1FSZojC9K3K5_wb9kh2
!new veQNbQuIkzgggfOIUD()
fCIy7c8y2Stf2OCCTN0
@PeterRincker
PeterRincker / SortGroup.vim
Last active March 17, 2024 04:51
Sort groups of lines in vim
" :[range]SortGroup[!] [n|f|o|b|x] /{pattern}/
" e.g. :SortGroup /^header/
" e.g. :SortGroup n /^header/
" See :h :sort for details
function! s:sort_by_header(bang, pat) range
let pat = a:pat
let opts = ""
if pat =~ '^\s*[nfxbo]\s'
let opts = matchstr(pat, '^\s*\zs[nfxbo]')
@chrisleee
chrisleee / BSTTest.java
Last active February 21, 2017 01:10
COMP 410 Assignment 2 BST Tests
package BST_A2;
import static org.junit.Assert.*;
import org.junit.Test;
public class BSTTest {
@Test
public void testFindMin() {
@benknoble
benknoble / LinkedListImplTest.java
Last active February 13, 2017 20:02
Comp 410 Spring 2017 Test cases
package LinkedListA0;
import static org.junit.Assert.*;
import org.junit.Test;
public class LinkedListImplTest {
@Test
public void clearEasy() {
@AndrewRadev
AndrewRadev / dsf.vim
Last active November 5, 2018 05:01
Delete surrounding function call
" Delete surrounding function call
" Relies on surround.vim
"
" function_call(cursor_here) => dsf => cursor_here
"
" Try `dsf` with more complicated structures:
"
" nested(function_call(cursor_here))
" nested(cursor_here(chewy_center))
" One::Two.new([cursor_here])
@romainl
romainl / _rnb.md
Last active August 12, 2021 21:56
RNB, a Vim colorscheme template
@lnznt
lnznt / chcc.bashrc
Created November 30, 2014 00:45
[bash function] change environment variable CC/CXX (.bashrc)
function chcc {
case "$1" in
--unset) unset CC ; unset CXX ;;
clang) export CC=clang ; export CXX=clang++ ;;
gcc) export CC=gcc ; export CXX=g++ ;;
distcc) export CC=distcc ; export CXX=distcc ;;
llvm-gcc) export CC=llvm-gcc ; export CXX=llvm-g++- ;;
llvm-gcc-4.8) export CC=llvm-gcc-4.8 ; export CXX=llvm-g++-4.8 ;;
arm) export CC=arm-linux-gnueabi-gcc ; export CXX=arm-linux-gnueabi-g++ ;;