Skip to content

Instantly share code, notes, and snippets.

@non
non / uxnbot.patch
Created October 21, 2022 01:34
patch that turns uxnbot.lua into uxnrepl.lua
--- uxnbot.lua 2022-10-20 21:33:58.783691604 -0400
+++ uxnrepl.lua 2022-10-20 21:33:14.229193549 -0400
@@ -1201,6 +1201,12 @@
end
end
local chat = require('chat')
+print('uxnrepl (ctrl-d to quit)')
+io.write('> ')
+io.flush()
for l in io.stdin:lines() do
@non
non / div16.tal
Last active October 20, 2022 03:50
tested implementation of signed division for 16-bit numbers in uxntal
( main method for testing )
|0100
#1234 #0001 ;testcases JSR2
#0000 #0431 ;testcases JSR2
#0039 #0003 ;testcases JSR2
#9321 #ffff ;testcases JSR2
#ffff #9321 ;testcases JSR2
#ffff #ffff ;testcases JSR2
#7654 #8000 ;testcases JSR2
#8000 #0001 ;testcases JSR2
;; tal-mode.el
;;
;; by d_m
;; use rx for regular expressions
(require 'rx)
;; set up a mode hook (currently unused)
(defvar tal-mode-hook nil)
@non
non / grep.tal
Last active February 10, 2022 03:52
Regex implementation in Uxntal. Includes a simple grep implementation was well as a REPL for testing.
( grep.tal )
( )
( by d_m )
( print a character to STDOUT )
%emit { #18 DEO }
( the first argument to grep is the regex )
( arguments are passed on STDIN, so we just )
( assume the first "line" is the argument )
@non
non / maze.tal
Last active January 22, 2023 08:00
Prototype maze generator for the UXN virtual machine.
( maze.tal )
( )
( mazes generated by randomized depth-first search )
( press any key to generate a new maze )
( )
( generator uses a simple 16-bit xorshift RNG )
( based on http://b2d-f9r.blogspot.com/2010/08/16-bit-xorshift-rng-now-with-more.html )
%DEBUG { #ff #0e DEO }
%<<5 { #50 SFT2 }
@non
non / rng.tal
Created November 26, 2021 06:46
( rng.tal )
( simple 16-bit xorshift RNG )
( based on http://b2d-f9r.blogspot.com/2010/08/16-bit-xorshift-rng-now-with-more.html )
%<<5 { #50 SFT2 }
%>>1 { #01 SFT2 }
%>>3 { #03 SFT2 }
%RTN { JMP2r }
%EMIT { #18 DEO }
%DIGIT { #00 SWP ;digits ADD2 LDA EMIT }
@non
non / csv.scala
Last active November 5, 2020 03:52
package cats.parse
package examples
import cats.implicits._
import Parser.{char, charWhere, charsWhile, string1}
object Csv {
def mkString(p: Parser1[Char]): Parser[String] =
@non
non / massdel.py
Created January 9, 2020 18:15
Script to delete all issues for a repo. This is different than just closing all of them. It uses the v4 GraphQL Github API.
#!/usr/bin/env python
#
# by Erik Osheim
#
# STEPS TO USE
#
# 0. install deps
# - pip install requests
#
# 1. generate personal access token
@non
non / sizes.txt
Last active October 16, 2019 10:09
Size of various JVM data structures in bytes (top column is number of elements).
COLLECTION 0 1 5 10 50 100 500 1000
Array[Int] 16 24 40 56 216 416 2016 4016
immutable.BitSet 24 24 24 24 24 32 96 160
immutable.IntMap[Int] 16 40 328 688 3568 7168 35968 71968
immutable.List[Int] 16 56 216 416 2016 4016 20016 40016
immutable.Map[Int,Int] 16 40 304 720 4856 9680 53504 111760
immutable.Queue[Int] 40 80 240 440 2040 4040 20040 40040
immutable.Set[Int] 16 32 264 480 3016 5840 27696 57952
immutable.SortedMap[Int,Int] 40 88 280 520 2440 4840 30008 62008
immutable.SortedSet[Int] 40 104 296 536 2456
#!/bin/sh
#
# simple streaming from the command line:
#
# ./cast.sh send *.mp3 # stream some files
#
# ./cast.sh recv # listen to the stream
#
# currently hardcodes localhost port 9999.
#