(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.
package main | |
import ( | |
"context" | |
"fmt" | |
"net" | |
"net/http" | |
"os" | |
"os/exec" | |
"os/signal" |
FROM node | |
RUN mkdir -p /app | |
WORKDIR /app | |
# .deps.json will only bust the cache when the package.json dependencies change | |
COPY .deps.json /app/package.json | |
RUN npm install | |
# cache will almost always bust here, but it's only copying files |
(* Enter your code here. Read input from STDIN. Print output to STDOUT *) | |
let () = | |
let ary = ref [] in | |
try ( while true do ary := (!ary@[read_int()]) done ) | |
with End_of_file -> | |
begin | |
List.fold_left (fun i x -> | |
if (i mod 2 != 0) then (print_int(x); print_string("\n"); (i + 1)) | |
else (i + 1) |
FROM library/node | |
MAINTAINER bobby@levelmoney.com | |
RUN mkdir /.npm | |
RUN mkdir /app | |
# cache (and skip if no changes) to the node_modules | |
WORKDIR /.npm | |
ADD package.json /.npm/package.json | |
# Set the version in the cache folder to 0. |
(ns shades.lenses) | |
; We only need three fns that know the structure of a lens. | |
(defn lens [focus fmap] {:focus focus :fmap fmap}) | |
(defn view [x {:keys [focus]}] (focus x)) | |
(defn update [x {:keys [fmap]} f] (fmap f x)) | |
; The identity lens. | |
(defn fapply [f x] (f x)) | |
(def id (lens identity fapply)) |
(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.
// Stateful is a simple implementation of the state pattern for javascript. | |
// | |
// Read more on this design pattern here: | |
// -> http://sourcemaking.com/design_patterns/state | |
// | |
// Initialize Stateful by passing it an object, the name of the initial state | |
// (defaults to "default"), and an optional hash of interfaces that will be | |
// applied for each state. If these interfaces are not passed, they default to | |
// the object's constructor's States property. So, for example: | |
// |
So, you want to send a motherfucking XMLHttpRequest (XHR, or commonly and falsly known as AJAX.) Too bad, just ran out of motherfucking XMLHttpRequests; but I still have one regular. XHR is not magic. It does not autofuckinmagically send things the way you want them do be sent. It does not do the thinking for you. It just sends an Http Request.
You get a hold on such a prime beast like this:
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 |