Skip to content

Instantly share code, notes, and snippets.

@lysu
lysu / introrx.md
Last active August 29, 2015 14:06 — forked from staltz/introrx.md

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.

@lysu
lysu / gist:61c0e7fdf60cba600f53
Last active August 29, 2015 14:23
generate-pojo.go
package main
import (
"bytes"
"database/sql"
"fmt"
"log"
"regexp"
"strings"
"text/template"
// ==UserScript==
// @name jQuery For Chrome (A Cross Browser Example)
// @namespace jQueryForChromeExample
// @include *
// @author Erik Vergobbi Vold
// @description This userscript is meant to be an example on how to use jQuery in a userscript on Google Chrome.
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
@lysu
lysu / generateSql.pl
Created December 8, 2012 10:16
Generate sql from file
my @ctypes=qw/0 1 0 1 1/;
while(<>) {
chop;
@F=split('\|', $_);
print "insert into table values(";
foreach my $col (@F) {
my $type=shift(@ctypes);
print ($type == 1 ? '"'.$col.'"' : $col);
print ",";
@lysu
lysu / diffColumn.awk
Created December 8, 2012 12:19
Compare 2ed Column and select exist in file2 but not in file1
awk 'FNR==NR {A[$2];next;} !($2 in A)' file1 file2
@lysu
lysu / log4j.properties
Created December 12, 2012 10:39
mybatis open logger
log4j.logger.com.ibatis=ALL
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=ALL
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=ALL
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=ALL
log4j.logger.java.sql.Connection=ALL
log4j.logger.java.sql.Statement=ALL
log4j.logger.java.sql.PreparedStatement=ALL
log4j.appender.ibatis.File = /home/robiplus/logs/ibatis.log
log4j.appender.ibatis.layout = org.apache.log4j.PatternLayout
log4j.appender.ibatis.layout.ConversionPattern = %p %d{yyyy-MM-dd HH:mm:ss} - %m%n
func Example_reuse_socket_connection() {
// Put two data: t1-data1, t1-data2 into mytube1.
// and one data: t2-staff into mytube2
master, err := beanstalk.Dial("tcp", "127.0.0.1:11300")
if err != nil {
panic(err)
}
master.Tube.Name = "mytube1"
_, err = master.Put([]byte("t1-data1"), 1, 0, 5*time.Minute)
gc 1 @7.559s 0%: 0.041+2.4+3.4+1.7+1.2 ms clock, 0.16+2.4+0+2.1/0.80/0+5.0 ms cpu, 5->6->4 MB, 4 MB goal, 4 P
gc 2 @7.596s 0%: 0.037+2.6+1.5+0.67+2.2 ms clock, 0.11+2.6+0+0.12/0.13/1.9+6.8 ms cpu, 5->6->4 MB, 8 MB goal, 4 P
gc 3 @7.635s 0%: 0.11+1.5+0.21+3.3+0.73 ms clock, 0.33+1.5+0+0.12/2.8/0+2.2 ms cpu, 6->7->4 MB, 7 MB goal, 4 P
gc 4 @7.687s 0%: 0.12+1.7+0.87+1.4+0.54 ms clock, 0.37+1.7+0+1.8/1.0/0+1.6 ms cpu, 7->8->4 MB, 8 MB goal, 4 P
gc 5 @7.729s 0%: 0.052+1.9+0.60+1.4+0.42 ms clock, 0.15+1.9+0+2.4/1.1/0+1.2 ms cpu, 8->8->4 MB, 8 MB goal, 4 P
gc 6 @7.776s 0%: 0.19+9.9+0.30+0.60+0.47 ms clock, 0.57+9.9+0+11/0.46/0+1.4 ms cpu, 7->9->5 MB, 8 MB goal, 4 P
gc 7 @7.843s 0%: 0.10+3.0+0.58+0.41+0.43 ms clock, 0.43+3.0+0+3.4/0.22/0+1.7 ms cpu, 8->9->4 MB, 9 MB goal, 4 P
gc 8 @7.887s 0%: 0.12+5.1+0.054+0.91+0.66 ms clock, 0.50+5.1+0+5.2/0.71/0+2.6 ms cpu, 8->8->5 MB, 8 MB goal, 4 P
gc 9 @7.956s 0%: 0.088+4.8+0.032+1.7+0.51 ms clock, 0.35+4.8+0+5.5/1.4/0+2.0 ms cpu, 9->10->5 MB, 9 MB goal, 4 P
gc 10 @8.035s 0%: 0
@lysu
lysu / poolflate
Last active November 30, 2015 17:21
gc 1 @3.265s 0%: 0.041+2.5+4.2+0.32+0.41 ms clock, 0.12+2.5+0+2.7/0.042/0+1.2 ms cpu, 7->9->8 MB, 4 MB goal, 4 P
gc 2 @3.273s 0%: 0.024+3.4+0.19+0.93+1.1 ms clock, 0.049+3.4+0+3.5/0.011/0+2.3 ms cpu, 9->21->21 MB, 12 MB goal, 4 P
gc 3 @3.279s 0%: 0.053+3.0+1.5+1.2+1.8 ms clock, 0.15+3.0+0+3.8/0.028/0+5.5 ms cpu, 22->38->37 MB, 19 MB goal, 4 P
gc 4 @3.288s 0%: 0.041+3.0+3.0+0.88+0.42 ms clock, 0.12+3.0+0+3.3/0.85/0+1.2 ms cpu, 38->44->43 MB, 42 MB goal, 4 P
gc 5 @3.297s 0%: 1.3+6.9+1.1+0.81+1.3 ms clock, 4.1+6.9+0+3.7/0.007/0+4.0 ms cpu, 52->64->53 MB, 76 MB goal, 4 P
gc 6 @3.313s 0%: 0.11+3.5+6.2+3.3+0.48 ms clock, 0.35+3.5+0+3.8/1.2/0+1.4 ms cpu, 66->71->45 MB, 82 MB goal, 4 P
gc 7 @3.675s 0%: 0.16+3.3+0.078+0.70+0.48 ms clock, 0.49+3.3+0+4.9/0.45/0+1.4 ms cpu, 78->86->14 MB, 80 MB goal, 4 P
gc 8 @3.682s 0%: 0.13+5.8+0.32+0.35+0.61 ms clock, 0.54+5.8+0+4.2/0.21/0+2.4 ms cpu, 15->29->27 MB, 11 MB goal, 4 P
gc 9 @3.691s 0%: 0.19+6.3+0.91+0.89+0.61 ms clock, 0.78+6.3+0+6.6/0.031/0+2.4 ms cpu, 29->54->54 MB, 27
gc 1 @2.957s 0%: 0.10+3.0+2.3+0.72+2.3 ms clock, 0.30+3.0+0+2.9/0.45/0+7.1 ms cpu, 31->35->20 MB, 4 MB goal, 4 P
gc 2 @2.967s 0%: 0.061+2.7+7.8+0.56+1.7 ms clock, 0.24+2.7+0+3.3/0.21/0+7.1 ms cpu, 21->36->23 MB, 32 MB goal, 4 P
gc 3 @2.981s 0%: 0.81+2.4+5.2+1.0+0.74 ms clock, 3.2+2.4+0+3.0/0.027/0+2.9 ms cpu, 24->34->24 MB, 16 MB goal, 4 P
gc 4 @2.993s 0%: 0.060+2.4+3.3+0.79+0.90 ms clock, 0.24+2.4+0+3.4/0.063/0+3.6 ms cpu, 25->33->31 MB, 28 MB goal, 4 P
gc 5 @3.002s 0%: 1.0+2.9+0.55+0.95+1.1 ms clock, 4.3+2.9+0+2.7/0.29/0+4.4 ms cpu, 36->47->37 MB, 48 MB goal, 4 P
gc 6 @3.010s 0%: 0.082+3.5+0.62+1.0+0.34 ms clock, 0.32+3.5+0+2.5/0.55/0+1.3 ms cpu, 45->54->44 MB, 53 MB goal, 4 P
gc 7 @3.021s 0%: 0.091+3.9+0.071+0.20+0.40 ms clock, 0.36+3.9+0+2.9/0.054/0+1.6 ms cpu, 70->81->43 MB, 71 MB goal, 4 P
gc 8 @3.031s 0%: 0.78+4.4+1.5+2.8+0.74 ms clock, 2.3+4.4+0+3.7/0.086/0+2.2 ms cpu, 64->75->30 MB, 65 MB goal, 4 P
gc 9 @3.044s 0%: 0.36+4.5+0.043+0.19+0.31 ms clock, 0.73+4.5+0+4.5/0.038/0+0.63 ms cpu, 38->48->37 MB,