Skip to content

Instantly share code, notes, and snippets.

@joshsh
joshsh / Ripple.hs
Last active April 23, 2018 16:41
The basic Ripple interpreter, in Haskell
{-
:! ghc -c SmSn/Ripple.hs
:load SmSn/Ripple
SmSn.Ripple.main
Examples:
reduce 1 [Do, dup, string "foo"]
reduce 1 [Do, plus, int 2, int 3, int 42]
@joshsh
joshsh / Activity.hs
Created April 23, 2018 00:19
Bayesian walks from SmSn activity logs
{-
:! ghc -c SmSn/Activity.hs
:load SmSn/Activity
SmSn.Activity.main
-}
module SmSn.Activity where
import SmSn.Bayesian
@joshsh
joshsh / Bayesian.hs
Last active April 23, 2018 00:28
Fun with Haskell and Bayesian networks
{-
Prerequisites:
cabal install random
cabal install MonadRandom
cabal install split
Text, e.g.:
cat /Users/josh/copy/humor/douglas_adams/hhgttg/book1.txt | grep -v "=\|Chapter" | tr '\r\n\t\"' ' ' | sed 's/ */ /g' > /tmp/bayes-play.txt
@joshsh
joshsh / gist:7d19bd4cf18abd33b0665ffa33476e5b
Created December 17, 2017 01:46
SmSn v2 syntax example: notes from a book
* Synesthesia: A Union of the Senses
as book:
author: Richard E. Cytowic
chapter: Introduction
section: Historical Developments
note:
* the emotion-color synesthesia noted by Cytowic
* "Cytowic has found examples of people in whom extreme emotions can be the trigger, so that anger, kissing, or even orgasms can release shapes, textures, or colors"
section: Criticism of Experiential Responses
section: Synesthetes as Cognitive Fossils
children:
-
id: foobar
-
id: quuxly
created: 1487976536438
id: jrWpedhT8hjABdhJ
text: |-
This is multiline text.
Newlines are escaped.
@joshsh
joshsh / gist:2b635493171857df18419ddd1cc8ddb4
Created August 1, 2017 19:25
find SmSn files with problematic verbatim blocks
for file in `find . -name "*.smsn"`; do echo $file" "$(grep -c "\`\`\`" $file); done
#!/bin/bash
ls | grep "^................$" > /tmp/files
for i in `cat /tmp/files`; do git mv $i $i.smsn; done
@id 11111
@title Arthur Dent
@created 1501437598535
* :oSxwi4mCUd8Oqq3Y:
* :t57BnfhEfUjzgWKi:
@text ```
He's a jerk.
A complete kneebiter.
```
@joshsh
joshsh / gist:a1cc675937f85a440643edc314136805
Created July 22, 2017 22:34
SmSn conversion setup script
#!/bin/bash
#
# Set up a directory for generating SmSn/SmSn-mode wiki documentation.
#
# After running this Bash script, you can run the Haskell scripts, e.g.
# runghc smsn-mode/smsn-to-git-markdown.hs ~/smsn+/input.auto.md
mkdir smsn-md
cd smsn-md/
@joshsh
joshsh / gist:8440a0a7668cfab9c8279e673edfbad0
Created July 18, 2017 06:19
recovering Freeplane <--> SmSn note links
Bash
FILE=art.mm
cat $FILE | grep CREATED|sed 's/.*CREATED..//' | sed 's/\".*//' | sort -u > /tmp/timestamps.csv
# export your graph with C-c C-w v, then:
cat /tmp/smsn-vertices.tsv | tr '\t' '_' | sed 's/_/,/' | sed 's/_.*//' > /tmp/timestamp-and-id.csv
R
timestamps <- read.csv(file("/tmp/timestamps.csv"), header=FALSE)$V1