Skip to content

Instantly share code, notes, and snippets.

@dantewang
dantewang / oneliner.sh
Last active August 29, 2015 14:02
One-line bash commands
# Bulk replace string in files:
sed -i "s/oldString/newString/g" `grep oldString -rl /path`
# Extract Tomcat pid from jps output
jps -m | grep Bootstrap | grep -o -E "[[:digit:]]*"

Description copied from http://blog.zhaojie.me/2012/11/how-to-generate-typoglycemia-text.html

Typoglycemia是个新词,描述的是人们识别一段文本时的一个有趣的现象:只要每个单词的首尾字母正确,中间的字母顺序完全打乱也没有关系,照样可以正常理解。例如这么一段文字:

I cdnuol't blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg: the phaonmneel pweor of the hmuan mnid. Aoccdrnig to a rseearch taem at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoatnt tihng is taht the frist and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it wouthit a porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Scuh a cdonition is arppoiatrely cllaed Typoglycemia.

Amzanig huh? Yaeh and you awlyas thguoht slpeling was ipmorantt.

我们其实可以较为轻松地识别出其原文:

@dantewang
dantewang / BasicFormatterImpl.java
Created May 11, 2012 09:22
Hibernate's BasicFormatterImpl -- it actually doesn't have any dependency on other classes in Hibernate
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@dantewang
dantewang / gitp2svnp.rb
Created December 26, 2011 02:52 — forked from zbyhoo/gitp2svnp.rb
Simple script converting git patch file into tortoise merge compatible format. Usage: gitp2svnp.rb <git_patch_file>
#!/usr/bin/ruby
if ARGV.length != 1
puts "usage: git2svn <file_name>"
puts " file_name - git patch file name"
exit
end
separator = "\n===================================================================\n"
new_file = false