Skip to content

Instantly share code, notes, and snippets.

@DASpringate
DASpringate / cond.R
Last active May 19, 2017 15:24
A simple R implementation of `cond` from Lisp. Allows for arbitrary numbers of conditionals without nested if statements
#' R implementation of `cond` from Lisp
#' allows for arbitrary numbers of conditionals without ugly nested if statements
#' conditionals are entered as pairs of expressions (clauses),
#' first the expression to be evaluated and second the return value if the expression is true
#' @param ... an even number of expressions as pairs (see example)
#' @param true the `else` expression (Taken from the Lisp (T resultN) see http://www.cis.upenn.edu/~matuszek/LispText/lisp-cond.html)
#' @return The paired value of the first true conditional expression or the value of true
#' @examples
#' x <- runif(1)
#' cond(x < 0.2, "lower tail",
@fsmunoz
fsmunoz / abcl-mqtt.lisp
Created June 24, 2013 14:02
Simple example of MQTT message publish in Common Lisp and ABCL, using the Eclipse Paho client
;; Simple example of MQTT message publish using Common Lisp and ABCL
;;
;; Uses the Eclipse Paho client
;;
;; Author: Frederico Munoz <frederico.munoz@pt.ibm.com>
;; Date: 22-Jun-2013
;; Keywords: mqtt, messaging, m2m, telemetry, abcl, iot, paho, lisp
;;
;; Copying and distribution of this file, with or without modification,
;; are permitted in any medium without royalty provided the copyright
@kanaka
kanaka / tokenizer.sh
Last active December 30, 2015 12:18
bash lisp tokenizer NOTE: doesn't handle \" within strings yet
#!/bin/bash
wholefile=$(cat $1)
filelen=${#wholefile}
idx=0
chunk=0
chunksz=500
while true; do
if (( ${#str} < ( chunksz / 2) )) && (( chunk < filelen )); then
@jerrypnz
jerrypnz / test_watchers.clj
Created November 6, 2012 09:33
Clojure wrapper for Java 7 WatchService (java.nio.files)
(load-file "./watch_service.clj")
(refer 'watch-service)
(defn print-ev
[ev ctx]
(println "[foo]" ev " --> " ctx)
(println "Parent Dir:" (.getParent ctx)))
(defn print-ev-2
[ev ctx]
@micha
micha / gist:997056
Created May 28, 2011 17:34
Euler project problem #1
#! /usr/bin/env racket
; Euler problem #1. Sum of integers between 1 and N which are
; divisible by i, j, k, ..., or l.
;
; The sum 1+2+3+...+n = (n^2 + n)/2, call this sum-range(n).
;
; Then the sum of i+2i+3i+...+qi = i * sum-range(floor(n/i)), where
; qi is the greatest multiple of i such that i <= n.
;
@tonsky
tonsky / .profile.boot
Created March 2, 2015 20:14
boot-clj plugin to report build status to AnyBar
(defn- send-udp [s port]
(with-open [socket (java.net.DatagramSocket.)]
(let [group (java.net.InetAddress/getByName "localhost")
bytes (.getBytes s)
packet (java.net.DatagramPacket. bytes (count bytes) group port)]
(.send socket packet)
(.close socket))))
(deftask anybar [p port VAL int "AnyBar port"]
(let [port (or port 1738)]
@Deraen
Deraen / Vagrantfile
Created December 14, 2014 00:05
Testing boot
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
$script = <<SCRIPT
apt-get install -y git maven openjdk-7-jdk
(
cd /usr/local/bin
wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -O lein
chmod +x lein
)