Skip to content

Instantly share code, notes, and snippets.

@zhaohangbo
zhaohangbo / RESTful Web Service的教程
Last active January 3, 2017 08:51
RESTful Web Service的教程
RESTful Web Service的教程
http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069?pgno=1
http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069?pgno=2
http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069?pgno=3
概要:
1、Representations:可以用JSON或者XML来代表资源。
2、Messages:Client和Service通过Message来交流。Client发送Http Request,Service回复Http Response。
@zhaohangbo
zhaohangbo / Mac使用机械键盘和改键工具
Created December 27, 2016 03:17
Mac使用机械键盘和改键工具
改键工具:Karabiner
https://pqrs.org/osx/karabiner/
改键博客:
http://tieba.baidu.com/p/3489459090
http://www.jianshu.com/p/d8e59d432214
@zhaohangbo
zhaohangbo / SSH的public_key和private_key
Created December 2, 2016 06:53
SSH的public_key和private_key
SSH的public_key和private_key
1、private_key [on your own PC]
Stored on the computer you log in from
2、public_key [on other PCs]
Stored on the .ssh/authorized_keys file on all the computers you want to log in to.
How it works ?
When you log in to a computer,
@zhaohangbo
zhaohangbo / Java转成Scala
Last active November 30, 2016 09:46
Java转成Scala
Java代码转换成Scala,常见的一些转换
转换:
SomeType.class ==> classOf[SomeType]
Class<?> ==> def read[UnknowType](classes: Set[Class[UnknowType]])
https://stackoverflow.com/questions/1135248/scala-equivalent-of-java-java-lang-classt-object
Java代码:
public Swagger read(Set<Class<?>> classes) {
@zhaohangbo
zhaohangbo / Google Tips
Created November 21, 2016 06:30
Google搜索技巧
1、双引号 “”
完全匹配搜索,返回的结果包含双引号中出现的所有的词,连顺序也必须完全匹配。
例如搜索: “seo方法图片”
2、减号 -
减号代表搜索不包含减号后面的词的页面。使用这个指令时减号前面必须是空格,减号后面没有空格,紧跟着需要排除的词。Google 和bd都支持这个指令。
例如:搜索 -引擎
返回的则是包含“搜索”这个词,却不包含“引擎”这个词的结果
@zhaohangbo
zhaohangbo / NullNotNone.scala
Created November 21, 2016 04:31
Use Option(x) instead of Some(x) to avoid Some(null)
object NullNotNone {
def main(args: Array[String]) {
test_func match {
case None => println("null is not none")
case Some(x) => println("so easy to be wrong")
}
}
def test_func: Option[java.lang.Double] = Some(null)
}
@zhaohangbo
zhaohangbo / 换行符 \r, \n, \r\n
Created September 24, 2016 05:37
换行符 \r, \n, \r\n
\r = CR (Carriage Return) // Used as a new line character in Mac OS before X
\n = LF (Line Feed) // Used as a new line character in Unix/Mac OS X
\r\n = CR + LF // Used as a new line character in Windows
So,
String lines[] = String.split("\\r?\\n");
@zhaohangbo
zhaohangbo / Java Serializable Object to Byte Array
Created September 23, 2016 13:12
Java Serializable Object to Byte Array
http://stackoverflow.com/questions/2836646/java-serializable-object-to-byte-array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = null;
try {
out = new ObjectOutputStream(bos);
out.writeObject(yourObject);
out.flush();
byte[] yourBytes = bos.toByteArray();
...
xargs
问题:在管道命令 | 后面加不加xargs有什么区别?
区别:
管道是实现“将前面的标准输出作为后面的标准输入”
xargs是实现“将标准输入作为命令的参数”
例如,
echo "--help"|cat, 相当于 cat "--help", --help作为cat的标准输入流(STDIN)
echo "--help"|xargs cat 相当于 cat --help , --help作为cat的参数
sql-migrate工具
工具:sql-migrate
https://github.com/rubenv/sql-migrate
模板:mysql代码库from公司
http://git.yottabyte.cn/summary/mysql.git
Available commands are:
down Undo a database migration(只恢复一个)
redo Reapply the last migration
status Show migration status