Skip to content

Instantly share code, notes, and snippets.

View fouric's full-sized avatar

kono dio da fouric

View GitHub Profile
(defmethod hash (status (set stream) &key &aux (block #0=(make-array (/ (blocklength status) 8) :element-type 'octet)) (rest #0#) (count 0) (length 0))
"Return the appropriate SHA checksum digest of the contents of a STREAM of (UNSIGNED-BYTE 8).
The STREAM will be closed afterwards, so use a CONCATENATED or BROADCAST stream if you need."
(declare (dynamic-extent block rest count length) (type fixnum count) (type unsigned-byte length))
(setq status (copy-status status))
(with-open-stream (stream set) ;How should I nicely check the STREAM-ELEMENT-TYPE is correct here?
(incf length (read-sequence block stream)) ;Such checking can truly stay with PAD and BLOCKHASH.
(loop
(setq count (read-sequence rest stream) length (+ length count))
(if (zerop count)
(defun make-net/1/construct-implicit-arcs (net)
(with-accessors+ (objects places transitions arcs next-guid)
net
(maphash (lambda (name transition)
;; initial value of in-arcs is a LIST of NAMES of places that this transition will be fed from
(let (arc-names)
(dolist (in-arc (in-arcs transition))
(if (symbolp in-arc)
;; if the in-arc form is a single symbol, then it names the place to be connected to, anonymous arc, single token
(let* ((from-place-name in-arc)
@fouric
fouric / common-lisp.lisp
Created March 31, 2020 05:48
hacky eval-on-compile
(in-package #:fouric)
;; TODO: ask whether to use symbol-plists or hash tables
;; actually, should almost certainly use a hash table in the fouric package, to prevent pollution...
;; or maybe just need to CLEAR-TESTS for everything before deploying binary
;; TODO: ask #lisp and lisp discord about this
(defun run-tests (name)
;;(format t "~&running tests for ~a::~s~%" (package-name (symbol-package name)) name)
(a:doplist (test-name test-function (get name 'function-tests))
2020-02-25 hashes dump to prevent Google idea stealing due to accidental unencrypted upload of files to Google Drive:
c9d22b84faf5d9b31a8ec42212f1d9f8 alexandria.txt
5b547ecdd36c0635584dfc04ee9b6687 animation.txt
00c7f9bbb2d923cd6f4d9852f31ff341 asp.txt
f0a103eb5e8fca07a4a66a8906e7c655 astaire.txt
52e405169c2194c72f30311ccf2a8870 async.txt
92c95642b98df58649ef6c30fe123cf3 ataglance.txt
45c0f3721de75b7c7b53cddf7fa511da athena.txt
a71068499261e730b6d3d0e177330baf author.txt
md5sum:
1745fa446f14a97dbf49a9deb98f4e41 mercurial.txt
9ac997c2338cfaed8ce58e4d6adb5633 butterfly.txt
ae1033dae0a93626b63a34e3d6649184 astaire.txt
c15e76cdd8646dba61e947b7fc98e928 counterstrike.txt
0320aa76274126316f5a755778447beb eiro.txt
3d524a3ccfcec2eeea7341ecb2270452 funny.txt
9ce61339f024815dda6a8c689e769a63 megan.txt
e0d4fed25bcc7f23221bb3b7827eae3d poseur.txt
@fouric
fouric / markov.py
Created January 7, 2020 21:41 — forked from pqcfox/markov.py
A simple Markov chain to generate nicknames or fake English words.
import collections
import random
import re
import string
alphabet = string.ascii_lowercase
# Make a counter for each lowercase letter, and add a count to it
# whenever a letter follows it in /usr/share/dict/words
counters = {letter: collections.Counter() for letter in alphabet}
@fouric
fouric / books.txt
Last active December 12, 2019 01:55
Switching Power Supply Design - Abraham Pressman
Practical Binary Analysis - Andiesse
Solving Mathematical Problems: A Personal Perspective - Terence Tao
Software Design Decoded: 66 Ways Experts Think - Marian Petre and Andre van der Hoek
Exercises in Style
Concepts in Programming Languages
The Innovator's Dilemma
Psychology of Intelligence
Thinking, Fast and Slow
Programming Languages: Application and Interpretation
(defclass square ()
((state :initarg :state :accessor state) ;; -1 if queen, 0, 1, ... N otherwise
(x :initarg :x :accessor x)
(y :initarg :y :accessor y)))
(defmethod update-square ((self square) new-state)
(if (!= (state self) -1)
(incf (state self) new-state) ;; it's not a queen - update
(setf (state self) 0))) ;; remove the queen
# Final Project
# AI-NQueens-CSP
# March 17, 2019
# Sharice Mayer
import numpy as np
from matplotlib import pyplot as plt
import random
import time
from timeit import default_timer as timer