Instantly share code, notes, and snippets.

View ReloadSystem.java
public class ReloadSystem {
public static void reloadSystem() {
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("bash", "-c", "bash ~/tieba-demo/Tieba/reload.sh");
try {
Process process = processBuilder.start();
View reload.sh
# 项目名
PRONAME="demo"
#echo $PRONAME
# 项目所在路径
PROPATH='/root/tieba-demo/Tieba/'
nohup git pull origin master >/dev/null 2>&1
#git pull origin master
cd $PROPATH
View insert.java
@Insert("INSERT IGNORE INTO t_user " +
"(email, password, salt, is_active) " +
"VALUES (#{email}, #{password}, #{salt}, 1)")
int addUser(TUser user);
//重点是 IGNORE
View insert.java
@Insert("INSERT INTO t_email_link VALUES (#{email}, #{link}, DATE_ADD(CURDATE(), INTERVAL 2 DAY))" +
"ON DUPLICATE KEY UPDATE link=#{link}, exp=DATE_ADD(CURDATE(), INTERVAL 2 DAY)")
void saveEmailAndChangePasswordLink(@Param("email") String email, @Param("link") String link);
//重点是 ON DUPLICATE KEY UPDATE
View RandomString.java
import java.security.SecureRandom;
import java.util.Locale;
import java.util.Objects;
import java.util.Random;
public class RandomString {
/**
* Generate a random string.
*/
View Bootstrap 点击时自动隐藏导航栏
<nav class="navbar navbar-light navbar-expand-md navigation-clean-button">
<div data-toggle="collapse" data-target=".navbar-collapse.show" class="container"><router-link class="navbar-brand" to="/">首页</router-link><button class="navbar-toggler" data-toggle="collapse" data-target="#navcol-1"><span class="sr-only">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse"
id="navcol-1">
<ul class="nav navbar-nav mr-auto">
<li class="nav-item" role="presentation"><router-link class="nav-link" to="/see-other-forum-list">查贴吧</router-link></li>
<li class="nav-item" role="presentation"><a class="nav-link" href="#">Second Item</a></li>
<li class="dropdown"><a class="dropdown-toggle nav-link dropdown-toggle" data-toggle="dropdown" aria-expanded="false" href="#">Dropdown</a>
<div class="dropdown-menu" role="menu"><a class="dropdown-item" role="presentation" href=
View JsonData.java
import java.io.Serializable;
/**
* 功能描述:工具类
*
* <p> 创建时间:May 14, 2018 7:58:06 PM </p>
*/
public class JsonData implements Serializable {
/**
View 加解密工具类.java
package com.diaolizhi.mybatisdemo.utils;
import com.diaolizhi.mybatisdemo.domain.User;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import java.util.Date;
View LazySingleton.java
package chapter3;
/**
* @program: studythread2
* @description: 懒汉式单例模式
* @author: diaolizhi
* @create: 2018-11-13 12:39
**/
public class LazySingleton {
View SynchronizedDemo.java
package chapter3;
/**
* @program: studythread2
* @description: synchronized Demo
* @author: diaolizhi
* @create: 2018-11-13 10:29
**/
public class SynchronizedDemo {