Skip to content

Instantly share code, notes, and snippets.

Ngoc Dao ngocdaothanh

Block or report user

Report or block ngocdaothanh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ngocdaothanh
ngocdaothanh / gist:3764694
Created Sep 22, 2012
Scala Assignment: Recursion
View gist:3764694
package recfun
import scala.collection.mutable.ListBuffer
import common._
/** https://class.coursera.org/progfun-2012-001/assignment/view?assignment_id=4 */
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {
@ngocdaothanh
ngocdaothanh / Benchmark.scala
Created Dec 17, 2011
ByteBuffer.allocateDirect vs Unsafe
View Benchmark.scala
object Benchmark {
private val LOOP_COUNT = 1000000
private val ARRAY_SIZE = 1024
def main(args: Array[String]) {
val t1 = System.currentTimeMillis
var i = 0
while (i < LOOP_COUNT) {
testDirectByteBuffer
View introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

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.

View one.jsp
<%--
Document : one
Created on : 24/03/2017, 3:37:22 PM
Author : Tyler
--%>
<html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<head>
@ngocdaothanh
ngocdaothanh / Build.scala
Created Jun 15, 2011
dependsOn packageBin
View Build.scala
import sbt._
import Keys._
object MyBuild extends Build {
val mySettings = Defaults.defaultSettings ++ Seq(
organization := "tv.cntt",
name := "comy",
version := "1.3-SNAPSHOT",
scalaVersion := "2.9.0-1"
)
@ngocdaothanh
ngocdaothanh / rtsp_to_file.sh
Created Dec 8, 2013
Use ffmpeg to save NVC1000 & IPE300M video streams to files
View rtsp_to_file.sh
ffmpeg -i rtsp://211.241.204.87/ch0_unicast_firststream -vcodec msmpeg4v2 -an output.avi
ffmpeg -i rtsp://211.241.204.87/ch0_unicast_secondstream -vcodec msmpeg4v2 -an output.avi
View build-ffmpeg.sh
#!/bin/bash
###########################################################################
# Choose your ffmpeg version and your currently-installed iOS SDK version:
#
VERSION="2.1.1"
SDKVERSION="7.0"
#
#
###########################################################################
@ngocdaothanh
ngocdaothanh / gist:7315180
Last active Dec 27, 2015
Hazelcast Topic 2.5.1 vs 3.1
View gist:7315180
// https://docs.google.com/file/d/0B4nP_B5KDxyPdnFySDJhVDI2Ujg/edit?usp=sharing
// https://groups.google.com/forum/#!searchin/hazelcast/ngoc/hazelcast/aeSPHp82Dcs/R5ZzkIfvCukJ
package test
import com.hazelcast.core.Hazelcast
object TestManyTopic {
def main(args: Array[String]): Unit = {
val c = null//new Config
View gist:6914654
C:\Users\tanaka\Downloads\xitrum-demos-2.10\target\xitrum>java -Xmx1024m -Xms256m -XX:MaxPermSize=128m -XX:+HeapDumpOnOutOfMemoryError -XX:+Aggressive
Opts -XX:+OptimizeStringConcat -XX:+UseFastAccessorMethods -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadi
ngEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=
true -server -Dxitrum.mode=production -cp "C:\Users\tanaka\Downloads\xitrum-demos-2.10\target\xitrum\bin\..\lib\*;config" demos.Boot
[INFO] Slf4jLogger started
[INFO] Using configuration file at C:\Users\tanaka\Downloads\xitrum-demos-2.10\target\xitrum\config\hazelcast_cluster_member.xml
[INFO] Using configuration file at C:\Users\tanaka\Downloads\xitrum-demos-2.10\target\xitrum\config\hazelcast_cluster_member.xml
[INFO] Prefer IPv4 stack is true.
[INFO] Picked Address[192.168.1.12]:5701, using socket ServerSocket[addr=/0.0.0.0,localport=5701], bind any local is tr
View output
[info] Set current project to bar (in build file:/Users/ngoc/tmp/x/)
[info] Generating Scala API documentation for main sources to /Users/ngoc/tmp/x/target/scala-2.10/api...
model contains 4 documentable templates
java.lang.AssertionError: assertion failed:
while compiling: /Users/ngoc/tmp/x/src/main/scala/foo/B.scala
during phase: global=terminal, atPhase=typer
library version: version 2.10.1
compiler version: version 2.10.1
reconstructed args: -Yno-self-type-checks -d /Users/ngoc/tmp/x/target/scala-2.10/api -classpath dummy_82279db5 -bootclasspath /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar:/System/Libra
You can’t perform that action at this time.