Skip to content

Instantly share code, notes, and snippets.

View darius's full-sized avatar

Darius Bacon darius

View GitHub Profile
@darius
darius / RABBIT.scm
Last active September 23, 2024 19:44
;;- -*-scheme-*-
;;; rabbit compiler
;;- This is the source code to the RABBIT Scheme compiler, by Guy Steele,
;;- taken from the Indiana Scheme repository and annotated by me, Darius
;;- Bacon. I converted it from all-uppercase to all-lowercase and
;;- reindented it with Emacs for better readability. I've added the
;;- comments starting with either ;- or ;*. Other comments are by Steele.
;;- The ;- comments were things I'd figured out, while ;* denoted things
;;- for me to look into. (Sometimes I didn't bother to type in the answer
(let grammar (grammar<- "
shifts: shift* :end.
shift: start [nap* :list] :list.
start: timestamp :drop 'Guard #' :count ' begins shift\n'.
nap: timestamp 'falls asleep\n'
timestamp 'wakes up\n' :list.
timestamp: '[' date _ time ']' _.
date: (!_ 1)+.
Parson (Cant edition) one-liners:
'#' :count ' @ ' :count ',' :count ': ' :count 'x' :count
:count ', ' :count
'Step ' {1} ' must be finished before step ' {1} ' can begin.'
:count ' players; last marble is worth ' :count ' points\n'
'position=<'_ :integer ','_ :integer :list ['> velocity=<'_ :integer ','_ :integer '>' :list]
{5} ' => ' {1}
{1} '=' :integer ', ' {1} '=' :integer '..' :integer
'depth: ' :count '\ntarget: ' [:count ',' :count :list] '\n'
;; Issues:
;; - Different behavior on ragged arguments, zip vs. transpose. How to resolve?
;; - Have to handle when the arguments don't match on operator
;; - Add methods for .ragged, .pad-left, .pad-right
;; We can avoid a 2x2 table of what to do here if we have methods to
;; deal with terms and lists in a unified way.
;; Currently:
;; - term: term<-, term.tag, term.parts
uh... thinking about balanced ternary again.
Earlier I thought a bit about written notation for balanced trits.
Some maybe fun follow-on topics:
-------
What would a 4-trit character encoding look like? It'd be less
cramped than the historical 6 bits of many earlier systems, but
more cramped than ASCII. Find a cute system starting with: the
;; "The ultimate conditional syntax" by Lionell Parreaux, examples
;; (untested translations to Cant)
;; Example 1
(hm (may some-value
(be {none} 0))
(let _ (console .log "It's not none!"))
(may some-value
(be {some {~ {some name} {left str}}}
(do [(name name.capitalize)]
# Reimplement einsum to check my understanding. Efficiency not a goal.
# in Python3
# An 'array' variable is a numpy ndarray.
# spec_string looks like "mn,np->mp"
import itertools
import numpy as np
def einsum(spec_string, *arrays):
instr, out = spec_string.split('->')
If the git config --global http.sslCAInfo command produced an empty output, it implies that git has not been explicitly configured with a specific Certificate Authority (CA) bundle file, and so it is falling back to the system's CA bundle file.
The fact that you see in the strace output that it's opening /etc/ssl/certs/ca-certificates.crt confirms that it is indeed using the system's CA bundle file. It means that git is using the correct file for SSL certificate verification.
Given that the certificate is valid, the issuer is Let's Encrypt (which is widely trusted), and the system is correctly referring to the CA bundle file, the issue is likely not with the SSL certificate itself or with the CA bundle file.
You may want to consider the following possibilities:
Network issues: Are you possibly behind a proxy or firewall that could be interfering with git's connection? Try cloning the repository from a different network environment, if possible.
withal@gmail.com
How about programs to read with especially interesting source code? The ray tracing book above sounds like it's of that type.
Studying well-written source code can be a valuable learning experience for programmers. Here are a few projects with interesting source code that your friend might enjoy:
SQLite (https://www.sqlite.org/): SQLite is a widely-used, self-contained, serverless, zero-configuration SQL database engine written in C. Its source code is well-documented and provides insight into efficient database management.
Redis (https://github.com/redis/redis): Redis is an in-memory data structure store, used as a database, cache, and message broker. It's written in C and offers a good example of clean and efficient coding practices.
Git (https://github.com/git/git): Git is a distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Its source code, primarily written in C, showcases advanced algorithms and data structure
withal@gmail.com
Binary search is not helpful here because, in the original nested loop, the total count of all the inner loop steps is going to be just n. But maybe we can simplify that code still: try rewriting it by fusing the cdf-computing loop with the (incf index) loop. Do you see what I'm getting at?
I see what you're getting at now. You want to compute the cdf and perform the resampling step in a single loop, effectively removing the need for the inner loop. Here's a version of the function that combines the two steps:
lisp
Copy code
(defun systematic-resample/normalized (weights)
(loop with n = (length weights)
with sum-weights = 0d0
with index = 0