Skip to content

Instantly share code, notes, and snippets.

View jingjiecb's full-sized avatar

Zilong Liu jingjiecb

View GitHub Profile
@jingjiecb
jingjiecb / gist:6978dbc2417bfbfbb8b491ef0c89cc62
Created January 30, 2026 08:59
sliding-window-rate-limiter.py
import time
from collections import deque
class SlidingWindowLimiter:
def __init__(self, window_size, limit):
self.window_size = window_size # 窗口大小(秒)
self.limit = limit # 限制次数
self.requests = deque() # 存储时间戳的队列
def allow_request(self):
@jingjiecb
jingjiecb / gist:26061046c97a595a26c4cd2d74ce0910
Created September 24, 2024 14:16
git backup script backup.sh
#!/bin/bash
dateString=`date '+%Y-%m-%d %H:%M:%S'`
export ALL_PROXY=127.0.0.1:7897
git add .
git commit -m "backup at $dateString"
git push
# Add the line above in `crontab -e` to run the script periodically(every 1h)
# * */1 * * * cd /path/to/your/dir & backup.sh
@jingjiecb
jingjiecb / FunctionalInterface.java
Created May 7, 2023 09:13
函数式接口示例
package org.example;
/**
* @author claws
* @since 2023/5/7
*/
public class InterfaceTester {
public static void main(String[] args) {
Printer printer = new Printer();
Person claws = new Person("claws");
@jingjiecb
jingjiecb / PaintingDsl.groovy
Last active May 5, 2023 17:05
PaintingDsl的测试脚本和定义脚本
package top.claws.dsl
import javax.swing.JFrame
import javax.swing.JPanel
import java.awt.Color
import java.awt.Graphics
/**
* @author claws
* @since 2023/5/5
@jingjiecb
jingjiecb / gist:902b8dd310234584aaef700e835394e6
Created April 7, 2023 14:44
自己继承AQS实现自定义锁,交替输入输出0和1
package org.example;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author claws
* @since 2023/4/7
*/
public class Main {