Skip to content

Instantly share code, notes, and snippets.

View nicholasren's full-sized avatar

Xiaojun Ren nicholasren

View GitHub Profile
@nicholasren
nicholasren / blocking-with-future.scala
Created May 11, 2014 10:19
solving nested future problem
val fa = callToRemoteServiceA();
val fb = callToRemoteServiceB();
val fc = callToRemoteServiceC(fa.get());
val fd = callToRemoteServiceD(fb.get());
val fe = callToRemoteServiceE(fb.get());
val executor = new ThreadPoolExecutor(4, 4, 1, TimeUnit.MINUTES, new LinkedBlockingQueue[Runnable]())
def solveRPN(expression: String):String = {
expression.split(" ").foldLeft(List[String]()) {
(stack:List[String], e:String) =>
e match {
case "*" =>
stack match {
case List(z) => List(z)
case x :: y :: ys => (y.toInt * x.toInt).toString :: ys
}
case "+" =>
#!/usr/bin/env ruby
require "fileutils"
def build_file_content prj_name
<<-EOS
name := \"#{prj_name}\"
version := \"0.1\"
scalaVersion := \"2.10.1\"
#settings
set :user, 'deployer'
set :domain, ENV['on'] == 'prod' ? '<prod ip>' : '<qa ip>'
set :deploy_to, '/var/www/example.com'
set :repository, 'git@github.com:your_company/sample.git'
set :branch, 'master'
task :provision do
# add nginx repo