Skip to content

Instantly share code, notes, and snippets.

diaolizhi

Block or report user

Report or block diaolizhi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@diaolizhi
diaolizhi / ReloadSystem.java
Created Jan 13, 2019
Java 执行 shell 脚本
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();
@diaolizhi
diaolizhi / reload.sh
Last active Jan 13, 2019
Linux git 同步 maven 编译 java -jar 执行
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
@diaolizhi
diaolizhi / insert.java
Last active Jan 7, 2019
mysql 插入数据时如果存在主键则只更新
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
@diaolizhi
diaolizhi / insert.java
Created Jan 7, 2019
mysql 插入数据时如果存在主键则跳过
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 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=
@diaolizhi
diaolizhi / JsonData.java
Created Nov 19, 2018
Spring Boot JsonData 封装
View JsonData.java
import java.io.Serializable;
/**
* 功能描述:工具类
*
* <p> 创建时间:May 14, 2018 7:58:06 PM </p>
*/
public class JsonData implements Serializable {
/**
@diaolizhi
diaolizhi / 加解密工具类.java
Last active Nov 18, 2018
Java JWT 加密解密
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;
@diaolizhi
diaolizhi / LazySingleton.java
Created Nov 13, 2018
Java 懒汉式单例模式 - 线程安全
View LazySingleton.java
package chapter3;
/**
* @program: studythread2
* @description: 懒汉式单例模式
* @author: diaolizhi
* @create: 2018-11-13 12:39
**/
public class LazySingleton {
@diaolizhi
diaolizhi / SynchronizedDemo.java
Created Nov 13, 2018
Java synchronized 作用于普通方法、静态方法、方法块
View SynchronizedDemo.java
package chapter3;
/**
* @program: studythread2
* @description: synchronized Demo
* @author: diaolizhi
* @create: 2018-11-13 10:29
**/
public class SynchronizedDemo {
You can’t perform that action at this time.