- 博客(354)
- 收藏
- 关注
原创 Shell Parameter Expansion
http://stackoverflow.com/questions/12671406/bash-removing-part-of-a-string[code="bash"]var="Memory Used: 19.54M"var=${var#*: } # Remove everything up to a colon and spacevar=${var...
2016-01-16 13:30:22 251
原创 lost on Py_DECREF/INCREF when handling PyList_Append in Python C extension
The main hint is in the docs, if it says 'Steals a reference' than the function basically takes ownership, if it says 'New Reference' than it did an INCREF for you, if nothing is said it probably does...
2015-11-03 21:41:16 288
原创 How can I convert a character to a integer in Python, and viceversa?
Use chr() and ord():>>> chr(97)'a'>>> ord('a')97
2015-10-27 14:38:04 252
原创 How to build a Ruby hash out of two equally-sized arrays?
ruby-doc.org/core-2.1.2/String.html
2014-09-03 15:54:20 151
原创 typedef struct in c
typedef struct atom { int element; struct atom *next;};vs.typedef struct { int element; struct atom *next;} atom;http://stackoverflow.com/questions/18806392/typedef-struct-...
2014-04-29 16:18:06 198
原创 An Example of Using std::tr1::bind
[code="c++"]#include #include using std::tr1::bind;using std::tr1::function;using std::tr1::placeholders::_1;using std::tr1::placeholders::_2;class CTest{ public: ...
2014-03-10 16:49:28 134
原创 c++中的virtual inheritance
[url]http://stackoverflow.com/questions/21558/in-c-what-is-a-virtual-base-class[/url]主要是为了避免歧义。
2014-01-27 10:20:19 174
原创 C中的宏 [Macro in C]
最近在学习c,话说从java转向c真的蛮痛苦。Anyway,学习就是一份好经历。看到如下一段code:[code="c"]#define APP_TOOL_OP_TYPES(f) \ f(SIMPLE, "simple", FALSE) \ f(JSON, "json", TRUE) ...
2014-01-26 10:04:47 163
原创 Java NIO
看了这个java nio的教程,明白了什么是Selector.wakeUp()[url]http://ifeve.com/selectors/[/url]wakeUp()某个线程调用select()方法后阻塞了,即使没有通道已经就绪,也有办法让其从select()方法返回。只要让其它线程在第一个线程调用select()方法的那个对象上调用Selector.wakeup()方...
2014-01-10 21:28:06 126
hadoop-2.2.0 build failure due to missing dependancy
The bug and fix is at https://issues.apache.org/jira/browse/HADOOP-10110
2014-01-06 13:18:18 112
原创 java i18n exception
http://www.cab.u-szeged.hu/WWW/java/tutorial/i18n/exception/subclass.html
2013-11-11 17:37:39 332
flume build过程中出现Too many unapproved licenses错误
在target/rat.txt下面寻找哪些文件前面打了问号,去掉这些文件!
2013-09-22 21:31:18 534
perl tips for qw qq qx q
q// is generally the same thing as using single quotes - meaning it doesn't interpolate values inside the delimiters.qq// is the same as double quoting a string. It interpolates.qw// return a list...
2013-07-26 16:58:02 157
原创 show git branch in your bash prompt
export PS1='\[\e[1;0m\][\[\e[38;5;174m\]\u\[\e[38;5;240m\]@\[\e[01;32m\]\h\[\e[38;5;222m\] \w\[\e[31m\]$(parse_git_branch "(%s)")\[\e[1;0m\]]\[\e[38;5;240m\]\$\[\e[1;0m\]\e[m'function parse_git_br...
2013-07-26 16:47:26 305
原创 Show git log history in beautiful format
git alias:lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit --date=relative
2013-07-26 15:44:21 145
原创 再谈Java的wait(), sleep(), notify()和notifyAll()
一段时间不用java,这些概念就全混淆了,有必要彻底澄清一下,总结在这里,当然以我的本事,不太可能写出水平较高的总结,这里主要是总结stackoverflow上面高人的言论。[u][b]先说sleep() 和 wait()[/b][/u][b]sleep()[/b] method causes the current thread to move from running stat...
2013-07-25 10:59:45 109
shell字符串截取
${string#substring} 从string左边去掉第一个substring${string%substring} 从string右边去掉第一个substring
2013-07-19 15:09:32 116
原创 ubuntu 安装 java 环境
本人安装的是oracle java61. 下载jrewget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jre-6u45-linux-x64.bin2. 下载jdk...
2013-07-07 12:38:51 125
原创 ubuntu 安装中文输入法
1. 安装语言包System Settings-->Language Support-->Install/Remove Languages => 安装Chinese(simplified)2. 安装IBus框架sudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt43. 启动IBus框架im-switc...
2013-07-07 10:57:44 174
Why singleton is anti-pattern?
[list][*] OO[*] Test[*] Other reasons?[/list]
2013-07-03 10:12:40 146
原创 How to generate the serialVersionUID when you implement Serializable interface,j
[url]http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/serialver.html[/url]
2013-07-01 10:52:40 86
Serialize/Deserialize Perl Class Objects
Today in a small project I need to serialize a perl class object to string in order to cache it. And when getting back the value from the cache I need to deserialize it to original class objects. ...
2013-06-18 14:09:16 99
原创 Java Override的两个问题
1: 如果子类中的方法的参数是父类的方法的子类型,那么算不算override?例如:[code="java"]class A {public void foo(A a){}}class B extends A {public void foo(B b){}}[/code]2:如果子类中的方法的返回类型改变了,那么算不算override?...
2013-06-01 11:40:57 120
原创 How many string objects are created?
This is a very common java interview question. Given the following:String x = new String("xyz");y="abc";x=x+y;How Many Strings have been created:A - 2B - 3C - 4D - ...
2013-06-01 10:18:48 172
使用Java的DelayQueue容易碰到的一个坑
今天不忙,学习一下java.util.concurrent.DelayQueue这个类的使用。参照了[url]http://www.concretepage.com/java/example_delayqueue_java.php[/url]上的例子,但是这里有个坑。先看一下整个code吧:[code="java"]import java.util.concurrent...
2013-05-27 17:32:25 900
原创 HBase Schema Design
As someone has said [url=http://www.stephenonsoftware.com/2012/06/hbase-schema-design.html]here[/url][quote]You need to look more at the types of queries that you will be needing to access your da...
2013-05-24 11:41:20 129
原创 use "--links" option of rsync
Today I used rsync to copy some files but I found for symbolic links it will ignore them if you just use simple command line:rsync SRC DESTWith google, I finally figure out I need to add the "...
2013-05-23 10:45:25 127
Question on HBase source code
I'm reading source code of hbase. When come to class org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher I find this class has private member *unassignedNodes* but I cannot find where nodes are added i...
2013-05-22 15:05:16 103
原创 Using the libjars option with Hadoop
As I have said in my last post, I was developing a hbase based mapreduce application. But one damn thing is the hadoop cluster managed by our system admin has no hbase jars in its classpath...So I...
2013-05-20 15:03:23 124
Use HBase to Solve Page Access Problem
Currrently I'm working on sth like calculating how many hits on a page. The problem is the raw data can be huge, so it may not scale if you use RDBMS.The raw input is as follows.Date Page Use...
2013-05-17 14:48:31 125
原创 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/thi
If you meet this exception, make sure you include the guava-r09-jarjar.jar JAR in your build path. This is usually located in /usr/lib/hadoop-0.20/lib.
2013-05-16 15:27:09 357
[leetcode] Decode ways
[url]http://leetcode.com/onlinejudge#question_91[/url]Decode WaysJun 25 '121292 / 5011A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B...
2013-05-02 21:47:39 112
原创 [leetcode] Balanced Binary Tree
Check if a binary tree is balanced or not. This solution is from the discuss board. Much better than mine.[code="java"]/** * Definition for binary tree * public class TreeNode { * int ...
2013-04-28 14:08:57 121
[leetcode] find median of two sorted arrays
[url]http://leetcode.com/onlinejudge#question_4[/url]Solution: a little ugly.[code="java"]public class Solution { public double findMedianSortedArrays(int A[], int B[]) { /...
2013-04-26 10:55:02 113
[leetcode] word ladder
Q: Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each inter...
2013-04-25 15:05:24 126
[leetcode] sqrt(x)
I have talked about this question in my previous posts.http://leetcode.com/onlinejudge#question_69Q:Implement int sqrt(int x).Compute and return the square root of x.Solution:[code...
2013-04-15 07:44:01 118
[leetcode] word ladder II
http://leetcode.com/onlinejudge#question_126Q: Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one let...
2013-04-15 07:35:45 7823
原创 [leetcode] Count and Say
http://leetcode.com/onlinejudge#question_38Question:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11...
2013-04-12 14:05:02 117
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人