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
#!/bin/sh | |
while true; do | |
clear; | |
poetry run pytest "$@"; | |
git ls-files -z | xargs -0 inotifywait -e CLOSE_WRITE; | |
done |
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
(require '[clojure.core.matrix :refer (matrix div sub mul add mget mmul inverse) :as m] | |
'[clojure.core.matrix.linear :refer (norm)] | |
'[clojure.math :refer (PI sqrt pow cos sin to-radians)] | |
'[com.climate.claypoole :as cp] | |
'[gnuplot.core :as g] | |
'[sfsim25.quaternion :as q] | |
'[sfsim25.atmosphere :refer :all] | |
'[sfsim25.clouds :refer :all] | |
'[sfsim25.shaders :as s] | |
'[sfsim25.ray :refer :all] |
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
% https://www.dickimaw-books.com/latex/admin/html/letter.shtml | |
\documentclass[12pt]{letter} | |
\usepackage[a4paper]{geometry} | |
\usepackage[british]{babel} | |
\begin{document} | |
\begin{letter}{Mrs Mabel Canary\\24 The Street\\ |
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
(require '[clojure.core.matrix :refer (matrix div sub mul add mget mmul) :as m] | |
'[clojure.core.matrix.linear :refer (norm)] | |
'[clojure.math :refer (PI sqrt pow cos sin to-radians)] | |
'[com.climate.claypoole :as cp] | |
'[gnuplot.core :as g] | |
'[sfsim25.quaternion :as q] | |
'[sfsim25.atmosphere :refer :all] | |
'[sfsim25.clouds :refer :all] | |
'[sfsim25.shaders :as s] | |
'[sfsim25.ray :refer :all] |
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
; Calculate Pi in Clojure | |
; https://rosettacode.org/wiki/Pi | |
; https://en.wikipedia.org/wiki/Spigot_algorithm | |
(defn pi-digits [& {:keys [q r t k n l]}] | |
(if (< (- (+ (* 4 q) r) t) (* n t)) | |
(cons n | |
(lazy-seq | |
(pi-digits :q (* q 10) | |
:r (* 10 (- r (* n t))) | |
:t t |
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
; This one is really nice and compact but it quickly runs out of stack space: | |
(defn primes [i] (cons i (lazy-seq (filter #(not (zero? (mod % i))) (primes (inc i)))))) | |
(take 100 (primes 2)) | |
; (2 3 5 7 ...) | |
(take 1000 (primes 2)) | |
; Error printing return value (StackOverflowError) at user/primes (NO_SOURCE_FILE:1). | |
; This one is slightly less elegant but works for large numbers: | |
(defn primes [i p] | |
(if (some #(zero? (mod i %)) p) |
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 '[magick MagickImage ImageInfo ColorspaceType]) | |
(defn spit-image [file-name width height data] | |
"Save an RGB image" | |
(let [info (ImageInfo.) | |
image (MagickImage.)] | |
(.constituteImage image width height "RGB" data) | |
(.setSize info (str width \x height)) | |
(.setDepth info 8) | |
(.setColorspace info ColorspaceType/RGBColorspace) |
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
(use-modules (oop goops) (ice-9 binary-ports) (rnrs bytevectors) (aiscm core) (system foreign) (aiscm xorg) (ice-9 format) | |
; http://yann.lecun.com/exdb/mnist/ | |
(define f (open-file "train-labels-idx1-ubyte" "rb")) | |
(define magic (bytevector-u32-ref (get-bytevector-n f 4) 0 (endianness big))) | |
(define n (bytevector-u32-ref (get-bytevector-n f 4) 0 (endianness big))) | |
(define bv (get-bytevector-n f n)) | |
(define labels (make (multiarray <ubyte> 1) #:memory (bytevector->pointer bv) #:shape (list n))) | |
(define f (open-file "train-images-idx3-ubyte" "rb")) | |
(define magic (bytevector-u32-ref (get-bytevector-n f 4) 0 (endianness big))) |
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
// Minimal OpenGL shader example using OpenGL directly | |
#include <math.h> | |
#include <stdio.h> | |
#include <GL/glew.h> | |
#include <GL/glut.h> | |
const char *vertexSource = "#version 130\n\ | |
in mediump vec3 point;\n\ | |
in mediump vec2 texcoord;\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
#!/usr/bin/env python3 | |
import sys | |
import numpy as np | |
import tensorflow as tf | |
class CharVec: | |
def __init__(self, text): | |
self.chars = np.array([ord(c) for c in sorted(set(text))]) |