Skip to content

Instantly share code, notes, and snippets.

View zxh's full-sized avatar
🎈

zxh zxh

🎈
  • AWS, Amazon
  • Beijing
View GitHub Profile
@zxh
zxh / LoggerFilter
Created July 14, 2018 07:49 — forked from calo81/LoggerFilter
Filter for reading and logging HttpServletRequest body, and resetting the input stream
package com.paddypower.financials.market.management.rest.logging;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@zxh
zxh / gen_pem_file.sh
Created June 26, 2018 01:59
generate .pem file
# Using ssh-keygen to export the key in the .pem format worked for me.
ssh-keygen -f id_rsa.pub -m 'PEM' -e > id_rsa.pem`
# Then simply copy the .pem key as necessary.
# For reference:
# the -f id_rsa.pub portion indicates the input file to read from
# -m 'PEM indicates a PEM filetype
# the -e option indicates that the output will be exported
@zxh
zxh / change_scala_version.sh
Created June 21, 2018 09:39
change scala version via brew
# show all scala versions
brew search scala
# install specific version, maybe scala 2.11
brew install scala@2.11
# unlink current scala version
brew unlink scala
# link new scala version
@zxh
zxh / Java.md
Last active June 1, 2018 09:37 — forked from JeOam/Java.md
Install Java 8 on OS X

on El Capitan, after installing the brew...

$ brew update
$ brew tap caskroom/cask
$ brew install Caskroom/cask/java

And Java 8 will be installed at /Library/Java/JavaVirtualMachines/jdk1.8.xxx.jdk/

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
@zxh
zxh / url_query_escape.go
Created March 28, 2018 10:03
goalng url encode, query param encode, path escape, query escape, space escape
package main
import (
"fmt"
"net/url"
)
func main() {
fmt.Println("Path参数中对空格的转义:"+url.PathEscape("hello world"))
fmt.Println("Query参数中对空格的转义:"+url.QueryEscape("hello world"))
@zxh
zxh / format.go
Created March 17, 2018 06:19
Convert CamelCase to underscore in golang
// Camelcase to underscore style.
func ToUnderScore(name string) string {
l := len(name)
ss := strings.Split(name, "")
// we just care about the key of idx map,
// the value of map is meaningless
idx := make(map[int]int, 1)
var rs []rune
@zxh
zxh / getip.go
Created February 9, 2018 07:43
golang get ip address
func getIp() (net.IP, error) {
interfaces, e := net.Interfaces()
if e != nil {
return nil, errors.New("get Interfaces error")
}
for _, i := range interfaces {
// the flags value maybe 'pointtopoint', it also has a ip, filter it.
if !strings.Contains(i.Flags.String(), "broadcast") {
continue
}
@zxh
zxh / List pattern matching last element in Scala.md
Last active May 2, 2017 05:37
List pattern matching last element in Scala.

Scala pattern matching 太强大了,但是想匹配一个 list 的最后一个元素,有些蛋疼。 本来想尝试 case (List(_* ,last)) => ... 但是居然编译都报错,原来 _* 只能扔到最后去。 如果用

(1 to 9).toList match {
  case _ :: 9 :: Nil=> "no way"
}

词的分类

  • 实词:名词、动词、形容词、状态词、区别词、数词、量词、代词
  • 虚词:副词、介词、连词、助词、拟声词、叹词。

ICTPOS3.0词性标记集

n 名词

nr 人名

@zxh
zxh / gist:7280252
Created November 2, 2013 15:47
What is Daemon thread in java
I answered it on stackoverflow.com:
http://stackoverflow.com/questions/2213340/what-is-daemon-thread-in-java/18428894#18428894
Java has a special kind of thread called daemon thread.
Very low priority.
Only executes when no other thread of the same program is running.
JVM ends the program finishing these threads, when daemon threads are the only threads running in a program.
What does daemon thread used for?