Skip to content

Instantly share code, notes, and snippets.

View shui's full-sized avatar

Shui Dujiang shui

View GitHub Profile

查看git上个人代码量

git log --author="username" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -

统计每个人的增删行数

git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done

查看仓库提交者排名前 5

@shui
shui / jsp-cannot-get-value-from-Model.md
Created November 17, 2017 11:56
JSP无法获取Model的值
    @RequestMapping(path = "/", method = GET)
    public String index(Model model)
            throws Exception {
        logger.info("processed by index");
        model.addAttribute("msg", "GOGOGO");
        return "go.jsp";
    }
@shui
shui / java-generic-erasure.md
Last active November 14, 2017 11:33
Java泛型擦除

在泛型代码内部,无法获得任何有关泛型参数类型的信息。

泛型类型只有在静态类型检查期间才会出现,在此之后,程序中所有的泛型类型都将被擦除,替换为他们的非泛型上界。例如,List<T>将被擦除为List,而普通的类型变量在未指定边界的情况下将被擦除为Object

擦除主要的正当理由是从非泛化代码到泛化代码的转变过程,以及在不破坏现有类库的情况下,将泛型融入Java语言。向后兼容性

擦除的代价是显著的。泛型不能用于显式地引用运行时类型的操作之中,例如转型、instanceof操作和new表达式,因为所有关于参数的类型信息都丢失了。

public class FilteringApples {
public static List<Apple> filterGreenApple(List<Apple> inventory) {
List<Apple> result = new ArrayList<>();
for (Apple apple : inventory) {
if ("green".equals(apple.getColor())) {
result.add(apple);
}
}
return result;
@shui
shui / tmux-cheatsheet.markdown
Created October 24, 2017 06:35 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
@shui
shui / sList.forEach.md
Created August 31, 2017 08:27
拥抱Java 8
        List<String> sList = new ArrayList<>(3);
        sList.add("a");
        sList.add("b");
        sList.add("c");
        // before 1.5
        for (int i = 0; i < 3; i++) {
            System.out.println(sList.get(i));
        }
 // 1.5
@shui
shui / fcitx-config.md
Last active September 7, 2017 00:35
Fcitx中文输入时“*”变“x”

Fcitx中文输入时输入*会输出x,在写Markdown的时候超级烦,需要不停切换输入法。 修改/usr/share/fcitx/data/punc.mb.zh_CNpunc-ng.mb.zh_CN两个文件中*的映射,重启Fcitx服务(Ref.:ubuntu 搜狗输入法崩溃 fcitx崩溃无痛重启方法)。

  1. 首先top,列出进程表,找到fcitx的pid或者直接pidof fcitx
  2. sudo kill 掉fcitx 以上两步可以直接用:pidof fcitx|xargs kill来使用(或者直接使用fcitx -r)。
  3. fcitx & 这里的意思是后台跑fcitx,回车几次就可以。
  4. sogou-qimpanel &amp; 同样,后台启动搜狗输入法面板。
@shui
shui / clean-sogou-cache.md
Created August 17, 2017 03:34
Ubuntu下搜狗输入法有一天突然不能输入中文了,以下命令work
rm -rf /tmp/fcitx*
rm -rf /tmp/sogou-qimpanel*
rm -rf ~/.sogou*
rm -rf ~/.config/sogou*
rm -rf ~/.config/fcitx*
rm -rf ~/.config/SogouPY*
var browserSync = require('browser-sync').create()
var reload = browserSync.reload
var gulp = require('gulp')
var gitbook = require('gitbook')
var path = require('path')
var del = require('del')
// path of your *.md book files
var rootPath = path.join('/gitbook')
@shui
shui / after_installation_of_ubuntu16.md
Last active March 21, 2018 03:38
After Installation of Ubuntu 16.04 LTS
# 删除不用的软件
sudo apt remove --purge libreoffice-common unity-webapps-common

# 安装必要的软件
sudo apt install -y git vim tmux unrar mysql-server mysql-client build-essential cmake gcc gthumb tree

# 安装docker-ce
  # step 1: 安装必要的一些系统工具
  sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common