(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
N.B. This is now a library, thanks to the efforts of the wonderful @mtnygard. And the README does a good job of making clear just how terrible an idea it is to actually do this. :)
As any Clojurist knows, the REPL is an incredibly handy development tool. It can also be useful as a tool for debugging running programs. Of course, this raises the question of how to limit access to the REPL to authorized parties. With the Apache SSHD library, you can embed an SSH server in any JVM process. It takes only a little code to hook this up to a REPL, and to limit access either by public key or
@Grab( 'com.typesafe.akka:akka-actor_2.10:2.3.2' ) | |
@Grab( 'com.typesafe:config:1.2.0' ) | |
import groovy.transform.Immutable | |
import akka.actor.ActorRef | |
import akka.actor.ActorSystem | |
import akka.actor.Props | |
import akka.actor.UntypedActor | |
import akka.actor.UntypedActorFactory | |
import akka.routing.RoundRobinRouter | |
import scala.concurrent.duration.Duration |
alias usejava6='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6) ; PATH=$JAVA_HOME/bin:$PATH' | |
alias usejava7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7) ; PATH=$JAVA_HOME/bin:$PATH' | |
alias usejava8='export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) ; PATH=$JAVA_HOME/bin:$PATH' |
(ns clojure-conj-talk.core | |
(:use [enchilada :only [canvas ctx canvas-size]] | |
[monet.canvas :only [fill-style fill-rect]] | |
[jayq.core :only [show]]) | |
(:require [cljs.core.async :refer [<! >! chan timeout]]) | |
(:require-macros [cljs.core.async.macros :as m :refer [go]])) | |
(def colors | |
(rand-nth [ | |
[ |
(require '[clojure.core.async :refer [chan go >! <! >!! <!!]]) | |
(require '[clojure.core.async :as async]) | |
(defn chan-bridge | |
([ch-source map-f ch-target] | |
"map map-f onto ch-source and copy the result to ch-target" | |
(chan-bridge (async/map map-f [ch-source]) ch-target)) | |
([ch-source ch-target] | |
"in a loop read from ch-source and write to ch-target | |
this function returns inmediately and returns the ch-target" |
import groovy.transform.* | |
////////////////////////////////////// | |
// Testing | |
////////////////////////////////////// | |
new MiniKanren().with { | |
// for a given 'q' and 'r' | |
def (q,r) = [ lvar( 'q' ), lvar( 'r' ) ] | |
Here's an example of how to embed a Gist on GitHub Pages:
{% gist 5555251 %}
All you need to do is copy and paste the Gist's ID from the URL (here 5555251
), and add it to a gist
tag surrounded by {%
and %}
.
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |