Skip to content

Instantly share code, notes, and snippets.

View chenggangpro's full-sized avatar
👨‍💻
In The Zone

Gang Cheng chenggangpro

👨‍💻
In The Zone
  • Shanghai,China
  • 10:39 (UTC +08:00)
View GitHub Profile
@chenggangpro
chenggangpro / nginx.conf
Created August 25, 2025 02:13 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@chenggangpro
chenggangpro / DataBuffersInputStream
Created July 24, 2025 07:55 — forked from jeronimonunes/DataBuffersInputStream
Convert Spring Boot DataBuffer Flux to InputStream
/**
* MIT License
*
* Copyright (c) 2024 Jerônimo Nunes Rocha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@chenggangpro
chenggangpro / docker-registry-mirrors.md
Created June 10, 2024 08:05 — forked from y0ngb1n/docker-registry-mirrors.md
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

-- 计算1到100的累加的结果。
WITH RECURSIVE t(n) AS ( //t为我们结果表,n为字段,可以只指定表明不指定字段
VALUES (1) //递归的开始,此时可理解为t表字段n只有一条记录 1
UNION ALL
SELECT n+1 FROM t WHERE n < 100
/*这里产生的结果为 2 ,此时t表的字段n有两条记录分别为1,2
* 3
* ...
* 100
*/
set session optimizer_trace="enabled=on",end_markers_in_json=on;
-- ⬇️可替换为要追踪的SQL语句
SELECT dia_sku_id
FROM (SELECT DISTINCT(sku_master_temp.dia_sku_id) AS dia_sku_id
FROM sku_price_cleaned
INNER JOIN (SELECT dia_sku_id
FROM sku_master
-- FORCE INDEX (index_sku_id_right)
WHERE sku_master.category_clean IN ('FTW')
AND sku_master.sub_category IN
package com.vm.project.advertise.project;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.PutObjectRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author evans
* @date 2022/3/7
* @since 1.0.0
*/
public class PetersonTests {
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author evans
* @date 2022/3/7
* @since 1.0.0
*/
public class DekkerTests {

CLH 是一种基于链表的可扩展,高性能,公平的自旋锁,申请线程只能在本地变量上自旋,它会不断轮询前驱的状态,如果发现前驱释放了锁就结束自旋。

public class CLHLock {

    public static class CLHNode{
        private volatile boolean isLocked = true;
    }

    // 尾部节点

MCS Spinlock 是一种基于链表的可扩展、高性能、公平的自旋锁,申请线程只在本地变量上自旋,直接前驱负责通知其结束自旋,从而极大地减少了不必要的处理器缓存同步的次数,降低了总线和内存的开销。

public class MCSLock {

    public static class MCSNode {
        volatile MCSNode next;
        volatile boolean isLocked = true;
    }