Skip to content

Instantly share code, notes, and snippets.

;; Programming Languages, Homework 5
#lang racket
(provide (all-defined-out)) ;; so we can put tests in a second file
;; definition of structures for MUPL programs - Do NOT change
(struct var (string) #:transparent) ;; a variable, e.g., (var "foo")
(struct int (num) #:transparent) ;; a constant number, e.g., (int 17)
(struct add (e1 e2) #:transparent) ;; add two expressions
(struct ifgreater (e1 e2 e3 e4) #:transparent) ;; if e1 > e2 then e3 else e4
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
Bost /
Created August 16, 2017 13:07
fish: for-loop
function for-loop
set list \
"foo" \
"bar" \
for item in $list
echo "item: $item"
Bost / utils.cljc
Created July 31, 2017 15:54
clojure: various utils
(defn in?
"true if seq contains elm"
[seq elm]
(boolean (some (fn [e] (= elm e)) seq)))
Bost /
Last active August 22, 2017 15:39
python: execute os command
#!/usr/bin/env python
from subprocess import Popen, PIPE
import operator
import os
import re
import datetime
import time
from functools import reduce
from pathlib import Path
Bost /
Last active July 31, 2017 14:45
bash: for-loop
#!/usr/bin/env bash
# Debugging
# set -x
# Stop on error
set -e
# Exit if variables are not set (recommended)
set –u
tstp() {
Bost / list-ppa
Last active July 26, 2017 16:35 — forked from jnakatsui/list-ppa
list ppa on *nix system
#!/usr/bin/env bash
# get all the PPAs installed on a system ready to share for reininstall
for APT in `find /etc/apt/ -name \*.list`; do
# list found files - helps in case of: '... public key is not available: NO_PUBKEY'
echo $APT
grep -o "^deb[a-z0-9\-]\+/[a-z0-9\-]\+" $APT | while read ENTRY ; do
USER=`echo $ENTRY | cut -d/ -f4`
PPA=`echo $ENTRY | cut -d/ -f5`
echo sudo apt-add-repository ppa:$USER/$PPA
Bost /
Last active July 31, 2017 14:46
bash: logging a la log4j
#!/usr/bin/env bash
# Debugging
# set -x
# Stop on error
set -e
# Exit if variables are not set (recommended)
set –u
Bost / cobol-mode.el
Created September 28, 2016 12:46 — forked from Edward-H/cobol-mode.el
An Emacs mode for COBOL code. It features syntax highlighting for most modern dialects, indentation, support for free- and fixed-format code and code skeletons.
;;; cobol-mode.el --- Mode for editing COBOL code -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2015 Edward Hart
;; Author: Edward Hart <>
;; Maintainer: Edward Hart
;; Version: 0
;; Created: 9 November 2013
;; Keywords: languages
Bost / loop-recur.clj
Last active November 23, 2015 11:49
clojure loop recur
(loop [r 0
break false]
(if-not break
(if (< r 5)
(println "Expensive calculation of r:" r)
(recur (inc r) false))
(println "Breaking the loop at:" r)
(recur r true)))))