This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.example; | |
| import java.util.concurrent.locks.AbstractQueuedSynchronizer; | |
| import java.util.concurrent.locks.ReentrantLock; | |
| /** | |
| * @author claws | |
| * @since 2023/4/7 | |
| */ | |
| public class Main { |