Skip to content

Instantly share code, notes, and snippets.

@alandipert
alandipert / fb.clj
Last active November 26, 2020 20:57
(defn fizzbuzz [n]
(let [fb (str ({0 "fizz"} (mod n 3))
({0 "buzz"} (mod n 5)))]
({"" (str n)} fb fb)))
@alandipert
alandipert / interfaces
Created March 12, 2013 20:14
raspbian configuration for bridging eth0 and wlan0
# /etc/network/interfaces
# Configured for bridging wifi<->ethernet
# Tested with:
# - RPi Model B Rev. 1
# - 2013-02-09-wheezy-raspbian
# - Edimax 8192-series USB wireless adapter
# - /etc/modprobe.d/8192cu.conf contents:
# - options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
# - firmware: c2d133fb4efe9c9995da7fd7e1c45d74254f5c4b
@alandipert
alandipert / midi.clj
Created March 31, 2010 12:37
Play music with Clojure and javax.sound.midi
(import '(javax.sound.midi MidiSystem Synthesizer))
(defn play-note [synth channel note-map]
(let [{:keys [note velocity duration]
:or {note 60
velocity 127
duration 1000}} note-map]
(. channel noteOn note velocity)
(Thread/sleep duration)
(. channel noteOff note)))
const removeAt = (xs, i) => xs.filter((x, j) => j !== i);
const permute = xs => xs.length
? xs.flatMap((x, i) => permute(removeAt(xs, i)).map(ys => [x, ...ys]))
: [[]];
(defconstant mv-limit 20)
(defparameter *mv-expected* 1)
(defparameter *mv* (make-array mv-limit))
(defun mv (&rest vals)
(do ((i 0 (1+ i))
(vs vals (cdr vs)))
((or (eql i *mv-expected*) (null vs))
(def mv-limit 20)
(def ^:dynamic *mv-arr*)
(def ^:dynamic *values-expected* 1)
(defn values [& vals]
(when (thread-bound? #'*values-expected*)
(dotimes [i (set! *values-expected*
(min *values-expected* (count vals)))]
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix.
;;
;; * :use makes functions available without a namespace prefix
;; (i.e., refers functions to the current namespace).
;;
;; * :import refers Java classes to the current namespace.
;;
#+BEGIN_COMMENT
Build wiki.html with:
emacs wiki.org --batch -f org-html-export-to-html --kill
#+END_COMMENT
#+OPTIONS: toc:nil
#+BEGIN_SRC emacs-lisp :exports none
(defun hyperorg/sort ()
(save-excursion
(goto-char (point-min))
(goto-char (1- (search-forward "*")))
library(promises)
library(future)
library(shiny)
library(testthat)
plan(multiprocess)
adderModule <- function(id, sleepFor, n) {
moduleServer(id, function(input, output, session) {
output$sum <- renderText({

testServer QA Notes

testServer() is a new function for testing the behavior of reactives inside of Shiny server functions and modules.

Server and module functions

Server functions define the reactive behavior of Shiny applications. Together with UI functions, server functions define a Shiny application. Server functions are R functions such as the following:

server &lt;- function(input, output, session) {