Skip to content

Instantly share code, notes, and snippets.

// 通过redis自增key获取全局唯一ID,每天重置
public String getUniqueId(String key) {
RedisScript<Long> luaScript = new DefaultRedisScript<>(
"local exists = redis.call('EXISTS', KEYS[1])\n" +
"if exists == 0 then\n" +
" redis.call('INCR', KEYS[1])\n" +
" redis.call('PEXPIRE', KEYS[1], ARGV[1])\n" +
" return tonumber(1)\n" +
"else\n" +
" return tonumber(redis.call('INCR', KEYS[1]))\n" +
@JoJoJotarou
JoJoJotarou / reg.md
Last active May 10, 2024 02:53
常用正则记录
  • 中国23个省、5个自治区、4个直辖市、2个特别行政区匹配

    (?:黑龙江|吉林|辽宁|河北|甘肃|青海|陕西|河南|山东|山西|安徽|湖北|湖南|江苏|四川|贵州|云南|浙江|江西|广东|福建|台湾|海南)(?:省)?|(?:北京|上海|天津|重庆)(?:市)?|(?:香港|澳门)(?:特别行政区)?|(?:新疆|内蒙古|宁夏|广西|西藏)(?:自治区|维吾尔自治区|回族自治区|壮族自治区)?
    
@JoJoJotarou
JoJoJotarou / .meta.xml
Last active December 19, 2023 17:45
IDEA MybatisX template (1. 自定义 controller 模板 2. mapperInterface 添加 @Mapper 注解)
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<!-- .meta.xml 添加自定义 controller 模板信息,其他不变 -->
<template>
<property name="configName" value="controller"/>
<property name="configFile" value="controller.ftl"/>
<property name="fileName" value="${domain.fileName}Controller"/>
<property name="suffix" value=".java"/>
<property name="packageName" value="${domain.basePackage}.controller"/>
<property name="encoding" value="${domain.encoding}"/>

卸载/安装

Contos

查看脚本 contos-docker-install.sh

Ubuntu

卸载

@JoJoJotarou
JoJoJotarou / a-guide-to-deploying-development-env-on-linux.md
Last active July 20, 2022 09:35
在Linux上部署开发环境的一份指南(尽量提供一键脚本)

💡使用 root 或具有 sudo 权限的用户 💡默认你正在配置一个新的环境,若不是则按需执行

apt 更换阿里云源

# debian 11.3
sudo sed -ri 's/(deb|security|ftp).debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && sudo apt update
@JoJoJotarou
JoJoJotarou / OmegaOptions.bak
Created May 23, 2022 09:35
SwitchOmega 配置备份
{"+__ruleListOf_auto switch":{"color":"#99dd99","defaultProfileName":"direct","format":"AutoProxy","lastUpdate":"2022-05-23T09:30:57.262Z","matchProfileName":"我的代理","name":"__ruleListOf_auto switch","profileType":"RuleListProfile","revision":"180f0415dc2","ruleList":"[AutoProxy 0.2.9]\n! Checksum: 8Ye3yjbQ4zEI4QMXmNSBMA\n! Expires: 6h\n! Title: GFWList4LL\n! GFWList with EVERYTHING included\n! Last Modified: Sun, 22 May 2022 00:32:24 -0400\n!\n! HomePage: https://github.com/gfwlist/gfwlist\n! License: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt\n!\n! GFWList is unlikely to fully comprise the real\n! rules being deployed inside GFW system. We try\n! our best to keep the list up to date. Please\n! contact us regarding URL submission / removal,\n! or suggestion / enhancement at issue tracker:\n! https://github.com/gfwlist/gfwlist/issues/.\n\n!---------403/451/503/520 & URL Redirects---------\n!--ehentai\n|http://85.17.73.31/\n!--||adorama.com\n||afreecatv.com\n||agnesb.fr\n||akiba-web.com\n||altrec.co
@JoJoJotarou
JoJoJotarou / mysql_catch_execption.sql
Created February 21, 2022 09:22
mysql 存储过程获取异常、回滚、手动提交
drop procedure if exists catch_execption;
create procedure catch_execption(in V_ID bigint)
begin
DECLARE result varchar(100) DEFAULT '00000';
DECLARE code CHAR(5);
DECLARE msg TEXT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@JoJoJotarou
JoJoJotarou / a_mysql_function_extension.md
Last active May 10, 2024 06:49
MySQL/MariaDB 常用函数收录

目录

  1. month_days.sql:获取当前日期月份的天
  2. date_verify.sql:校验字符是否符合日期格式要求
  3. json_maker.sql: 从sp连接的字符串生成JSON
  4. clear_num.sql:将字符串转成数值,清理非字符
  5. str_split.sql: 将字符串转json数组
@JoJoJotarou
JoJoJotarou / mysql_reg.sql
Created June 11, 2021 08:35
mysql 正则表达式
# mysql取字符串中的数值(小数据需要保留)
# 正常写法:(?!\.)\D
# 解释:取出所有非数字的字符,不包括小数点
select regexp_replace('(12.0 -&dd放大21)', '(?!\\\.)\\D', '')
# 结果:12.021
-- 用户授权
GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'%' identified by 'your_password';
-- 刷新权限,修改权限后必需执行
flush privileges;