2014年12月10日

scala函数式编程

摘要: 学习了一些scala的基础语法http://twitter.github.io/scala_school/zh_cn/index.html,尝试一下scala的函数式编程。用函数式编程如何实现:sum(f, a,b)=s = 0for i in [a, b] s+=f(i)return s这是命令... 阅读全文

posted @ 2014-12-10 19:41 Torstan 阅读(189) 评论(0) 推荐(0) 编辑

akka简单示例-1

摘要: 刚刚开始接触akka,网上找了2个简单示例,并在公司运营机器上尝试,踩了一些坑,在此记录。1. 本地hello world 1 [torstan@sparkb5-i ~/akka_example/hello_world]$ cat src/helloWorld.scala 2 package ou... 阅读全文

posted @ 2014-12-10 17:41 Torstan 阅读(1085) 评论(0) 推荐(0) 编辑

2014年11月14日

ulimit小结

摘要: 1. limits是一个进程的资源,会被子进程继承2. soft limit -S, hard limits -Hhard limits只能被root用户修改,启动的时候会加载配置/etc/security/limits.confsoft limits可以被任何用户修改,但不能超过hard limi... 阅读全文

posted @ 2014-11-14 16:36 Torstan 阅读(721) 评论(0) 推荐(0) 编辑

2014年10月31日

Spark调优

摘要: 使用Spark有一段时间了,现在记录spark调优的一些经验。1.textFile的minparitition,只是设置最小的partition数目,下界(比如3),当数据量大的时候,改参数不起作用。可以尝试设置成10002. reduceByKey的并行度,也就是reduce的数目。 2.1 s... 阅读全文

posted @ 2014-10-31 22:42 Torstan 阅读(1281) 评论(0) 推荐(0) 编辑

2014年9月25日

C语言里面关于数组的一个容易忽视的小细节

摘要: ginobili@VM_44_28_sles10sp1:~/code> cat test3.cpp#include int main(){ char a[5] = {0}; char *pa = a; printf("a = %p, pa = %p, &a=... 阅读全文

posted @ 2014-09-25 22:07 Torstan 阅读(200) 评论(0) 推荐(0) 编辑

2014年9月19日

Bash的几个知识点

摘要: 1. 区别 builtin command, external command,bash script。用builtin command(hash、type、command),而不是which命令(external command)查看某个命令是安装了(跟PATH变量相关):hash foo >/d... 阅读全文

posted @ 2014-09-19 12:24 Torstan 阅读(139) 评论(0) 推荐(0) 编辑

2013年12月24日

select m objects from n objects randomly

摘要: Q: how to select m objects randomly from n objects with euqal possibility?A: allocate an array of m elements to keep the final result. put the first m... 阅读全文

posted @ 2013-12-24 21:57 Torstan 阅读(318) 评论(0) 推荐(0) 编辑

2013年11月14日

get top k elements of the same key in hive

摘要: key points:1. group by key and sort by using distribute by and sort by.2. get top k elements by a UDF (user defined function) RANK---------Here is the source code.--------------package com.example.hive.udf;import org.apache.hadoop.hive.ql.exec.UDF; public final class Rank extends UDF{ priv... 阅读全文

posted @ 2013-11-14 19:17 Torstan 阅读(517) 评论(0) 推荐(0) 编辑

2013年11月6日

My advice to young people - Donald Knuth [video]

摘要: http://www.youtube.com/watch?v=75Ju0eM5T2cItookanoteofwhatknuthsaidinthevideo.1.Don'tdisbeliefthatbecausesomethingistrandy,somethingisgood.Iprobablygotheotherextreme,ifIfindtoomanypeopleadoptanidea,Iprobablythinkitiswrong.Ifmyworkistoopopular,IprobablythinkIhavetochangeit.Ofcourse,Itseemstooridi 阅读全文

posted @ 2013-11-06 13:08 Torstan 阅读(255) 评论(0) 推荐(0) 编辑

2013年9月30日

Pick two points at random from the interior of a unit square, what is the expected distance between them?

摘要: My solution is as folllowing.This integration is hard to solve. I googled it, and found the result is 1/3*ln(1+sqrt(2)) + 1/15*(2+sqrt(2)) = 0.52140543..please see the link below.http://mathworld.wolfram.com/SquareLinePicking.htmlhttp://www.stat.columbia.edu/~liam/teaching/4109-fall10/chapter4.pdf 阅读全文

posted @ 2013-09-30 21:30 Torstan 阅读(273) 评论(0) 推荐(0) 编辑

导航