Skip to content

Instantly share code, notes, and snippets.

@Jared314
Jared314 / nand2tetris-hdl-parse.clj
Created December 28, 2013 03:39
nand2tetris HDL parser using Instaparse
(ns stuff
(:require [instaparse.core :as insta]))
(def hdl-parse
(insta/parser
"CHIP = <'CHIP'> <SPACE+> NAME <SPACE*> <'{'> <SPACE*> INSPEC <SPACE*> OUTSPEC <SPACE*> PARTS <SPACE*> <'}'>
INSPEC = <'IN'> <SPACE+> (SPECITEM <SPACE*> <','?> <SPACE*>)* <';'>
OUTSPEC = <'OUT'> <SPACE+> (SPECITEM <SPACE*> <','?> <SPACE*>)* <';'>
PARTS = <'PARTS:'> <SPACE*> (PART <SPACE*>)*
PART = NAME <'('> (<SPACE*> PARTIO <','>?)+ <');'>
@Jared314
Jared314 / instaparse-enlive-parsing.clj
Created May 19, 2013 06:53
Using Instaparse and Enlive for simple parsing and tree transformation / rewriting
(ns test1
(:require [instaparse.core :as insta]
[net.cgrand.enlive-html :as enlive]
[clojure.walk :as walk]))
(defn render [nodes]
(walk/postwalk #(if (and (map? %) (:tag %))
(with-meta (hash-map (:tag %) (:content %)) (:attrs %))
%) nodes))
@Jared314
Jared314 / testdata.txt
Last active December 26, 2020 04:25
Adventures in Validating Email Addresses with Clojure
admin@mailserver1
niceandsimple@example.com
very.common@example.com
a.little.lengthy.but.fine@dept.example.com
disposable.style.email.with+symbol@example.com
postbox@com
user@[192.168.2.1]
user@[IPv6:2001:db8:1ff::a0b:dbd0]
@Jared314
Jared314 / build-core64.sh
Last active June 11, 2022 13:08
Remaster Tiny Core Linux Core for x64
#!/bin/sh
# Ubuntu 12.04
# sudo apt-get -y install p7zip-full genisoimage
wget http://www.tinycorelinux.net/4.x/x86/release/Core-current.iso
wget http://www.tinycorelinux.net/4.x/x86/release/distribution_files/core64.gz
wget http://www.tinycorelinux.net/4.x/x86/release/distribution_files/vmlinuz64
# extract files
7z x Core-current.iso -ocore-current