Skip to content

Instantly share code, notes, and snippets.

View alexandru's full-sized avatar
😺
Having fun

Alexandru Nedelcu alexandru

😺
Having fun
View GitHub Profile

There are two problems with this piece of code:

  1. it blocks the current thread - Monix is always defaulting to process things synchronously and you might argue that this timeoutOnSlowDownstream operator violates the principle of least surprise, but if you want the timeout to work, it must not block the thread that executes onNext - consider that on top of Javascript it's not even possible

So it is better doing this and the timeout will get triggered:

def onNext(elem: Int) = Future {
  sum += elem
  Thread.sleep(20000)
#!/usr/bin/env bash
# Install script adapted from:
# https://gist.github.com/dwayne/2983873
NODE_DIR="$HOME/.nodejs"
echo 'export PATH=$HOME/$NODE_DIR/bin:$PATH' >> ~/.bashrc
echo 'export NODE_PATH=$HOME/$NODE_DIR/lib/node_modules' >> ~/.bashrc
source ~/.bashrc
@alexandru
alexandru / latency.txt
Created May 31, 2012 14:32 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@alexandru
alexandru / gist:2044035
Created March 15, 2012 12:49 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p125
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1333785)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p125 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem