Skip to content

Instantly share code, notes, and snippets.

package main
import (
"time"
"github.com/gopherjs/gopherjs/js"
)
func main() {
c := make(chan string)
//Three concurrent infinite loops generating events
while true
do
cat ~/fifo | (
while read rev ref
do
tarfile=$rev.tar.gz
(cd ~/gittest/server/ && git archive --format=tar $rev) | gzip > $tarfile
for cfg in `ls configs/`
do
use std
const runcmd = {cmd : byte[:][:]
var output, status
match std.spork(cmd)
| `std.Ok (pid, stdin, stdout):
match std.fslurp(stdout)
| `std.Ok out: output = out
use sys
use std
// XXX move to stdlib
const rename = {from, to
var ret = sys.rename(from, to)
-> ret == 0
}
@andrewchambers
andrewchambers / notes.txt
Last active April 12, 2018 13:01
Notes on a new interpreted language
I have been thinking recently about a set of features that might be
interesting for an interpreted language. Largely I am uninterested in the
syntax for now, just the properties of the language and implementation.
1. Actor model similar to erlang with total isolation of actors except
via message passing. Crashing one actor does not affect other actors
unless they want to be affected.
2. Mutability within an actor, but only immutable objects can be passed
@andrewchambers
andrewchambers / errors.md
Created August 28, 2018 22:49
Error values feedback

In my own code, I use my own error package. My observation is that a root cause of an error is special, most values in the error chain are useless except to preserve line information. Users and debuggers usually only care about the first error and the last error in the chain.

A typical formatting of an error is "Unable to ${TOP_ACTION}: ${ROOT_CAUSE}"

A typical usage of my package is:

My observation is that a root cause of an error is special, I usually only care about the first error and the last error in the chain except for logs.

In the end I disliked pkg/errors naming conventions and wrote my own small package.

A typical usage of my package in a server:

(set *hist-file* (first (sh/expand "~/.janetsh.hist")))
(def tc
{
# The wrapping \x01 ... \x02 tell readline the surrounded string has zero length.
# Without it we get strange artifacts in the string history.
:bold "\x01\x1b[1m\x02"
:none "\x01\x1b[0m\x02"
})
@andrewchambers
andrewchambers / sysrc
Last active May 28, 2019 23:52
Janetsh sysrc nixos
users.extraUsers.ac = {
shell = "${janetsh}/bin/janetsh-posix-wrapper";
};
environment.etc."janetsh.rc".text = ''
(import posixsh)
(def env-blacklist @{"_" true})
(when (not (= "1" (os/getenv "__NIXOS_SET_ENVIRONMENT_DONE")))
{ stdenv, fetchFromGitHub, janet, pkgconfig, readline80}:
stdenv.mkDerivation rec {
pname = "janetsh";
version = "0.0.1";
src = fetchFromGitHub {
owner = "andrewchambers";
repo = "janetsh";
rev = "72253ce31bee9974a2fee232cce5d049b2ade215";