Correct/Repeat the last command under Bash

If you often type the wrong command (or repeat the simmilar commends) under bash shell (like me), you may need to read this post:

cp file1.txt /path/to/dst
cp file1.a1 /path/to/dst
cp file1.a2 /path/to/dst

Substitute the first occurrence

How do I replace .txt with a1 and a2

If you often t…

More

Run Java main from Maven from Command line

Maven exec plugin lets you run the main method of a Java class in your project, with the project dependencies automatically included in the classpath. This article show you a way of using the maven e…

More

Mockito 101

Mockito is a mocking framework that lets you write beatiful tests with clean and simple API. It biases toward minimal specifications, makes different behaviors look different, and displays clear error messag…

More

Remove Duplicates from Sorted Array

Question

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with c…

More

Text Justification

Question

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is,…

More

[转] 胡适在北京大学毕业典礼上的讲话(1932年6月27日)

【导读】1932年,时任北大文学院院长的胡适,在6月27日毕业典礼上有一段讲话,初载于1932年7月3日《独立评论》,流传至今。胡适谈到的许多问题至今仍然存在:“即便为了吃饭,学问决不会辜负人的。吃饭而不求学问,三年五年之后,你们都要被后进少年淘汰掉的。”

More