Skip to content

Instantly share code, notes, and snippets.

View rebcabin's full-sized avatar

Brian Beckman rebcabin

View GitHub Profile
@rebcabin
rebcabin / gist:5688990
Last active December 17, 2015 23:29
rxjava + clojure concurrency mystery
(ns expt2.core
(:require clojure.string clojure.pprint)
(:import [rx Observable subscriptions.Subscriptions]))
(defmacro pdump [x]
`(let [x# ~x]
(do (println "----------------")
(clojure.pprint/pprint '~x)
(println "~~>")
(clojure.pprint/pprint x#)
@rebcabin
rebcabin / gist:7623311
Created November 24, 2013 04:27
A basic Observable / Observer in Mathematica / Wolfram
Or, we can emulate the Reactive Framework's "GenerateWithTime".
Cold GenerateWithTime
Rx.Observable.GenerateWithTime = function(
initialState, // : State
condition, // : State -> bool
resultSelector, // : State -> Result
timeSelector, // : State -> int
iterate) // : State -> State

Literate Clojure

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@rebcabin
rebcabin / macrology.org
Created December 4, 2015 15:49
A MVE for StackOverflow question 34079242

Macrology

@rebcabin
rebcabin / gensymmed-code.lisp
Last active December 14, 2015 18:46
gensymming functions versus lisp-unit tests
(defpackage :io.github.rebcabin.temporary
(:use :common-lisp)
(:use :lisp-unit)
#+sbcl (:use :sb-ext))
(in-package :io.github.rebcabin.temporary)
;;; I can definitely define a function with a gensymmed name:
(defmacro m1 ()
(let ((g (gensym)))
(* ::Package:: *)
(* ::Input:: *)
(*ClearAll[reset,shift];*)
(*reset[h_[As___, shift[k_, E_], Bs___]]:=*)
(*Block[{K=x\[Function]reset[h[As,x,Bs]]},*)
(*Print[<|"As"->{As},"h"->h,"k"->k,"E"->E,"Bs"->{Bs}|>];*)
(*reset[E/.{k->K}]];*)
(*reset[E_]:=E;*)
@rebcabin
rebcabin / _reader-macros.md
Created January 31, 2016 21:52 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

Module[{myNotebook, myCells, myStyles, myDemoIntegral, myDemoSolution,
myMathGroup, myItemGroup, myNumberedGroup, myCode, myProgramText,
myMeatyContentGroup, mySectionGroup, myDocumentGroup,
myFontFunction, myDefaultStyles, myNonDefaultStyles},
myDemoIntegral = RowBox[{
RowBox[{"\[Integral]",
RowBox[{"x", RowBox[{"\[DifferentialD]", "x"}]}]}],
"+", SqrtBox["z"]}];
myDemoSolution = RowBox[{
FractionBox[SuperscriptBox["x", "2"], "2"],