Skip to content

Instantly share code, notes, and snippets.


Samuel Chase samebchase

View GitHub Profile
View realistic.clj
(ns my-amazing.module.core
(:require [another-library.json.module :as json]
[yet-another.http.library :as http]))
View ClojureNamespace.raku
grammar Namespace {
token TOP { <ns-form>
# <clojure-forms>
# token clojure-forms { }
token ns-form { <.ws>?
(<.comment-line> <ws>?)*
View balanced-parens.raku
#!/usr/bin/env raku
use v6.d;
use Grammar::Tracer;
grammar BalancedParens {
token TOP { <balanced-paren> }
token balanced-paren { <lparen> <balanced-paren>* <rparen> }
View simple-ns.raku
#!/usr/bin/env raku
use v6.d;
use Grammar::Tracer;
grammar SimpleNs {
token TOP { <simple-ns> }
token simple-ns { <lparen> <ns-keyword> <.ws> <ns-name> <rparen> }
View trivial.raku
#!/usr/bin/env raku
use v6.d;
use Grammar::Tracer;
grammar EmptyLispForm {
token TOP { <lparen> <rparen> }
token lparen { '(' }
token rparen { ')' }
samebchase / realistic-ns-with-actions.raku
Created Nov 28, 2020
View realistic-ns-with-actions.raku
#!/usr/bin/env raku
use v6.d;
#use Grammar::Tracer;
grammar RealisticNs {
token TOP { <realistic-ns> }
token realistic-ns { <lparen>
<ns-keyword> <.ws> <ns-name> <.ws>
samebchase /
Last active Nov 29, 2020
[WIP]: Raku Grammars

Parsing Clojure namespace forms using Raku grammars

One day, I started wondering if it would be possible to parse Clojure namespace forms and generate a dependency graph of the various namespaces used in a real-world Clojure project. While that was the original motivation, I ended up down the Raku grammar rabbit hole, and had an enjoyable time learning how to use them. I'm glad you're joining me in reliving that journey.


samebchase / Usage.txt
Created Apr 2, 2020
Utility to convert milliseconds since the UNIX Epoch to a readable timestamp. Also, handles timezone offsets.
View Usage.txt
❯ timestamp-from-ms 1585725108000
❯ timestamp-from-ms 1585725108000 +5:30
❯ timestamp-from-ms 1585725108000 -5:30
#include <vector>
#include <cassert>
#include <iostream>
#include <forward_list>
using std::cout;
using std::cin;
using std::endl;
using std::vector;
(* *)
open Core.Std;;
open Sequence;;
let print_party_hat height =
let hat_width line_no =
2*line_no + 1 in
let print_char_n char n =
String.make n char