自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(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 199

原创 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 256

原创 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 202

原创 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 129

原创 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 158

原创 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 107

原创 c++中的virtual inheritance

[url]http://stackoverflow.com/questions/21558/in-c-what-is-a-virtual-base-class[/url]主要是为了避免歧义。

2014-01-27 10:20:19 121

原创 ssl 与 java 实例

http://www.iteye.com/topic/1125183

2014-01-27 10:10:15 88

原创 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 121

原创 Java NIO

看了这个java nio的教程,明白了什么是Selector.wakeUp()[url]http://ifeve.com/selectors/[/url]wakeUp()某个线程调用select()方法后阻塞了,即使没有通道已经就绪,也有办法让其从select()方法返回。只要让其它线程在第一个线程调用select()方法的那个对象上调用Selector.wakeup()方...

2014-01-10 21:28:06 94

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 94

原创 java i18n exception

http://www.cab.u-szeged.hu/WWW/java/tutorial/i18n/exception/subclass.html

2013-11-11 17:37:39 294

flume build过程中出现Too many unapproved licenses错误

在target/rat.txt下面寻找哪些文件前面打了问号,去掉这些文件!

2013-09-22 21:31:18 495

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 132

原创 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 138

原创 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 126

原创 再谈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 90

shell字符串截取

${string#substring} 从string左边去掉第一个substring${string%substring} 从string右边去掉第一个substring

2013-07-19 15:09:32 102

原创 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 86

原创 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 130

Why singleton is anti-pattern?

[list][*] OO[*] Test[*] Other reasons?[/list]

2013-07-03 10:12:40 106

原创 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 66

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 79

原创 一个命令创建多个目录

可能我太土了,才发现下面这个命令!mkdir -p src/{test,main}/{java,resources}

2013-06-13 12:36:40 285

原创 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 84

原创 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 134

使用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 839

原创 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 105

原创 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 89

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 82

原创 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 94

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 89

原创 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 309

[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 85

原创 [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 103

[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 80

[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 92

[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 86

[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 7438

原创 [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 78

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除