Skip to content

Instantly share code, notes, and snippets.

View shui's full-sized avatar

Shui Dujiang shui

View GitHub Profile
@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 / tmux-cheatsheet.markdown
Created October 24, 2017 06:35 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

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

恢复会话:

tmux at [-t 会话名]
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 / java-generic-erasure.md
Last active November 14, 2017 11:33
Java泛型擦除

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

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

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

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

@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";
    }

查看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 / Main.java
Created January 9, 2018 01:15
BFS demo
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
}
boolean bfs(Node start, Node end) {
LinkedList<Node> queue = new LinkedList<>();
@shui
shui / gist:58c3e5db451b91a63326d2790c2148cd
Last active January 16, 2018 07:59
ubuntu 登录界面屏蔽其他用户

查看用户组

cat /etc/group

查看所有用户

cat /etc/passwd
@shui
shui / 1.md
Created January 17, 2018 04:53
MySQL用户管理

创建用户:

CREATE USER 'username'@'host' IDENTIFIED BY 'password';

删除用户:

DROP USER 'username'@'host';

授权:

@shui
shui / debian-autostart.md
Created January 29, 2018 06:01
用update-rc.d命令给Debian添加开机启动项

用update-rc.d命令给Debian添加开机启动项 Linux系统设置开机启动有很多方法,网上也有许多详细教程。本文只关注用update-rc.d命令给Debian添加开机启动。

例如:将test.sh脚本添加到开机自启。

1.将test.sh脚本放到/etc/init.d/目录下

cp test.sh /etc/init.d/  
cd /etc/init.d/  
chmod +x test.sh